@@ -36,14 +36,14 @@ public function getUsages(Node $node, Scope $scope): array
36
36
return [];
37
37
}
38
38
39
- protected function shouldMarkMethodAsUsed (ReflectionMethod $ method ): bool
39
+ protected function shouldMarkMethodAsUsed (ReflectionMethod $ method ): ? VirtualUsageData
40
40
{
41
- return false ; // Expected to be overridden by subclasses.
41
+ return null ; // Expected to be overridden by subclasses.
42
42
}
43
43
44
- protected function shouldMarkConstantAsUsed (ReflectionClassConstant $ constant ): bool
44
+ protected function shouldMarkConstantAsUsed (ReflectionClassConstant $ constant ): ? VirtualUsageData
45
45
{
46
- return false ; // Expected to be overridden by subclasses.
46
+ return null ; // Expected to be overridden by subclasses.
47
47
}
48
48
49
49
/**
@@ -60,8 +60,10 @@ private function getMethodUsages(ClassReflection $classReflection): array
60
60
continue ; // skip methods from ancestors
61
61
}
62
62
63
- if ($ this ->shouldMarkMethodAsUsed ($ nativeMethodReflection )) {
64
- $ usages [] = $ this ->createMethodUsage ($ nativeMethodReflection );
63
+ $ usage = $ this ->shouldMarkMethodAsUsed ($ nativeMethodReflection );
64
+
65
+ if ($ usage !== null ) {
66
+ $ usages [] = $ this ->createMethodUsage ($ nativeMethodReflection , $ usage );
65
67
}
66
68
}
67
69
@@ -82,18 +84,20 @@ private function getConstantUsages(ClassReflection $classReflection): array
82
84
continue ; // skip constants from ancestors
83
85
}
84
86
85
- if ($ this ->shouldMarkConstantAsUsed ($ nativeConstantReflection )) {
86
- $ usages [] = $ this ->createConstantUsage ($ nativeConstantReflection );
87
+ $ usage = $ this ->shouldMarkConstantAsUsed ($ nativeConstantReflection );
88
+
89
+ if ($ usage !== null ) {
90
+ $ usages [] = $ this ->createConstantUsage ($ nativeConstantReflection , $ usage );
87
91
}
88
92
}
89
93
90
94
return $ usages ;
91
95
}
92
96
93
- private function createConstantUsage (ReflectionClassConstant $ constantReflection ): ClassConstantUsage
97
+ private function createConstantUsage (ReflectionClassConstant $ constantReflection, VirtualUsageData $ data ): ClassConstantUsage
94
98
{
95
99
return new ClassConstantUsage (
96
- UsageOrigin::createVirtual ($ this ),
100
+ UsageOrigin::createVirtual ($ this , $ data ),
97
101
new ClassConstantRef (
98
102
$ constantReflection ->getDeclaringClass ()->getName (),
99
103
$ constantReflection ->getName (),
@@ -102,10 +106,10 @@ private function createConstantUsage(ReflectionClassConstant $constantReflection
102
106
);
103
107
}
104
108
105
- private function createMethodUsage (ReflectionMethod $ methodReflection ): ClassMethodUsage
109
+ private function createMethodUsage (ReflectionMethod $ methodReflection, VirtualUsageData $ data ): ClassMethodUsage
106
110
{
107
111
return new ClassMethodUsage (
108
- UsageOrigin::createVirtual ($ this ),
112
+ UsageOrigin::createVirtual ($ this , $ data ),
109
113
new ClassMethodRef (
110
114
$ methodReflection ->getDeclaringClass ()->getName (),
111
115
$ methodReflection ->getName (),
0 commit comments