My configurations for Rector
  • PHP 74.2%
  • Shell 24.8%
  • JavaScript 1%
Find a file
2026-02-11 19:41:58 +10:00
scripts Initial commit 2026-02-07 15:27:22 +00:00
src feat: removal of paths 2026-02-11 19:36:36 +10:00
.editorconfig Initial commit 2026-02-07 15:27:22 +00:00
.gitignore build: set up dev tools 2026-02-11 18:55:19 +10:00
.php-cs-fixer.php build: set up dev tools 2026-02-11 18:55:19 +10:00
bun.lock Initial commit 2026-02-07 15:27:22 +00:00
commitlint.config.js Initial commit 2026-02-07 15:27:22 +00:00
composer.json build: remove Pest 2026-02-11 19:30:05 +10:00
herd.yml Initial commit 2026-02-07 15:27:22 +00:00
lefthook.yml Initial commit 2026-02-07 15:27:22 +00:00
LICENSE Initial commit 2026-02-07 15:27:22 +00:00
mise.toml Initial commit 2026-02-07 15:27:22 +00:00
package.json Initial commit 2026-02-07 15:27:22 +00:00
phpstan.neon build: set up dev tools 2026-02-11 18:55:19 +10:00
phpunit.xml Initial commit 2026-02-07 15:27:22 +00:00
publish.env.example Initial commit 2026-02-07 15:27:22 +00:00
README.md docs: add some documentation 2026-02-11 19:41:58 +10:00
rector.php feat: removal of paths 2026-02-11 19:36:36 +10:00

Rector Config

A helper for my Rector configurations

Installation

Add my Composer repository to your composer.json:

{
    "repositories": [
        {
            "type": "composer",
            "url": "https://code.rvx.works/api/packages/RVxLab/composer"
        }
    ]
}

Then require the package:

composer require rvxlab/rector-config

Add the following to your rector.php:

use RVxLab\RectorConfig\RectorConfigurator;

return RectorConfigurator::defaultPreset()
    ->withBasePath(__DIR__)
    ->getConfigBuilder();

The call to withBasePath(__DIR__) is required, otherwise a ConfigurationException will be thrown.

Presets

  • defaultPreset()
    • Default configuration. Makes no path assumptions
  • laravelPreset()
    • Configuration for Laravel applications. Sets up app, bootstrap, database, and tests directories
  • packagePreset()
    • Configuration for PHP packages. Sets up src and tests directories

Configuration Options

Adding Paths

Adding paths can be done with the withPaths() methods.

The paths are relative to the base path set using withBasePath().

Removing Paths

Removing paths can be done with the withoutPaths() methods.

The paths are relative to the base path set using withBasePath().

Adding Skips

Skips can be configured with the addSkip() and addSkips() methods.

addSkip() with just the rector class will add it if it wasn't defined already.

Calling it with a rector class and parameters will try to merge the parameters with the existing ones, or overwrite them if the $override flag is set to true.

addSkips() does the same as addSkip(), but for multiple rector classes in an array. The structure mimics the withSkips method from Rector.

License

This package is licensed under the MIT License.