File tree Expand file tree Collapse file tree 3 files changed +50
-1
lines changed
Expand file tree Collapse file tree 3 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -64,11 +64,15 @@ public function getAdditionalConstructors(ClassReflection $classReflection): arr
6464 $ additionalConstructors = [];
6565 $ nativeReflection = $ classReflection ->getNativeReflection ();
6666
67- foreach ($ nativeReflection ->getBetterReflection ()->getImmediateMethods () as $ method ) {
67+ foreach ($ nativeReflection ->getBetterReflection ()->getMethods () as $ method ) {
6868 if (!$ method ->isPublic ()) {
6969 continue ;
7070 }
7171
72+ if ($ method ->getImplementingClass ()->getName () !== $ nativeReflection ->getName ()) {
73+ continue ;
74+ }
75+
7276 $ declaringTrait = null ;
7377 if ($ method ->getDeclaringClass ()->isTrait ()) {
7478 $ declaringTrait = $ method ->getDeclaringClass ()->getName ();
Original file line number Diff line number Diff line change 88use PHPStan \Testing \RuleTestCase ;
99use Symfony \Contracts \Service \Attribute \Required ;
1010use function class_exists ;
11+ use const PHP_VERSION_ID ;
1112
1213/**
1314 * @extends RuleTestCase<UninitializedPropertyRule>
@@ -55,6 +56,18 @@ public function testRequiredAttributes(): void
5556 ]);
5657 }
5758
59+
60+ public function testBug468 (): void
61+ {
62+ if (!class_exists (Required::class)) {
63+ self ::markTestSkipped ('Required symfony/service-contracts@3.2.1 or higher is not installed ' );
64+ }
65+ if (PHP_VERSION_ID < 80100 ) {
66+ self ::markTestSkipped ('Test requires PHP 8.1. ' );
67+ }
68+ $ this ->analyse ([__DIR__ . '/data/bug-468.php ' ], []);
69+ }
70+
5871 public static function getAdditionalConfigFiles (): array
5972 {
6073 return [
Original file line number Diff line number Diff line change 1+ <?php // lint >= 8.1
2+
3+ namespace Bug468 ;
4+
5+ use Symfony \Contracts \Service \Attribute \Required ;
6+
7+ interface MyQueryInterface {
8+ public function execute (): array ;
9+ }
10+
11+ trait GenreFetcherTrait
12+ {
13+ private MyQueryInterface $ query ;
14+
15+ protected function dosomething (): array
16+ {
17+ return $ this ->query ->execute ();
18+ }
19+
20+ #[Required]
21+ public function setQuery (
22+ MyQueryInterface $ query ,
23+ ): void {
24+ $ this ->query = $ query ;
25+ }
26+ }
27+
28+ class HelloWorld
29+ {
30+ use GenreFetcherTrait;
31+
32+ }
You can’t perform that action at this time.
0 commit comments