php-cs-fixer/accessible-object

A library to reveal object internals.

Maintainers

👁 keradus

Package info

github.com/PHP-CS-Fixer/AccessibleObject

Type:application

pkg:composer/php-cs-fixer/accessible-object

Statistics

Installs: 670 643

Dependents: 4

Suggesters: 0

Stars: 11

Open Issues: 0

v1.2.0 2025-08-20 20:33 UTC

Requires

  • php: ^5.6 || ^7.0 || ^8.0

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 5f77857a0fedf1a24b4877de2852338b3b2f4433

  • Fabien Potencier <fabien.woop@symfony.com>
  • Dariusz Rumiński <dariusz.ruminski.woop@gmail.com>

This package is auto-updated.

Last update: 2026-06-12 13:06:11 UTC


README

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'