PHP Classes
elePHPant
Icontem

Advanced Sourcecode Reflection in PHP: Retrieve extended class reflection information

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2011-03-21 (5 years ago) RSS 2.0 feedStarStarStarStar 76%Total: 849 All time: 3,938 This week: 1,045Up
Version License PHP version Categories
advanced-reflection 1.0.0GNU Lesser Genera...5.2.2PHP 5, Language
Description Author

This package can retrieve extended reflection information on classes or functions.

It can extends the reflection classes and parses PHP source code to retrieve additional details on classes and functions.

Currently it returns the body of their code, the declaration, the line, column and file position in the source file, besides other details that can be retrieved by the base reflection support.

Innovation Award
PHP Programming Innovation award nominee
April 2011
Number 2


Prize: One copy of RadPHP XE
PHP 5 introduced reflection support in PHP, thus allowing applications to introspect PHP classes at runtime and do something useful with classes meta-information.

This class goes further by parsing the actual PHP source code to provide additional useful meta-information details besides what PHP reflection support provides.

Manuel Lemos
Picture of Artur Graniszewski
  Performance   Level  
Name: Artur Graniszewski <contact>
Classes: 13 packages by
Country: Poland Poland
Innovation award
Innovation award
Nominee: 7x

Winner: 1x

Details
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.
Screenshots  
  • example1.PNG
  Files folder image Files  
File Role Description
Plain text file reflection_php53.php Class Main class (PHP 5.3+ only)
Plain text file reflection_php52.php Class Main class (PHP 5.2+)
Accessible without login Plain text file example_php53.php Example Example #1 (PHP 5.3+ only)
Accessible without login Plain text file example_php52.php Example Example #2 (PHP 5.2+)
Accessible without login Plain text file license.txt Lic. LGPL license
Accessible without login Plain text file readme.txt Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 0%
Total:849
This week:0
All time:3,938
This week:1,045Up
 User Ratings  
 
 All time
Utility:100%StarStarStarStarStarStar
Consistency:93%StarStarStarStarStar
Documentation:87%StarStarStarStarStar
Examples:87%StarStarStarStarStar
Tests:-
Videos:-
Overall:76%StarStarStarStar
Rank:64