Skip to content

Commit 219fd61

Browse files
authored
Core: MagicMethodsByClass: Add support for entity inherit.
1 parent 53fb347 commit 219fd61

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Core/Core.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,15 @@ private function getMagicMethodsByClass(object $entity, ?string $prefix = null):
274274
}
275275
if (isset($cache[$class]) === false) {
276276
$classRef = $this->getReflection($entity);
277-
if (preg_match_all('~@method\s+(?:\S+\s+)?(\w+)\(~', (string) $classRef->getDocComment(), $parser) > 0) {
278-
$cache[$class] = $parser[1] ?? [];
279-
} else {
280-
$cache[$class] = [];
281-
}
277+
do {
278+
if (preg_match_all('~@method\s+(?:\S+\s+)?(\w+)\(~', (string) $classRef->getDocComment(), $parser) > 0) {
279+
$cache[$class] = array_merge($cache[$class] ?? [], $parser[1] ?? []);
280+
} else {
281+
$cache[$class] = [];
282+
}
283+
$classRef = $classRef->getParentClass();
284+
} while ($classRef !== false);
285+
$cache[$class] = array_unique($cache[$class]);
282286
}
283287

284288
$return = [];

0 commit comments

Comments
 (0)