mindplay/filereflection

This package is abandoned and no longer maintained. The author suggests using the roave/better-reflection package instead.

Complements the PHP reflection API with the missing ReflectionFile class

1.2.1 2015-06-17 16:00 UTC

This package is auto-updated.

Last update: 2023-11-29 13:55:45 UTC


README

⚠️ DEPRECATED ⚠️

Consider using Roave/BetterReflection instead.

https://github.com/mindplay-dk/filereflection

This library complements the PHP reflection API with the missing ReflectionFile class.

Build Status

A few other libraries were available to do this already, but this one implements an important feature missing from other implementations I could find: resolution of local type-names according to the name resolution rules.

The interface is very simple:

ReflectionFile {

    public __construct( string $path )

    public string getPath ( void )
    public string getNamespaceName ( void )
    public string resolveName ( string $name )
    public ReflectionClass getClass ( string $name )
    public ReflectionClass[] getClasses ( void )

}

Usage of course is straight forward too:

use mindplay\filereflection\ReflectionFile;

$file = new ReflectionFile('/path/to/MyNamespace/MyClass.php');

var_dump($file->resolveName('MyOtherClass')); // => '\MyNamespace\MyOtherClass'

Note that this library currently omits reflection/enumeration of functions, constants, etc.