xp-lang / php-compact-methods
PHP 的紧凑方法
v2.0.0
2024-03-24 12:47 UTC
Requires
- php: >=7.4.0
- xp-framework/compiler: ^9.0 | ^8.0
- xp-framework/core: ^12.0 | ^11.0 | ^10.0
Requires (Dev)
- xp-framework/test: ^2.0 | ^1.0
README
为 XP 编译器 提供的插件,它为 PHP 语言添加了紧凑方法。
示例
紧凑方法使用 fn
关键字,类似于 PHP 7.4 箭头函数。RFC 在其 未来范围 部分建议了这一点。
class Person { private $name; public fn name(): string => $this->name; }
安装
在您的项目中安装 XP 编译器后,还需要包含此插件。
$ composer require xp-framework/compiler # ... $ composer require xp-lang/php-compact-methods # ...
无需采取进一步操作。