定制 dive-be/php-crowbar 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

dive-be/php-crowbar

Composer 安装命令:

composer require dive-be/php-crowbar

包简介

Access private methods / properties

README 文档

README

Social Card of PHP Crowbar

Access private methods / properties

Latest Version on Packagist GitHub Tests Action Status Total Downloads

This package allows you to access methods / properties in a class with a restricted access modifier i.e. private / protected.

Installation

You can install the package via composer:

composer require dive-be/php-crowbar

Usage

Assume the following class with a private property. It offers no way to read / write its $content property.

class SealedCrate
{
    public function __construct(
        private string $content,
    ) {}
    
    private function peek(): string
    {
        return $this->content;
    }
}

$crate = new SealedCrate('Apples');

You can get the property using the Crowbar:

Crowbar::pry($crate)->content; // Apples

You can set the property:

Crowbar::pry($crate)->content; // Original: Apples

Crowbar::pry($crate)->content = 'Strawberries';

Crowbar::pry($crate)->content; // Altered: Strawberries

You can also invoke private methods:

Crowbar::pry($crate)->peek(); // Strawberries

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email oss@dive.be instead of using the issue tracker.

Credits

License

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

统计信息

  • 总下载量: 4k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 3
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-04-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固