Skip to content

Commit 68eb458

Browse files
authored
Make sure the pattern was matched at least once.
1 parent 67c1243 commit 68eb458

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

custom-standards/Flyeralarm/Sniffs/Docblock/ReturnTypeSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ private function isStartingWithUppercaseLetter($singleCharacter)
143143
*/
144144
private function checkReturnTypeShape(string $subject)
145145
{
146-
preg_match_all('#(?<separator>\s*\|\s*)?(?<atom>[^<>\|]+)(?<generic><(?<nested>.*)>)?#', $subject, $matches);
146+
$matched = preg_match_all('#(?<separator>\s*\|\s*)?(?<atom>[^<>\|]+)(?<generic><(?<nested>.*)>)?#', $subject, $matches);
147147

148-
if (implode('', $matches[0]) !== $subject) {
148+
if (!$matched || implode('', $matches[0]) !== $subject) {
149149
throw new \InvalidArgumentException('Invalid structure in return type "' . $subject . '"');
150150
}
151151

0 commit comments

Comments
 (0)