-
Notifications
You must be signed in to change notification settings - Fork 24
XP Framework method parameter annotations #116
Conversation
- Add hasAnnotation() - Add getAnnotation() - Add hasAnnotations() - Add getAnnotations()
- Add normalParameterGetAnnotationRaisesException()
|
Quoting @mrosoiu
Hrm, in Java it's similar: public class Example {
public void setConnection(@Inject(name = "db") DBConnection conn) {
// ...
}
}See http://docs.oracle.com/javase/1.5.0/docs/guide/language/annotations.html Same goes for C#: public class Example
{
public void SetConnection([Inject(Name = "db")] DBConnection conn)
{
// ...
}
}See http://msdn.microsoft.com/library/z0w1kczw.aspx Is the pain in our syntax proposal caused by the |
|
@mikey179 proposed embedding the parameter name in the annotation and the writing it on top of the method declaration line (or was it in the apidoc) - can't remember exactly where. Anyways, this could be an alternative: <?php
class Example extends Object {
#[@$conn: inject(name= 'db')]
public function setConnection(DBConnection $conn) {
// ...
}
}
?>This is also similar to C# syntax for attribute targets (see above MSDN page, about halfway down the page). @mrosoiu - how does that look to you? |
|
Timm, the "pain and suffering" is definitely a matter of personal taste. Please don't take it as something against your and @mikey179's efforts on this issue. Plus, it was said in a funny context, with awesome llamas and all :) I understand the reasons behind the need of Regarding your alternative proposal with parameter annotations included in method annotations: I've been playing with it a bit and it doesn't look bad at all; not sure about performance / speed impact, but I definitely like it more than |
one containing the annotations and one the annotations with targets - Parse the regular annotations into DETAIL_ANNOTATIONS as before and the annotations with targets into the new element DETAIL_TARGET_ANNO - Remove tokenizing the method signature # Backwards compatible
# See changes to lang.XPClass
# See changes to lang.XPClass
# See changes to lang.XPClass
|
XP Language way of doing this @ xp-lang/compiler#4 |
XP Framework method parameter annotations
# See xp-framework/rfc#218, implemented by pull request #116
Implementation for xp-framework/rfc#218
See also pull request #33