蛋白质 / 扩展
提供了一种扩展静态类的新方法的方式
1.0.3
2019-05-28 14:31 UTC
Requires
- php: ^7.2
This package is auto-updated.
Last update: 2024-08-29 04:31:49 UTC
README
蛋白质 | 扩展
提供了一种扩展静态类的新方法的方式
安装
composer require proteins/extensions
通过以下方式在类中包含特性
use Proteins\Extensions; class Test { use Extensions; }
通过新方法扩展类
class Test { use Extensions; public static function foo(){ echo "Foo!"; } } Test::foo(); // Foo! Test::bar(); // Fatal error: Call to undefined method Test::bar Test::extend([ 'bar' => function(){ echo "Bar!"; }, ]); Test::bar(); // Bar!