Skip to content

Commit

Permalink
Try preventing "Method was not found in reflection of class" when get…
Browse files Browse the repository at this point in the history
…ting a method prototype
  • Loading branch information
ondrejmirtes committed Jul 4, 2024
1 parent 27dd6aa commit 25658f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Reflection/Native/NativeMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public function getPrototype(): ClassMemberReflection
$prototypeDeclaringClass = $this->reflectionProvider->getClass($prototypeMethod->getDeclaringClass()->getName());
}

if (!$prototypeDeclaringClass->hasNativeMethod($prototypeMethod->getName())) {
return $this;
}

$tentativeReturnType = null;
if ($prototypeMethod->getTentativeReturnType() !== null) {
$tentativeReturnType = TypehintHelper::decideTypeFromReflection($prototypeMethod->getTentativeReturnType());
Expand Down
4 changes: 4 additions & 0 deletions src/Reflection/Php/PhpMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ public function getPrototype(): ClassMemberReflection
$prototypeDeclaringClass = $this->reflectionProvider->getClass($prototypeMethod->getDeclaringClass()->getName());
}

if (!$prototypeDeclaringClass->hasNativeMethod($prototypeMethod->getName())) {
return $this;
}

$tentativeReturnType = null;
if ($prototypeMethod->getTentativeReturnType() !== null) {
$tentativeReturnType = TypehintHelper::decideTypeFromReflection($prototypeMethod->getTentativeReturnType());
Expand Down

0 comments on commit 25658f6

Please sign in to comment.