-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Update to PHPStan 2.0 #135
Conversation
@@ -20,8 +20,3 @@ parameters: | |||
ignoreErrors: | |||
- | |||
identifier: missingType.generics | |||
|
|||
# overly detailed |
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 added the doc comments in the tests, so this error does not show any more
@@ -53,8 +51,9 @@ public function processNode(Node $node, Scope $scope): ?array | |||
} | |||
|
|||
$classType = $scope->getType($classAndMethodArrayExprs->getClassExpr()); | |||
if ($classType instanceof ConstantStringType) { | |||
$className = $classType->getValue(); | |||
if (count($classType->getConstantStrings()) === 1) { |
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.
PHPStan 2.0 throws an error if you use this instanceof ConstantStringType
construction and they recommend that you use ->getConstantStrings()
instead, see https://phpstan.org/blog/why-is-instanceof-type-wrong-and-getting-deprecated
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.
can/could/should we return multipe results when count($classType->getConstantStrings()) > 1
instead of discarding it?
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.
This is the class passed to a Symfony\Component\Validator\Constraints\Callback
attribute instance. It cannot be multiple classes
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 see 👍 - for attributes it makes sense.
tests/Rules/LocalOnlyPublicClassMethodRule/Fixture/SkipPublicCallbackMethod.php
Show resolved
Hide resolved
@@ -23,6 +23,10 @@ | |||
|
|||
final class LocalOnlyPublicClassMethodRuleTest extends RuleTestCase | |||
{ | |||
/** |
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.
PHPStan 2 requires that these parameters have a more detailed type description
could use the rector RC release |
Thank you Carlos! I've rebased and cherry picked in #141 |
Updates the code of this repository to be compatible with PHPStan 2.0, see the comments for more details
To work on this I had to disable the following dev dependencies:
Because they still depend on the old PHPStan 1.x. Once these dependencies get updated, this can be fully tested with them