huangdijia/invade
最新稳定版本:v2.0.1
Composer 安装命令:
composer require huangdijia/invade
包简介
A PHP function to work with private properties and methods
关键字:
README 文档
README
This package offers an invade function that will allow you to read/write private properties of an object. It will also allow you to call private methods.
Installation
You can install the package via composer:
composer require huangdijia/invade
Usage
Imagine you have this class defined which has a private property and method.
<?php use function Huangdijia\Invade\invade; class MyClass { private string $privateProperty = 'private value'; private function privateMethod(): string { return 'private return value'; } } $myClass = new MyClass();
This is how you can get the value of the private property using the invade function.
use function Huangdijia\Invade\invade; invade($myClass)->privateProperty; // returns 'private value'
The invade function also allows you to change private values.
use function Huangdijia\Invade\invade; invade($myClass)->privateProperty = 'changed value'; invade($myClass)->privateProperty; // returns 'changed value
Using invade you can also call private functions.
use function Huangdijia\Invade\invade; invade($myClass)->privateMethod(); // returns 'private return value'
Testing
composer test
composer analyze
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-17