nyholm/nsa 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nyholm/nsa

最新稳定版本:1.3.1

Composer 安装命令:

composer require nyholm/nsa

包简介

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

README 文档

README

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.

Usage

$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);
    }
}

Install

$ composer require nyholm/nsa

License

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

统计信息

  • 总下载量: 5.76M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 230
  • 点击次数: 1
  • 依赖项目数: 88
  • 推荐数: 1

GitHub 信息

  • Stars: 229
  • Watchers: 6
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04