Hello PHP Internals!
Recently a RFC was included on the PHP Wiki[1]. I know there've been a lot of buzz related to PHP 5.4, but this is not the subject of this email.
I'm here to propose a new feature in PHP: Annotations. A patch is already available with 54 tests for the moment[2].
I worked together with Guilherme Blanco to make this support happen in a fresh PHP SVN trunk checkout.
Please review, comment and provide feedback! I think it's a very useful support and may benefit users a lot.
[1] http://wiki.php.net/rfc/annotations
[2] http://www.adoy.net/php/Annotations.diff
Regards,
Pierrick
(Sorry if you receive this message twice but it looks like I have problems with the ML)
Hi Pierrick,
Awesome RFC! :) I think this is a really useful addition on many levels.
We had a chat about this yesterday, i just wanted to throw it into the discussion here again:
I think a solution where "->getAnnotations()" returns only an array of the annotations data is simpler to use.
Validation of the data would have to be done by the user in this case, but you could of course
add a layer in PHP that transforms this data into an object structure.
greetings,
Benjamin
On Wed, 25 Aug 2010 08:56:53 -0400, Pierrick Charron [email protected]
wrote:
Quoted text · 10 lines
Hello PHP Internals!
Recently a RFC was included on the PHP Wiki[1]. I know there've been a lot of buzz related to PHP 5.4, but this is not the subject of this email.
I'm here to propose a new feature in PHP: Annotations. A patch is already available with 54 tests for the moment[2].
I worked together with Guilherme Blanco to make this support happen in a fresh PHP SVN trunk checkout.
Please review, comment and provide feedback! I think it's a very useful support and may benefit users a lot.[1] http://wiki.php.net/rfc/annotations
[2] http://www.adoy.net/php/Annotations.diffRegards,
Pierrick(Sorry if you receive this message twice but it looks like I have problems with the ML)
One of the advantage of classes vs array is that you have to create the class and define its structure and behaviour before using it. For example you cannot do with Array something like the [Inherited] annotation :
[Inherited]
class SampleAnnotation extends ReflectionAnnotation {}
How could you define that the SampleAnnotation annotation is Inherited or not if you define it on the fly ?
Pierrick
2010/8/25 Benjamin Eberlei [email protected]:
Quoted text · 20 lines
Hi Pierrick,
Awesome RFC! :) I think this is a really useful addition on many levels.
We had a chat about this yesterday, i just wanted to throw it into the discussion here again:
I think a solution where "->getAnnotations()" returns only an array of the annotations data is simpler to use.
Validation of the data would have to be done by the user in this case, but you could of course
add a layer in PHP that transforms this data into an object structure.greetings,
BenjaminOn Wed, 25 Aug 2010 08:56:53 -0400, Pierrick Charron [email protected]
wrote:Hello PHP Internals!
Recently a RFC was included on the PHP Wiki[1]. I know there've been a lot of buzz related to PHP 5.4, but this is not the subject of this email.
I'm here to propose a new feature in PHP: Annotations. A patch is already available with 54 tests for the moment[2].
I worked together with Guilherme Blanco to make this support happen in a fresh PHP SVN trunk checkout.
Please review, comment and provide feedback! I think it's a very useful support and may benefit users a lot.[1] http://wiki.php.net/rfc/annotations
[2] http://www.adoy.net/php/Annotations.diffRegards,
Pierrick(Sorry if you receive this message twice but it looks like I have problems with the ML)
The inheritance support of annotations only affects classes am I right? I would get rid of this stuff completely, its rather complicated and simplify to only returning only the annotations specified on the reflected class.
As I said before, no-one hinders you from implementing arbitrary complex user-land annotation frameworks on top of a very simple annotations implementation that returns simple arrays only.
For inheritance like features the user could walk the inheritance graph from the specified child to its last super-class and array_merge() all the annotations it needs.
greetings,
Benjamin
On Wed, 2010-08-25 at 11:59 -0400, Pierrick Charron wrote:
Quoted text · 26 lines
One of the advantage of classes vs array is that you have to create the class and define its structure and behaviour before using it. For example you cannot do with Array something like the [Inherited] annotation :
[Inherited]
class SampleAnnotation extends ReflectionAnnotation {}How could you define that the SampleAnnotation annotation is Inherited or not if you define it on the fly ?
Pierrick
2010/8/25 Benjamin Eberlei [email protected]:
Hi Pierrick,
Awesome RFC! :) I think this is a really useful addition on many levels.
We had a chat about this yesterday, i just wanted to throw it into the discussion here again:
I think a solution where "->getAnnotations()" returns only an array of the annotations data is simpler to use.
Validation of the data would have to be done by the user in this case, but you could of course
add a layer in PHP that transforms this data into an object structure.greetings,
BenjaminOn Wed, 25 Aug 2010 08:56:53 -0400, Pierrick Charron [email protected]
wrote:Hello PHP Internals!
Recently a RFC was included on the PHP Wiki[1]. I know there've been a lot of buzz related to PHP 5.4, but this is not the subject of this email.
I'm here to propose a new feature in PHP: Annotations. A patch is already available with 54 tests for the moment[2].
I worked together with Guilherme Blanco to make this support happen in a fresh PHP SVN trunk checkout.
Please review, comment and provide feedback! I think it's a very useful support and may benefit users a lot.[1] http://wiki.php.net/rfc/annotations
[2] http://www.adoy.net/php/Annotations.diffRegards,
Pierrick(Sorry if you receive this message twice but it looks like I have problems with the ML)
Hi Pierrick, Guilherme
2010/8/25 Pierrick Charron [email protected]:
I'm here to propose a new feature in PHP: Annotations. A patch is already available with 54 tests for the moment[2].
I worked together with Guilherme Blanco to make this support happen in a fresh PHP SVN trunk checkout.
Please review, comment and provide feedback! I think it's a very useful support and may benefit users a lot.
After looking over both the RFC and patch I think its a great feature, and its something I remember Guilherme have bugged about since 5.3's development stage ;-).
The syntax for one is decent, by having it in the code rather than a source code comment and its somewhat compatible with that in C#. The only thing I could see missing in the patch, although its a minor thing is to dump Annotations when doing something like: Reflection::export(new Reflection...(...)); and your small TODO in ReflectionAnnotation::__construct() :)
But I'm a +1 for merging this into trunk, as it will without doubt get improved as we go, like with Traits.
--
regards,
Kalle Sommer Nielsen
[email protected]