diff --git a/stubs/CoreGenericAttributes.phpstub b/stubs/CoreGenericAttributes.phpstub index d995180815a..665cf95bfac 100644 --- a/stubs/CoreGenericAttributes.phpstub +++ b/stubs/CoreGenericAttributes.phpstub @@ -8,7 +8,7 @@ final class AllowDynamicProperties } /** @psalm-immutable */ -#[Attribute(Attribute::TARGET_METHOD)] +#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_PROPERTY)] final class Override { public function __construct() {} diff --git a/tests/AttributeTest.php b/tests/AttributeTest.php index 66d7f170507..3944723d8cc 100644 --- a/tests/AttributeTest.php +++ b/tests/AttributeTest.php @@ -43,6 +43,32 @@ class Foo {} public function providerValidCodeParse(): iterable { return [ + 'overrideAttributeOnOverriddenMethod' => [ + 'code' => ' [ + 'code' => ' [ 'code' => ' 'InvalidAttribute - src' . DIRECTORY_SEPARATOR . 'somefile.php:11:39 - Attribute Attr cannot be used on a class constant', ], + 'getAttributesOnClassConstantWithOverrideAttribute' => [ + 'code' => 'getAttributes(\Override::class); + ', + 'error_message' => 'InvalidAttribute - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:39 - Attribute Override cannot be used on a class constant', + ], 'getAttributesOnParameterWithNonParameterAttribute' => [ 'code' => '