You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an odd situation that I am unable to reproduce using psalm.dev regarding what I believe is a false positive when inheriting a method with list (or array).
Locally, I get the following (although each one is deep in a namespace):
ERROR: MethodSignatureMismatch - DefaultEncoderReconciler.php:31:33 - Argument 1 of DefaultEncoderReconciler::reconcile has wrong type 'array<array-key, mixed>', expecting 'list' as defined by EncoderReconcilerInterface::reconcile
If I widen the param type in the DefaultEncoderReconciler by removing the actual array, the error does not occur.
This may be related to #5126 as it also refers to the array typehint overriding the phpdoc which appears to be what is happening in this case.
Error:
class DefaultEncoderReconciler implements EncoderReconcilerInterface, PublicService {
/**
* @param list<Encoder> $encoders
*/
public function reconcile(array $encoders, bool $foo = false): void { }
}
No Error:
class DefaultEncoderReconciler implements EncoderReconcilerInterface, PublicService {
/**
* @param list<Encoder> $encoders
*/
public function reconcile($encoders, bool $foo = false): void { }
}
After failing to create a reproduction on psalm.dev I started stripping away code and configuration line by line until I discovered what appears to be the trigger; the presence of preloadClasses="true" in a stub.
I have an odd situation that I am unable to reproduce using psalm.dev regarding what I believe is a false positive when inheriting a method with list (or array).
The code looks something like this: https://psalm.dev/r/b8d39294ea
Locally, I get the following (although each one is deep in a namespace):
ERROR: MethodSignatureMismatch - DefaultEncoderReconciler.php:31:33 - Argument 1 of DefaultEncoderReconciler::reconcile has wrong type 'array<array-key, mixed>', expecting 'list' as defined by EncoderReconcilerInterface::reconcile
If I widen the param type in the DefaultEncoderReconciler by removing the actual array, the error does not occur.
This may be related to #5126 as it also refers to the array typehint overriding the phpdoc which appears to be what is happening in this case.
Error:
No Error:
After failing to create a reproduction on psalm.dev I started stripping away code and configuration line by line until I discovered what appears to be the trigger; the presence of preloadClasses="true" in a stub.
Triggers the error. Removing preloadClasses="true" also removes the error.
Version: dev-master@93e9054f98b040bf246c2023201503db3dbf162c
The text was updated successfully, but these errors were encountered: