-
Notifications
You must be signed in to change notification settings - Fork 464
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
Fix ConstantArrayType::isCallable #3637
base: 1.12.x
Are you sure you want to change the base?
Conversation
if (!$phpVersion->supportsCallableInstanceMethods()) { | ||
$methodReflection = $type->getMethod($method->getValue(), new OutOfClassScope()); | ||
if ($classOrObject->isString()->yes() && !$methodReflection->isStatic()) { | ||
$has = $has->and(TrinaryLogic::createNo()); |
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.
In findTypeAndMethodNames
there is a continue;
I don't want to.
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.
Why not $has = TrinaryLogic::createNo()
?
98e97b0
to
1b48917
Compare
cc @herndlm, since you implemented it first in https://github.com/phpstan/phpstan-src/pull/1529/files#diff-2e28cc3b285eae2b224df51cda5d6d532675e945e2995e2cd76293bca56799d6R343 |
This pull request has been marked as ready for review. |
if (!$phpVersion->supportsCallableInstanceMethods()) { | ||
$methodReflection = $type->getMethod($method->getValue(), new OutOfClassScope()); | ||
if ($classOrObject->isString()->yes() && !$methodReflection->isStatic()) { | ||
$has = $has->and(TrinaryLogic::createNo()); |
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.
Why not $has = TrinaryLogic::createNo()
?
Indeed ; simplified. |
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.
The implementation if isCallable()
needs to be synced with getCallableParametersAcceptors
otherwise there are going to be bugs. That's why currently both methods use $this->findTypeAndMethodNames()
.
I provided another solution in 8993085 I can modify findTypeAndMethodNames directly, but that means that I need to allow calling
which impact the usage in
So I dunno if:
|
I don't understand why we'd need to create I'm sorry, I don't like the current state of this PR enough to merge it. I'd have to look into it myself. |
Currently when we call
the logic done is
Then the array returned is a single We need a way to track that some values were skipped.
The other idea I have would be to check that the count of
|
0c165ad
to
58de58f
Compare
@ondrejmirtes I repushed the changes with my last idea (based on the count) ; you might prefer it. |
I basically copied the logic
findTypeAndMethodNames
with the following changes:no
as result of$type->hasMethod($method->getValue())
TrinaryLogic::extremIdentity
Closes phpstan/phpstan#12063