backendtea / psl-phpstan-extension
PHPStan psl extension
Installs: 452
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 1
Type:phpstan-extension
pkg:composer/backendtea/psl-phpstan-extension
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
Description
The main scope of this extension is to help phpstan to detect the types after using Psl\Type\shape.
Its intended to produce the same output as the psalm plugin.
Given the following example:
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 assumes that $input is of type array<"age"|"location"|"name", array<"city"|"country"|"state", string>|int|string>.
If we enable the extension, you will get a more specific and correct type of array{name: string, age: int, location?: array{city: string, state: string, country: string}}.