Skip to content

Commit d8e8ce0

Browse files
DanielEScherzerkocsismate
authored andcommitted
gen_stub: stop cloning AttributeInfo objects
They are immutable
1 parent 6b741e3 commit d8e8ce0

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

build/gen_stub.php

+2-10
Original file line numberDiff line numberDiff line change
@@ -2085,9 +2085,6 @@ public function __clone()
20852085
$this->args[$key] = clone $argInfo;
20862086
}
20872087
$this->return = clone $this->return;
2088-
foreach ($this->attributes as $key => $attribute) {
2089-
$this->attributes[$key] = clone $attribute;
2090-
}
20912088
foreach ($this->framelessFunctionInfos as $key => $framelessFunctionInfo) {
20922089
$this->framelessFunctionInfos[$key] = clone $framelessFunctionInfo;
20932090
}
@@ -3151,9 +3148,6 @@ public function __clone()
31513148
if ($this->type) {
31523149
$this->type = clone $this->type;
31533150
}
3154-
foreach ($this->attributes as $key => $attribute) {
3155-
$this->attributes[$key] = clone $attribute;
3156-
}
31573151
}
31583152
}
31593153

@@ -3183,6 +3177,8 @@ public function getDeclaration(array $allConstInfos): string {
31833177
}
31843178
}
31853179

3180+
// Instances of AttributeInfo are immutable and do not need to be cloned
3181+
// when held by an object that is cloned
31863182
class AttributeInfo {
31873183
public /* readonly */ string $class;
31883184
/** @var \PhpParser\Node\Arg[] */
@@ -4012,10 +4008,6 @@ public function __clone()
40124008
foreach ($this->funcInfos as $key => $funcInfo) {
40134009
$this->funcInfos[$key] = clone $funcInfo;
40144010
}
4015-
4016-
foreach ($this->attributes as $key => $attribute) {
4017-
$this->attributes[$key] = clone $attribute;
4018-
}
40194011
}
40204012

40214013
/**

0 commit comments

Comments
 (0)