Skip to content

Releases: rectorphp/rector

Released Rector 0.10.16 fixing version and allowing older php-parser

30 Apr 09:03
e615756

Choose a tag to compare

New Features 🎉

  • Added @changelog annotation above rule to explain why the rule does what it does in the output #6073 - thanks @sabbelasichon

Just add it to your Rector rule:

/**
 * @changelog https://wiki.php.net/rfc/typed_properties_v2#proposal
 */
final class TypedPropertyRector extends AbstractRector
{
}

Run Rector:

vendor/bin/rector ...

And if this rule changed the code, it will show the link too:

Applied Rectors:

* TypedPropertyRector - https://wiki.php.net/rfc/typed_properties_v2#proposal


  • [DeadCode] Added RemoveUnusedPrivateMethodParameterRector - #6168
  • Refactored file processors to make use of File object (similar to Scope concept from PHPStan) #6085
  • Added dump_node() helper function to see what node you have #6229 - thanks @ullique for inspiration
dump_node($string);
// change 2nd to increase depth
dump_node($string, 3);

New Downgrade Rules


Bugfixes 🐛

  • Fixed invalid doc block tag crashing #6068
  • Fixed parent, self, static prefixing on class name change #6159
  • Fixed use of AbstractRectorTestCase in tests while using rector/rector-prefixed - f801c76
  • Fixed AUTOLOAD_PATHS and BOOTSTRAP_FILES parameters in tests - #6239
  • Fixed displayed Rector version in rector/rector-prefixed 26d6fff
  • Fixed code conflicts with different php-parser version in rector/rector-prefixed - f15648e, thanks @phpstan for inspiration

Released Rector 0.10.4 with Static Annotation Parser

09 Apr 16:34

Choose a tag to compare

New Features 🎉

use Symfony\Component\Routing\Annotation\Route;

final class SomeController
{
    /**
     * @Route(path="/some_path", name="some_name")
     */
    public function some()
    {
    }
}
  • #6045 make use of PHPDocNodeTraverser to work with docblock changes

Read more about these features:


Bugfixes 🐛

  • #6057 Restore parent node connection on new node
  • #6064 Fix Php4ConstructorRector with non-stmts content
  • #5967 Fix printing files with fatal errorsage rector deps

Released Rector 0.10 with Static Reflection and PHP 7.1 version

22 Mar 12:46

Choose a tag to compare


Added Static Reflection 🚀🚀🚀

Do you have files with side effects or missing classes in autoload?

function hi()
{
    echo 'hello';
}

hi();

Static reflection finally refactors code without running it.


Do you still need to include files with constants or custom autoloader? Use BOOTSTRAP_FILES parameter:

$parameters->set(Option::BOOTSTRAP_FILES, [
    __DIR__ . '/constants.php',
    __DIR__ . '/project/special/autoload.php',
]);

Prefixed Rector with min PHP 7.1 🐘

Previous version required at least PHP 7.3 to run or Docker. Both were an obstacle to run Rector out of the box on every project.

We changed that. Now you can run Rector with older PHP and conflicting dependencies with ease:

php --version
# PHP 7.1

composer require symfony/console:^2.8

composer require rector/rector-prefixed:^0.10

Other Changes

  • Inspired by PHPStan, you can run Rector without "process" command if you have configured paths in rector.php:
vendor/bin/rector
13/260 [▓░░░░░░░░░░░░░░░░░░░░░░░░░░░]   5%

Upgrade Today

composer require rector/rector:^0.10
# or prefixed version
composer require rector/rector-prefixed:^0.10

Released Rector 0.9

28 Dec 13:29
5203352

Choose a tag to compare


New Features 🎉

  • PHP 8 upgrade set
  • Downgrade sets
  • Debuggable scoped Rector

Do you want to know more? Check the Release post

0.8.46

01 Nov 21:18
7ce55d6

Choose a tag to compare

Summary release for last 2 weeks, since 0.8.28


New Features 🎉

  • [#4490] [EarlyReturn] Brand new set
  • [#4517] [Doctrine] Add a Doctrine DBAL 2.11 set, Thanks @chrisguitarguy
  • [#4526] [CakePHP] Started ruleset for CakePHP 4.2, Thanks @markstory
  • [#4468] [CodeQuality] Added NewStaticToNewSelfRector
  • [#4442] [DoctrineCodeQuality] Added ImproveDoctrineCollectionDocTypeInEntityRector
  • [#4471] [Restoratoin] Added InferParamFromClassMethodReturnRector
  • [#4457] [CodeQualityString] Added MoveOutMethodCallInsideIfConditionRector, Thanks @samsonasik
  • [#4489] [Performance] Add CountArrayToEmptyArrayComparisonRector, Thanks @samsonasik
  • [#4515] [Nette] Add RemoveParentAndNameFromComponentConstructorRector

Changes ⌚

  • AbstractFileSystemRector was dropped and replaced by FileNode, this was a crappy part of Rector, that split node-based refatoring and file-based; now the logic is simplified to essential code, and to workwith file, we can use FileNode
  • [#4510] [TypeDeclaration] We switched types from string "int" fully to @phpstan types new IntegerType()
  • [#4513] Composer v2 was released, so we put it right into our GitHub Actions CI and cut install time to 50 %

Removed 🧹

  • [#4451] [DynamicTypedAnalysis] Very narrow package with lack of practise didn't get any feedback. As unfinished and better suitable for tombstoning, this part was dropped to keep Rector's focus on automated refactoring
  • [#4521] [Decouple] This had only 1 rule, it was hard to configure and use - the set was dropped, better use PHPStorm for local refactoring

They Write about Rector

0.8.28

15 Oct 23:10
16031da

Choose a tag to compare

This is first release note list, so we included changes from the last month.


New Features 🎉

Do you want to run Rector only on changed files?

# rector.php
use Rector\Core\Configuration\Option;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
    $parameters = $containerConfigurator->parameters();
    $parameters->set(Option::ENABLE_CACHE, true);
};

  • [#4311] Add init command, so you can create rector.php config
vendor/bin/rector init

# "rector.php" created

  • [#4336] [Restoration] Add RestoreFullyQualifiedNameRector to restore accidentaly shortened class names
-public \SomeClass $someProperty;
+public \App\Full\SomeClass $someProperty;
  • [#4341] [Symfony] Add AutoWireWithClassNameSuffixForMethodWithRequiredAnnotationRector for class method names with @require annotation, Thanks @samsonasik

  • [#4348] [PHP 8.0] Add @required annotation to #[Required] attribute from Symfony 5.2
  • [#4350] [PHP 8.0] Add @route annotation to #[Route] attribute in Symfony 5.2

  • [#4379] [Downgrade PHP 7.4] Added downgrade array spread rule, Thanks @leoloso

composer require rector/simple-php-doc-parser

  • [#4344] [SOLID] Added ChangeAndIfToEarlyReturnRector for refactoring early returns, Thanks @dobryy
 class SomeClass
 {
     public function canDrive(Car $car)
     {
-        if ($car->hasWheels && $car->hasFuel) {
-            return true;
+        if (!$car->hasWheels) {
+            return false;
         }
-        return false;
+        if (!$car->hasFuel) {
+            return false;
+        }
+
+        return true;
     }
 }

Bugfixes 🐛

  • [#4415] Fix ArraySpreadInsteadOfArrayMergeRector for iterator_to_array() function, Thanks @drupol