Sitelet https://github.com/php/php-src/pull/20342/commits/4e5214b2217bb9493f3b007df9cf0ebe1ce9f0a9
Skip to content
Merged
Changes from 1 commit
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
Next Next commit
fix: Allow variadic syntax in PHPDoc parameter annotation in `gen_stu…
…b.php`

Closes #20277
  • Loading branch information
mitelg committed Oct 31, 2025
commit 4e5214b2217bb9493f3b007df9cf0ebe1ce9f0a9
8 changes: 4 additions & 4 deletions build/gen_stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -3323,12 +3323,12 @@ public function getType(): string {
$matches = [];

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

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

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

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