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

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

componenta/reflection
=====================

Reflection helpers for Componenta

v1.0.0(1mo ago)097MITPHPPHP ^8.4

Since Jun 16Pushed 1mo agoCompare

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

READMEChangelog (1)Dependencies (1)Versions (2)Used By (7)

Componenta Reflection
=====================

[](#componenta-reflection)

Small reflection helper for Componenta internals.

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

[](#installation)

```
composer require componenta/reflection
```

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

[](#requirements)

- PHP 8.4+

Related Packages
----------------

[](#related-packages)

This package is standalone and is mostly an internal helper for Componenta libraries.

PackageWhy it uses reflection`componenta/di`Reads parameters, properties, and attributes during dependency resolution.`componenta/interceptor`Reads method attributes for attribute-based interceptors.`componenta/class-finder`Attribute and inheritance filters can inspect discovered classes.`componenta/policy`Attribute policies can be read through reflection providers or app compilation.What It Provides
----------------

[](#what-it-provides)

- Cached reflection for classes, objects, closures, functions, methods, and invokable objects.
- Attribute lookup helpers for a single reflector.
- Deep attribute lookup across a class, its methods, properties, and constants.
- `WeakMap`-backed metadata cache for attribute instances.

Reflecting Values
-----------------

[](#reflecting-values)

```
use Componenta\Reflection\Reflection;

$class = Reflection::class(App\Service\UserService::class);
$object = Reflection::object($service);
$closure = Reflection::callable(static fn(): string => 'ok');
$method = Reflection::callable([App\Service\UserService::class, 'handle']);
```

`Reflection::reflect()` accepts mixed input and returns the matching PHP reflector or `null`.

```
$reflector = Reflection::reflect($value);
```

Reading Attributes
------------------

[](#reading-attributes)

```
use Componenta\Reflection\Reflection;

$class = Reflection::class(App\Command\CreatePostCommand::class);

$policies = Reflection::getMetadata($class, PermissionPolicy::class);
$policy = Reflection::getFirstMetadata($class, PermissionPolicy::class);
$hasPolicy = Reflection::hasMetadata($class, PermissionPolicy::class);
```

`getMetadata()` returns `array|null`: `null` means no matching attributes.

Deep Attribute Lookup
---------------------

[](#deep-attribute-lookup)

```
$attributes = Reflection::getDeepMetadata($class, SomeAttribute::class);

foreach ($attributes as $path => $items) {
    // $path examples:
    // App\Command\CreatePostCommand
    // App\Command\CreatePostCommand::handle
    // App\Command\CreatePostCommand::$title
    // App\Command\CreatePostCommand::STATUS
}
```

Cache Management
----------------

[](#cache-management)

```
Reflection::clearReflectors();
```

Use this in tests when a test mutates reflector state or needs isolation.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance91

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity51

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

44d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20490712?v=4)[Andrey Shelamkoff](/maintainers/Shelamkoff)[@Shelamkoff](https://github.com/Shelamkoff)

---

Top Contributors

[![Shelamkoff](https://avatars.githubusercontent.com/u/20490712?v=4)](https://github.com/Shelamkoff "Shelamkoff (1 commits)")

### Embed Badge

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

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

###  Alternatives

[esensi/core

The foundational components of Esensi

232.1k](/packages/esensi-core)

PHPackages © 2026

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