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

Allow space in intersection type

Ref #1645
This commit is contained in:
Brown 2019-05-16 13:52:58 -04:00
parent 6b04503cc4
commit 66bbe5bb74
2 changed files with 24 additions and 5 deletions

View File

@ -991,13 +991,17 @@ class CommentAnalyzer
continue;
}
if ($next_char === '|') {
++$i;
$type .= $next_char;
continue;
if ($next_char === '|' || $next_char === '&') {
$nexter_char = $i < $l - 2 ? $return_block[$i + 2] : null;
if ($nexter_char === ' ') {
++$i;
$type .= $next_char;
continue;
}
}
if ($last_char === '|') {
if ($last_char === '|' || $last_char === '&') {
continue;
}

View File

@ -974,6 +974,21 @@ class AnnotationTest extends TestCase
private $s = null;
}',
],
'intersectionWithSpace' => [
'<?php
interface A {
public function foo() : void;
}
interface B {
public function bar() : void;
}
/** @param A & B $a */
function f(A $a) : void {
$a->foo();
$a->bar();
}'
],
];
}