diff --git a/Makefile b/Makefile index 0c8e12f..26d428f 100644 --- a/Makefile +++ b/Makefile @@ -23,3 +23,4 @@ install: @sudo ln -sf $(shell pwd)/bin/pint /usr/local/bin/pint @sudo ln -sf $(shell pwd)/bin/exakat /usr/local/bin/exakat @sudo ln -sf $(shell pwd)/bin/frankenphp /usr/local/bin/frankenphp + @sudo ln -sf $(shell pwd)/bin/rector /usr/local/bin/rector diff --git a/README.md b/README.md index a1f3bce..88d4e64 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ phpctl sh echo 'Hello, World!' # To run arbitrary sh commands inside the contain | `box` | Runs [Box](https://github.com/box-project/box). | | `exakat` | Runs [Exakat](https://www.exakat.io) | | `frankenphp` | Runs [FrankenPHP](https://frankenphp.dev) | +| `rector` | Runs [Rector](https://getrector.com) | ### Scaffolders | Command | Description | diff --git a/bin/rector b/bin/rector new file mode 100755 index 0000000..21194ac --- /dev/null +++ b/bin/rector @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +phpctl rector $@ diff --git a/examples/rector/.gitignore b/examples/rector/.gitignore new file mode 100644 index 0000000..48b8bf9 --- /dev/null +++ b/examples/rector/.gitignore @@ -0,0 +1 @@ +vendor/ diff --git a/examples/rector/README.md b/examples/rector/README.md new file mode 100644 index 0000000..210eb88 --- /dev/null +++ b/examples/rector/README.md @@ -0,0 +1,36 @@ +# Rector + +This is an example of how to use Rector to refactor your code. + +Run `phpctl rector -n` (yes, with the `-n` flag) to see what Rector would do. + +You should be seeing something like: +```shell +➜ rector git:(feat/rector) ✗ phpctl rector -n +Running opencodeco/phpctl:php82 + 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% +1 file with changes +=================== + +1) src/example.php:0 + + ---------- begin diff ---------- +@@ @@ + paths([ + __DIR__ . '/src', + ]); + + // register a single rule + $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); + + // define sets of rules + $rectorConfig->sets([ + LevelSetList::UP_TO_PHP_82 + ]); +}; diff --git a/examples/rector/src/example.php b/examples/rector/src/example.php new file mode 100644 index 0000000..2f101e8 --- /dev/null +++ b/examples/rector/src/example.php @@ -0,0 +1,3 @@ +