1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Be resilient to docblock spaces

This commit is contained in:
Brown 2019-06-06 13:57:00 -04:00
parent 2e7d26af6a
commit 0221282074
2 changed files with 34 additions and 2 deletions

View File

@ -1038,18 +1038,19 @@ class CommentAnalyzer
if ($nexter_char === ' ') {
++$i;
$type .= $next_char;
$type .= $next_char . ' ';
continue;
}
}
if ($last_char === '|' || $last_char === '&') {
$type .= ' ';
continue;
}
if ($next_char === ':') {
++$i;
$type .= ':';
$type .= ' :';
$expects_callable_return = true;
continue;
}

View File

@ -132,6 +132,37 @@ class ClassMoveTest extends \Psalm\Tests\TestCase
'Ns\A' => 'Ns\B',
]
],
'renameEmptyClassWithSpacesInDocblock' => [
'<?php
namespace Ns;
class A {}
/**
* @param ?A $a
* @param string | null $b
* @return A | null
*/
function foo(?A $a, $b) : ?A {
return $a;
}',
'<?php
namespace Ns;
class B {}
/**
* @param null|B $a
* @param string | null $b
* @return null|B
*/
function foo(?B $a, $b) : ?B {
return $a;
}',
[
'Ns\A' => 'Ns\B',
]
],
'renameClassWithInstanceMethod' => [
'<?php
namespace Ns;