Repository navigation
Conversation
Infer the bottom type for unresolved template arguments of a generic object when the supplied callable cannot return. Preserve template types inferred from callable parameters and assertions. Closes phpstan/phpstan#15770
The class reflection lookup already excludes nullable unions. Remove the redundant trinary check and cover the nullable callback return type in the regression fixture.
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.
Summary
A callback that always throws has return type
never. When the expected return type is a generic object such asOpt<E>, PHPStan could not inferEand reportedargument.templateType. The call then returnedOpt<mixed>in the analysis.Infer
neverfor unresolved template arguments of the generic return object while preserving declared defaults and types inferred from callable parameters or assertions. This letsOpt<T|E>simplify toOpt<T>in the reported case. Apply the same inference toClosure,callable, and their native implementation.Verification
Opt<int>withoutargument.templateType.phpstan_turboand 241 with it.CI follow-up
Removed a redundant object check identified by mutation testing and added a regression assertion for a nullable generic callback return.
The four PHAR integration failures for OpenEMR, phpstan-dba, phpstan-laravel and Shopware have identical diagnostics in the earlier CI run for #7115.
Closes phpstan/phpstan#15770