1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix #953 - support spaces either side of |

This commit is contained in:
Matthew Brown 2018-08-22 22:53:44 -04:00
parent ebc65baa91
commit 867ebd4441
2 changed files with 20 additions and 1 deletions

View File

@ -735,11 +735,23 @@ class CommentChecker
) {
throw new DocblockParseException('Invalid string ' . $return_block);
}
} elseif ($char === ' ' || $char === "\t") {
} elseif ($char === ' ') {
if ($brackets) {
continue;
}
if ($next_char === '|') {
++$i;
$type .= $next_char;
continue;
}
$last_char = $i > 0 ? $return_block[$i - 1] : null;
if ($last_char === '|') {
continue;
}
if ($next_char === ':') {
++$i;
$type .= ':';

View File

@ -960,6 +960,13 @@ class AnnotationTest extends TestCase
$a1->bar();',
],
'spaceInType' => [
'<?php
/** @return string | null */
function foo(string $s = null) {
return $s;
}',
],
];
}