Skip to content

Commit

Permalink
feat(classMap): 支持多级继承的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
twinh committed Mar 1, 2023
1 parent fa3c0b0 commit 6c152f0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/ClassMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,16 @@ protected function filterDuplicates(array $map, $mapName)
{
foreach ($this->duplicates as $name => $classes) {
foreach ($classes as $class => $flag) {
// 如果是继承某个主类,则认为是该主类是想要的类
// 只考虑一个主类的情况
// 如果是继承某个主类,则认为是该类是想要的类
$parent = get_parent_class($class);
if ($parent && isset($this->duplicates[$name][$parent])) {
$map[$name] = $class;
unset($this->duplicates[$name]);
break;
unset($this->duplicates[$name][$parent]);
}
}
if (1 === count($this->duplicates[$name])) {
unset($this->duplicates[$name]);
}
}

foreach ($this->duplicates as $name => $classes) {
Expand Down

0 comments on commit 6c152f0

Please sign in to comment.