Repository navigation
Conversation
Contributor
Author
|
Updated the regression fixture to avoid the runtime RoundingMode polyfill on older PHP versions. It now parses a unit enum directly; the full local suites pass on PHP 8.3 and 8.4. |
Contributor
Author
|
I checked the current-head failures. The pinned Larastan suite has the same two failures with the upstream base PHAR and this PR’s PHAR; Doctrine also reports the same 28 errors with both builds. The PHP 8.6 extension jobs fail during Composer dependency resolution, and Analyse (7) fails uploading its artifact (ENOTFOUND). The other integration errors also appear in the independent #6679 run. I have left the focused fix unchanged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes phpstan/phpstan#15380.
When PHPStan runs on a PHP version without native enum reflection, BetterReflection uses its generic class adapter. The enum-specific class check then misses
RoundingMode::HalfAwayFromZero, and resolving the default forround()asks a unit enum case for a backing value, causing the reportedLogicException.Check whether the reflected constant is an enum case before reading its value expression, returning the existing
EnumCaseObjectTypeinstead.The regression parses a unit enum directly and uses the real generic class adapter, avoiding the runtime's
RoundingModepolyfill on older PHP versions. It fails with the reported exception before the fix and passes afterward.AnalyserIntegrationTest::testBug15380also analyses the reportedround(1.5)call withphpVersion: 80500, using a separate test container and restoring the original container afterward. The fixture consumes the result so the unrelated no-effect rule does not obscure crash coverage.For a red/green check on the development runtime, I temporarily selected the generic class adapter used by old PHP runtimes and removed the existing enum-case guard. The integration test threw the reported
LogicException; restoring the guard made it pass. Both temporary production edits were then reverted. This simulation is not an actual PHP 7.4 run.Validation on PHP 8.4.12:
The full configured suite also passes on PHP 8.3.33: 21,567 tests, 96,687 assertions, 204 skips, no failures or errors. Its analyser integration suite has 202 tests, 667 assertions and one existing skip. The focused resolver suite passes on both runtimes.
I have not run the packaged PHAR on PHP 7.4 locally; the regression deliberately exercises its generic-adapter path on the development runtime.