xp-framework/rfc — Issue #95: Member utilities
Author: thekid
Created: 2011-10-17 15:53:37+00:00
State: open
Labels: draft, framework

Scope of Change
====
A new API will be created to easily work with members.

Rationale
====
Remove boilerplate code.

Functionality
====

Current
----
XPClass::getMethods() returns an array of lang.reflect.Method objects. To
select only those decorated with an @inject annotation, the standard loop
and filter approach is used:

```php
getMethods() as $m) {
if (!$m->hasAnnotation('inject')) continue;

$value= $m->getAnnotation('inject');
// ...
}
?>
```

Annotation class
----
The new invoke.Annotation class provides a fast alternative to searching
for methods annotated with a certain annotation.

```php

```

Usage:

```php
methodsOf('some.test.Class') as $m) {
// ...
}
?>
```

Methods class
----
The new invoke.Methods class provides static methods to factor selectors.

```php

```

Examples:

```php
in('some.test.Class') as $m) {
// ...
}

foreach (Methods::findAll('[@inject] public *(ioc.Resource)')->in('some.ioc.Class') as $m) {
$value= $m->getAnnotation('inject');
// ...
}
?>
```

Security considerations
====
n/a

Speed impact
====
n/a

Dependencies
====
- xp-framework/rfc #109 - for the invoke package

Related documents
====
n/a