rector/rector-prefixed
Prefixed distribution of Rector, the PHP tool for automated refactoring and instant code upgrades. All dependencies are scoped under a unique namespace to avoid version conflicts with your project's own packages, making it safe to install and run in any PHP codebase.
This package is a frozen (archived, April 2021) prefixed + PHP 7.1 downgraded build of Rector. It exists for one reason: letting you run Rector in environments where installing rector/rector directly is impossible — old PHP runtimes, or projects with dependency trees that conflict with Rector's own bundled Symfony/PHPStan versions. If neither constraint applies, do not start here — install rector/rector or the rector.phar instead.
Minimal setup:
composer require --dev rector/rector-prefixed
Create rector.php in the project root:
<?php
declare(strict_types=1);
use Rector\Core\Configuration\Option;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(SetList::CODE_QUALITY);
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PATHS, [__DIR__ . '/src']);
};
First use case — a safe dry run on one directory:
vendor/bin/rector process src --dry-run
Look first at: vendor/bin/rector (the binary), the generated rector.php, and the .cache/rector directory Rector creates. Then run vendor/bin/rector list to confirm which sets this old build actually ships with — the set list is a 2021 snapshot and will not match current docs.
Upgrade-in-place with a pinned set. The most common pattern is importing a SetList::PHP_XX set that targets the PHP version of the host environment. Because this build is downgraded to PHP 7.1, sets above PHP_74/PHP_80 may be absent or incomplete. Pin the config to the highest set that is actually present when you run vendor/bin/rector list.
Run as a one-shot migration, then remove. Since the package is archived, treat it as a temporary codemod, not a permanent CI tool. Typical workflow:
vendor/bin/rector process src (without --dry-run).Isolate it from the runtime dependency tree. Because this build is prefixed, its internal vendor libraries (Symfony, PHPStan, etc.) live under prefixed namespaces. That is its entire value: you can install it into a project where a normal Rector install would collide with your framework's locked Symfony version. Lean on that — don't try to share code between your app and Rector's internals.
Integrate as a Composer script, not a global binary.
{
"scripts": {
"rector:check": "rector process src --dry-run --no-progress-bar",
"rector:fix": "rector process src"
}
}
Batch multiple directories with per-path sets. You can configure separate paths and even separate rule sets per path in older Rector versions using Option::PATHS and conditional container configuration. A pragmatic pattern here: run SetList::CODE_QUALITY on src/ but exclude tests/ and migrations/ via Option::SKIP.
Use --dry-run in CI and full processing locally. The archived build has less reliable change-detection caching than modern versions, so always validate dry-run output before letting it rewrite files in a pipeline.
Extension via custom rules — limited. The prefixed build makes writing custom AbstractRector subclasses fragile because your rule's use Rector\... imports may resolve to a different class identity than the one the prefixed binary loads. If you must write custom rules, keep them in a separate Composer autoload namespace and test them explicitly with vendor/bin/rector process --dry-run, checking that the rule actually reports changes. If no changes appear, the rule was not registered — a common prefixed-build symptom.
It is archived — no new rules, no new PHP version support. The last release is 2021-04-09. Anything introduced to Rector after that (new sets, PHP 8.1/8.2 rules, performance fixes, bugfixes for newer Symfony versions) is simply not there. Use it only as a stopgap; the opportunity cost of staying on it is high. Migrate to current Rector via PHAR or a scoped install.
Prefixed ≠ compatible with your custom rules. The prefixing that makes the tool install-safe is also what breaks custom rule authoring: your rule file autoloads unprefixed Rector\ classes, while the binary runs prefixed internals. Symptoms include rules silently not firing, or Class not found for Rector\Core\... types. Debugging path: run with -vvv, confirm the rule appears in vendor/bin/rector list-adjacent diagnostics, and verify the rule class is registered in your set/config.
Downgraded to PHP 7.1 — some PHP 7.2+ syntax rules behave differently. Because the parser/runtime targets 7.1, transformations involving newer syntax (arrow functions, typed properties in some contexts, ??=, etc.) may be skipped or produce partial output. If you need PHP 7.4+ modernisation, this package is the wrong tool — its own downgrade constraint limits what it can safely rewrite.
Composer may silently pick the wrong package. Both rector/rector and rector/rector-prefixed install a rector binary at vendor/bin/rector. If both end up in the tree (e.g., transitively), the binary you invoke may not be the one you think. Verify with vendor/bin/router --version or inspect vendor/bin/rector symlink target. Prefer explicit composer require --dev rector/rector-prefixed and run composer why rector/rector to confirm the plain package isn't also present.
Caching confusion. Rector caches files under .cache/rector. After configuration changes, a stale cache can make it look like rules "aren't firing." Fix: delete .cache/rector and re-run. This is a frequent false alarm with the aged prefixed build because its cache invalidation logic predates several modern fixes.
Config format is the old one. This build uses ContainerConfigurator closure-style rector.php, not the newer fluent config. Copying a modern config from current docs (using RectorConfig, ->withPaths(), ->withSets()) will fail with this package. Always cross-check against docs mirrored to the 2021 timeframe.
CI integration pitfalls. The archived build has no --no-interaction-stable guarantees in newer setups, and its exit codes on dry-run changes are less polished than current Rector. Do not rely on exit code alone for gating — parse the --dry-run output for "would have changed" markers if you need CI enforcement.
Extension points worth knowing. Useful options exposed via $parameters: Option::PATHS, Option::SKIP, Option::AUTO_IMPORT_NAMES, Option::IMPORT_SHORT_CLASSES, Option::FILE_EXTENSIONS. Use Option::SKIP aggressively — a 2021 Rector build is more likely to touch files you didn't intend (fixtures, generated code) than current versions.
Escape hatch — use the PHAR. If prefixing conflicts are the reason you chose this package, note that rector.phar from the matching era gives similar isolation without the custom-rule fragility. Given the package is archived, moving to the PHAR for one more migration and then to rector/rector with --with-dependencies is the pragmatic progression. Don't build long-term workflows on the prefixed package.
How can I help you explore Laravel packages today?