From 63af31610a695588638c68916f2dce457c4b8197 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 ee1f6914aa28..697c171be5fc 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -2169,7 +2169,7 @@ public function getMethodSynopsisElement(DOMDocument $doc): ?DOMElement { $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); @@ -3355,6 +3355,24 @@ public function __construct( private readonly array $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 * @param array &$declaredStrings Map of string content to From 24c0b6f7a1d8d785e5ce32a98b473d29ff5a5f81 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 | 1 + 1 file changed, 1 insertion(+) diff --git a/build/gen_stub.php b/build/gen_stub.php index 697c171be5fc..1b7373184b3d 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -4425,6 +4425,7 @@ public function getLegacyVersion(): FileInfo { public static function parseStubFile(string $code): FileInfo { $parser = new PhpParser\Parser\Php7(new PhpParser\Lexer\Emulative()); $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 { From 869abebc6610d249b8e5002ebc9c6a257285425d 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 1b7373184b3d..cb41618867c1 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -4434,7 +4434,7 @@ protected function pName_FullyQualified(Name\FullyQualified $node): string { }; $stmts = $parser->parse($code); - $nodeTraverser->traverse($stmts); + $stmts = $nodeTraverser->traverse($stmts); $fileTags = DocCommentTag::parseDocComments(self::getFileDocComments($stmts)); $fileInfo = new FileInfo($fileTags);