-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Schema from PHPSTAN array shape #38
Labels
enhancement
New feature or request
Comments
To clarify - PHPStan uses "array shapes" to refer to this feature: https://phpstan.org/writing-php-code/phpdoc-types#array-shapes.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
The text was updated successfully, but these errors were encountered: