Skip to content

Commit

Permalink
Fix Reflector exception when a parameter name starts with another par…
Browse files Browse the repository at this point in the history
…ameter's name
  • Loading branch information
BenMorel committed Apr 15, 2023
1 parent 84c9880 commit ea2aa6d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Reflection/Reflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private function getParameterTypeFromDocComment(ReflectionParameter $parameter):
return null;
}

$pattern = '/@param(.*)\$' . $parameter->getName() . '/';
$pattern = '/@param(.*)\$' . $parameter->getName() . '\W/';

/** @var list<array{string}> $matches */
preg_match_all($pattern, $docComment, $matches, PREG_SET_ORDER);
Expand Down
12 changes: 12 additions & 0 deletions tests/Classes/KitchenSink.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@ public function multipleDocblockTypes(
): void {
}

/**
* @param int[] $a
* @param string[] $ab
*/
public function parameterNameThatStartsWithAnotherParametersName(
#[ExpectParameterType('int[]')]
array $a,
#[ExpectParameterType('string[]')]
array $ab,
): void {
}

/**
* @param (Countable&Traversable)|null $b
*/
Expand Down

0 comments on commit ea2aa6d

Please sign in to comment.