wearesho-team / base-collection
基于ArrayObject的泛型集合
1.0.2
2022-12-01 12:40 UTC
Requires
- php: ^7.4 || ^8.0
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2024-09-29 04:09:03 UTC
README
泛型集合的实现。
安装
composer require wearesho-team/base-collection
用法
创建你的类集合并实现type()
方法。
它必须返回声明的(存在的)类名
<?php use Wearesho\BaseCollection; class MyCollection extends BaseCollection { public function type(): string { return stdClass::class; } }
现在你有了泛型集合!
如果你尝试添加非你类型实例的项,你将捕获到InvalidArgumentException