Skip to content

Commit 6dad206

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: fix: Allow variadic syntax in PHPDoc parameter annotation in `gen_stub.php` (#20342)
2 parents 77d306e + 324db3a commit 6dad206

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

build/gen_stub.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,11 +2215,11 @@ public function toArgInfoCode(?int $minPHPCompatability): string {
22152215
$this->numRequiredArgs,
22162216
$minPHPCompatability === null || $minPHPCompatability >= PHP_81_VERSION_ID
22172217
);
2218-
2218+
22192219
foreach ($this->args as $argInfo) {
22202220
$code .= $argInfo->toZendInfo();
22212221
}
2222-
2222+
22232223
$code .= "ZEND_END_ARG_INFO()";
22242224
return $code . "\n";
22252225
}
@@ -4310,13 +4310,13 @@ protected function pName_FullyQualified(Name\FullyQualified $node): string {
43104310
return implode('\\', $node->getParts());
43114311
}
43124312
};
4313-
4313+
43144314
$stmts = $parser->parse($code);
43154315
$nodeTraverser->traverse($stmts);
4316-
4316+
43174317
$fileTags = DocCommentTag::parseDocComments(self::getFileDocComments($stmts));
43184318
$fileInfo = new FileInfo($fileTags);
4319-
4319+
43204320
$fileInfo->handleStatements($stmts, $prettyPrinter);
43214321
return $fileInfo;
43224322
}
@@ -4337,16 +4337,16 @@ private function handleStatements(array $stmts, PrettyPrinterAbstract $prettyPri
43374337
$conds = [];
43384338
foreach ($stmts as $stmt) {
43394339
$cond = self::handlePreprocessorConditions($conds, $stmt);
4340-
4340+
43414341
if ($stmt instanceof Stmt\Nop) {
43424342
continue;
43434343
}
4344-
4344+
43454345
if ($stmt instanceof Stmt\Namespace_) {
43464346
$this->handleStatements($stmt->stmts, $prettyPrinter);
43474347
continue;
43484348
}
4349-
4349+
43504350
if ($stmt instanceof Stmt\Const_) {
43514351
foreach ($stmt->consts as $const) {
43524352
$this->constInfos[] = parseConstLike(
@@ -4364,7 +4364,7 @@ private function handleStatements(array $stmts, PrettyPrinterAbstract $prettyPri
43644364
}
43654365
continue;
43664366
}
4367-
4367+
43684368
if ($stmt instanceof Stmt\Function_) {
43694369
$this->funcInfos[] = parseFunctionLike(
43704370
$prettyPrinter,
@@ -4378,7 +4378,7 @@ private function handleStatements(array $stmts, PrettyPrinterAbstract $prettyPri
43784378
);
43794379
continue;
43804380
}
4381-
4381+
43824382
if ($stmt instanceof Stmt\ClassLike) {
43834383
$className = $stmt->namespacedName;
43844384
$constInfos = [];
@@ -4390,10 +4390,10 @@ private function handleStatements(array $stmts, PrettyPrinterAbstract $prettyPri
43904390
if ($classStmt instanceof Stmt\Nop) {
43914391
continue;
43924392
}
4393-
4393+
43944394
$classFlags = $stmt instanceof Class_ ? $stmt->flags : 0;
43954395
$abstractFlag = $stmt instanceof Stmt\Interface_ ? Modifiers::ABSTRACT : 0;
4396-
4396+
43974397
if ($classStmt instanceof Stmt\ClassConst) {
43984398
foreach ($classStmt->consts as $const) {
43994399
$constInfos[] = parseConstLike(
@@ -4447,7 +4447,7 @@ private function handleStatements(array $stmts, PrettyPrinterAbstract $prettyPri
44474447
throw new Exception("Not implemented {$classStmt->getType()}");
44484448
}
44494449
}
4450-
4450+
44514451
$this->classInfos[] = parseClass(
44524452
$className,
44534453
$stmt,
@@ -4461,15 +4461,15 @@ private function handleStatements(array $stmts, PrettyPrinterAbstract $prettyPri
44614461
);
44624462
continue;
44634463
}
4464-
4464+
44654465
if ($stmt instanceof Stmt\Expression) {
44664466
$expr = $stmt->expr;
44674467
if ($expr instanceof Expr\Include_) {
44684468
$this->dependencies[] = (string)EvaluatedValue::createFromExpression($expr->expr, null, null, [])->value;
44694469
continue;
44704470
}
44714471
}
4472-
4472+
44734473
throw new Exception("Unexpected node {$stmt->getType()}");
44744474
}
44754475
if (!empty($conds)) {
@@ -4501,7 +4501,7 @@ private static function handlePreprocessorConditions(array &$conds, Stmt $stmt):
45014501
throw new Exception("Unrecognized preprocessor directive \"$text\"");
45024502
}
45034503
}
4504-
4504+
45054505
return empty($conds) ? null : implode(' && ', $conds);
45064506
}
45074507

@@ -4540,7 +4540,7 @@ public function getType(): string {
45404540
$matches = [];
45414541

45424542
if ($this->name === "param") {
4543-
preg_match('/^\s*([\w\|\\\\\[\]<>, ]+)\s*(?:[{(]|\$\w+).*$/', $value, $matches);
4543+
preg_match('/^\s*([\w\|\\\\\[\]<>, ]+)\s*(?:[{(]|(\.\.\.)?\$\w+).*$/', $value, $matches);
45444544
} elseif ($this->name === "return" || $this->name === "var") {
45454545
preg_match('/^\s*([\w\|\\\\\[\]<>, ]+)/', $value, $matches);
45464546
}
@@ -4562,7 +4562,7 @@ public function getVariableName(): string {
45624562

45634563
if ($this->name === "param") {
45644564
// Allow for parsing extended types like callable(string):mixed in docblocks
4565-
preg_match('/^\s*(?<type>[\w\|\\\\]+(?<parens>\((?<inparens>(?:(?&parens)|[^(){}[\]<>]*+))++\)|\{(?&inparens)\}|\[(?&inparens)\]|<(?&inparens)>)*+(?::(?&type))?)\s*\$(?<name>\w+).*$/', $value, $matches);
4565+
preg_match('/^\s*(?<type>[\w\|\\\\]+(?<parens>\((?<inparens>(?:(?&parens)|[^(){}[\]<>]*+))++\)|\{(?&inparens)\}|\[(?&inparens)\]|<(?&inparens)>)*+(?::(?&type))?)\s*(\.\.\.)?\$(?<name>\w+).*$/', $value, $matches);
45664566
} elseif ($this->name === "prefer-ref") {
45674567
preg_match('/^\s*\$(?<name>\w+).*$/', $value, $matches);
45684568
}

0 commit comments

Comments
 (0)