PHP Classes
elePHPant
Icontem

Advanced Sourcecode Reflection in PHP: Retrieve extended class reflection information

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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 (4 years ago) RSS 2.0 feedStarStarStarStar 77%Total: 814 All time: 3,962 This week: 1,197Up
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
Name: Artur Graniszewski is available for providing paid consulting. Contact Artur Graniszewski .
Classes: 13 packages by
Country: Poland Poland
Age: 33
All time rank: 3205 in Poland Poland
Week rank: 219 Up5 in Poland Poland Equal
Innovation award
Innovation award
Nominee: 7x

Winner: 1x

Details provided by the author  
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:814All time:3,962
 This week:0This week:1,197Up
 User Ratings  
 
 All time
Utility:100%StarStarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:91%StarStarStarStarStar
Examples:91%StarStarStarStarStar
Tests:-
Videos:-
Overall:77%StarStarStarStar
Rank:29