Skip to content

Commit

Permalink
Replace all references to static variables when moving class (#8780)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
weirdan committed Nov 27, 2022
1 parent 24769a2 commit 05b8e0e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Expand Up @@ -369,6 +369,8 @@ public static function analyze(
}
}
}

return true;
}

if ($var_id) {
Expand Down
23 changes: 23 additions & 0 deletions tests/FileManipulation/ClassMoveTest.php
Expand Up @@ -749,6 +749,29 @@ class Hello extends \Foo\Base {}
'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',
],
],
];
}
}

0 comments on commit 05b8e0e

Please sign in to comment.