Open jakubvojacek opened 3 years ago
To clarify - PHPStan uses "array shapes" to refer to this feature: https://phpstan.org/writing-php-code/phpdoc-types#array-shapes.
array<int>
is just a general array (https://phpstan.org/writing-php-code/phpdoc-types#general-arrays).
We have an API that maps the URL to PHP method and the POST JSON data to method arguments, for example
curl -XPOST https://mysite/api/device/add -d'{"id": 1, "data": [1,2,3]}'
would callThanks to PHP strict typing, it checks the type of basic types (int, string, booo) but it does not check content of arrays. We are already using PHPStan to pass static analysis tests and it would be cool to enforce the already existing rules via Nette\Schema.
Using reflection, I can get the phpdoc but there is no way (I think) that I could validate it using Nette/Schema. To accomplish that, a new method
fromPhpstanArrayShape(string $shape)
(with a much better name) would have to be created.Do you think this is something that could be useful?