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

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

crowdstar/reflection
====================

Allow to directly access protected/private properties and call protected/private methods.

2.0.1(2mo ago)120.1k↓35%1Apache-2.0PHPPHP &gt;=8.0CI passing

Since Jun 26Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/Crowdstar/reflection)[ Packagist](https://packagist.org/packages/crowdstar/reflection)[ Docs](https://www.glu.com)[ RSS](/packages/crowdstar-reflection/feed)WikiDiscussions master Synced 1mo ago

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

[![Build Status](https://github.com/Crowdstar/reflection/workflows/Tests/badge.svg)](https://github.com/Crowdstar/reflection/actions)[![Latest Stable Version](https://camo.githubusercontent.com/c821bdb7940c4727a0be1dc92fd00ac7d4b0ee4b738a7ded55664dc2babbe348/68747470733a2f2f706f7365722e707567782e6f72672f43726f7764737461722f7265666c656374696f6e2f762f737461626c652e737667)](https://packagist.org/packages/crowdstar/reflection)[![Latest Unstable Version](https://camo.githubusercontent.com/18c0776cab75e8320d0ab0a3556c151c543dbe4eef1c9c553ef6bc6bae4d776f/68747470733a2f2f706f7365722e707567782e6f72672f43726f7764737461722f7265666c656374696f6e2f762f756e737461626c652e737667)](https://packagist.org/packages/crowdstar/reflection)[![License](https://camo.githubusercontent.com/543656e7e48286012056dd8ba8dcf26b11b6a07b4b3c275b6d890c8ecf872fb0/68747470733a2f2f706f7365722e707567782e6f72672f43726f7764737461722f7265666c656374696f6e2f6c6963656e73652e737667)](https://packagist.org/packages/crowdstar/reflection)

A PHP reflection library to directly access protected/private properties and call protected/private methods. Static properties and methods can also be accessed/invoked from a class directly.

This library works with major versions of PHP from 5.3 to 8.5.

Installation
============

[](#installation)

For PHP 8.0+, please use version 2.0:

```
composer require crowdstar/reflection:~2.0.0
```

For old versions of PHP (PHP 5.3 to PHP 7.4), please use version 1.0 instead:

```
composer require crowdstar/reflection:~1.0.0
```

How To Use It
=============

[](#how-to-use-it)

Three static methods are provided to access protected/private properties and call protected/private methods of an object/class:

- `CrowdStar\Reflection\Reflection::getProperty()`: Get current value of a property.
- `CrowdStar\Reflection\Reflection::setProperty()`: Set a new value to a property.
- `CrowdStar\Reflection\Reflection::callMethod()`: Call a method of a class/object.

Here is a sample code showing how to use them:

```
