Hi!
- Annotations are like enum fields, or a function headers. You can only specify these values defined by the annotation. In normal data structures like arrays you can define what you will.
This is irrelevant for PHP as it's not compiled. So the check would happen in runtime, how does it matter when? I'd rather prefer the check to happen at the time of use - this way, if I have bad annotation and nobody uses it, my class won't break.
- The meta information is defined on top of the property to which this information belongs. - To use this information by the validator you must make this information public in the object model. This can be more work, or the informations should not be accessible through the object.
I'm not sure I understand. How public is more work? And what's the problem with it being accessible?
- When I look at the code I can promptly see what validation rules are used for this property.
You can see it with data too, it'd be right there.
- Metadata is a part of the property, method or class. This information should not be described contextless.
Why it should be a part of the property? Property is not an entity in PHP anyway - you can't assign it somewhere (as property, not value) and get back to it later - classes, methods and properties are not first-class objects in PHP (unlike some other languages, yes). So I'm not sure I understand why having metadata as part of the property is important (or what it means at all).
class Controller { [Inject] public function setRouter(Router $router) { } } The dependency injection container must know the method on which the router should be injected into the controller. Sure this information can
You are answering the question "how current proposal is useful". It is not a question that I asked. I asked "why the same can't be done with plain data?" Showing more examples of how you can use annotations doesn't answer this question.
Can you really not see the elegancy and the advantage for the users?
Elegancy is subjective. Please understand that I'm not asking all these questions because I hate this proposal or the idea of annotations or you :) I am asking them because I think we have to have very clear understanding of why we doing it - especially when we are asked to introduce new syntax to the language which would have implications for the future. And "it looks nice" doesn't cut it. So far I wasn't shown clear case of why it's superior - that's what I am asking.
-- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php