Skip to content

Releases: rectorphp/rector

Released Rector 0.14.7

07 Nov 09:35
Compare
Choose a tag to compare

New Features 🥳

  • Move Rector Laravel to the community (#3019) - thanks to @driftingly for taking package further 👏
  • [CodeQuality] Add TernaryEmptyArrayArrayDimFetchToCoalesceRector (#3027)
  • NullToStrictStringFuncCallArgRector - Register a few more functions (#2994), Thanks @craigfrancis!
  • Update all classlike pseudo rector (#3002), Thanks @webmaster777!
  • Register Ctype functions (#3008), Thanks @bkosun!
  • Compatibility with BetterReflection 6.x (#2999), Thanks @ondrejmirtes!

Bugfixes 🐛

  • [CodeQuality] Skip different array_filter value on SimplifyEmptyArrayCheckRector (#3000)
  • [CodeQuality] Skip different value left and right on SimplifyEmptyArrayCheckRector (#2998)
  • [Php70] Handle crash on First class callable on ThisCallOnStaticMethodToStaticCallRector (#3003)
  • [Down_To_PHP71] Handle Downgrade Param Widening + Downgrade Reflection Get on DowngradeLevelSetList::DOWN_TO_PHP_71 (#3001)
  • Add real path to filePaths when not false (#3004), Thanks @jamwid07!
  • [DeadCode] Handle RemoveUnusedPrivateMethodRector+RemoveDuplicatedIfReturnRector when private method used in FuncCall with ArrowFunction (#3007)
  • [Php80] Handle crash on extends \mysqli on AddParamBasedOnParentClassMethodRector (#3009)
  • [Php80] Skip callable type different definition on ClassPropertyAssignToConstructorPromotionRector (#3010)
  • [EarlyReturn] Handle crash on RemoveAlwaysElseRector+ReturnEarlyIfVariableRector (#3011)
  • [DeadCode] Handle crash on has first class callable on RemoveUnusedConstructorParamRector (#3015)
  • [Php80] Handle nested annotation not end with () on AnnotationToAttributeRector (#3017)
  • [TypeDeclaration] Skip intersection with iterable on ReturnTypeDeclarationRector on php 8.1 feature enabled (#3022)
  • InlineConstructorDefaultToPropertyRector fix code example (#7465) (#3028), Thanks @GeniJaho!
  • [Php81] Skip on Array Destructuring on ReadOnlyPropertyRector (#3030)

Released Rector 0.14.6

15 Oct 23:03
Compare
Choose a tag to compare

New Features 🥳

  • Move cakephp Rector from the core to the community (#2966)
  • Use better composer-unused (#2972)

Bugfixes 🐛

  • [DeadCode][Privatization] Handle crash on RemoveDeadZeroAndOneOperationRector+ChangeReadOnlyPropertyWithDefaultValueToConstantRector (#2962)
  • [DeadCode][EarlyReturn] Handle RemoveUnusedVariableAssignRector+RemoveAlwaysElseRector (#2964)
  • Fix wrong results in ExactCompareFactory (#2973), Thanks @jlherren!
  • [Php81] Skip assigned after defined as constructor promotion on ReadOnlyPropertyRector (#2976)
  • [Php80] Handle crash on nullable scalar with mixed param on MixedTypeRector (#2977)
  • [Core] Set compatible with latest BetterReflection usage to handle assert($startLine > 0) notice (#2978)
  • [TypeDeclaration] Handle Parent ClassMethod has no Return_ stmt on ReturnTypeDeclarationRector (#2980)
  • [Privatization] Skip Property unsetted on ChangeReadOnlyPropertyWithDefaultValueToConstantRector (#2981)
  • fix symfony deprecation reports (rectorphp/rector-src@e58f390)
  • [Core] Remove second param on ClassLikeAstResolver::resolveClassFromClassReflection() (#2975)
  • [Core] Ensure refresh Scope Nodes when AbstractRector refactor() return array of Nodes (#2979)
  • [Core][Symfony] Handle crash on get dynamic value ClassConstFetch by method call on ChangeStringCollectionOptionToConstantRector (#2984)
  • [Php80] Handle crash after transform with trait-string on UnionTypesRector (#2985)
  • Fix multi property default assign (#2986)
  • Add new rule to simplify a last useless variable assignment. (#2963), Thanks @Wohlie!
  • Fix missing extra import on NestedAnnotationToAttributeRector (#2989)
  • Assert JoinColumns in CPP should be converted (#2991)

Released Rector 0.14.5

29 Sep 11:06
Compare
Choose a tag to compare

Bugfixes 🐛

Released Rector 0.14.4

27 Sep 23:40
Compare
Choose a tag to compare

New Features 🥳

  • [Naming] Add TwigEnvironment special name to RenameParamToMatchTypeRector to keep the context (#2951)
  • Add support for interface in AnnotationToAttributeRector rule (#2958), Thanks @astronom!

Bugfixes 🐛

  • Skip short class names on StringClassNameToClassConstantRector, as mostly internal classes or strings (#2950)
  • [CodeQuality] Skip nullable mixed on ReturnTypeFromStrictScalarReturnExprRector (#2947), Thanks @thomasschiet!
  • [Php81] Handle crash insensitive function name on NullToStrictStringFuncCallArgRector (#2953)
  • [AutoImport] Add support for auto import in alias same last name (#2952)
  • [Php80] Skip no default next indirect in return Expr on ChangeSwitchToMatchRector (#2959)

Released Rector 0.14.3

23 Sep 10:02
Compare
Choose a tag to compare

New Features 🥳


Bugfixes 🐛

  • [Down_To_PHP71] Handle both parent and child typed for trailing comma downgrade on DowngradeLevelSetList::DOWN_TO_PHP_71 (#2910)
  • [PHP 8.1] Do not process static methods from Enum class (#2911)
  • [PHP 7.4] Fix literator separator string/int missmatch in PHPStan type (#2913)
  • [Doctrine] Handle Partial removal annotation has annotation below on RemoveRedundantDefaultPropertyAnnotationValuesRector (#2914)
  • [DeadCode] Handle assign empty array on if cond on RemoveUnusedNonEmptyArrayBeforeForeachRector (#2917)
  • [DeadCode] Skip assign if cond on RemoveUnusedNonEmptyArrayBeforeForeachRector (#2918)
  • Skip first class callables in NullToStrictStringFuncCallArgRector (#2919), Thanks @thomasschiet!
  • [Skipper] Handle provide direct relative path in Skipper (#2921)
  • Fix VarAnnotationIncorrectNullableRector, add support for closure params when generating php doc (#2922), Thanks @dorrogeray!
  • [CodingStyle] Skip has non-printable chars on SymplifyQuoteEscapeRector (#2926)
  • [Php80] Handle crash on Nested Annotation to Attribute setting PhpVersion::PHP_80 (initializer - 1) (#2929)
  • [Visibility] Does not turn abstraction into static from implicit public abstractions in ExplicitPublicClassMethodRector (#7483) (#2930), Thanks @Goral64!
  • [Php55] Allow alias name on StringClassNameToClassConstantRector (#2931)
  • [TypeDeclaration] Add AddArrowFunctionReturnTypeRector (#2933)
  • [DeadCode] Skip nullable array on not empty on RemoveUnusedNonEmptyArrayBeforeForeachRector (#2935)
  • [AutoImport] Allow auto import to use existing alias in use statement (#2937)
  • Skip properties with default values for MakeTypedPropertyNullableIfCheckedRector (#2936), Thanks @Wohlie!
  • [AutoImport] Add GroupUse support on auto import (#2939)
  • [AutoImport] Skip multiple namespaces on single file on auto imports (#2940)
  • Skip method of abstract class for StaticCallOnNonStaticToInstanceCallRector. (#2938), Thanks @Wohlie!
  • Skip magic methods for StaticCallOnNonStaticToInstanceCallRector. (#2941), Thanks @Wohlie!
  • Add refactorings for ...val() (#2942), Thanks @Wohlie!
  • [DeadCode] Handle crash on RemoveUnusedPrivatePropertyRector+RemoveJustPropertyFetchForAssignRector (#2943)
  • Fix type error on downgraded version. (#2946), Thanks @Wohlie!
  • [TypeDeclaration] Skip intersection array on ReturnTypeDeclarationRector on PHP 8.1 feature enabled (#2948)
  • [Php56] Skip after exit() on AddDefaultValueForUndefinedVariableRector (#2949)
  • ParamAnalyzer: Accept all FunctionLike (#2945), Thanks @jtojnar!

Released Rector 0.14.2

04 Sep 16:42
Compare
Choose a tag to compare

Bugfixes 🐛

  • [Php74] Skip Nested ternary parenthesized multiline on ParenthesizeNestedTernaryRector (#2902)
  • Update nikic/php-parser to 4.15.1 (#2903)
  • [Php55] Handle pre-slash string on StringClassNameToClassConstantRector (#2905)
  • Explain how to persist Rector caches between CI runs (#2906), Thanks @CodeCasterNL!
  • Fix missing FileSystem class in Symfony project (#7449)

Released Rector 0.14.1

03 Sep 08:55
Compare
Choose a tag to compare

New Features 🥳

Read on the blog: Support for Nested Doctrine Annotation to Flat Attributes in Rector 0.14

  • [PHP 8.0] Add NestedAnnotationToAttributeRector (#2781)
  • [PHP 8.0] Add way to adjust specifics attribute arguments (#2834)

  • [BetterPhpDocParser] Add ArrayItemNode to improve value transfer in annotation curly lists (#2786) (#2795)
  • + 20 % performance improvement by lazy loading resources (#2774), Thanks @ossinkine!
  • [PHP 8.0] Refactor ChangeSwitchToMatchRector to StmstAwareInterface (#2801)
  • [Naming] Add ArrowFunction support on RenameParamToMatchTypeRector (#2818)
  • Support for ConstFetch (true, false, null) in NodeFactory::createArrayItem (#2778), Thanks @xorik!
  • [PHP 7.4] Add MoneyFormatToNumberFormatRector (#2727)
  • [DX] Make tracy debug functions part of dev-only, so developers can use own debug style (#2848)
  • Add rector-debugging to require-dev (#2857)
  • Support for ConstFetch (true, false, null) in NodeFactory::createArrayItem (#2778), Thanks @xorik!
  • [PHP 8.0] Add custom JMS AccesorOrder explicit key (#2895)

Bugfixes 🐛

  • Handle crash on RenameFunctionRector+ForRepeatedCountToOwnVariableRector+CountOnNullRector+NullToStrictStringFuncCallArgRector (#2777)
  • [CodeQuality] Fix out-of-order items removal in UnusedForeachValueToArrayKeysRector (#2779)
  • [PHP 8.0] Keep quoted string with doublecolon in AnnotationToAttributeRector (#2784)
  • [PHP 8.0] Fix ChangeSwitchToMatchRector for next new variable re-use (#2798)
  • Fix generics and intersection in TypedPropertyRector (#7392) (#2800), Thanks @Khartir!
  • [CodeQuality] Add StaticCall support on OptionalParametersAfterRequiredRector (#2817)
  • [PHP 5.5] Make StringClassNameToClassConstantRector skip lcfirst (#2888)
  • [AutoImport] Handle auto import crash on docblock @SuppressWarnings(PHPMD.ElseExpression) inside anonymous class (#2808)
  • [CodingStyle] Skip translation functions on EncapsedStringsToSprintfRector (#2809)
  • [PHP 8.1] Handle crash backed Enum not implemented on FirstClassCallableRector (#2815)
  • [EarlyReturn] Do not remove previous If_ stmts on ChangeNestedIfsToEarlyReturnRector (#2820)
  • [EarlyReturn] Handle crash on assign in if else before on RemoveAlwaysElseRector (#2822)
  • [EarlyReturn] Skip ChangeAndIfToEarlyReturnRector in case of simple scalar return (#2826)
  • [EarlyReturn] Skip indirect return with define variable after parent else on ChangeAndIfToEarlyReturnRector (#2836)
  • [DeadCode] Skip object shape pseudo-type in RemoveNonExistingVarAnnotationRector (#2837)
  • [PHP 8.0] Handle single quoted is_granted on AnnotationToAttributeRector (#2842)
  • [DowngradePhp80/72] Handle DowngradeTrailingCommasInParamUseRector+DowngradeParameterTypeWideningRector (#2843)
  • [CodingStyle] Handle multiple assigns on SplitDoubleAssignRector (#2873)
  • [Testing] Use own FixtureFileFinder to keep dependency low (#2858)
  • [PHP 7.4] Add ParenthesizeNestedTernaryRector (#2859)
  • Fix class not found from Easy-Testing package (#2864)
  • [phpstan] Resolve duplicated methods (#2869)
  • [EarlyReturn] Skip else has inline html on RemoveAlwaysElseRector (#2870)
  • [Php55] Skip StringClassNameToClassConstantRector on case insensitive (#2896)
  • [Transform] Skip transitional interface in AddInterfaceByTraitRector (#2898)
  • [CodeQuality] Skip static::class on InlineConstructorDefaultToPropertyRector (#2899)

Inline Symplify Packages to Allow Changes in Single Place 👍

Based on community feedback, we've narrowed down few dependencies that Rector uses actively, but were maintained in external repository.
Inlining only the classes we need makes Rector easier to contribute as the code is available in the repository.

  • symplify/astral
  • symplify/package-builder
  • symplify/smart-file-system
  • symplify/symplify-kernel
  • symplify/skipper

Read on the blog: Tests Made Simpler

Apart making contributions simpler, the vendor is 10 % smaller, narrow from 1949 files to 1765 👍

  • [DX] Inline Skipper (#2877)
  • [DX] Remove internally SmartFileInfo, to save memory for every single file + service (#2876)
  • [DX] Reduce inner use of SmartFileInfo, and injected SmartFileSystem (#2847)
  • [DX] Inline symplify/astral to use only active classes (#2851)
  • [DX] Make use of FilePathHelper over inner magic of FileSystem in SmartFileInfo (#2862)
  • [tests] Use file paths over value objects in tests to improve performance (#2878)
  • [DX] Use own path normalizer (#2881)
  • [DX] Localize few PackageBuilder classes (#2884)
  • [DX] Remove PackageBuilder classes (#2885)

Removed 💀

  • [DeadCode] Merge RemoveDeadConstructorRector, to RemoveEmptyClassMethodRector with same behavior (#2829)
  • [DeadCode] Remove RemoveUnusedParamInRequiredAutowireRector, as one time job for private project; not useful for generic (#2830)
  • [CodeQuality] Remove SimplifyIfIssetToNullCoalescingRector, as overly complex and should be handled by manual context (#2828)
  • [Restoration] Remove CompleteImportForPartialAnnotationRector, one time custom job, not useful for generic rules (#2831)
  • [Transform] Remove ServiceGetterToConstructorInjectionRector, only for risky doctrine case, that should be handled manually (#2832)
  • [DX] Remove upgrade RectorConfig set, as last 2 version use only PHP (#2852)
  • [DX] Cleanup of text file processor, unused MultipleFilesChangedTrait and misc (#2861)
  • [DX] Remove composer-json-manipulator (#2871)
  • [DX] Remove the composer upgrade as unused to narrow focus back to PHP (#2871)

Symfony Rector 🎼

  • [Symfony 2.8] Make ServiceSetStringNameToClassNameRector skip classes used twice to avoid autowiring error (#232)

Doctrine Rector 🟠

Released Rector 0.14

17 Aug 22:34
Compare
Choose a tag to compare

First, we're just passed great achievement. Rector has pased over 10 000 000 downloads 🎉 🥳

Thank you for joining us on this adventurous journey. Slowly but surely we're removing legacy code from codebases all over the world 🙏 👍


2 Community Packages

In Rector 0.14, 2 Rector extensions have matured enough to become standalone packages. We've decided to move them from the core closer to their own communities. Where they can grow faster and with inline of their community standards 👍 👪

Typo3 and Nette are now moved from Rector core to their own repositories:

Read more about it in a post from our blog.


New Features 🥳

  • [tests] Add Ability to yield files with names (#2732), Thanks @Wirone!
  • [TypedDeclaration] Add MockObject property type support to TypedPropertyFromAssignsRector (#2737)
  • [TypeDeclaration] Make anonymous class return specific type, if implements (#2738)
  • Improve ReturnTypeWillChangeRector to handle any method of defined type; move PhpDocFromTypeDeclarationDecorator to Downgrade rules (#2754)
  • [Php73] Add Method Call support on on IsCountableRector (#2762)

Bugfixes 🐛

  • [Php80] Skip default no stmt next is case on ChangeSwitchToMatchRector (#2728)
  • [DeadCode] Skip RemoveAlwaysTrueIfConditionRector on property use by @var docblock on Trait (#2729)
  • [Php80][TypeDeclaration] Handle UnionTypesRector+AddArrayReturnDocTypeRector on auto import FullyQualified doc (#2730)
  • [DeadCode] Handle assign in If_ cond on RemoveUnusedNonEmptyArrayBeforeForeachRector (#2734)
  • [Php80] Preserve int key defined not start from 0 on AnnotationToAttributeRector (#2735)
  • [TypeDeclaration] Skip data providers in AddArrayReturnDocTypeRector, they're overly complex and not helpful to type (#2736)
  • [CodingStyle] Fix re-print of self in PreferThisOrSelfMethodCallRector (#2759)
  • [Php54][Php80] Handle no scope on LongArrayToShortArrayRector+AnnotationToAttributeRector (#2749)
  • [Php81] Skip Encapsed on NullToStrictStringFuncCallArgRector (#2744)
  • [CodeQuality] Skip not ArrayType on ForeachItemsAssignToEmptyArrayToAssignRector (#2752)
  • AddReturnTypeDeclarationBasedOnParentClassMethodRector fix mixed return type by parent interface (#2755), Thanks @MartinMystikJonas!
  • [Php73] Skip escaped Dash on RegexDashEscapeRector (#2753), Thanks @ebrigham1!
  • [CodeQuality][Up_TO_PHP_81] Handle crash indentation on combination LevelSetList::UP_TO_PHP_81 with SetList::CODE_QUALITY (#2760)
  • [Php81] Handle crash on Crypt() single arg on NullToStrictStringFuncCallArgRector (#2767)
  • [Php80] Handle trailing comma on AnnotationToAttributeRector on Doctrine JoinColumn (#2766)
  • [CodeQuality][Up_TO_PHP_81] Handle crash indentation on combination LevelSetList::UP_TO_PHP_81 with SetList::CODE_QUALITY - take 2 (#2763)
  • [DeadCode] Fix RemoveUnusedPrivateMethodParameterRector args keys re-order (#2770)
  • [Php55] Handle no quote in backslash on PregReplaceEModifierRector (#2771)
  • Make ServiceGetterToConstructorInjectionRector report only if node has changed, retarget to Class_ node with higher priority (#2772)

Doctrine Rector 🟠

  • Add set to convert gedmo annotations to attributes (#117) - Thanks @acrobat
  • Add DoctrineTargetEntityStringToClassConstantRector (#98) - Thanks @dritter

Symfony Rector 🎼

  • Skip non-direct inheritors for AbstractType in RemoveDefaultGetBlockPrefixRector (#219)
  • Handle single action with __construct on InvokableControllerRector (#218)
  • [Symfony 2.5] Add AddViolationToBuildViolationRector (#211)
  • [Symfony 2.8] Add ServiceSetStringNameToClassNameRector for fluents configs (#213)
  • [Symfony60] Fix added return type for Router::getRouteCollection (#207) - Thanks @kick-the-bucket

Released Rector 0.13.10

03 Aug 12:54
Compare
Choose a tag to compare

New Features 🎉

  • [Php80] Add MixedTypeRector (#2701)
  • [CodingStyle] Skip has static call call non static method on StaticArrowFunctionRector and StaticClosureRector (#2713)
  • [Doc] Add documentation for parallel troubleshooting (#2722), Thanks @rafaelbernard!
  • Add class-string typehint to MethodCallRename (#2726), Thanks @alexander-schranz!

Bugfixes 🐛

  • [Php81] Skip Doctrine ORM MappedSuperClass attribute on ReadOnlyPropertyRector (#2712)
  • [CodeQuality][CodingStyle] Handle crash assert($subStartPos >= 0 && $subEndPos >= 0) on combination CodeQuality and CodingStyle rules (#2707)
  • [DeadCode] Handle crash on negation class const fetch with static:: and parent:: on RemoveDeadZeroAndOneOperationRector (#2714)
  • [DowngradePhp81] Handle no scope on DowngradeFirstClassCallableSyntaxRector inside ArrayItem (#2709)
  • Fix/do not inline constructor default when readonly (#2720), Thanks @kpn13!
  • Fix/early return inline constructor default 7319 (#2716), Thanks @kpn13!
  • [TypeDeclaration] Handle crash on intersection in Union type on AddMethodCallBasedStrictParamTypeRector (#2704)
  • [DeadCode] Skip RemoveAlwaysTrueIfConditionRector on property use by @var docblock (#2717)
  • Apply ParametersAcceptorSelectorVariantsWrapper::select() take 2 (#2718)
  • ExplicitMethodCallOverMagicGetSetRector fix (#2719), Thanks @MartinMystikJonas!
  • [Php56] Skip already initialized on next Stmt on AddDefaultValueForUndefinedVariableRector (#2721)
  • [Php56] Ensure return null on empty variable initialization after check with existing stmts on AddDefaultValueForUndefinedVariableRector (#2723)
  • [Php56] Handle jump not Expression stmt next initialized on AddDefaultValueForUndefinedVariableRector (#2725)

Released Rector 0.13.9

23 Jul 11:54
Compare
Choose a tag to compare

New Features 🎉

  • [CodingStyle] Add StaticArrowFunctionRector (#2657)
  • [CodingStyle] Add StaticClosureRector (#2658)
  • [Php80] Add implements interface support on single file on AddParamBasedOnParentClassMethodRector (#2660
  • [PHP 8.1] Extend MyCLabsMethodCallToEnumConstRector with getValue() and static call (#2695)
  • [PHP 8.1] Keep use stmts in MyCLabsClassToEnumRector enum (#2696)
  • Add AddReturnTypeDeclarationBasedOnParentClassMethodRector (#2666), Thanks @MartinMystikJonas!
  • [DX] Add input validation for method, property and function name to avoid invalid output ast (#2668)
  • Improve namespace names validation (#2670)

Bugfixes 🐛

  • [DeadCode] Skip global and static variable on RemoveJustVariableAssignRector (#2641)
  • [DeadCode] Skip global and static variable on ReturnEarlyIfVariableRector (#2642)
  • [StrictTypes] Add MethodCall/StaticCall to ExclusiveNativeCallLikeReturnMatcher (#2646)
  • [TypeDeclaration] Add assigned new to variable in ReturnTypeFromReturnNewRector (#2647)
  • DependencyClassMethodDecorator: Prevent duplication of arguments (#2643), Thanks @jtojnar!
  • [TypeDeclaration] Skip Type modified between Assign and Return_ on ReturnTypeFromReturnNewRector (#2650)
  • [TypeDeclaration] Skip modififed type between assign and return on ReturnTypeFromStrictNewArrayRector (#2651)
  • [Php74] Skip TypedPropertyRector on final class by @Final docblock (#2654)
  • [DeadCode] Handle crash on indirect parent BinaryOp on RemoveDuplicatedInstanceOfRector (#2656), #7293
  • [TypeDeclaration] Skip property exists in parent on TypedPropertyFromStrictConstructorRector (#2659)
  • Fix test to only resolve to known classes (#2663), Thanks @dritter!
  • Fix getter method property substitution when the readable types don't match. (#2667), Thanks @mad-briller!
  • [CodeQuality] Handle crash attribute used on trait on CallableThisArrayToAnonymousFunctionRector (#2675)
  • Attempt to fix incorrect doctrine table attribute values on php 8.1 (#2699), Thanks @acrobat!
  • [Transform] Handle crash string in EnumCase on StringToClassConstantRector (#2680)
  • Fix InlineArrayReturnAssignRector and ChangeReadOnlyPropertyWithDefaultValueToConstantRector collision (#2701)

Removed 🗑️

  • move ReturnTypeFromStrictTypedCallRector to enterprise (#2685)
  • [DX] Cleanup, Remove RepeatedLiteralToClassConstantRector, as very narrow use case; use rather phpstan + Remove ChangeLocalPropertyToVariableRector, as buggy and unreliable; better use PHPStan (#2686)
  • Remove UnwrapFutureCompatibleIfFunctionExistsRector as very niche and specific (#2688)
  • [CodingStyle] Deprecate PHPStormVarAnnotationRector, rather tokens responsibility (#2677)