See everything and do whatever you want. No privacy rule will stop us. Used in tests, debugging and fixtures to access properties and methods.

Fund package maintenance!

Installs: 3 998 894

Dependents: 86

Suggesters: 1

Security: 0

Stars: 226

Watchers: 9

Forks: 9

Open Issues: 0

1.3.0 2021-07-15 18:25 UTC

This package is auto-updated.

Last update: 2024-02-15 23:36:46 UTC


Latest Version Software License Build Status Code Coverage Quality Score Total Downloads

This small class helps you to test your private and protected properties and methods. One could argue that you never should test private methods but sometimes it just makes the test code a lot cleaner and easier to write and understand. This library is all about DX.


$object = new Dog();

NSA::setProperty($object, 'name', 'Foobar');
$name = NSA::getProperty($object, 'name');
$result = NSA::invokeMethod($object, 'doAction', 'jump', '1 meter');

echo $name; // "Foobar"
echo $result; // "Dog just did 'jump' for 1 meter"

// Access static properties and methods
$age = NSA::getProperty('\Dog', 'age');
echo $age; // 12
class Dog
    private $name = 'unnamed';
    private static $age = 12;

    private function doAction($action, $parameter)
        return sprintf("Dog just did '%s' for %s", $action, $parameter);


$ composer require nyholm/nsa


The MIT License (MIT). Please see License File for more information.