In beforeSave, afterSave, … is there a way to determine and act upon all the number attributes? Or string attributes? Or required attributes? You get the idea of what I’d like to be able to do, identify attribute by their rule and then perform an action, str_replace, …
$phpTypes can be - string, boolean, integer, double, array
$types can be - char, string, text, boolean, smallint, integer, bigint, float, decimal, datetime, timestamp, time, date, binary, and money.
For rules that’s a bit tricky. But you can use $this->getActiveValidators($attribute) method of ActiveRecord to determine what rules are applied to an attribute.
What is your goal?
Because this should usually be solved by rules themselves. Give a look at Filter core validator.
If this won’t solve your problem, I’d suggest you to create a Trait with the transformations you’d like to perform, attach it to the model and call the trait transformations on beforeSave, afterSave, or wherever needed.