Bruce Weirdan
Bruce Weirdan
Psalm is really confused by the conditional ServiceRepository class declaration, where the hierarchy depends on whether another package (`var-exporter`) is installed or not.
And your reproducer does not install `doctrine/orm`, but `ServiceRepository` depends on `EntityRepository` provided with that package (regardless of `var-exporter`).
The linked PR provides a workaround.
This would require a specific return type provider. Currently we only have a generic stub for `array_intersect_key()`: https://github.com/vimeo/psalm/blob/62b525993d6091c8c2b95bfdc0b70a4e077e6f1e/stubs/CoreGenericFunctions.phpstub#L30-L42
Another variation: https://psalm.dev/r/f05f18c046 (note the type of `after_concat` element) Funny thing though, if you uncomment `'after' => self::AFTER` - it works as expected: https://psalm.dev/r/003ab2965b
So the simplest test case is: https://psalm.dev/r/7fa1a03bd7 This is not a bug per se, as the inferred type is correct, just not as precise as it could be.
@jcvignoli in your second example, how does `Settings.php` get loaded? In the first example autoload could load it (because the `Settings` class is referenced), but it's not immediately clear what's...
It looks like the issue affects ternary specifically. `or` doesn't have this problem: https://psalm.dev/r/4a713a58d7
I'd just validate that the index exists: https://psalm.dev/r/9d49161cec