PHPackages                             phpdocumentor/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. phpdocumentor/reflection

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phpdocumentor/reflection
========================

Reflection library to do Static Analysis for PHP Projects

6.4.4(5mo ago)12521.4M—6%61[11 issues](https://github.com/phpDocumentor/Reflection/issues)[1 PRs](https://github.com/phpDocumentor/Reflection/pulls)20MITPHPPHP 8.1.\*|8.2.\*|8.3.\*|8.4.\*|8.5.\*CI passing

Since Nov 29Pushed 1w ago8 watchersCompare

[ Source](https://github.com/phpDocumentor/Reflection)[ Packagist](https://packagist.org/packages/phpdocumentor/reflection)[ Docs](http://www.phpdoc.org)[ RSS](/packages/phpdocumentor-reflection/feed)WikiDiscussions 7.x Synced 1mo ago

READMEChangelog (10)Dependencies (20)Versions (71)Used By (20)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![Qa workflow](https://github.com/phpDocumentor/Reflection/workflows/Qa%20workflow/badge.svg)](https://github.com/phpDocumentor/Reflection/workflows/Qa%20workflow/badge.svg)[![Coveralls Coverage](https://camo.githubusercontent.com/03a089edf71e8a65d4ca8a180d3cb38f52cccfc54698a83bcfd74bed9aa61dad/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6769746875622f706870446f63756d656e746f722f5265666c656374696f6e2e737667)](https://coveralls.io/github/phpDocumentor/Reflection?branch=master)[![Scrutinizer Code Coverage](https://camo.githubusercontent.com/02bbc18b5c4ea46b00d97192fe0d2cb4dffae72411453a2c8ae39eeb32a499ce/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f706870446f63756d656e746f722f5265666c656374696f6e2e737667)](https://scrutinizer-ci.com/g/phpDocumentor/Reflection/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7f6101570c5e152efa7c8342bef193a3dcbd78ac7b43cdca0740cbe6a3ebd234/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f706870446f63756d656e746f722f5265666c656374696f6e2e737667)](https://scrutinizer-ci.com/g/phpDocumentor/Reflection/?branch=master)[![Stable Version](https://camo.githubusercontent.com/e52b3f3028d58f5fa2513911fab34d48a8fb0cc4c88fe803898efdb551bfe592/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706870446f63756d656e746f722f5265666c656374696f6e2e737667)](https://packagist.org/packages/phpDocumentor/Reflection)[![Unstable Version](https://camo.githubusercontent.com/da8ae8d3948f9a8d4a6ed145bd1507366a303c806fbf031eff146366823fc3d0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f706870446f63756d656e746f722f5265666c656374696f6e2e737667)](https://packagist.org/packages/phpDocumentor/Reflection)

Reflection
==========

[](#reflection)

Using this library it is possible to statically reflect one or more files and create an object graph representing your application's structure, including accompanying in-source documentation using DocBlocks.

The information that this library provides is similar to what the (built-in) Reflection extension of PHP provides; there are however several advantages to using this library:

- Due to its Static nature it does not execute procedural code in your reflected files where Dynamic Reflection does.
- Because the none of the code is interpreted by PHP (and executed) Static Reflection uses less memory.
- Can reflect complete files
- Can reflect a whole project by reflecting multiple files.
- Reflects the contents of a DocBlock instead of just mentioning there is one.
- Is capable of analyzing code written for any PHP version (starting at 5.2) up to and including your installed PHP version.

Features
--------

[](#features)

- \[Creates an object graph\] containing the structure of your application much like a site map shows the structure of a website.
- Can read and interpret code of any PHP version starting with 5.2 up to and including your currently installed version of PHP.
- Due it's clean interface it can be in any application without a complex setup.

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

[](#installation)

In order to inspect a codebase you need to tell composer to include the `phpdocumentor/reflection` package. This can easily be done using the following command in your command line terminal:

```
composer require phpdocumentor/reflection:~6.0

```

After the installation is complete no further configuration is necessary and you can immediately start using it.

Basic Usage
-----------

[](#basic-usage)

This Reflection library uses [PSR-4](http://php-fig.com) and it is recommended to use a PSR-4 compatible autoloader to load all the files containing the classes for this library.

An easy way to do this is by including the [composer](http://getcomposer.org) autoloader as shown here:

```
include 'vendor/autoload.php';

```

Once that is done you can use the `createInstance()` method of the `\phpDocumentor\Reflection\Php\ProjectFactory` class to instantiate a new project factory and pre-configure it with sensible defaults. Optional you can specify the parser version that shall be used as an argument of `createInstance()`. By default the php7 parser is prefered. And php5 is used as a fallback. See the [documentation of phpparser](https://github.com/nikic/PHP-Parser/blob/master/UPGRADE-2.0.md#creating-a-parser-instance) for more info.

```
$projectFactory = \phpDocumentor\Reflection\Php\ProjectFactory::createInstance();

```

At this point we are ready to analyze your complete project or just one file at the time. Just pass an array of file paths to the `create` method of the project factory.

```
$projectFiles = [new \phpDocumentor\Reflection\File\LocalFile('tests/example.file.php')];
$project = $projectFactory->create('My Project', $projectFiles);

```

When the process is ready a new object of type `phpDocumentor\Reflection\Php\Project` will be returned that contains a complete hierarchy of all files with their classes, traits and interfaces (and everything in there), but also all namespaces and packages as a hierarchical tree.

> See the [example](example.php) script for a detailed and commented example

###  Health Score

77

—

ExcellentBetter than 100% of packages

Maintenance84

Actively maintained with recent releases

Popularity67

Solid adoption and visibility

Community49

Growing community involvement

Maturity95

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~85 days

Recently: every ~31 days

Total

58

Last Release

53d ago

Major Versions

2.0.0-alpha2 → 3.0.02016-02-19

3.0.x-dev → 4.0.0-alpha12018-06-15

4.x-dev → 5.0.02021-07-01

5.x-dev → 6.0.02024-05-23

6.x-dev → 7.x-dev2026-03-27

PHP version history (10 changes)0.1.0PHP &gt;=5.3.3

2.0.0-alpha1PHP &gt;=5.4.0

4.0.0-alpha1PHP &gt;=7.1

4.0.0-beta2PHP &gt;=7.2

5.3.0PHP ^7.4|8.0.\*|8.1.\*

5.3.2PHP ^7.4|8.0.\*|8.1.\*|8.2.\*|8.3.\*

6.0.0PHP 8.1.\*|8.2.\*|8.3.\*

6.1.0PHP 8.1.\*|8.2.\*|8.3.\*|8.4.\*

6.4.2PHP 8.1.\*|8.2.\*|8.3.\*|8.4.\*|8.5.\*

7.x-devPHP 8.2.\*|8.3.\*|8.4.\*|8.5.\*

### Community

Maintainers

![](https://www.gravatar.com/avatar/a647298f39a390bc7ea26c9ae9f0b98e87192d18a1065392df4ff20660e9577d?d=identicon)[mvriel](/maintainers/mvriel)

![](https://www.gravatar.com/avatar/1323714f58f9144af310e5e4217e61b96ad7c42bc5c93a1f2d97deca95f6f4f8?d=identicon)[ashnazg](/maintainers/ashnazg)

![](https://www.gravatar.com/avatar/471baf346b526fa9e1259ee3d577b1dd72fbb45337b495d5475f87ba063490cb?d=identicon)[jaapio](/maintainers/jaapio)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (421 commits)")[![jaapio](https://avatars.githubusercontent.com/u/1060433?v=4)](https://github.com/jaapio "jaapio (407 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (367 commits)")[![mvriel](https://avatars.githubusercontent.com/u/193704?v=4)](https://github.com/mvriel "mvriel (126 commits)")[![ashnazg](https://avatars.githubusercontent.com/u/100170?v=4)](https://github.com/ashnazg "ashnazg (73 commits)")[![jrfnl](https://avatars.githubusercontent.com/u/663378?v=4)](https://github.com/jrfnl "jrfnl (12 commits)")[![arogachev](https://avatars.githubusercontent.com/u/8326201?v=4)](https://github.com/arogachev "arogachev (11 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (10 commits)")[![cebe](https://avatars.githubusercontent.com/u/189796?v=4)](https://github.com/cebe "cebe (9 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (7 commits)")[![boenrobot](https://avatars.githubusercontent.com/u/1029536?v=4)](https://github.com/boenrobot "boenrobot (7 commits)")[![lacatoire](https://avatars.githubusercontent.com/u/20201470?v=4)](https://github.com/lacatoire "lacatoire (5 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (4 commits)")[![joncave](https://avatars.githubusercontent.com/u/621103?v=4)](https://github.com/joncave "joncave (3 commits)")[![benji07](https://avatars.githubusercontent.com/u/166890?v=4)](https://github.com/benji07 "benji07 (3 commits)")[![adrianhardy](https://avatars.githubusercontent.com/u/2385586?v=4)](https://github.com/adrianhardy "adrianhardy (2 commits)")[![AJenbo](https://avatars.githubusercontent.com/u/204594?v=4)](https://github.com/AJenbo "AJenbo (2 commits)")[![boekkooi](https://avatars.githubusercontent.com/u/399895?v=4)](https://github.com/boekkooi "boekkooi (2 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (2 commits)")[![jeromegamez](https://avatars.githubusercontent.com/u/67554?v=4)](https://github.com/jeromegamez "jeromegamez (2 commits)")

---

Tags

hacktoberfestreflectionphpdocstatic analysisreflectionphpDocumentor

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phpdocumentor-reflection/health.svg)

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

###  Alternatives

[phpdocumentor/reflection-common

Common reflection classes used by phpdocumentor to reflect the code structure

9.1k706.8M26](/packages/phpdocumentor-reflection-common)[phpdocumentor/reflection-docblock

With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.

9.4k722.2M1.2k](/packages/phpdocumentor-reflection-docblock)[icanhazstring/composer-unused

Show unused packages by scanning your code

1.7k7.0M188](/packages/icanhazstring-composer-unused)[phpdocumentor/phpdocumentor

Documentation Generator for PHP

4.4k3.1M878](/packages/phpdocumentor-phpdocumentor)[bmitch/churn-php

Discover files in need of refactoring.

1.4k1.5M12](/packages/bmitch-churn-php)[php-di/phpdoc-reader

PhpDocReader parses @var and @param values in PHP docblocks (supports namespaced class names with the same resolution rules as PHP)

7431.6M55](/packages/php-di-phpdoc-reader)

PHPackages © 2026

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