Skip to content

Releases: rectorphp/rector

Released Rector 0.13.8

07 Jul 09:47
Compare
Choose a tag to compare

New Features 🎉

  • [CodeQuality] Add TernaryFalseExpressionToIfRector (#2590)
  • [TypeDeclaration] Add ReturnTypeFromStrictScalarReturnExprRector (#2601)
  • [EarlyReturn] Add ReturnEarlyIfVariableRector (#2609)
  • [Php54] Add ArrayToShortArrayRector (#2615), Thanks @edsrzf!
  • [DeadCode] Add RemoveJustVariableAssignRector (#2618)
  • [TypeDeclaration] Add TypedPropertyFromStrictSetUpRector (#2636)

Bugfixes 🐛

  • [DeadCode] Handle always terminated Switch_ on RemoveUnreachableStatementRector (#2591)
  • [DeadCode] Handle collection of Case_ on RemoveUnreachableStatementRector (#2593)
  • [DeadCode] Handle anonymous and arrow function uses in RemoveJustPropertyFetchRector (#2592), Thanks @kick-the-bucket!
  • [Naming] Skip used in arrow function args on RenameVariableToMatchMethodCallReturnTypeRector (#2599)
  • [TypeDeclaration] Skip AddArrayReturnDocTypeRector on custom phpstan type (#2608)
  • [DeadCode] Handle edge cases on RemoveJustVariableAssignRector (#2621)
  • [Php71] Skip First Class Callable on RemoveExtraParametersRector (#2622)
  • [CodeQuality] Fix CompactToVariablesRector to resolve values when the compact() is called (#2627)
  • [DX] Improve direct return of Stmt arrays in Rector rules, remove NodesToAddCollector from AbstractRector (#2623)
  • [CodingStyle] Handle VarConstantCommentRector+NewlineAfterStatementRector (#2629)
  • [Php80] Skip no default on case collection assign on ChangeSwitchToMatchRector (#2631)
  • [DeadCode] Do not remove first class callable VariadicPlaceholder arg on RemoveUnusedPrivateMethodParameterRector (#2634)
  • [TypeDeclaration] Do not change more detailed return doc on ReturnTypeFromStrictNewArrayRector (#2638)

Removed 🗑️

  • Remove RemoveOverriddenValuesRector as flow of control is not reliable and could cause invalid removal (#2614)
  • [CodeQuality] Remove DateTimeToDateTimeInterfaceRector as mostly opinionated and way too much generics (#2598)
  • [EarlyReturn] Remove ReturnAfterToEarlyOnBreakRector as risky and turning around next/previous nodes (#2624)
  • [Transform] Remove CallableInMethodCallToVariableRector as very narrow use case and sensitive to wrong change (#2625)

Released Rector 0.13.7

29 Jun 12:05
Compare
Choose a tag to compare

New Features 🎉

  • Decouple new Downgrade PHP package: https://github.com/rectorphp/rector-downgrade-php
  • [TypeDeclaration] Add ReturnTypeFromStrictReturnExprRector (#2563)
  • [TypeDeclaration] Add ReturnTypeFromStrictNativeFuncCallRector (#2570)
  • [TypeDeclaration] Add ReturnTypeFromStrictNewArrayRector (#2572)
  • [DowngradePhp80] Add DowngradeMixedTypeTypedPropertyRector (#2579)
  • [Parallel] Display stack trace on --debug on parallel (#2561)
  • Bump PHPStan to 1.8 (#2588)

Bugixes 🐛

  • [PSR4] Do not remove declare(strict_types=1) on NormalizeNamespaceByPSR4ComposerAutoloadRector (#2551)
  • [Php54] Add MethodCall and StaticCall support on RemoveReferenceFromCallRector (#2553)
  • Clean MethodToMethodCallRector (#2554) , Thanks @SelrahcD!
  • [DowngradePhp80] Do not change correct Union array docblock to mixed[] on DowngradeUnionTypeDeclarationRector (#2555)
  • [CodeQuality] Drop ArrayThisCallToThisMethodCallRector as changes behavior and better handled by FirstClassCallableRector (#2571)

Released Rector 0.13.6

21 Jun 15:37
Compare
Choose a tag to compare

New Features 🎉

  • [Core] AbstractScopeAwareRector is ready to be used in custom rules (#2537)
  • [PHP 8.1] Add FirstClassCallableRector (#2544)
  • [Php81] NullToStrictStringFuncCallArgRector - Register more functions (#2543), Thanks @hungtrinh!
  • Improve RectorConfig import methods (#2526), Thanks @alexndlm!

Bugfixes 🐛

  • [Renaming] Do not rename docblock same name not found in use inside namespace (#2471)
  • [TypeDeclaration] Skip generic on ReturnTypeDeclarationRector (#2469)
  • [DeadCode] Skip using coealesce assign operator on return on RemoveUnusedPrivatePropertyRector (#2476)
  • [DeadCode] Skip has return reassign Coalesce Op on RemoveUnusedPrivatePropertyRector (#2477)
  • [Php55] Handle crash on concat variable single quote on PregReplaceEModifierRector (#2483)
  • [PSR4] Handle invalid missing ; on NormalizeNamespaceByPSR4ComposerAutoloadRector with GroupUse (#2488)
  • [Php70] Refactor MultiDirnameRector by moving nestingLevel check to separate method (#2492)
  • [Php81] Fix crash on redis->set() on ReadOnlyPropertyRector (#2494)
  • [TypeDeclaration] Skip implements mixed, and already has typed return on AddReturnTypeDeclarationRector (#2509)
  • [Php81] Skip param reassign on ReadOnlyPropertyRector (#2498)
  • [CodeQuality] Fix default array param in CallableThisArrayToAnonymousFunctionRector (#2527)
  • [Transform] Handle with this->method() from current class on MethodCallToMethodCallRector (#2531)
  • [PHP 7.0] skip non-existing method in StaticCallOnNonStaticToInstanceCallRector (#2532)
  • [PHP 7.4] Skip default expr type on property, if there is mixed assign (#2534)
  • [Php56] Skip multiple catch with same variable on AddDefaultValueForUndefinedVariableRector (#2533)
  • [Php80] Skip Assign on its var not directly used in next return on ChangeSwitchToMatchRector (#2535), #7247
  • [Php81] Skip str_replace() pass array subject on NullToStrictStringFuncCallArgRector (#2541)

Released Rector 0.13.5

09 Jun 13:19
Compare
Choose a tag to compare

New Features 🎉

  • [DeadCode] Add RemoveJustPropertyFetchRector (#2433)
  • [DX] Make ClassAnnotationMatcher differentiate between known and unknown classes (#2319), Thanks @dritter!
  • [CS] Fix dynamic and broken indent detection, allow to configure spacing via RectorConfig::indent() method (#2442)
  • [DX] Add deprecation exception about old ContainerConfigurator, to prepare for removal even in CI (#2463)
  • use PHPStan 1.7.12, with phpdoc-parser 1.6.0 to fix endline issue (rectorphp/rector-src@56651d0)
  • [DX] Detach typo3 from core to allow stable growth of both packages (#2446)
  • [scoped] Build with Scoper 0.17.2 (#2445)

Bugfixes 🐛

  • [DX] Remove too detailed --type in init command, use fw documentation instead (#2430)
  • [Renaming] Keep comment on RenameClassRector (#2439)
  • [Renaming] Do not Rename Docblock inner Namespace on RenameClassRector (#2441)
  • [Renaming] Handle crash on FuncCall with Arg class name conflict with use statement or namespace on RenameClassRector with auto import enabled (#2431)
  • [DX] Remove symlinks option to require safe way of providing explicit paths (#2443)
  • [Php74] Remove ReservedFnFunctionRector (#2447)
  • [Renaming] Skip rename docblock on conflict with alias on RenameClassRector (#2450)
  • [DeadCode][PHPUnit] handle crash on RemoveJustPropertyFetchForAssignRector+SimplifyForeachInstanceOfRector (#2453)
  • [CodingStyle] Skip non-empty-string on VarConstantCommentRector (#2451)
  • [Renaming] Do not rename class with same name inside different namespace on RenameClassRector (#2455)
  • [Php72] Handle crash on PreInc usage on CreateFunctionToAnonymousFunctionRector (#2456)
  • [Php70] Handle crash on EregToPregMatchRector (#2460)

Released Rector 0.13.4

04 Jun 08:24
Compare
Choose a tag to compare

New Features 🎉

  • Update to php-parser 4.14.0 to work with literal _ number separator (#2321)
  • Update to PHPStan 1.7.10 (#2424)
  • [DowngradePhp82] Add DowngradeReadonlyClassRector to downgrade readonly class (#2322)
  • [PHP 8.0] Add ConstantListClassToEnumRector (#2404)
  • [DowngradePhp80] Add DowngradeEnumToConstantListClassRector (#2416)
  • [DeadCode] Add RemoveJustPropertyFetchForAssignRector (#2423)

Bugfixes 🐛

  • [PHP 8.0] Fix double annotation change on annotation to attribute (#2403)
  • [Attribute] Fix UseAliasNameMatcher for the last part of use import rename (#2402)
  • [Core] Fix bootstrap stubs load on PHP 7.2 when vendor/ excluded via skip() (#2394)
  • [Php74] Skip nullable mixed on Php 8.0 feature enabled on TypedPropertyRector (#2414)
  • [Php80] Mirror additional docblock on importNames() on ClassPropertyAssignToConstructorPromotionRector (#2410)
  • [Renaming] Skip docblock rename different namespace on RenameClassRector (#2419)

Released Rector 0.13.3

31 May 12:41
Compare
Choose a tag to compare

Rector release downgrade is now handled in single run and with parallel run ⚡ It's faster and vendor includes only the packages it really uses.


New Features 🎉

  • [Laravel] Add set for Laravel 9.x (#49), Thanks @hirenkeraliya
  • [Attribures] Add annotation to attribute core rename in AnnotationToAttributeRector (#2384)

This now allows annotation to attribute rename with change in the namespace:

-use Project\Annotation\Security as SC;
+use Project\Attribute\Security as SC;

-/**
- * @SC\LoggedIn
- */
+#[SC\LoggedIn]
final class PrivateController
{
}

Bugfixes 🐛

  • [Transform] Skip different method on CallableInMethodCallToVariableRector (#2395)
  • [CodeQuality] Add empty array support to InlineArrayReturnAssignRector (#2397)
  • [PHP 8.2] Skip readonly class on property without type in ReadOnlyClassRector (#2398)
  • Add annotation to attribute core rename in AnnotationToAttributeRector (#2380)
  • [DowngradePhp81] Handle crash parent Arg is missing scope on DowngradeFirstClassCallableSyntaxRector (#2387)

Changes 📆

  • remove working-dir option as not compatible with parallel run, better handle via CI working-dir options (#2387)

Released Rector 0.13.2

27 May 21:49
Compare
Choose a tag to compare

Bugfixes 🐛

  • Fix missing ReflectionUnionType class by moving stub loader to RectorContainerFactory (#2382)

Released Rector 0.13.1

27 May 18:27
Compare
Choose a tag to compare

New Features 🎉

  • [CodeQuality] Add InlineIsAInstanceOfRector (#2364)
  • [DX] Move configure to direct call in RectorConfig (#2367)
  • [DX] Various config merge, improve RectorConfig methods (#2371)
  • [DX] Remove non-PHP file formatting based on editorconfig, rather let external coding standard tools handle the file format (#2378)

Bugfixes 🐛

  • [Php73] Skip Encapsed on StringifyStrNeedlesRector (#2352), Thanks @samsonasik!
  • [TypeDeclaration] Skip curly {@inheritdoc} on AddArrayReturnDocTypeRector (#2359), Thanks @samsonasik!
  • Allow to rename method if in interface (#2362)
  • [Php81] Skip ArrayDimFetch from ArrayObject in Assign var on ReadOnlyPropertyRector (#2363), Thanks @samsonasik!
  • [PhpDocInfo] Fixes Partial value update got duplicated on DoctrineAnnotationTagValueNode change (#1862), Thanks @samsonasik!

Released Rector 0.13 with Scope Refresh and StmtsAwareInterface

23 May 10:59
Compare
Choose a tag to compare

New Features 🎉

  • [Php82] Add ReadOnlyClassRector (#2296), Thanks @samsonasik!
  • [Order] Add a-z ordering feature to OrderAttributesRector (#2243), Thanks @Lenny4!
  • [Symfony] Add CommandPropertyToAttributeRector (#163), Thanks @stephanvierkant
  • [Experimental] Add refactorWithScope() method to get typed Scope easily and required (#2227)
  • Add Scope refresh for changed or new nodes (#2292)

From YAML routes to Annotations 🚀

  • [Symfony] Add new rule to add annotations from router configuration to symfony controllers (#169), Thanks @malteschlueter
-foo_baz:
-    path: /foo/{baz}
-    defaults: { _controller: FooBundle:Bar:baz, _format: json }
-    methods: [ GET, POST ]

+/**
+ * @Route(name="foo_baz", path="/foo/{baz}", methods={"GET","POST"}, defaults={_format="json"})
+ */
 public function bazAction(string $baz)

New StmtsAwareInterface node

  • [DX] Add StmtsAwareInterface to catch node by type (#2269)

Do you need to iterface all rules with stmts in them? Hook in one node type:

   /**
     * @return array<class-string<Node>>
     */
    public function getNodeTypes(): array
    {
        return [StmtsAwareInterface::class];
    }

Bugfixes 🐛

  • [CodeQuality] Skip CallableThisArrayToAnonymousFunctionRector when inside of Attribute (#2212), #6910, Thanks @samsonasik!
  • Added new functions to NullToStrictStringFuncCallArgRector (#2217), Thanks @FlorinProfeanu!
  • [Parallel] Fix --debug not working in parallel (#2307), Thanks @samsonasik!
  • [DowngradePhp80] Handle match inside ArrowFunction on DowngradeMatchToSwitchRector (#2330), Thanks @samsonasik!
  • [DowngradePhp80] Add in arrow function in return support on DowngradeMatchToSwitchRector (#2331), Thanks @samsonasik!
  • [DowngradePhp80] Apply PHPStan 1.7.x-dev compatible for PhpParameterReflection (#2336), Thanks @samsonasik!
  • [DeadCode] Skip used in Closure use on RemoveUnusedConstructorParamRector (#2341), Thanks @samsonasik!
  • [Naming] Move collecting param names method to FunctionLikeManipulator (#2347), Thanks @samsonasik!
  • [Naming] Handle Grouped use import on UseImportsResolver (#2348), Thanks @samsonasik!

Released Rector 0.12.23

01 May 15:51
Compare
Choose a tag to compare

This release fixes major slowdown on find parents node rules in stmts: #7144, thanks for report and provided detailed info @bobvandevijver and @jrmcpeek 🙇

Update as soon as possible to enjoy the speed again 👍

  • [Code] Improve BetterNodeFinder::findFirstPrevious() to only locate previous of parent if no previous of Node (#2209), Thanks @samsonasik!

New Features 🎉

  • [CodeQuality] Add InlineArrayReturnAssignRector (#2183)
  • Add RectorConfigProvider to ask for configuration behave for 3rd party packages (#2187)
  • [Core] Add $seconds, $maxNumberOfProcess, and $jobSize parameters to RectorConfig::parallel() method (#2188), Thanks @samsonasik!
  • [DX] Move PhpVersionProvider from AbstractRector to particular services (#2189)
  • [DowngradePhp80] Support match as array item in DowngradeMatchToSwitchRector (#2178), Thanks @jrstanley!

Bugfixes 🐛

  • [DeadCode] Improve RemoveUnreachableStatementRector performance by return after array_splice early (#2193), Thanks @samsonasik!
  • [DeadCode] Register array_splice into impure functions on PureFunctionDetector (#2194), Thanks @samsonasik!
  • [CodingStyle] Skip readonly type property on AddArrayDefaultToArrayPropertyRector (#2196), Thanks @samsonasik!
  • [DeadCode] Remove RemoveCodeAfterReturnRector, already handled at RemoveUnreachableStatementRector (#2199), Thanks @samsonasik!