Skip to content

Commit 4e5214b

Browse files
committed
fix: Allow variadic syntax in PHPDoc parameter annotation in gen_stub.php
Closes #20277
1 parent a585ace commit 4e5214b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

build/gen_stub.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3323,12 +3323,12 @@ public function getType(): string {
33233323
$matches = [];
33243324

33253325
if ($this->name === "param") {
3326-
preg_match('/^\s*([\w\|\\\\\[\]<>, ]+)\s*(?:[{(]|\$\w+).*$/', $value, $matches);
3326+
preg_match('/^\s*([\w\|\\\\\[\]<>, ]+)\s*(?<type>[{(]|(\.\.\.)?\$\w+).*$/', $value, $matches);
33273327
} elseif ($this->name === "return" || $this->name === "var") {
3328-
preg_match('/^\s*([\w\|\\\\\[\]<>, ]+)/', $value, $matches);
3328+
preg_match('/^\s*(?<type>[\w\|\\\\\[\]<>, ]+)/', $value, $matches);
33293329
}
33303330

3331-
if (!isset($matches[1])) {
3331+
if (!isset($matches["type"])) {
33323332
throw new Exception("@$this->name doesn't contain a type or has an invalid format \"$value\"");
33333333
}
33343334

@@ -3345,7 +3345,7 @@ public function getVariableName(): string {
33453345

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

0 commit comments

Comments
 (0)