Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/duncan3dc/object-intruder
A small PHP library to access private/protected properties/methods of objects
https://github.com/duncan3dc/object-intruder
php reflection
Last synced: about 2 months ago
JSON representation
A small PHP library to access private/protected properties/methods of objects
- Host: GitHub
- URL: https://github.com/duncan3dc/object-intruder
- Owner: duncan3dc
- License: apache-2.0
- Created: 2016-10-30T16:35:55.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-06-20T18:03:04.000Z (over 3 years ago)
- Last Synced: 2024-04-23T15:02:27.426Z (5 months ago)
- Topics: php, reflection
- Language: PHP
- Size: 35.2 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# object-intruder
A small PHP library to access private/protected properties/methods of objects[![release](https://poser.pugx.org/duncan3dc/object-intruder/version.svg)](https://packagist.org/packages/duncan3dc/object-intruder)
[![build](https://github.com/duncan3dc/object-intruder/workflows/buildcheck/badge.svg?branch=master)](https://github.com/duncan3dc/object-intruder/actions?query=branch%3Amaster+workflow%3Abuildcheck)
[![coverage](https://codecov.io/gh/duncan3dc/object-intruder/graph/badge.svg)](https://codecov.io/gh/duncan3dc/object-intruder)## Installation
The recommended method of installing this library is via [Composer](//getcomposer.org/).
Run the following command from your project root:
```bash
$ composer require duncan3dc/object-intruder
```## Usage
```php
use duncan3dc\ObjectIntruder\Intruder;$table = new Intruder(new Table);
$table->secretMethodNotPublic("Hello", "World");
$table->privateStuff = "modified";
```Unfortunatly due to a limitation of [__call](http://php.net/manual/en/language.oop5.overloading.php#object.call) methods with parameters passed by reference are not supported.
However there is a workaround available using the `_call()` method:
```php
$stuff = "start";$table = new Intruder(new Table);
$table->_call("secretMethod", $stuff, Table::MODIFY);
```## Changelog
A [Changelog](CHANGELOG.md) has been available since the beginning of time## Where to get help
Found a bug? Got a question? Just not sure how something works?
Please [create an issue](//github.com/duncan3dc/object-intruder/issues) and I'll do my best to help out.
Alternatively you can catch me on [Twitter](https://twitter.com/duncan3dc)