PHP code example of php-cs-fixer / accessible-object

1. Go to this page and download the library: Download php-cs-fixer/accessible-object library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

php-cs-fixer / accessible-object example snippets



class Foo
{
    private $bar = 'baz';
}

$object = new Foo();
echo $object->bar; // PHP Fatal error:  Uncaught Error: Cannot access private property Foo::$bar

$accessibleObject = new AccessibleObject($object);
echo $accessibleObject->bar; // 'baz'