2017 © Pedro Peláez
 

library reflection

FSi Reflection Component is an extension of built-in reflection classes in PHP 5.3 that saves a lot memory, thanks to factory design pattern.

image

fsi/reflection

FSi Reflection Component is an extension of built-in reflection classes in PHP 5.3 that saves a lot memory, thanks to factory design pattern.

  • Tuesday, August 19, 2014
  • by chives
  • Repository
  • 7 Watchers
  • 7 Stars
  • 38,830 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 3 Versions
  • 2 % Grown

The README.md

Reflection - Optimized reflection package for PHP 5.3

FSi Reflection component is an extension of built-in reflection classes in PHP 5.3. Some of their methods are rewritten in such way that reflection objects are cached and never created twice for the same class/method/property/function or extension. This is achieved by usage of factory pattern. Some of the methods that cannot be rewriten to use such a cache throw an exception. All ReflectionProperty and ReflectionMethod objects returned from this library are previously set as accessible so they can be used even if they're private or protected., (*1)

Setup and autoloading

We highly recommend to use autoloader generated by composer.phar, (*2)

Adding reflection into composer.json, (*3)

{
    ... 
    "require": {
        ... 
        "fsi/reflection": "0.9.*" 
        ...
    },
    ...
}

Usage example

The key idea of using this reflection library is not to contruct reflection classes by their constructors but through the factory() methods added to each reflection class. Let's assume we have a class named ClassA:, (*4)

``` php <?php class ClassA { private $privateProperty;, (*5)

protected $protectedProperty;

public $publicProperty;

public function __construct($constructorParam)
{

}

private function privateMethod($paramA, $paramB)
{
    return $paramA . '-' .$paramB;
}

protected function protectedMethod($paramC, $paramD)
{
    return $paramC . '+' .$paramD;
}

public function publicMethod($paramE, $paramF)
{
    return $paramE . '=' .$paramF;
}

}, (*6)


In order to create reflection objects you can: ``` php <?php use FSi\Reflection\ReflectionClass; use FSi\Reflection\ReflectionProperty; use FSi\Reflection\ReflectionMethod; $reflectionClassA = ReflectionClass::factory('ClassA'); $reflectionPropertyPrivate = $reflectionClassA->getProperty('privateProperty'); $reflectionPropertyPrivate = ReflectionProperty::factory('ClassA', 'privateProperty'); $reflectionMethodPrivate = $reflectionClassA->getMethod('privateMethod'); $reflectionMethodPrivate = ReflectionMethod::factory('ClassA', 'privateMethod');

You must remember that using any reflection class' constructor directly in your code will throw an exception., (*7)

The Versions

19/08 2014

dev-master

9999999-dev

FSi Reflection Component is an extension of built-in reflection classes in PHP 5.3 that saves a lot memory, thanks to factory design pattern.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Norbert Orzechowicz
by Lukasz Cybula

component reflection fsi

03/10 2012

0.9.2

0.9.2.0

FSi Reflection Component is an extension of built-in reflection classes in PHP 5.3 that saves a lot memory, thanks to factory design pattern.

  Sources   Download

The Requires

  • php >=5.3.0

 

by Norbert Orzechowicz
by Lukasz Cybula

component reflection fsi

10/07 2012

0.9.1

0.9.1.0

FSi Reflection Component

  Sources   Download

The Requires

  • php >=5.3.0

 

by Lukasz Cybula

component reflection fsi