Skip to content

Commit

Permalink
php-kafka#38 Try search parent class in the same namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Alexeev authored and Pavel Alexeev committed Jan 5, 2022
1 parent 32d5b78 commit 75a43ae
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Parser/ClassParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,21 @@ private function getParentClassStatements(): ?array
return [];
}

if (null !== $usedClasses[$this->getParentClassName()]) {
if (null !== @$usedClasses[$this->getParentClassName()]) {
$parentClass = $usedClasses[$this->getParentClassName()];
}

$rc = new ReflectionClass($parentClass);
try {
$rc = new ReflectionClass($parentClass);
}
catch (\ReflectionException $e) {
try {
$rc = new ReflectionClass($this->getNamespace() . '\\' . $parentClass);
}
catch (\ReflectionException $e) {
throw new ReflectionException("Parent class [{$parentClass}] for [{$this->getNamespace()}\\{$this->getClassName()}] not found!", $e->getCode(), $e);
}
}
$filename = $rc->getFileName();

if (false === $filename) {
Expand Down

0 comments on commit 75a43ae

Please sign in to comment.