Derick Rethans wrote:
Problems: 1. There is no way to document the 'virtual' properties with any of the existing documentation tools (such as phpdoc and doxygen)
Rather then adding abstract properties, why not simply document the possible values inside the doc comments ala:
/** * @var abstract int Contains all X */
2. There is no way how the magic methods know if a specific 'virtual' property exists or not as those properties are not declared usually - unless you define an array with property names as a class constant (which is not allowed either).
That's the whole concept behind the feature, if the values were known you may as well use clearly declared property and method names.
3. There is no way for the magic methods to return a meaningfull error when a property doesn't "exist". Of course it is possible to throw an error with "trigger_error" or "throw" in case a property doesn't "exist" in a specific class, but the file and line numbers would not match the actually get/set action. debug_backtrace() can be used to retrieve the correct file and line, but as you have to do this for every class where you want to use setters and getters *and* you have to implement your own error message rendering function this is not really a suitable option either.
How about adding a 3rd optional argument to __get and __set which would be an array of acceptable values for the "name" parameter? If there is a mismatch a standard warning message will be raised if this parameter was supplied.
ilia -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php