Skip to content
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

Replace is_(int,object,resource,scalar) extensions with stubs #1884

Merged
merged 2 commits into from
Oct 21, 2022

Conversation

BackEndTea
Copy link
Contributor

These were the ones i found that didn't contain special logic besides just specifying the types.

@BackEndTea
Copy link
Contributor Author

Looks like the test failures arent unique to this check.

I added another failing test case for is_string.
Looks like for is_int($value) === true does not correcly set the assert-if-false data

@rvanvelzen
Copy link
Contributor

I'll be fixing the negation logic soon, which should resolve those failures.

@rvanvelzen
Copy link
Contributor

You can fix the issue by applying this patch:

diff --git a/src/Analyser/TypeSpecifier.php b/src/Analyser/TypeSpecifier.php
index c70b847a5..f04522ca5 100644
--- a/src/Analyser/TypeSpecifier.php
+++ b/src/Analyser/TypeSpecifier.php
@@ -1270,9 +1270,9 @@ class TypeSpecifier
        {
                if ($context->null()) {
                        $asserts = $assertions->getAsserts();
-               } elseif ($context->truthy()) {
+               } elseif ($context->true()) {
                        $asserts = $assertions->getAssertsIfTrue();
-               } elseif ($context->falsey()) {
+               } elseif ($context->false()) {
                        $asserts = $assertions->getAssertsIfFalse();
                } else {
                        throw new ShouldNotHappenException();

@ondrejmirtes ondrejmirtes merged commit 76928bb into phpstan:1.9.x Oct 21, 2022
@ondrejmirtes
Copy link
Member

Thank you!

@rvanvelzen
Copy link
Contributor

The new stubs don't need the double assertion anymore though :)

@ondrejmirtes
Copy link
Member

Cleaned up :) 00d7cdb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants