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:
parent
24769a2089
commit
05b8e0eea6
@ -369,6 +369,8 @@ class StaticPropertyFetchAnalyzer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($var_id) {
|
||||
|
@ -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',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user