(this page is translated by Google; We're working hard on a human translation)
Reflections
Nette\Reflection is a set of classes extending the standard classes reflective of PHP, especially on the annotation and some properties Nette\Object .
Reflection is a programmatic approach to certain reverse engineering. It allows us to identify such information as what properties and methods of the class has.
Types of reflection
There are several types of reflection:
- Class Reflections ( ClassReflection ) - name, implemented interfaces, annotations , defined constants and methods ...
- Reflection properties ( PropertyReflection ) - name, default, annotation , access modifier, statism, ...
- Reflection method ( MethodReflection ) - name, parameters, annotations , access modifier, statism, abstract, finálnost ...
- Reflection function ( FunctionReflection ) - name, title, parameters, namespace around, the file name ...
- Reflection parameter ( MethodParameterReflection ) - name, duty, default, type (field / class), the order parameter ...
- Reflections PHP extension ( ExtensionReflection ) - name, version, dependencies, defined classes, functions, constants and key in php.ini
For a detailed overview of available methods to study the API documentation and the PHP manual .
Getting reflection
Reflection can be obtained either directly by using its constructor ...
// získání reflexe třídy Nette\Application\Presenter
$classReflection = new Nette\Reflection\ClassReflection( 'Nette\Application\Presenter' );
// získání reflexe metody forward třídy Nette\Application\Presenter
$methodReflection = new Nette\Reflection\MethodReflection( 'Nette\Application\Presenter' , 'forward' ); ... Or as the return value of "superior reflection":
// získání reflexe metody forward třídy Nette\Application\Presenter
$methodReflection = $classReflection ->getMethod( 'forward' ); Facilitate work with the reflection
Classes inheriting Nette\Object to the method getReflection () to facilitate work with reflections. This allows us to work so simply reflections
class Foo extends Nette\Object
{
/** @var string */
public $bar ;
public function getBarType()
{
return $this ->getReflection() //získáme objekt reflexe třídy Foo
->getProperty( 'bar' ) //získáme objekt reflexe vlastnosti bar
->getAnnotation( 'var' ); //získáme hodnotu anotace var
}
}



