xp-framework/xp-framework — pull request #93 by thekid (2011-12-28 09:29:27+00:00)
Title: Access to private constructors, methods and fields

The current 5.8-SERIES allows accessing **protected** constructors, methods and fields in any of the supported PHP versions (5.2.10 through 5.3.8 officially). For **private** versions of this, accessing them fails currently as there is no way to enable this completely in PHP versions without `setAccessible()` in its reflection API.

This pull request includes changes to allow for private access to work when running on PHP >= 5.3.2. For example, given the following:

```php
getClass()->getMethod('fixture')->invoke($self);
}
}
?>
```

*When run on PHP >= 5.3.2*

```sh
$ xp PrivateAccess
PHP Version 5.3.2
Private fixture() method called
```

*When run on PHP < 5.3.2*

```sh
$ xp PrivateAccess
PHP Version 5.2.17
Uncaught exception: Exception lang.reflect.TargetInvocationException (PrivateAccess::main)
at lang.reflect.Method::invoke(NULL, array[1]) [line 91 of class.php]
Caused by Exception lang.IllegalAccessException (Cannot invoke private PrivateAccess::fixture from scope PrivateAccess)
at lang.reflect.Method::invoke(NULL) [line 11 of PrivateAccess.class.php]
at PrivateAccess::main(array[0]) [line 0 of StackTraceElement.class.php]
... 2 more
```

This is aligned with the strategy of *suggesting* PHP 5.3.x, but still working on 5.2.x in XP 5.9-SERIES.