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

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

brick/reflection
================

Low-level tools to extend PHP reflection capabilities

0.7.1(3mo ago)23273.0k↓57.9%3[1 issues](https://github.com/brick/reflection/issues)[1 PRs](https://github.com/brick/reflection/pulls)5MITPHPPHP ^8.1CI failing

Since Oct 3Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/brick/reflection)[ Packagist](https://packagist.org/packages/brick/reflection)[ RSS](/packages/brick-reflection/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (7)Versions (22)Used By (5)

Brick\\Reflection
=================

[](#brickreflection)

[![](https://raw.githubusercontent.com/brick/brick/master/logo.png)](https://raw.githubusercontent.com/brick/brick/master/logo.png)

A collection of low-level tools to extend PHP reflection capabilities.

[![Build Status](https://github.com/brick/reflection/workflows/CI/badge.svg)](https://github.com/brick/reflection/actions)[![Coverage Status](https://camo.githubusercontent.com/909076c133d6e2e582f5c5cfcfc508ca8ad80f5511c9a845cad64af189e4893d/68747470733a2f2f636f6465636f762e696f2f6769746875622f627269636b2f7265666c656374696f6e2f67726170682f62616467652e737667)](https://codecov.io/github/brick/reflection)[![Latest Stable Version](https://camo.githubusercontent.com/1d98c39b3b960ee95709ffebf1748a45006f17d0a912b753695bb0046d48173b/68747470733a2f2f706f7365722e707567782e6f72672f627269636b2f7265666c656374696f6e2f762f737461626c65)](https://packagist.org/packages/brick/reflection)[![Total Downloads](https://camo.githubusercontent.com/5ec07a5ba2a30c46868af5a4c8962035f1449bb5721d171c44f0bbd6314149ed/68747470733a2f2f706f7365722e707567782e6f72672f627269636b2f7265666c656374696f6e2f646f776e6c6f616473)](https://packagist.org/packages/brick/reflection)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](http://opensource.org/licenses/MIT)

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

[](#installation)

This library is installable via [Composer](https://getcomposer.org/):

```
composer require brick/reflection
```

Requirements
------------

[](#requirements)

This library requires PHP 8.1 or later.

Project status &amp; release process
------------------------------------

[](#project-status--release-process)

This library is still under development.

The current releases are numbered `0.x.y`. When a non-breaking change is introduced (adding new methods, optimizing existing code, etc.), `y` is incremented.

**When a breaking change is introduced, a new `0.x` version cycle is always started.**

It is therefore safe to lock your project to a given release cycle, such as `0.7.*`.

If you need to upgrade to a newer release cycle, check the [release history](https://github.com/brick/reflection/releases)for a list of changes introduced by each further `0.x.0` version.

Documentation
=============

[](#documentation)

Here is a brief overview of the classes in this package.

ReflectionTools
---------------

[](#reflectiontools)

This class is a collection of tools that build on top of PHP's reflection classes to provide additional functionality.

Just create an instance of `ReflectionTools` and you can use the following methods:

- `getClassMethods()` returns reflections of all the non-static methods that make up one object, including private methods of parent classes.
- `getClassProperties()` returns reflections of all the non-static properties that make up one object, including private properties of parent classes.
- `getClassHierarchy()` returns the hierarchy of classes, starting from the first ancestor and ending with the class itself.
- `getReflectionFunction()` returns a reflection object for any callable.
- `getFunctionName()` returns a meaningful name for the given function, including the class name if it is a method.
- `exportFunctionSignature()` exports a function's signature, such as `public function foo(string $bar): int`.

ImportResolver
--------------

[](#importresolver)

ImportResolver resolves class names to their fully qualified name, taking into account the current namespace and `use` statements of the PHP file they were used in.

This is particularly useful for parsing annotations such as `@param ClassName $foo`, where the FQCN of ClassName depends on the file it appears in, for example:

```
