Skip to content

Released Rector 2.0

Latest
Compare
Choose a tag to compare
@TomasVotruba TomasVotruba released this 12 Dec 10:52
· 72 commits to main since this release

Rector 2.0 is here 🥳

The main purpose of this release is performance improvements, thanks to modern dependencies:

  • php-parser 4.x to 5.0
  • PHPStan 1.x to 2.0
  • and min PHP version 7.2 to 7.4 because of dependencies above

We've managed to fit in couple cool features: 5 New Features in Rector 2.0


For custom rules writers, see upgrading guide. The rest of upgrade is straighforward 🎉


To celebrate the upgrade, we're also modernized our logo! 🤩


New Features and Improvements 🎉

  • Add "--only" option to process only a single rule (#6441), Thanks @cweiske!
  • [DX] Add version-based set loading based on installed package version (#6428)
  • [dx] enable polyfills by default when PHP is on, to make config simpler (#6433)
  • [dx] enable all attributes, if none are selected to streamline config (#6451)
  • feat: add the option to use the annotation value as an argument to the attribute (#6468), Thanks @carlos-granados!
  • feat: add Behat annotations to attributes set (#6510), Thanks @carlos-granados!

Deprecated and Removed 💀

  • [deprecation] Deprecate AbstractScopeAwareRector in favor of single AbstractRector (#6425)
  • [deprecation] Deprecate MixedTypeRector, to avoid mixed type filled blindly, use type declaration set instead (#6434)
  • [docs] getRuleDefinition() no longer required for custom rules (#6440)
  • [deprecation] Remove deprecated PublicConstantVisibilityRector, cleanup deprecated SetListInterface (#6424)
  • [deprecated] Remove deprecated AbstractTestCase (#6426)

Bugfixes 🐛

  • [Php80] Returns null on no change on ClassPropertyAssignToConstructorPromotionRector (#6418)
  • [attributes] Make sure the target attribute class exists (#6454)
  • [TypeDeclaration] Skip test methods with exception in ReturnNeverTypeRector, [php74] Skip conditinal assign in RestoreDefaultNullToNullableTypePropertyRector as most likely desired to assign or fail (#6430)
  • Support php-64bit as required in composer.json (#6432), Thanks @hans-thomas!
  • [dx] Allow external rules without getRuleDefinition() to make them easier to write (#6438)
  • [fix] class phpdoc generic method (#6439), Thanks @lammafish!
  • Fix RemoveDoubleAssignRector in case of method call (#6442)
  • Upgrade to PHPParser 5 and PHPStan 2 (#6431)
  • [CodeQuality] Handle crash on return array constant on ExplicitReturnNullRector (#6458)
  • [Php80] Handle crash single quoted doctrine on AnnotationToAttributeRector (#6459)
  • [Php71] Skip already array destruct on ListToArrayDestructRector (#6460)
  • [TypeDeclaration] Skip mixed as on right of and on ParamTypeByMethodCallTypeRector (#6401)
  • [Renaming] Fix space on union docblock during rename on RenameClassRector (#6463)
  • [CodeQuality] Skip used by array callable on LocallyCalledStaticMethodToNonStaticRector (#6473)
  • [CodeQuality] Skip compare nullable object on UseIdenticalOverEqualWithSameTypeRector (#6474)
  • Use Type->getIterableValueType() over ArrayType-> getItemType() (#6479), Thanks @staabm!
  • [DeadCode] Allow remove assign variable with next method call on RemoveDoubleAssignRector (#6443)
  • [DeadCode] Handle InterpolatedStringPart crash on RemoveUnusedForeachKeyRector (#6457)
  • [DeadCode] Skip used by get_object_vars() when implements JsonSerializable on RemoveUnusedPromotedPropertyRector (#6472)
  • [DeadCode] Handle crash on valid conditional type on RemoveUselessReturnTagRector (#6475)
  • Use Type->getIterableKeyType() over ArrayType->getKeyType() (#6480), Thanks @staabm!
  • Update developing with docker: Fix php version to 8.2. (#6490), Thanks @uncaught!
  • [Renaming] Handle docblock aliased rename on RenameClassR* [Php81] Allow not readonly property on API Platform api resource (#6531), Thanks @alexndlm!
    ector (#6498)
  • [CodeQuality][Renaming] Handle DynamicDocBlockPropertyToNativePropertyRector+RenameClassRector with aliased name (#6506)
  • [TypeDeclaration] Skip with default value and assigned mixed on TypedPropertyFromAssignsRector (#6514)
  • [Php80] Mirror comments on assign on ChangeSwitchToMatchRector (#6516)
  • [Php70] Handle parent method call on Php4ConstructorRector (#6519)
  • [Php70] Do not replace if method call if method exists in current class on call same method with parent on Php4ConstructorRector (#6520)
  • [PostRector] Keep first comment before first Use_ on UnusedImportRemovingPostRector (#6522)
  • [Php81] Allow not readonly property on API Platform api resource (#6531), Thanks @alexndlm!
  • [Php81] Skip by ref param on ReadOnlyPropertyRector (#6532)
  • [Php70] Handle ArrayDimFetch on WrapVariableVariableNameInCurlyBracesRector (#6533)
  • Fix fixture end ] fixture on NestedAnnotationToAttributeRector (#6537)
  • [Php80] Handle mix quote single and double on AnnotationToAttributeRector (#6538)
  • [CodeQuality] Handle crash on yield from on OptionalParametersAfterRequiredRector (#6545)
  • Fix str_contains() never returns 0 (#6546)
  • [CodeQuality] Handle crash on unary minums on OptionalParametersAfterRequiredRector (#6547)
  • [CodeQuality] Handle crash on assign ref on OptionalParametersAfterRequiredRector (#6551)
  • [Attributes] Cover slash newline in AnnotationToAttributeRector with values (#6557)
  • [TypedPropertyFromAssignsRector] Handle parse_url() native function with second arg on TypedPropertyFromAssignsRector (#6562)
  • [TypeDeclaration] Handle default value with contant type on TypedPropertyFromAssignsRector (#6563)
  • [NodeTypeResolver] Handle namespaced function call name on NodeTypeResolver (#6564)

rectorphp/rector-symfony 🎵

  • Fill listener method name, based on kernel.x event name in EventListenerToEventSubscriberRectory (#694)
  • [scoped] Fix scoped prefixed UrlGeneratorInterface on RedirectToRouteRector (#692)
  • [DependencyInjection] Add GetBySymfonyStringToConstructorInjectionRector (#688)
  • [DependencyInjection] Add TraitGetByTypeToInjectRector (#687)
  • [DependencyInjection] Extract CommandGetByTypeToConstructorInjectionRector to make migration smoother (#686)
  • [DependencyInjection] Extract GetByTypeMethodCallToConstructorInjectionRector to make migration smoother (#685)
  • [Symfony 7.2] Add SetList (#684), Thanks @alamirault
  • Upgrade deprecated ScopeAware to AbstractRector (#680)
  • Fix twig 2.40 set to 2.4 (#678)
  • [deprecation] Remove deprecated rules (#677)
  • Remove deprecated set list marker (#676)

rectorphp/rector-doctrine 🟠

  • [deprecation] Remove deprecated AddReturnDocBlockToCollectionPropertyGetterByToManyAttributeRector, InitializeDefaultEntityCollectionRector, TypedPropertyFromDoctrineCollectionRector (#347)

rectorphp/rector-phpunit 🟢

  • [PHPUnit] Support list in YieldDataProviderRector (#418), Thanks @staabm
  • [Phpunit] Avoid reprint doc for remove/replace when no @return tag on YieldDataProviderRector (#417)
  • [PHPUnit] Add missing DocblockUpdater usage on YieldDataProviderRector when removing @return doc (#416)
  • [PHPUnit] Change @return array<> to @return Iterator<> on YieldDataProviderRector (#415)
  • [CodeQuality] Handle createMock as well in PreferPHPUnitThisCallRector (#407)
  • [fix] Keep original message in AssertEqualsOrAssertSameFloatParameterToSpecificMethodsTypeRector (#406)
  • [PHPUnit 10] Remove AssertIssetToAssertObjectHasPropertyRector (#405)
  • [CodeQuality] Skip possible data provider method called and used as array on YieldDataProviderRector (#404)