Skip to content

Commit edd9423

Browse files
westonruterclaude
andcommitted
Build/Test Tools: Fix PHPStan errors in GlobalDocBlockVisitor.
Specify the iterable value type on `beforeTraverse()`'s return, and cast `preg_replace()`'s `string|null` result to `string` (the regex is hard-coded and valid, so null is unreachable in practice). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent c943c2e commit edd9423

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

tests/phpstan/GlobalDocBlockVisitor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ final class GlobalDocBlockVisitor extends NodeVisitorAbstract {
4747
* Resets state at the start of each parser traversal.
4848
*
4949
* @param array<int, Node> $nodes Top-level nodes about to be traversed.
50-
* @return null
50+
* @return array<int, Node>|null
5151
*/
5252
public function beforeTraverse( array $nodes ): ?array {
5353
$this->stack = array();
@@ -126,7 +126,7 @@ private function parse_global_tags( string $docblock ): array {
126126
$map = array();
127127
if ( preg_match_all( '/@global\s+(\S+(?:\s*\|\s*\S+)*)\s+\$(\w+)/', $docblock, $matches, PREG_SET_ORDER ) > 0 ) {
128128
foreach ( $matches as $match ) {
129-
$map[ $match[2] ] = preg_replace( '/\s+/', '', $match[1] );
129+
$map[ $match[2] ] = (string) preg_replace( '/\s+/', '', $match[1] );
130130
}
131131
}
132132
return $map;

0 commit comments

Comments
 (0)