Skip to content

Commit 75a43ae

Browse files
Pavel AlexeevPavel Alexeev
Pavel Alexeev
authored and
Pavel Alexeev
committed
php-kafka#38 Try search parent class in the same namespace
1 parent 32d5b78 commit 75a43ae

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Parser/ClassParser.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,21 @@ private function getParentClassStatements(): ?array
190190
return [];
191191
}
192192

193-
if (null !== $usedClasses[$this->getParentClassName()]) {
193+
if (null !== @$usedClasses[$this->getParentClassName()]) {
194194
$parentClass = $usedClasses[$this->getParentClassName()];
195195
}
196196

197-
$rc = new ReflectionClass($parentClass);
197+
try {
198+
$rc = new ReflectionClass($parentClass);
199+
}
200+
catch (\ReflectionException $e) {
201+
try {
202+
$rc = new ReflectionClass($this->getNamespace() . '\\' . $parentClass);
203+
}
204+
catch (\ReflectionException $e) {
205+
throw new ReflectionException("Parent class [{$parentClass}] for [{$this->getNamespace()}\\{$this->getClassName()}] not found!", $e->getCode(), $e);
206+
}
207+
}
198208
$filename = $rc->getFileName();
199209

200210
if (false === $filename) {

0 commit comments

Comments
 (0)