Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/backendtea/psl-phpstan-extension
https://github.com/backendtea/psl-phpstan-extension
Last synced: 17 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/backendtea/psl-phpstan-extension
- Owner: BackEndTea
- Created: 2022-05-25T20:31:51.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-05-25T20:43:23.000Z (over 2 years ago)
- Last Synced: 2024-11-24T19:41:49.135Z (about 2 months ago)
- Language: PHP
- Size: 6.84 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PHPStan PSL extension
## 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](https://github.com/php-standard-library/psalm-plugin).
Given the following example:```php
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}}`.