Skip to content
Permalink
Browse files

Add rename namespace command

  • Loading branch information...
muglug committed Jun 19, 2019
1 parent 84e002e commit 4823e35f8e601ffcfeb1ad11f0dac2c830b311db
Showing with 10 additions and 2 deletions.
  1. +10 −2 docs/manipulating_code/refactoring.md
@@ -4,21 +4,29 @@ Sometimes you want to make big changes to your codebase like moving methods or c

Psalm has a refactoring tool you can access with either `vendor/bin/psalm-refactor` or `vendor/bin/psalm --refactor`, followed by appropriate commands.

## Moving all classes from one namespace to another

```
vendor/bin/psalm-refactor --move "Ns1\*" --into "Some\Other\Namespace"
```

This moves all classes in `Ns1` (e.g. `Ns1\Foo`, `Ns1\Baz`) into the specified namespace. Files are moved as necessary.

## Moving classes between namespaces

```
vendor/bin/psalm-refactor --move "Ns1\Foo" --into "Ns2"
```

This tells Psalm to move class `Ns1\Foo` into the namespace `Ns2`, so any reference to `Ns1\Foo` becomes `Ns2\Foo`).
This tells Psalm to move class `Ns1\Foo` into the namespace `Ns2`, so any reference to `Ns1\Foo` becomes `Ns2\Foo`). Files are moved as necessary.

## Moving and renaming classes

```
vendor/bin/psalm-refactor --rename "Ns1\Foo" --to "Ns2\Bar\Baz"
```

This tells Psalm to move class `Ns1\Foo` into the namespace `Ns2\Bar` and rename it to `Baz`, so any reference to `Ns1\Foo` becomes `Ns2\Bar\Baz`).
This tells Psalm to move class `Ns1\Foo` into the namespace `Ns2\Bar` and rename it to `Baz`, so any reference to `Ns1\Foo` becomes `Ns2\Bar\Baz`). Files are moved as necessary.

## Moving methods between classes

0 comments on commit 4823e35

Please sign in to comment.
You can’t perform that action at this time.