PHPackages                             console-helpers/parser-reflection - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. console-helpers/parser-reflection

Abandoned → [goaop/parser-reflection](/?search=goaop%2Fparser-reflection)Library[Parsing &amp; Serialization](/categories/parsing)

console-helpers/parser-reflection
=================================

Provides reflection information, based on raw source

3.1.0(8mo ago)10124251[3 issues](https://github.com/goaop/parser-reflection/issues)MITPHPPHP &gt;=8.2CI passing

Since Nov 22Pushed 1mo ago6 watchersCompare

[ Source](https://github.com/goaop/parser-reflection)[ Packagist](https://packagist.org/packages/console-helpers/parser-reflection)[ GitHub Sponsors](https://github.com/lisachenko)[ RSS](/packages/console-helpers-parser-reflection/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (10)Dependencies (7)Versions (51)Used By (0)

Parser Reflection API Library
-----------------------------

[](#parser-reflection-api-library)

🔍 Static Code Analysis Meets Reflection
---------------------------------------

[](#-static-code-analysis-meets-reflection)

**Parser Reflection API** brings the power of PHP's Reflection API to static code analysis. Built on top of [nikic/php-parser](https://github.com/nikic/PHP-Parser), this library lets you introspect classes, methods, and properties **without ever loading them into memory**.

### ✨ Key Features

[](#-key-features)

🧠 **Pure AST-Based Reflection**

Forget autoloading. This library parses your PHP source files directly into an Abstract Syntax Tree (AST) and extracts reflection data from the syntax itself — no `include`, no `require`, no side effects. Analyze classes without bootstrapping your entire application. Perfect for static analyzers, code generators, documentation tools, and IDE plugins.

### Why Use It?

[](#why-use-it)

- 📊 **Source code analysis** — inspect structure without executing anything
- 🧪 **Safe introspection** — avoid triggering constructors or static initializers
- 🔌 **Drop-in compatible** — extends native `\ReflectionClass`, `\ReflectionMethod`, etc.

[![GitHub Workflow Status](https://camo.githubusercontent.com/8504fec750480b3cdf3ac354177d536898b418be001ac1296b7a206bfb04bd98/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f676f616f702f7061727365722d7265666c656374696f6e2f706870756e69742e796d6c3f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/8504fec750480b3cdf3ac354177d536898b418be001ac1296b7a206bfb04bd98/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f676f616f702f7061727365722d7265666c656374696f6e2f706870756e69742e796d6c3f6272616e63683d6d6173746572)[![PHPStan Badge](https://camo.githubusercontent.com/3a6d38fc5ef50cf5af3f711e5e857a2ce964a35205fd11bbfacc1add9559a748/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c25323031302d627269676874677265656e2e7376673f7374796c653d666c6174266c696e6b3d68747470732533412532462532467068707374616e2e6f7267253246757365722d677569646525324672756c652d6c6576656c73)](https://camo.githubusercontent.com/3a6d38fc5ef50cf5af3f711e5e857a2ce964a35205fd11bbfacc1add9559a748/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c25323031302d627269676874677265656e2e7376673f7374796c653d666c6174266c696e6b3d68747470732533412532462532467068707374616e2e6f7267253246757365722d677569646525324672756c652d6c6576656c73)[![GitHub release](https://camo.githubusercontent.com/5f7b3401d2a7ef0ec63a594ae79939fd2e0477e40a5ca661c9e1c094881f3166/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f676f616f702f7061727365722d7265666c656374696f6e2e737667)](https://github.com/goaop/parser-reflection/releases/latest)[![Total Downloads](https://camo.githubusercontent.com/dbb59ed27bd55a0a44060000815d6bd9068edb024445c0a550357deee5219603/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f676f616f702f7061727365722d7265666c656374696f6e2e737667)](https://packagist.org/packages/goaop/parser-reflection)[![Daily Downloads](https://camo.githubusercontent.com/6dc6d20c5c14e0fefd816fe9933c68a62bf5a0879aaf5e175e2eb30f09a20291/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64642f676f616f702f7061727365722d7265666c656374696f6e2e737667)](https://packagist.org/packages/goaop/parser-reflection)[![PHP Version](https://camo.githubusercontent.com/db2abc4c99337a799d57b191c749e512b551eaebf6ce7c37e0ea9eac2eb1b9f6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e342d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/9e266e078f7e7dfea20ef4db560a66d4a27ff84c76ba46befdc9d50423600825/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f676f616f702f7061727365722d7265666c656374696f6e2e737667)](https://packagist.org/packages/goaop/parser-reflection)[![Sponsor](https://camo.githubusercontent.com/bb12d9dc1322843f286cc097e773f46484771b3a0c3980fa8aebed6cb736e447/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53706f6e736f722d2545322539442541342545462542382538462d6c69676874677261793f7374796c653d666c6174266c6f676f3d676974687562)](https://github.com/sponsors/lisachenko)

Installation
------------

[](#installation)

Library can be installed with Composer. Installation is quite easy:

```
$ composer require goaop/parser-reflection
```

Composer will install the library to your project's `vendor/goaop/parser-reflection` directory.

Usage
-----

[](#usage)

### Initialization

[](#initialization)

Prior to the first use library can be optionally initialized. If you use Composer for installing packages and loading classes, then you shouldn't worry about initialization, library will be initialized automatically.

If project uses a custom autoloader then you should follow the next steps:

1. Create a new class that implements `\Go\ParserReflection\LocatorInterface`
2. Create an instance of that class and pass it to the `ReflectionEngine::init()` method for initial configuration

### Reflecting concrete classes/methods/properties without loading them

[](#reflecting-concrete-classesmethodsproperties-without-loading-them)

Just use `Go\ParserReflection` package reflection classes like traditional ones:

```
$parsedClass = new \Go\ParserReflection\ReflectionClass(SomeClass::class);
var_dump($parsedClass->getMethods());

$parsedMethod = new \Go\ParserReflection\ReflectionMethod(SomeClass::class, 'someMethod');
echo (string)$parsedMethod;
```

Or you can use an additional classes [`ReflectionFile`](docs/reflection_file.md) and [`ReflectionFileNamespace`](docs/reflection_file_namespace.md) to analyse a raw PHP files:

```
$parsedFile     = new \Go\ParserReflection\ReflectionFile('SomeClass.php');
$fileNameSpaces = $parsedFile->getFileNamespaces();
// We can iterate over namespaces in the file
foreach ($fileNameSpaces as $namespace) {
    $classes = $namespace->getClasses();
    // Iterate over the classes in the namespace
    foreach ($classes as $class) {
        echo "Found class: ", $class->getName(), PHP_EOL;
        // Now let's show all methods in the class
        foreach ($class->getMethods() as $method) {
            echo "Found class method: ", $class->getName(), '::', $method->getName(), PHP_EOL;
        }

        // ...all properties in the class
        foreach ($class->getProperties() as $property) {
            echo "Found class property: ", $class->getName(), '->', $property->getName(), PHP_EOL;
        }
    }
}
```

How it works?
-------------

[](#how-it-works)

To understand how library works let's look at what happens during the call to the `new \Go\ParserReflection\ReflectionClass(SomeClass::class)`

```
┌─────────────────────┐
│   ReflectionClass   │
└──────────┬──────────┘
           │ asks for AST node
           ▼
┌─────────────────────┐
│  ReflectionEngine   │
└──────────┬──────────┘
           │ locates file
           ▼
┌─────────────────────┐
│  ComposerLocator    │ ──► Composer autoloader
└──────────┬──────────┘
           │ parses file
           ▼
┌─────────────────────┐
│  nikic/php-parser   │ ──► Returns AST
└──────────┬──────────┘
           │ wraps nodes
           ▼
┌─────────────────────┐
│  Reflection Objects │
└─────────────────────┘

```

- `\Go\ParserReflection\ReflectionClass` asks reflection engine to give an AST node for the given class name
- Reflection engine asks a locator to locate a filename for the given class
- `ComposerLocator` instance asks the Composer to find a filename for the given class and returns this result back to the reflection engine
- Reflection engine loads the content of file and passes it to the [PHP-Parser](https://github.com/nikic/PHP-Parser) for tokenization and processing
- PHP-Parser returns an AST (Abstract Syntax Tree)
- Reflection engine then analyse this AST to extract specific nodes and wrap them into corresponding reflection classes.

Compatibility
-------------

[](#compatibility)

All parser reflection classes extend PHP internal reflection classes, this means that you can use `\Go\ParserReflection\ReflectionClass` instance in any place that asks for `\ReflectionClass` instance. All reflection methods should be compatible with original ones, providing an except methods that requires object manipulation, such as `invoke()`, `invokeArgs()`, `setAccessible()`, etc. These methods will trigger the process of class loading and switching to the internal reflection.

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance76

Regular maintenance activity

Popularity29

Limited adoption so far

Community26

Small or concentrated contributor base

Maturity89

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 75.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~144 days

Recently: every ~437 days

Total

26

Last Release

256d ago

Major Versions

0.6.0 → 1.0.0-alpha2015-12-26

1.x-dev → 2.0.02018-12-12

2.x-dev → 3.0.0-RC12020-11-19

3.0.1 → 4.0.0-RC12024-02-04

PHP version history (6 changes)0.5.0PHP &gt;=5.5.0

1.2.1PHP &gt;=5.6.0

2.0.0PHP &gt;=7.0

2.1.0PHP &gt;=7.1

3.0.0-RC1PHP &gt;=7.3

4.0.0-RC1PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/84e70d0bdeaa7cd5875b73c862ccd8359d2df057fb48a716fdd14d99a7f24fca?d=identicon)[aik099](/maintainers/aik099)

---

Top Contributors

[![lisachenko](https://avatars.githubusercontent.com/u/640114?v=4)](https://github.com/lisachenko "lisachenko (371 commits)")[![samsonasik](https://avatars.githubusercontent.com/u/459648?v=4)](https://github.com/samsonasik "samsonasik (65 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (28 commits)")[![MaximilianKresse](https://avatars.githubusercontent.com/u/545671?v=4)](https://github.com/MaximilianKresse "MaximilianKresse (7 commits)")[![xfuturomax](https://avatars.githubusercontent.com/u/8144576?v=4)](https://github.com/xfuturomax "xfuturomax (3 commits)")[![Fedott](https://avatars.githubusercontent.com/u/165486?v=4)](https://github.com/Fedott "Fedott (3 commits)")[![loren-osborn](https://avatars.githubusercontent.com/u/2467372?v=4)](https://github.com/loren-osborn "loren-osborn (2 commits)")[![JustBlackBird](https://avatars.githubusercontent.com/u/1167086?v=4)](https://github.com/JustBlackBird "JustBlackBird (2 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (2 commits)")[![func0der](https://avatars.githubusercontent.com/u/529819?v=4)](https://github.com/func0der "func0der (2 commits)")[![pdelre](https://avatars.githubusercontent.com/u/1379248?v=4)](https://github.com/pdelre "pdelre (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![siwinski](https://avatars.githubusercontent.com/u/1034024?v=4)](https://github.com/siwinski "siwinski (1 commits)")[![VolCh](https://avatars.githubusercontent.com/u/396345?v=4)](https://github.com/VolCh "VolCh (1 commits)")[![ddinchev](https://avatars.githubusercontent.com/u/1397692?v=4)](https://github.com/ddinchev "ddinchev (1 commits)")[![dg](https://avatars.githubusercontent.com/u/194960?v=4)](https://github.com/dg "dg (1 commits)")[![marcovtwout](https://avatars.githubusercontent.com/u/438046?v=4)](https://github.com/marcovtwout "marcovtwout (1 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")

---

Tags

astparser-reflectionphpphp-parserreflection

###  Code Quality

TestsPHPUnit

Static AnalysisRector

### Embed Badge

![Health badge](/badges/console-helpers-parser-reflection/health.svg)

```
[![Health](https://phpackages.com/badges/console-helpers-parser-reflection/health.svg)](https://phpackages.com/packages/console-helpers-parser-reflection)
```

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M95](/packages/dedoc-scramble)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M341](/packages/psalm-plugin-laravel)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k13](/packages/tempest-framework)[jolicode/automapper

JoliCode AutoMapper

217527.7k11](/packages/jolicode-automapper)[cakephp/bake

Bake plugin for CakePHP

11212.0M194](/packages/cakephp-bake)[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1882.3M41](/packages/dereuromark-cakephp-ide-helper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
