thekid/rfc — Issue #36: RFC 0033: Annotation support for members / lang.reflect.Field
Author: thekid
Created: 2011-10-09 14:16:14+00:00
State: open
Labels: rfc

Scope of Change
====
Annotations will be supported for member variables. XPClass::getFields()
will no longer return an hash of name => value for each member variable
but an array of Field objects.

Rationale
====
A situation in which this will be useful is when generating WSDLs for
complex types (objects). Because PHP can not initialize member variables
to objects and because PHP variables only get a type when they're
assigned something, we cannot correctly reflect types of those member
variables.

Functionality
====

Type hinting member variables
----

```php

```

Retrieving class fields
----

```php
getFields() as $field) {
echo $field->getType(), ' ', $field->getName(), "\n";
}
?>
```

Security considerations
====
n/a

Speed impact
====
- Reflection will be a bit slower

Dependencies
====

Related documents
====
- xp-framework/rfc #16: Metadata for PHP4

- http://xp-framework.net/downloads/0033.rfc.diff
Implementing patch

- http://xp-framework.net/downloads/ReflectionTest.class.phps
Test case (NOTE: requires xp-framework/rfc #32 and xp-framework/rfc #33 patches to work!)

- http://xp-framework.net/downloads/TestClass.class.phps
Test class for above test case

Comments
====
n/a