Skip to content

Commit 17acc47

Browse files
committed
gen_stub: Fix generation for @generate-legacy-arginfo 70000
> Uncaught Error: Cannot indirectly modify readonly property ClassInfo::$constInfos in gen_stub.php:4158
1 parent 9f71d29 commit 17acc47

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

build/gen_stub.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ function reportFilePutContents(string $filename, string $content): void {
4343
}
4444
}
4545

46+
function clone_fn(object $obj) {
47+
return clone $obj;
48+
}
49+
4650
if (!function_exists('array_any')) {
4751
function array_any(array $array, callable $callback): bool {
4852
foreach ($array as $key => $value) {
@@ -2184,9 +2188,7 @@ public function toArgInfoCode(?int $minPHPCompatibility): string {
21842188

21852189
public function __clone()
21862190
{
2187-
foreach ($this->args as $key => $argInfo) {
2188-
$this->args[$key] = clone $argInfo;
2189-
}
2191+
$this->args = array_map(clone_fn(...), $this->args);
21902192
$this->return = clone $this->return;
21912193
}
21922194
}
@@ -4154,17 +4156,9 @@ private function createIncludeElement(DOMDocument $doc, string $query, int $inde
41544156

41554157
public function __clone()
41564158
{
4157-
foreach ($this->constInfos as $key => $constInfo) {
4158-
$this->constInfos[$key] = clone $constInfo;
4159-
}
4160-
4161-
foreach ($this->propertyInfos as $key => $propertyInfo) {
4162-
$this->propertyInfos[$key] = clone $propertyInfo;
4163-
}
4164-
4165-
foreach ($this->funcInfos as $key => $funcInfo) {
4166-
$this->funcInfos[$key] = clone $funcInfo;
4167-
}
4159+
$this->constInfos = array_map(clone_fn(...), $this->constInfos);
4160+
$this->propertyInfos = array_map(clone_fn(...), $this->propertyInfos);
4161+
$this->funcInfos = array_map(clone_fn(...), $this->funcInfos);
41684162
}
41694163

41704164
/**

ext/zend_test/test.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* @generate-class-entries static
55
* @generate-c-enums
6-
* @generate-legacy-arginfo 80000
6+
* @generate-legacy-arginfo 70000
77
* @undocumentable
88
*/
99
namespace {

ext/zend_test/test_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/zend_test/test_decl.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)