arokettu / private-access
Simple and fast methods to read private properties and call private methods
3.0.0
2023-01-14 12:47 UTC
Requires
- php: >= 5.6
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: *
- phpcompatibility/php-compatibility: *
- phpunit/phpunit: ^4.8.36 | >= 6.0 < 10
- psy/psysh: *
- squizlabs/php_codesniffer: *
README
A small simple library to access private properties of the objects. Actually it's more an example of mad skillz than a useful tool. No Reflection API calls!
Installation
Use composer:
composer require arokettu/private-access --dev
Usage
These four simple functions can come in handy as helpers for something like PsySH
get_private_field()
set_private_field()
call_private_method()
get_private_const()
Example
<?php class X { private $field = 123; } $x = new X(); var_dump(\Arokettu\Debug\get_private_field($x, 'field')); // 123 \Arokettu\Debug\set_private_field($x, 'field', 321); // $x->field = 321;
Documentation
Read full documentation here: https://sandfox.dev/php/private-access.html
Also on Read the Docs: https://php-private-access.readthedocs.io/
Support
Please file issues on our main repo at GitLab: https://gitlab.com/sandfox/php-private-access/-/issues
License
The library is available as open source under the terms of the MIT License.