Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions doc/refactorings.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Fixes:
- [Generate Method](#generate-method)
- [Implement Contracts](#implement-contracts)
- [Import Class](#import-class)
- [Expand Class](#expand-class)
- [Import Missing Classes](#import-missing-classes)
- [Override Method](#override-method)

Expand Down Expand Up @@ -893,6 +894,53 @@ class Hello
}
```

Expand Class
------------

Expand the class name from unqualified name to fully qualified name.

- **Command**: _VIM function only_
- **VIM plugin**: _VIM function only_
- **VIM function**:`:call phpactor#ClassExpand()`

### Motivation

Although importing classes can make code cleaner, sometimes the code can be more
readable if the fully qualified name is specified. For example, we might register
a list of listeners in a file.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=> Although importing classes can make code cleaner, sometimes the code can be more readable if the fully qualified name is specified.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that make sense?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds fine, I'll take it.
Let me ask that if the "but" kind of weird in there so you trying to drop it? (Sorry, I'm not so good at English)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a bit weird -- it would work with Blah statements make the code cleaner, but sometimes. I guess it's either although or but. (disclaimer I'm a native speaker but not a language expert, so cannot say why, just it feels better :) )


### Before and After

Cursor position shown as `<>`:

```php
<?php

namespace App\Event;

class UserCreatedEvent
{
protected $listenrs = [
AssignDefaultRole<>ToNewUser::class
];
}
```

After selecting `App\Listeners\AssignDefaultRoleToNewUser` from the list of candidates:

```php
<?php

namespace App\Event;

class UserCreatedEvent
{
protected $listenrs = [
\App\Listeners\AssignDefaultRoleToNewUser::class
];
}
```

Import Missing Classes
----------------------

Expand Down