packagist rector/rector 0.8.28

latest releases: dev-main, 1.2.8, 1.2.7...
4 years ago

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

Don't miss a new rector release

NewReleases is sending notifications on new releases.