kenny1911 / typed-properties-helper
一组用于处理类型化类属性的辅助函数。
v1.0.1
2022-08-01 07:20 UTC
Requires
- php: ^7.4 | ^8.0
Requires (Dev)
- phpunit/phpunit: ^9.2
This package is auto-updated.
Last update: 2024-09-29 06:08:54 UTC
README
TypedPropertiesHelper
是一组用于处理类型化类属性的辅助函数。
安装
composer require kenny1911/typed-properties-helper
使用方法
检查对象属性是否已初始化
use function Kenny1911\TypedProperties\is_initialized; $obj = new class { public int $init = 123; public int $notInit; }; is_initialized($obj, 'init'); // True is_initialized($obj, 'notInit'); // False
检查对象属性是否已类型化
use function Kenny1911\TypedProperties\is_typed; $obj = new class { public int $typed; public $notTyped; }; is_typed($obj, 'typed'); // True is_typed($obj, 'notTyped'); // False