-
Notifications
You must be signed in to change notification settings - Fork 479
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
TypeSpecifier - understand \Composer\Pcre\Preg::match() == 1 same way as === 1 #3178
Conversation
@@ -33,6 +33,7 @@ | |||
) | |||
->ignoreErrorsOnPackage('phpunit/phpunit', [ErrorType::DEV_DEPENDENCY_IN_PROD]) // prepared test tooling | |||
->ignoreErrorsOnPackage('jetbrains/phpstorm-stubs', [ErrorType::PROD_DEPENDENCY_ONLY_IN_DEV]) // there is no direct usage, but we need newer version then required by ondrejmirtes/BetterReflection | |||
->ignoreErrorsOnPackage('composer/pcre', [ErrorType::SHADOW_DEPENDENCY]) // reverse dependency on composer/pcre to support https://github.com/composer/pcre/pull/24 |
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.
@janedbal is this the correct way to handle a optional runtime dependency?
Alternativly to this PR we could ask composer/pcre to turn the And a third alternative could be that we handle callables which return |
This isn't right, I don't want to hardcode things about other people's code in PHPStan's core. The right way to handle this is to let TypeSpecifierContext know about various comparison operators and values on the other side of the comparison. So that extensions can react to this information. |
So you say we need a new extension type? |
Not new extension type, we'd need to find a way how to pass this information in TypeSpecifierContext. |
ok, I need to think about that |
My idea: right now we have methods null(), true(), truthy(), falsy(), false(). The new context called for extensions in these cases would return false for all of the current methods. But there could be a new method called comparison() and it would return information the extension could act on. |
I will give it a try right now |
required for composer/pcre type narrowing analog
required for composer/pcre#24 (comment) to cover the
==1
and===1
testcases