File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1+ # 💀 Deprecation notice
2+
3+ Accessing internals using this package makes it difficult for your IDE/SCA tools to track types properly.
4+ If you need to access internals, consider the following alternative:
5+ ``` php
6+ $bar = \Closure::bind(static fn ($object): string => $object->bar, null, Foo::class)($object);
7+ ```
8+
19# AccessibleObject
210
311` AccessibleObject ` is small class allowing you to easily access internals of any object.
@@ -10,12 +18,12 @@ While we strongly discourage you to using it, it may be helpful in debugging or
1018<?php
1119class Foo
1220{
13- private $bar = 'baz';
21+ private string $bar = 'baz';
1422}
1523
1624$object = new Foo();
17- echo $object->bar; // PHP Fatal error: Uncaught Error: Cannot access private property Foo::$bar
25+ $bar = $object->bar; // PHP Fatal error: Uncaught Error: Cannot access private property Foo::$bar
1826
1927$accessibleObject = new AccessibleObject($object);
20- echo $accessibleObject->bar; // 'baz'
28+ $bar = $accessibleObject->bar; // 'baz'
2129```
You can’t perform that action at this time.
0 commit comments