Skip to content
Open
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
25 changes: 22 additions & 3 deletions build/gen_stub.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -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);
Expand DownExpand Up@@ -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<string, ConstInfo> $allConstInfos */
public function generateCode(string $invocation, string $nameSuffix, array $allConstInfos, ?int $phpVersionIdMinimumCompatibility): string {
$php82MinimumCompatibility = $phpVersionIdMinimumCompatibility === null || $phpVersionIdMinimumCompatibility >= PHP_82_VERSION_ID;
Expand DownExpand Up@@ -4842,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 {
Expand All@@ -4850,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);
Expand DownExpand Up@@ -5020,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) {
Expand Down
Loading