Why rules(),behaviors(),actions(),filters() methods don't have corresponding properties that would give posibility to configure it/modify by evnt/bhv

Why such methods as model rules(), component behaviors(), controller actions(), filters() realized in Yii as methods and not as public properties?

If realize this things as class properties (and use the same methods that available now for reading them), we would have posibility to configure it via configuration and modify by events and behaviors.

Having a method you have much more possibilities to create dynamic return values.

Mike, I don’t offer to remove methods, I offer to add properties and:

a.) Use merged array of properties & methods inside Yii

b.) Modify default methods, that will return values of properties and users will redefine it & merge with corresponding class properties manually

There are several reasons that we do not introduce these properties:

  1. the extra properties may "pollute" the property namespace of the base classes. For example, having a "$rules" property in AR means you will have trouble if a table also contains a column named "rules".

  2. some of these methods already have the corresponding ways to allow customization by external classes. For example, you can manipulate the result of getValidators to customize the rules of a model. So instead of adding new properties without actual needs, we handle these requests case by case, depending on how often is a feature used in real applications.

  1. In any projects where we use 3-rd party extensions, often we need to configure it for our objectives. It will be reasonably not edit their sources, that makes it unubdatable and not use inheriting, that can cause problems with names and paths, but configure it via config.

  2. You will see actual needs of this if you look on this from the point of view of creating flexible CMS on the top of Yii with admin inerface, that can modify application configuration. From this point we have a reason to do all components of Yii more configurable.

The reason is to make it like puzzle – Less project-specific code,less dependencies in your code, just add all, that you need to config.

  1. Polluting of property namespace of the base classes isn’t so serious problem to set aside improvement of flexibility. Note that this flexibility dont mean just freedom to use methods or to use properties. It means a principal abitilty to configure things about i talk via config.

Fully agree with qiang, the current implementation is versatile enough and consistent with the way yii configures things. It is one of the things I love about yii.

If you will have properties with getters/setters, you wold able to do that same way