WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

PHP-CS-Fixer/AccessibleObject

Repository files navigation

💀 Deprecation notice

Accessing internals using this package makes it difficult for your IDE/SCA tools to track types properly. If you need to access internals, consider the following alternative:

$bar = \Closure::bind(static fn (Foo $object): string => $object->bar, null, Foo::class)($object);

AccessibleObject

AccessibleObject is small class allowing you to easily access internals of any object. In general, it's bad practice to do so. While we strongly discourage you to using it, it may be helpful in debugging or testing old, sad, legacy projects.

Example

<?php
class Foo
{
    private string $bar = 'baz';
}

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

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •