exposer/class-exposer

允许访问类中的私有方法和属性

v1.0.0 2015-08-22 12:06 UTC

This package is not auto-updated.

Last update: 2024-09-14 17:48:26 UTC


README

为什么?

在测试类中的私有和受保护方法时非常有用。

##安装

您可以简单地下载或复制并粘贴ClassExposer.php类,并将其包含在自己的PHP文件中。

Composer

也可以通过Composer使用

$ composer require exposer/class-exposer

请确保在您的composer.json文件中将minimum-stability设置为'dev'。

用法

// Include the ClassExposer Class
require_once 'ClassExposer.php';
// Pass an object instance in to the ClassExposer
$myExposedClass = new Exposer\ClassExposer(new MyClass());

// Access all methods and properties as normal
$myExposedClass->myPrivateMethod();
$myExposedClass->myPrivateProperty = "foo";
echo $myExposedClass->myPrivateProperty;