dkx / private-properties-accessor
This package is abandoned and no longer maintained.
No replacement package was suggested.
Accessor for private properties without reflection
0.1.0
2019-08-23 06:42 UTC
Requires
- php: ^7.3
Requires (Dev)
- phpstan/extension-installer: >=1.0
- phpstan/phpstan: >=0.11
- phpstan/phpstan-phpunit: >=0.11
- phpstan/phpstan-strict-rules: >=0.11
- phpunit/phpunit: >=8.0
This package is auto-updated.
Last update: 2024-01-23 16:47:15 UTC
README
Accessor for private properties without reflection
Based on https://ocramius.github.io/blog/accessing-private-php-class-members-without-reflection/
Installation
$ composer require dkx/private-properties-accessor
Usage
<?php
declare(strict_types=1);
use DKX\PrivatePropertiesAccessor\PrivatePropertiesAccessor;
$accessor = new PrivatePropertiesAccessor($class);
$prop = & $accessor->getProperty('propFromClass');
$prop = 'hello world';
var_dump($class->propFromClass); // output: hello world
Get all properties
<?php
$props = $accessor->getProperties();
This method uses get_object_vars
function which means that it will not return parent private properties.