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

Replace all references to static variables when moving class (#8780)

Previously `psalter` would only replace the first occurence of the
property access. Now it replaces all properties (by keeping the old name
unknown in the context).
This commit is contained in:
Bruce Weirdan 2022-11-27 11:44:53 -04:00 committed by GitHub
parent 24769a2089
commit 05b8e0eea6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View File

@ -369,6 +369,8 @@ class StaticPropertyFetchAnalyzer
}
}
}
return true;
}
if ($var_id) {

View File

@ -749,6 +749,29 @@ class ClassMoveTest extends TestCase
'Foo\Hello' => 'Foo\Bar\Hello',
],
],
'renamesAllStaticPropReferences' => [
'input' => '<?php
namespace Foo;
class Bar {
public static $props = [1, 2, 3];
}
echo Bar::$props[1];
echo Bar::$props[2];
',
'output' => '<?php
namespace Zoo;
class Baz {
public static $props = [1, 2, 3];
}
echo \Zoo\Baz::$props[1];
echo \Zoo\Baz::$props[2];
',
'migrations' => [
'Foo\Bar' => 'Zoo\Baz',
],
],
];
}
}