Skip to content

Commit 7b08fe9

Browse files
committed
Do not list private constructors as inherited
1 parent 38e1387 commit 7b08fe9

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

build/gen_stub.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2901,7 +2901,7 @@ private function collectInheritedMembers(
29012901
$parentsWithInheritedProperties[$parentName] = $parent;
29022902
}
29032903

2904-
if (!$hasConstructor && $parentInfo->hasConstructor()) {
2904+
if (!$hasConstructor && $parentInfo->hasNonPrivateConstructor()) {
29052905
$parentsWithInheritedMethods[$parentName]["name"] = $parent;
29062906
$parentsWithInheritedMethods[$parentName]["types"][] = "constructorsynopsis";
29072907
}
@@ -2959,22 +2959,10 @@ private function hasConstructor(): bool
29592959
return false;
29602960
}
29612961

2962-
/**
2963-
* @param array<string, ClassInfo> $classMap
2964-
*/
2965-
private function hasParentConstructor(array $classMap): bool
2962+
private function hasNonPrivateConstructor(): bool
29662963
{
2967-
foreach ($this->extends as $parentName) {
2968-
$parent = $classMap[$parentName->toString()] ?? null;
2969-
if ($parent === null) {
2970-
throw new Exception("Missing parent class " . $parent->toString());
2971-
}
2972-
2973-
if ($parent->hasConstructor()) {
2974-
return true;
2975-
}
2976-
2977-
if ($parent->hasParentConstructor($classMap)) {
2964+
foreach ($this->funcInfos as $funcInfo) {
2965+
if ($funcInfo->name->isConstructor() && !($funcInfo->flags & Class_::MODIFIER_PRIVATE)) {
29782966
return true;
29792967
}
29802968
}

0 commit comments

Comments
 (0)