backendtea / psl-phpstan-extension
PHPStan psl 扩展
0.0.1
2022-05-25 20:41 UTC
Requires
- php: ^7.4 || ^8.0
- phpstan/phpstan: ^1.7
Requires (Dev)
- azjezz/psl: ^1.6||^2.0
- doctrine/coding-standard: ^9.0
- nikic/php-parser: ^4.13.0
- php-parallel-lint/php-parallel-lint: ^1.2
- phpstan/phpstan-phpunit: ^1.0
- phpstan/phpstan-strict-rules: ^1.0
- phpunit/phpunit: ^9.5
Conflicts
- azjezz/psl: <1.6||>=3.0
README
描述
此扩展的主要作用是帮助phpstan在使用Psl\Type\shape
后检测类型。它的目的是产生与psalm插件相同的输出。以下是一个示例
use Psl\Type; $specification = Type\shape([ 'name' => Type\string(), 'age' => Type\int(), 'location' => Type\optional(Type\shape([ 'city' => Type\string(), 'state' => Type\string(), 'country' => Type\string(), ])) ]); $input = $specification->coerce($_GET['user']);
PhpStan 假定$input
的类型为array<"age"|"location"|"name", array<"city"|"country"|"state", string>|int|string>
。
如果我们启用此扩展,您将获得更具体和正确的类型array{name: string, age: int, location?: array{city: string, state: string, country: string}}
。