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
When using attributes on a class, there is no way to ignore an issue for just one attribute.
Currently, the only option is to ignore the error type for the WHOLE class.
A way to ignore an issue for a single attribute would solve this particular issue.
A way to ignore an issue for just a specific parameter would allow more fine-grained suppressing for this case but also any suppresses on functions and methods.
As far as I can tell this is also not possible using the config issueHandlers, since InvalidArgument wants a referencedFunction. I haven't been able to get that to work for an Attribute
<?php
#[Attribute(Attribute::TARGET_CLASS)]
finalclassAttribute1 {
publicfunction__construct(string$input) {}
}
#[Attribute(Attribute::TARGET_CLASS)]
finalclassAttribute2 {
publicfunction__construct(string$input) {}
}
// The InvalidArgument on Attribute1 should not be suppressed:
#[Attribute1(false)]
// I want to suppress the argument on Attribute2:
#[Attribute2(false)]
classExample {
publicfunctionmethod1(string$input): array {
// This InvalidArgument should not be suppressed:return array_values($input);
}
}
Psalm output (using commit ef3b018):
ERROR: InvalidArgument - 14:14 - Argument 1 of Attribute1::__construct cannot be false, string value expected
ERROR: InvalidArgument - 16:14 - Argument 1 of Attribute2::__construct cannot be false, string value expected
ERROR: InvalidArgument - 20:29 - Argument 1 of array_values expects array<array-key, mixed>, but string provided
When using attributes on a class, there is no way to ignore an issue for just one attribute.
Currently, the only option is to ignore the error type for the WHOLE class.
As far as I can tell this is also not possible using the config
issueHandlers
, sinceInvalidArgument
wants areferencedFunction
. I haven't been able to get that to work for an Attributehttps://psalm.dev/r/312d1075f3
The text was updated successfully, but these errors were encountered: