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

ActiveLibrary

web-fu/reflection
=================

Reflection API

v2.5.1(1mo ago)16.9k↑16.7%2MITPHPPHP ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0CI passing

Since Mar 7Pushed 1mo ago1 watchersCompare

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

READMEChangelog (7)Dependencies (10)Versions (20)Used By (2)

Reflection
==========

[](#reflection)

[![Latest Stable Version](https://camo.githubusercontent.com/4ca4f9ef97e0888f534b1fa88319b60f38812e2a8e48b1c1e04785f797152a06/68747470733a2f2f706f7365722e707567782e6f72672f7765622d66752f7265666c656374696f6e2f76)](https://packagist.org/packages/web-fu/reflection)[![PHP Version Require](https://camo.githubusercontent.com/67b9fb90aae70b38c58ee53dd428cee6744bf9e1bab06edbf9647ac0a0590447/68747470733a2f2f706f7365722e707567782e6f72672f7765622d66752f7265666c656374696f6e2f726571756972652f706870)](https://packagist.org/packages/web-fu/reflection)[![Test status](https://github.com/web-fu/reflection/actions/workflows/tests.yaml/badge.svg)](https://github.com/web-fu/reflection/actions/workflows/tests.yaml/badge.svg)[![Static analysis status](https://github.com/web-fu/reflection/actions/workflows/static-analysis.yml/badge.svg)](https://github.com/web-fu/reflection/actions/workflows/static-analysis.yml/badge.svg)[![Code style status](https://github.com/web-fu/reflection/actions/workflows/code-style.yaml/badge.svg)](https://github.com/web-fu/reflection/actions/workflows/code-style.yaml/badge.svg)

### This library is a type safe wrapper for PHP Reflection API.

[](#this-library-is-a-type-safe-wrapper-for-php-reflection-api)

This library is born with the purpose to solve the problem of type safety in PHP Reflection API. Reflection API is a very powerful tool, but presents some issues.

For example:

- the original `ReflectionClass::getConstant` return `false` if the constant does not exist or if the constant is equal to `false`.
- `ReflectionClass::newInstance` return a generic object, but it is possible to know the type of the object.
- New interfaces are added to the Reflection API in different PHP versions, so it is not possible to use them in a cross-version way.

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

[](#installation)

web-fu/reflection is available on [Packagist](https://packagist.org/packages/web-fu/reflection) and can be installed using [Composer](https://getcomposer.org/).

```
composer require web-fu/reflection
```

> Requires PHP 8.0 or newer.

Usage
-----

[](#usage)

This wrapper try to use the same names of the original Reflection API, but with a different namespace.

```
