Fix array_find return type defaulting to mixed#11848
Open
eyupcanakman wants to merge 3 commits into
Open
Conversation
The two new tests in TypeParseTest added by vimeo#11768 were written against master/7.x where Closure types render with an `impure-` purity prefix. On 6.x there is no purity tracking on Closures, so the actual output is `Closure(...)` rather than `impure-Closure(...)`. The other 10 new tests from the PR were unaffected and continue to pass. Fixes Unit Tests failure on 6.x for testThisAsCallableReturnType and testThisModelVariableNotTreatedAsThis.
On PHP 8.1/8.2 the `Override` attribute is not a built-in class. When
psalm scans a vendor file using `#[\Override]` (e.g. amphp/socket's
UnlimitedSocketPool), Scanner::fileExistsForClassLike falls back to
`new ReflectionClass('Override')` which triggers the project autoloader.
The suicidal autoloader then exits, failing the SuicidalAutoloaderTest.
The whitelist already handles the analogous PHP 8.2 case
(AllowDynamicProperties) and other version-gated names. Adding `Override`
makes the test pass on PHP 8.1/8.2 again.
Note: this is a test-fixture workaround. A deeper fix would be to teach
Scanner::fileExistsForClassLike to skip ReflectionClass for known
version-gated PHP attribute names; that should be tracked separately.
02ae2fb to
0521730
Compare
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.
Fix #11331
array_find(PHP 8.4) had no return type provider, so its callmap entry resolved tomixed. ExtendArrayFilterReturnTypeProviderto also handlearray_find: it reuses the existing callback narrowing and returns the matching element type, ornullwhen nothing matches. The other functions are unchanged.