File tree Expand file tree Collapse file tree 3 files changed +30
-4
lines changed
Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ parameters:
2121 - PHPUnit\Framework\Exception
2222 - Nette\DI\MissingServiceException
2323 methodThrowTypeDeclarations:
24+ ReflectionMethod:
25+ getPrototype:
26+ - ReflectionException
2427 PHPStan\Broker\Broker:
2528 getClass:
2629 - PHPStan\Broker\ClassNotFoundException
Original file line number Diff line number Diff line change @@ -130,9 +130,19 @@ private function getDocblock($reflection): ?string
130130 {
131131 if ($ reflection instanceof MethodReflection) {
132132 $ declaringClass = $ reflection ->getDeclaringClass ();
133- $ nativeClassReflection = $ declaringClass ->getNativeReflection ();
134- $ nativeMethodReflection = $ nativeClassReflection ->getMethod ($ reflection ->getName ());
135- $ docBlock = $ nativeMethodReflection ->getDocComment ();
133+ $ classReflection = $ declaringClass ->getNativeReflection ();
134+ $ methodReflection = $ classReflection ->getMethod ($ reflection ->getName ());
135+ $ docBlock = $ methodReflection ->getDocComment ();
136+
137+ while ($ docBlock === false ) {
138+ try {
139+ $ methodReflection = $ methodReflection ->getPrototype ();
140+ } catch (ReflectionException $ exception ) {
141+ return null ;
142+ }
143+
144+ $ docBlock = $ methodReflection ->getDocComment ();
145+ }
136146
137147 return $ docBlock !== false ? $ docBlock : null ;
138148 }
Original file line number Diff line number Diff line change @@ -57,9 +57,22 @@ function descriptiveAnnotationAlias(): void
5757 throw new LogicException ();
5858}
5959
60- class UnusedThrows
60+ interface Foo {
61+
62+ /**
63+ * @throws LogicException Description.
64+ */
65+ public function uncheckedException (): void ;
66+ }
67+
68+ class UnusedThrows implements Foo
6169{
6270
71+ public function uncheckedException () : void
72+ {
73+ throw new LogicException ();
74+ }
75+
6376 /**
6477 * @throws RuntimeException
6578 * @throws RuntimeException Description.
You can’t perform that action at this time.
0 commit comments