To use this library simplycreate instances of:
* AdvancedReflectionClass,
* AdvancedReflectionMethod,
* AdvancedReflectionFunction,
These are extending the ReflectionClass, ReflectionMethod and
ReflectionFunction built in the PHP 5.x, so they are equipped
with all the methods from the original Reflection PHP mechanism
and additional ones:
* getBody() returns source code (string) containing main body of
the class/method/function
* getDeclaration() returns source code (string) containing entire
declaration of the class/method/function
* getStartColumn() returns starting column number (integer) of the
class/method/function in the starting line of code (getStartLine()).
* getStartPosition() returns position (integer) of the first character
of the class/method/function in the sourcecode file
Example taken from the PHP manual and modified for this library:
<?php
namespace A\B;
class Foo { public $test; }
$function = new \System\Reflection\AdvancedReflectionClass('A\\B\\Foo');
var_dump($function->inNamespace());
var_dump($function->getName());
var_dump($function->getNamespaceName());
var_dump($function->getDeclaration());
?>
See examples files for futher info.
|