可持续开发 / phpstan-higher-order-collections
PHPStan 的高阶集合支持
dev-main
2023-02-27 10:39 UTC
Requires
- php: ^7.4 || ^8.0
- phpstan/phpstan: ^0.12.48|^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- illuminate/collections: ^8.9
- phpunit/phpunit: ^9.4
Suggests
- illuminate/collections: This package works with Laravel Collections by default, but does not require them
- laravel/framework: This package works with Laravel Collections by default, but does not require them
This package is auto-updated.
Last update: 2024-09-27 14:14:13 UTC
README
此插件为 Laravel(Laravel)中流行的集合概念上的高阶消息(Higher Order Messaging)添加了 PHPStan 支持。
此扩展提供以下功能
Illuminate\Support\Collection
使用 PHPStan 泛型 知道其内容的类型,这确保了在代理对象上调用方法实际上是有效的,并且它们的返回类型被正确推断。
安装
要使用此扩展,请在 Composer 中要求它
composer require --dev sustainabil-it/phpstan-higher-order-collections
如果您有特殊需求,例如自己的集合实现,则此插件公开了一些配置选项
parameters:
higherOrderCollection:
- collectionClass: Illuminate\Support\Enumerable
- proxyClass: Illuminate\Support\HigherOrderCollectionProxy
- keyTemplate: TKey
- typeTemplate: TValue
- proxyTemplate: TReturn
- proxyMethods:
- map
- filter
如果您还安装了 phpstan/extension-installer,则一切准备就绪!
手动安装
如果您不想使用 phpstan/extension-installer
,请将 extension.neon 包含在您的项目 PHPStan 配置中
includes:
- vendor/sustainabil-it/phpstan-higher-order-collections/extension.neon