From 88aa4b4bc96cce8bf1891a2e05d9a6f3cc4f908d Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Tue, 23 Jun 2026 22:25:09 +0200 Subject: [PATCH 1/3] build/gen_stub: include attribute arguments in synopsis modifiers --- build/gen_stub.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 28b168c72642..5acd67c82f9e 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -2122,7 +2122,7 @@ public function getMethodSynopsisElement(array $funcMap, array $aliasMap, DOMDoc $methodSynopsis->appendChild($methodparam); foreach ($arg->attributes as $attribute) { - $attribute = $doc->createElement("modifier", "#[\\" . $attribute->class . "]"); + $attribute = $doc->createElement("modifier", (string) $attribute); $attribute->setAttribute("role", "attribute"); $methodparam->appendChild($attribute); @@ -3130,6 +3130,24 @@ public function __construct(string $class, array $args) { $this->args = $args; } + public function __toString(): string { + $code = '#[\\' . $this->class; + if (!empty($this->args)) { + $prettyPrinter = new Standard; + $args = []; + foreach ($this->args as $arg) { + $argStr = $prettyPrinter->prettyPrintExpr($arg->value); + if ($arg->name !== null) { + $argStr = $arg->name->name . ': ' . $argStr; + } + $args[] = $argStr; + } + $code .= '(' . implode(', ', $args) . ')'; + } + $code .= ']'; + return $code; + } + /** @param array $allConstInfos */ public function generateCode(string $invocation, string $nameSuffix, array $allConstInfos, ?int $phpVersionIdMinimumCompatibility): string { $php82MinimumCompatibility = $phpVersionIdMinimumCompatibility === null || $phpVersionIdMinimumCompatibility >= PHP_82_VERSION_ID; From 75e023cae9792fad453788e4c22fade5567c399b Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Wed, 24 Jun 2026 00:33:10 +0200 Subject: [PATCH 2/3] use CloningVisitor to resolve cvalues --- build/gen_stub.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 5acd67c82f9e..e0469168f5d0 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -4860,6 +4860,7 @@ function parseStubFile(string $code): FileInfo { $lexer = new PhpParser\Lexer\Emulative(); $parser = new PhpParser\Parser\Php7($lexer); $nodeTraverser = new PhpParser\NodeTraverser; + $nodeTraverser->addVisitor(new PhpParser\NodeVisitor\CloningVisitor); $nodeTraverser->addVisitor(new PhpParser\NodeVisitor\NameResolver); $prettyPrinter = new class extends Standard { protected function pName_FullyQualified(Name\FullyQualified $node): string { @@ -5038,7 +5039,7 @@ function findEquivalentFuncInfo(array $generatedFuncInfos, FuncInfo $funcInfo): function generateCodeWithConditions( iterable $infos, string $separator, Closure $codeGenerator, ?string $parentCond = null): string { $code = ""; - + // For combining the conditional blocks of the infos with the same condition $openCondition = null; foreach ($infos as $info) { From e6f364b319dbd36cbc34f1b443ad498f8fd8cf0d Mon Sep 17 00:00:00 2001 From: Jordi Kroon Date: Wed, 24 Jun 2026 08:34:35 +0200 Subject: [PATCH 3/3] prevent namespacedName must not be accessed before initialization --- build/gen_stub.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index e0469168f5d0..0a4c95cbe989 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -4869,7 +4869,7 @@ protected function pName_FullyQualified(Name\FullyQualified $node): string { }; $stmts = $parser->parse($code); - $nodeTraverser->traverse($stmts); + $stmts = $nodeTraverser->traverse($stmts); $fileInfo = new FileInfo; $fileDocComments = getFileDocComments($stmts);