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

Add non regression tests #1155

Merged
merged 2 commits into from
Apr 1, 2022
Merged

Conversation

VincentLanglet
Copy link
Contributor

Comment on lines 14 to 19
/** @var A[] */
$y = doFoo();

$x = array_fill_keys($y, null);

assertType('array<string, null>', $x);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should not be any code at the top level of a test. please move it into a method (same in other test files)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but can you explain me why ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC code on the top level would be executed when running the test suite. but we just want phpstan to analyse it

@VincentLanglet VincentLanglet force-pushed the regressionTetss branch 2 times, most recently from fb73614 to 5128351 Compare March 31, 2022 16:37
@VincentLanglet
Copy link
Contributor Author

Regressions tests added @ondrejmirtes =)

// Incorrect! This is DOMNode|null not DOMElement|null
// It's also possible to contain a DOMText node, which is not an instance
// of DOMElement, but an instance of DOMNode!
if ($element->firstChild instanceof DOMText) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test would never fail. The error message is: Instanceof between DOMElement|null and DOMText will always evaluate to false.

This test needs to be in ImpossibleInstanceOfRuleTest. Please verify that locally by reverting the stubs update commit. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the test

It fails without the stub update
image

@ondrejmirtes ondrejmirtes merged commit 2b3d282 into phpstan:1.6.x Apr 1, 2022
@ondrejmirtes
Copy link
Member

Thank you very much!

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