Download Latest Version Released Rector 2.6.3 source code.zip (4.3 MB)
Email in envelope

Get an email when there's a new version of Rector

Home / 2.6.1
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2026-08-03 7.5 kB
Released Rector 2.6.1 source code.tar.gz 2026-08-03 2.1 MB
Released Rector 2.6.1 source code.zip 2026-08-03 4.5 MB
Totals: 3 Items   6.6 MB 0

Bugfix :bug:

  • [composer-based] Fix fatal error in the composer-based command on a lazy-initialized property, e.g. PHPStan UnionType::$normalized (#8280)

    PHP Fatal error: Uncaught Error: Typed property PHPStan\Type\UnionType::$normalized must not be accessed before initialization in src/Console/Command/ComposerBasedCommand.php:205


Composer-based sets keep growing: Twig, nette/utils and the rest of Symfony :package:

Follow-up release to 2.6.0. The composer-based rollout continues - Twig and nette/utils join, and every remaining Symfony rule now declares the package version its target API was added in.

:::php
use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withComposerBased(
        doctrine: true,
        netteUtils: true,
        phpunit: true,
        symfony: true,
        twig: true,
    );


The new Twig composer-based set replaces the twig112twig127 → ... → twig30 chain with a single set, where every rule checks the installed twig/twig version:

:::diff
 final class SomeTwigUse
 {

-    public function run(Twig_Environment $twigEnvironment)
+    public function run(\Twig\Environment $twigEnvironment)
     {
-        return new Twig_SimpleFilter('some_filter', 'strlen');
+        return new \Twig\TwigFilter('some_filter', 'strlen');
     }
 }


Package bonding (composer-based rollout) :package:

  • [NetteUtils] Bind nette/utils rules to the installed package version; nette-utils4.php becomes composer-based.php and is loaded as a single set (#8275)
  • [rector-symfony] Add Twig composer-based set (#996)
  • [rector-symfony] Bond the remaining 48 Symfony rules to their composer package version (#994)
  • [rector-symfony] Register LoadValidatorMetadataToAttributeRector in the composer-based set - the last interface-bonded rule left outside it (#997)
  • [rector-symfony] Bond ContainerInterfaceServiceToServiceContainerRector to symfony/dependency-injection >=6.0 (#999)
  • [rector-doctrine] Bond AddGetReferenceTypeRector to doctrine/data-fixtures >=1.6 and the annotation-to-attribute sets to their package constraints (#497)
  • [rector-doctrine] Bond version-specific rules and configuration to composer package constraints (#495) *
  • [rector-phpunit] Bond RemoveExpectAnyFromMockRector to PHPUnit 11+ (#756) *

* landed in 2.6.0, missing from its release notes

The per-version sets are not touched - every rule stays registered where it was.


Set changes :chart_with_upwards_trend:

  • [CodingStyle] Remove ConsistentImplodeRector from the coding style level - the swapped implode($array, $glue) signature was removed in PHP 8.0, so the rule belongs to the php80 set only, where it already is (#8273)
  • [rector-doctrine] Add DoctrineSetList::COMPOSER_BASED constant, remove the empty DOCTRINE_BUNDLE_210 set (#499)


Bugfixes :bug:

  • [TypeDeclarationDocblocks] Skip docblock reprint when nothing changed in AddParamArrayDocblockFromAssignsParamToParamReferenceRector (#8271)
  • [rector-symfony] [Symfony44] Fix duplicated return in ConsoleExecuteReturnIntRector on a trailing comment (#992), plus a fixture for a block comment with a commented-out return (#993)
  • [rector-symfony] [Symfony44] Skip redundant (int) cast on a match return in ConsoleExecuteReturnIntRector - a match of int constants is a UnionType, so the instanceof IntegerType check missed it (#998)

    :::diff public function execute(InputInterface $input, OutputInterface $output): int {

    • return (int) match ($input->getArgument('type')) {
    • return match ($input->getArgument('type')) { 'a' => 0, default => 1, }; }


Deprecations :skull:

Deprecated rules still run, but print a warning and will be removed in a future major release. These are coding standard preferences or opinionated rewrites - a coding standard tool is the better place for them.

rector-src

  • WrapEncapsedVariableInCurlyBracesRector - also removed from the coding style level (#8272)

    :::diff function run($world) {

    • echo "Hello $world!";
    • echo "Hello {$world}!"; }

The actual PHP 8.2 deprecation, ${var}, is covered by VariableInStringInterpolationFixerRector in the php82 set.

  • CountArrayToEmptyArrayComparisonRector - also removed from the coding style level (#8274)

    :::diff -count($array) === 0; -count($array) > 0; +$array === []; +$array !== [];

  • ArraySpreadInsteadOfArrayMergeRector - the spread result is harder to read, and ... mid-array looks dangerous in review (#8277)

    :::diff -$values = array_merge($firstValues, $secondValues); +$values = [...$firstValues, ...$secondValues];

  • UnusedForeachValueToArrayKeysRector - also removed from the code quality level (#8278)

    :::diff -foreach ($values as $key => $value) { +foreach (array_keys($values) as $key) { $items[$key] = null; }

rector-doctrine

  • GetRepositoryServiceLocatorToRepositoryServiceInjectionRector - it resolved the repository class by running a regular expression over the entity file contents (#498)


Renames :arrows_counterclockwise:

  • [rector-symfony] ReplaceServiceArgumentRectorContainerInterfaceServiceToServiceContainerRector, no longer configurable (#999)

Both sets configured it with the same 2 values, for a single Symfony 6.0 BC break - the Psr\Container\ContainerInterface and Symfony\...\DependencyInjection\ContainerInterface aliases of the service_container service were removed. Now hardcoded, and the ReplaceServiceArgument value object is gone.

:::diff
 use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

-return service(ContainerInterface::class);
+return service('service_container');


Source: README.md, updated 2026-08-03