Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions build/gen_stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<string, ConstInfo> $allConstInfos
* @param array<string, string> &$declaredStrings Map of string content to
Expand Down Expand Up @@ -4407,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 {
Expand All @@ -4415,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);
Expand Down
Loading