You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The main scope of this extension is to help phpstan to detect the types after using `Psl\Type\shape`.
6
-
Its intended to produce the same output as the [psalm plugin](https://github.com/php-standard-library/psalm-plugin).
12
+
The main goal of this extension is to help PHPStan to detect the types after using `Psl\Type\shape`.
13
+
7
14
Given the following example:
8
15
9
16
```php
@@ -22,6 +29,29 @@ $specification = Type\shape([
22
29
$input = $specification->coerce($_GET['user']);
23
30
```
24
31
25
-
PhpStan assumes that `$input` is of type `array<"age"|"location"|"name", array<"city"|"country"|"state", string>|int|string>`.
32
+
PHPStan assumes that `$input` is of type `array<"age"|"location"|"name", array<"city"|"country"|"state", string>|int|string>`.
26
33
27
34
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}}`.
35
+
36
+
Besides coerce, this extension also supports `matches()` and `assert()` methods.
37
+
38
+
## Installation
39
+
40
+
To use this extension, require it in [Composer](https://getcomposer.org/):
0 commit comments