Skip to content

Normalize arguments before calling into TypeSpecifyingExtensions #4034

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

Merged
merged 2 commits into from
May 30, 2025

Conversation

staabm
Copy link
Contributor

@staabm staabm commented May 30, 2025

@@ -98,6 +98,11 @@ public static function reorderFuncArguments(
return null;
}

// return identical object if not reordered, as TypeSpecifier relies on object identity
Copy link
Contributor Author

Choose a reason for hiding this comment

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

related to this comment is this line:

if ($expr === $node) {
return true;
}

without this fix the actual fix in TypeSpecifier would cause a regression:

➜  phpstan-src git:(2.1.x) ✗ vendor/bin/phpunit tests/PHPStan/Analyser/AnalyserIntegrationTest.php  --filter testBug7500
PHPUnit 9.6.23 by Sebastian Bergmann and contributors.

Random Seed:   1748588377
Warning:       XDEBUG_MODE=coverage (environment variable) or xdebug.mode=coverage (PHP configuration setting) has to be set

F                                                                   1 / 1 (100%)

Time: 00:46.162, Memory: 90.00 MB

There was 1 failure:

1) PHPStan\Analyser\AnalyserIntegrationTest::testBug7500
Failed asserting that actual size 1 matches expected size 0.

Emitted errors:
- Call to function ksort() with array<T of Bug7500\PositionEntityInterface&Bug7500\TgEntityInterface> will always evaluate to true
  in /Users/staabm/workspace/phpstan-src/tests/PHPStan/Analyser/data/bug-7500.php on line 36

/Users/staabm/workspace/phpstan-src/src/Testing/PHPStanTestCase.php:228
/Users/staabm/workspace/phpstan-src/tests/PHPStan/Analyser/AnalyserIntegrationTest.php:921

FAILURES!
Tests: 1, Assertions: 3, Failures: 1.

@staabm staabm marked this pull request as ready for review May 30, 2025 07:26
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@ondrejmirtes ondrejmirtes merged commit efcc982 into phpstan:2.1.x May 30, 2025
421 of 422 checks passed
@ondrejmirtes
Copy link
Member

Perfect, thank you!

@staabm staabm deleted the normal branch May 30, 2025 07:31
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.

preg_match call with named arguments incorrect type inference
3 participants