RJS Assistant
PhpStorm-style PHP refactorings for VS Code and Cursor.
Features
Press Alt+Enter (or Ctrl+.) on a PHP closure or arrow function to see available refactorings:
Convert closure to arrow function
// Before
$fn = function (int $x) use ($y) { return $x + $y; };
// After
$fn = fn (int $x) => $x + $y;
The refactoring is offered when the closure:
- Has exactly one
return statement
- Does not use by-reference captures (
use (&$var))
- Does not have a
void return type
Convert arrow function to closure
// Before
$fn = fn (int $x) => $x + $y;
// After
$fn = function (int $x) use ($y) { return $x + $y; };
Automatically detects which outer-scope variables need to be listed in the use() clause.
Supported features
- Typed parameters and return types are preserved
- Static closures/arrow functions
$this is excluded from the use() clause (auto-bound in non-static closures)
- Nested closures (refactoring applies to the innermost one at cursor)
Installation
Search for "RJS Assistant" in the VS Code or Cursor extension marketplace, or install from the command line:
code --install-extension ralphjsmit.ralphjsmit-assistant
| |