1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Don't migrate virtual nodes (#5780)

* Add a failing test for issue #5002

* Don't try to migrate virtual nodes

Fixes #5002
This commit is contained in:
pawel-slowik 2021-05-18 04:21:32 +02:00 committed by GitHub
parent 9eda9f9bbf
commit d82f02879c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 0 deletions

View File

@ -30,6 +30,7 @@ use Psalm\Issue\UnusedConstructor;
use Psalm\Issue\UnusedMethod;
use Psalm\Issue\UnusedProperty;
use Psalm\IssueBuffer;
use Psalm\Node\VirtualNode;
use Psalm\Progress\Progress;
use Psalm\Progress\VoidProgress;
use Psalm\Storage\ClassLikeStorage;
@ -1198,6 +1199,9 @@ class ClassLikes
bool $force_change = false,
bool $was_self = false
) : bool {
if ($class_name_node instanceof VirtualNode) {
return false;
}
$calling_fq_class_name = $source->getFQCLN();
// if we're inside a moved class static method

View File

@ -708,6 +708,41 @@ class ClassMoveTest extends \Psalm\Tests\TestCase
'Bar\Bat' => 'Bar\Baz\Bahh',
],
],
'moveClassBewareOfPropertyNotSetInConstructorCheck' => [
'<?php
namespace Foo {
class Base
{
protected $property1;
public function __construct()
{
$this->property1 = "";
}
}
}
namespace Foo {
class Hello extends Base {}
}',
'<?php
namespace Foo {
class Base
{
protected $property1;
public function __construct()
{
$this->property1 = "";
}
}
}
namespace Foo\Bar {
class Hello extends \Foo\Base {}
}',
[
'Foo\Hello' => 'Foo\Bar\Hello',
],
],
];
}
}