-
Notifications
You must be signed in to change notification settings - Fork 358
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
More-phpstan-typing #781
More-phpstan-typing #781
Conversation
count: 1 | ||
path: src/JsonSchema/Constraints/Factory.php | ||
|
||
- | ||
message: "#^Method JsonSchema\\\\Constraints\\\\Factory\\:\\:setErrorContext\\(\\) has no return type specified\\.$#" | ||
count: 1 | ||
message: "#^Property JsonSchema\\\\Constraints\\\\Factory\\:\\:\\$checkMode \\(int\\<0, 511\\>\\) does not accept int\\.$#" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like a bug in phpstan.
The type should be an int-mask but it is being loosened to just int for some reason
af8c3a6
to
088bc5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks on these type of contributions. I'm unclear if there is a specific reason for adding the types as DocBlock version instead of native ones. The master
branch supports PHP 7.2 and up, so we can use most of the native typehints. We only can't use typed properties, mixed return type, union types or Enums.
Would you be okay with improving the PR to use more of the native type hints instead of adding their respective. DocBlock versions. Obvious the @phpstan-param
can remain to reduce the type further.
@@ -89,6 +92,12 @@ public function addErrors(array $errors) | |||
} | |||
} | |||
|
|||
/** | |||
* @param int $errorContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer the native type hint over a docblock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added native typehints for some the stuff i already touched (and a bit more)
Adding native typehints would be a BC break for people extending the class. Is this okay? |
I don't think this is a big problem. We are just strengthening the code base as we are making more explicit what the return types are. |
9d7546b
to
0557806
Compare
Thanks for all the additions. This is a great step forward into type completion for JSON Schema and bringing it back into modern PHP standards. |
Just some more low hanging phpstan error fixes