Skip to content

Commit 2fdcd5a

Browse files
Merge pull request #8436 from TimWolla/attribute-target
Configure a correct attribute target in stubs/CoreGenericClasses.phpstub
2 parents 88d3382 + 3c2018a commit 2fdcd5a

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

stubs/CoreGenericClasses.phpstub

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,19 +496,19 @@ final class WeakMap implements ArrayAccess, Countable, IteratorAggregate, Traver
496496
}
497497

498498

499-
#[Attribute]
499+
#[Attribute(Attribute::TARGET_METHOD)]
500500
final class ReturnTypeWillChange
501501
{
502502
public function __construct() {}
503503
}
504504

505-
#[Attribute]
505+
#[Attribute(Attribute::TARGET_PARAMETER)]
506506
final class SensitiveParameter
507507
{
508508
public function __construct() {}
509509
}
510510

511-
#[Attribute]
511+
#[Attribute(Attribute::TARGET_CLASS)]
512512
final class AllowDynamicProperties
513513
{
514514
public function __construct() {}

tests/AttributeTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,22 @@ public function anotherMethod(): string
787787
false,
788788
'8.1',
789789
],
790+
'sensitiveParameterOnMethod' => [
791+
'<?php
792+
793+
namespace SensitiveParameter;
794+
795+
use SensitiveParameter;
796+
797+
class HelloWorld {
798+
#[SensitiveParameter]
799+
public function __construct(
800+
string $password
801+
) {}
802+
}
803+
',
804+
'error_message' => 'Attribute SensitiveParameter cannot be used on a method',
805+
],
790806
];
791807
}
792808
}

0 commit comments

Comments
 (0)