PHPackages                             bramus/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. bramus/reflection

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

bramus/reflection
=================

Better Reflection for PHP

1.0(7y ago)4436[1 issues](https://github.com/bramus/reflection/issues)1MITPHPPHP ^7.2CI failing

Since May 13Pushed 4y ago1 watchersCompare

[ Source](https://github.com/bramus/reflection)[ Packagist](https://packagist.org/packages/bramus/reflection)[ RSS](/packages/bramus-reflection/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (2)Versions (4)Used By (1)

`bramus/reflection`
===================

[](#bramusreflection)

[![Build Status](https://github.com/bramus/reflection/workflows/CI/badge.svg)](https://github.com/bramus/reflection/actions) [![Source](https://camo.githubusercontent.com/2dab3e2bd4e5a7b7d9b8eaaab85eafc0b98b83307960d9b69e70c63b4e19bb33/687474703a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d6272616d75732f7265666c656374696f6e2d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/bramus/reflection) [![Version](https://camo.githubusercontent.com/b855684a7148380173fd7165d69f6f688550302fe62d7ca0da7618430f13e419/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6272616d75732f7265666c656374696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bramus/reflection) [![Downloads](https://camo.githubusercontent.com/1414d40ac12b852dba7ae5bebc74624388808a69300959561be294df2e123d8d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6272616d75732f7265666c656374696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bramus/reflection/stats) [![License](https://camo.githubusercontent.com/4b4edd5a2c0c2f331d42714c3306237c5d7e06c623ced25e2a393f800f920077/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6272616d75732f7265666c656374696f6e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/bramus/reflection/blob/master/LICENSE)

`bramus/reflection` is a library that tries to make [PHP's built-in Reflection](https://www.php.net/manual/en/book.reflection.php) better.

Built by Bram(us) Van Damme *()* and [Contributors](https://github.com/bramus/reflection/graphs/contributors)

Prerequisites/Requirements
--------------------------

[](#prerequisitesrequirements)

- PHP 7.2 or greater

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

[](#installation)

Installation is possible using Composer

```
$ composer require bramus/reflection ~1.0

```

Usage
-----

[](#usage)

### A note

[](#a-note)

All classes in `bramus/reflection` extend PHP's built-in versions. Therefore they have all of the functions like their parent class:

- `\Bramus\Reflection\ReflectionClass` extends [PHP's built-in `ReflectionClass`](https://www.php.net/manual/en/class.reflectionclass.php).
- `\Bramus\Reflection\ReflectionClassConstant` extends [PHP's built-in `ReflectionClassConstant`](https://www.php.net/manual/en/class.reflectionclassconstant.php).

### `ReflectionClass`

[](#reflectionclass)

When compared to `\ReflectionClass`, `\Bramus\Reflection\ReflectionClass` works exactly the same, but will:

- Return an associative array containing `\Bramus\Reflection\ReflectionClassConstant` instances *(instead of simple values)* when calling [`getConstants()`](https://www.php.net/manual/en/reflectionclass.getconstants.php).
- Return a `\Bramus\Reflection\ReflectionClassConstant` instance *(instead of simple value)* when calling [`getConstant()`](https://www.php.net/manual/en/reflectionclass.getconstant.php).

Here's an example comparing `getConstant()`;

- Using PHP's built-in `ReflectionClass`:

    ```
     class Weekday
     {
     	/**
     	 * Monday
     	 */
     	const MONDAY = 1;

     	/**
     	 * Tuesday
     	 */
     	const TUESDAY = …
     }

     $reflected = new \ReflectionClass(Weekday::class);
     $constant = $reflected->getConstant('MONDAY');

     var_dump($constant);
     // int(1)
    ```
- Using `\Bramus\Reflection\ReflectionClass`:

    ```
     class Weekday
     {
     	/**
     	 * Monday
     	 */
     	const MONDAY = 1;

     	/**
     	 * Tuesday
     	 */
     	const TUESDAY = …
     }

     $reflected = new \Bramus\Reflection\ReflectionClass(Weekday::class);
     $constants = $reflected->getConstant('MONDAY');

     var_dump($constant);
     // object(Bramus\Reflection\ReflectionClassConstant)#40 (2) {
     //   ["name"]=>
     //   string(6) "MONDAY"
     //   ["class"]=>
     //   string(7) "Weekday"
     //   ["docComment":"Bramus\Reflection\ReflectionClassConstant":private]=>
     //   object(phpDocumentor\Reflection\DocBlock)#86 (7) {
     //     …
     //   }
     // }
    ```

### `ReflectionClassConstant`

[](#reflectionclassconstant)

When compared to `\ReflectionClassConstant`, `\Bramus\Reflection\ReflectionClassConstant` works exactly the same, but will:

- Return a `\phpDocumentor\Reflection\DocBlock` instance *(instead of a string)* when calling [`getDocComment()`](https://www.php.net/manual/en/reflectionclassconstant.getdoccomment.php)
- Provide you with a `getDocCommentString()` method in case you want to access the contents as [`\ReflectionClassConstant::getDocComment()`](https://www.php.net/manual/en/reflectionclassconstant.getdoccomment.php) would return
- Provide you with a `getSummary()` shorthand, directly on the `\Bramus\Reflection\ReflectionClassConstant` instance.
- Provide you with a `getDescription()` shorthand, directly on the `\Bramus\Reflection\ReflectionClassConstant` instance.

### Other Reflection Classes

[](#other-reflection-classes)

Other Reflection Classes are not provided. They might be in the future.

Testing
-------

[](#testing)

`bramus/reflection` ships with unit tests using [PHPUnit](https://github.com/sebastianbergmann/phpunit/) `~8.0`.

- If PHPUnit is installed globally run `phpunit` to run the tests.
- If PHPUnit is not installed globally, install it locally throuh composer by running `composer install --dev`. Run the tests themselves by calling `./vendor/bin/phpunit` or using the composer script `composer test`

```
$ composer test

```

License
-------

[](#license)

`bramus/reflection` is released under the MIT public license. See the enclosed `LICENSE` for details.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

2607d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/213073?v=4)[Bramus](/maintainers/bramus)[@bramus](https://github.com/bramus)

---

Top Contributors

[![bramus](https://avatars.githubusercontent.com/u/213073?v=4)](https://github.com/bramus "bramus (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.0k](/packages/craftcms-cms)[mcp/sdk

Model Context Protocol SDK for Client and Server applications in PHP

1.5k1.5M83](/packages/mcp-sdk)[phpdocumentor/reflection

Reflection library to do Static Analysis for PHP Projects

12525.9M147](/packages/phpdocumentor-reflection)[oat-sa/tao-core

TAO core extension

66143.7k120](/packages/oat-sa-tao-core)[voku/arrayy

Array manipulation library for PHP, called Arrayy!

4915.7M18](/packages/voku-arrayy)[symfony/ai-platform

PHP library for interacting with AI platform provider.

521.4M276](/packages/symfony-ai-platform)

PHPackages © 2026

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