PHPackages                             best-served-cold/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. best-served-cold/reflection

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

best-served-cold/reflection
===========================

Reflection - Simple utility to reflect objects and classes to access properties and methods.

1.0.3(9y ago)0130MITPHPPHP &gt;=5.6

Since Mar 14Pushed 9y ago1 watchersCompare

[ Source](https://github.com/nark3d/Reflection)[ Packagist](https://packagist.org/packages/best-served-cold/reflection)[ Docs](http://bestservedcold.com)[ RSS](/packages/best-served-cold-reflection/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (5)Used By (0)

[![Build Status](https://camo.githubusercontent.com/cc129f254a8d00605c19a72f35fa19fb66302c479f1f1f475058f75b87cfb3d3/68747470733a2f2f7472617669732d63692e6f72672f6e61726b33642f5265666c656374696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/nark3d/Reflection)[![Build Status](https://camo.githubusercontent.com/167470d3a97687e4ff0f316c477735149152471652a977f17c1265aa64a70efa/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e61726b33642f5265666c656374696f6e2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/nark3d/Reflection/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/1f00d21d1cabb71d27cb5c9b015e69a94a4e760ae63f1d87560e67222cefc94c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e61726b33642f5265666c656374696f6e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/nark3d/Reflection/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/6d912fb37338544f933e19aa6c15741ecfd748a33efe835925cb4af65ad6608a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e61726b33642f5265666c656374696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/nark3d/Reflection/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/c333527250dee9c3e1e413d23e400dbba1a591cf58038f272027bbac79634c8b/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f34633038363365652d383934372d343638632d396237652d3136353730346539386335662f6d696e692e706e67)](https://insight.sensiolabs.com/projects/4c0863ee-8947-468c-9b7e-165704e98c5f)[![Latest Stable Version](https://camo.githubusercontent.com/008b1ff57deb91301e949976d0b456752a845a79c73bf0c33b2affb6344c32fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626573742d7365727665642d636f6c642f7265666c656374696f6e2e737667)](https://packagist.org/packages/best-served-cold/reflection)[![Code Climate](https://camo.githubusercontent.com/6e62161f331650803d24b3016a1bf4e10ee0e1ab1bb9bd692d0ef793b973a44e/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6e61726b33642f5265666c656374696f6e2f6261646765732f6770612e737667)](https://codeclimate.com/github/nark3d/Reflection)[![Issue Count](https://camo.githubusercontent.com/9ac2b5e60f03491167828de0227c36dd0698b7cc85ee57689c2d595a3b3425df/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6e61726b33642f5265666c656374696f6e2f6261646765732f69737375655f636f756e742e737667)](https://codeclimate.com/github/nark3d/Reflection)

Reflection
==========

[](#reflection)

A simple way of interrogating private methods and properties via overloading.

Install
-------

[](#install)

```
composer require best-served-cold/reflection
```

Usage
-----

[](#usage)

Take this class:

```
class ExampleClass
{
    protected $protectedProperty = 1;
    protected static $protectedStaticProperty = 2;
    private $privateProperty = 3;
    private static $privateStaticProperty = 4;

    protected function protectedMethod($number)
    {
        return $number + 1;
    }

    private function privateMethod($number)
    {
        return $number + 2;
    }

    protected static function protectedStaticMethod($number)
    {
        return $number + 3;
    }

    private static function privateStaticMethod($number)
    {
        return $number + 4;
    }
}
```

### Usage as a class

[](#usage-as-a-class)

```
$reflectionClass = new ReflectionClass(ExampleClass::class);

echo $reflectionClass->protectedStaticProperty . PHP_EOL;
echo $reflectionClass->privateStaticProperty . PHP_EOL;
echo $reflectionClass->protectedStaticMethod(2) . PHP_EOL;
echo $reflectionClass->privateStaticMethod(4) . PHP_EOL;
```

Returns:

```
2
4
5
8
```

### Usage as an object

[](#usage-as-an-object)

```
$reflectionObject = new ReflectionObject(new Exampleclass);

echo $reflectionObject->protectedProperty . PHP_EOL;
echo $reflectionObject->privateProperty . PHP_EOL;
echo $reflectionObject->protectedMethod(2) . PHP_EOL;
echo $reflectionObject->privateMethod(4) . PHP_EOL;
```

Returns:

```
1
3
3
6
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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

Every ~0 days

Total

4

Last Release

3394d ago

### Community

Maintainers

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

---

Top Contributors

[![nark3d](https://avatars.githubusercontent.com/u/2162621?v=4)](https://github.com/nark3d "nark3d (14 commits)")

---

Tags

reflectionBest Served ColdEasy reflectionAuto reflection

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/best-served-cold-reflection/health.svg)

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

###  Alternatives

[phpdocumentor/reflection-common

Common reflection classes used by phpdocumentor to reflect the code structure

9.1k725.9M34](/packages/phpdocumentor-reflection-common)[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k309.5M3.0k](/packages/symfony-property-access)[phpdocumentor/reflection

Reflection library to do Static Analysis for PHP Projects

12524.8M137](/packages/phpdocumentor-reflection)[php-di/phpdoc-reader

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

7432.6M56](/packages/php-di-phpdoc-reader)[minime/annotations

The KISS PHP annotations library

229386.3k38](/packages/minime-annotations)[spatie/php-attribute-reader

A clean API for working with PHP attributes

90897.0k18](/packages/spatie-php-attribute-reader)

PHPackages © 2026

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