Skip to content

Releases: rectorphp/rector

Released Rector 0.17.9

03 Aug 13:15
Compare
Choose a tag to compare

Bugfixes 🐛

Released Rector 0.17.8

03 Aug 12:56
Compare
Choose a tag to compare

New Features 🥳

  • [TypeDeclaration] Add Closure support on BoolReturnTypeFromStrictScalarReturnsRector (#4610)
  • AddMethodCallBasedStrictParamTypeRector: Support changing protected methods in final classes (#4611), Thanks @staabm!
  • [TypeDeclaration] Add StrictStringParamConcatRector (#4624)

Bugfixes 🐛

  • [PHPStanStaticTypeMapper] FQCN for Closure type mapper (#4584)
  • Fixed constant types handling in TypedPropertyFromStrictConstructorRector (#4588), Thanks @staabm!
  • [TypeDeclaration] Skip coalesce on StrictArrayParamDimFetchRector (#4589)
  • Bump to phpdoc-parser 1.23 and fill construct() attributes (#4590)
  • [TypeDeclaration] Skip override string on StrictArrayParamDimFetchRector (#4591)
  • [Autoloading] Using SimpleParameterProvider on BootstrapFilesIncluder (#4592)
  • [Php81] Fix regression skip call by ref on ReadOnlyPropertyRector (#4593)
  • [PHPStanStaticTypeMapper] Make use of toPhpDocNode() on ObjectTypeMapper (#4581)
  • [PHPStanStaticTypeMapper] Fix IntersectionTypeMapper to make ObjectType have FQCN (#4598)
  • [Php81] Skip re-assign with AssignOp on ReadOnlyPropertyRector (#4600)
  • Reduce ConstExprClassNameDecorator overhead (#4603), Thanks @staabm!
  • Resolve native return-type from native union-type in short ternary (#4606), Thanks @staabm!
  • [Strict] Skip from docblock @return on DisallowedEmptyRuleFixerRector (#4608)
  • [Strict] Skip @return docblock on BooleanInIfConditionRuleFixerRector (#4609)
  • [Php81] Fix regression skip call by ref on ReadOnlyPropertyRector on non __construct method (#4614)
  • [CodeQuality][Strict] Handle infinite loop on SimplifyDeMorganBinaryRector+SimplifyIfReturnBoolRector+DisallowedEmptyRuleFixerRector (#4615)
  • [CodingStyle][Namespace_] Support constant imports (#4612), Thanks @natepage!
  • [Php81] Skip property fetch from new static on ReadOnlyPropertyRector (#4617)
  • [CodingStyle] Handle crash on empty cases on BinarySwitchToIfElseRector (#4618)
  • Fix string type on StrictArrayParamDimFetchRector (#4623)
  • [PHPStanStaticTypeMapper] Handle crash on DowngradeMixedTypeDeclarationRector for PHPStan\Type\ConditionalType (#4625)
  • [Php73] Handle crash Type Error on JsonThrowOnErrorRector (#4626)
  • [Php81] Skip call by ref on ReadOnlyPropertyRector on FuncCall (#4630)
  • [Printer] Fix printing PHPStan AlwaysRememberedExpr with add unwrapper inside BetterStandardPrinter::p (#4629)
  • [TypeDeclaration] Skip has parent class method on AddParamTypeFromPropertyTypeRector (#4627)

Removed 💀

  • [Printer] Remove has InlineHTML node check after apply changes on PhpFileProcessor (#4601)

Released Rector 0.17.7

23 Jul 21:16
Compare
Choose a tag to compare

New Features 🥳

  • [CodingStyle] Skip filled by construct on AddArrayDefaultToArrayPropertyRector (#4549)
  • Add constuctor support to ReplaceArgumentDefaultValueRector (#4554)
  • StaticMapper: added fast path for IdentifierTypeNode (#4565), Thanks @staabm!
  • Add ReturnTypeFromStrictParamRector (#4501), Thanks @staabm!
  • Add TypedPropertyFromStrictConstructorReadonlyClassRector (#4552), Thanks @staabm!
  • ReturnTypeFromStrictTernaryRector: Support complex ternaries (#4515), Thanks @staabm!

Bugfixes 🐛

  • Support final methods in ClassMethodReturnTypeOverrideGuard (#4509), Thanks @staabm!
  • Support literals in ReturnTypeFromStrictTypedCallRector (#4511), Thanks @staabm!
  • [TypeDeclaration] Null stmts check early on ReturnTypeFromStrictParamRector (#4512)
  • [Performance] Use filtered filePaths from ApplicationFileProcessor::configurePHPStanNodeScopeResolver on WorkerRunner::run() (#4513)
  • [DX] Show progress bar 100% on RectorConsoleOutputFormatter::report() (#4516)
  • [ChangesReporting] Reuse defined errors vairable on ConsoleOutputFormatter (#4517)
  • [ApplicationFileProcessor] Refactor ApplicationFileProcessor to filter file paths early before run both parallel and non-parallel (#4519)
  • [DX] Fix hang on twice run after all files processed cached (#4521)
  • [Application] Move filter files by config extensions to FileFactory (#4522)
  • [Php81][Php82][Privatization] Handle extends non-readonly class on ReadOnlyPropertyRector+ReadOnlyClassRector+FinalizeClassesWithoutChildrenRector (#4524)
  • Fix wrong results in RemoveAlwaysElseRector (#4527), Thanks @jlherren!
  • Support class-const-fetch in ReturnTypeFromStrictTypedCallRector (#4520), Thanks @staabm!
  • [EarlyReturn] Skip append variable on PreparedValueToEarlyReturnRector (#4530)
  • Refactor MyCLabs\Enum\Enum::equals calls to comparisons (#4532), Thanks @rojtjo!
  • [Performance][NodeManipulator] Avoid loop on search first variable named on next sliced next stmts on StmtsManipulator (#4537)
  • [Performance] [TypeDeclaration] Reduce resolve ClassReflection on each property on TypedPropertyFromStrictConstructorRector (#4536)
  • [Performance][TypeDeclaration] Reduce resolve ClassReflection from Property on AllAssignNodePropertyTypeInferer (#4539)
  • [Application] Merge process files on both parallel and non-parallel process (#4523)
  • [PHPStan] Merge assert phpstan errors to one (#4544)
  • [Performance] [Php74] Reduce ClassReflection lookup from property on PropertyTypeChangeGuard (#4545)
  • Use instanceof check on ClassReflection resolve (#4547)
  • [Reflection] Reduce Scope pulling on ReflectionResolver (#4548)
  • [Strict] Skip empty() from param doc on DisallowedEmptyRuleFixerRector (#4550)
  • Fix space in paths (#4553)
  • Skip traits in CountOnNullRector (#4556)
  • Make use of toPhpDocNode() - take #2 (#4555)
  • [Performance] [PostRector] Only check phpdocinfo on Stmt and Param on NameImportingPostRector (#4558)
  • [CodeQuality] Skip pull property from inner class on CompleteDynamicPropertiesRector (#4561)
  • Prevent unnecessary scope creation (#4562), Thanks @staabm!
  • NameImportingPhpDocNodeVisitor: Cheap checks first (#4563), Thanks @staabm!
  • [Performance][Renaming] No need PhpDocInfo refactor on Name node on ClassRenamer (#4566)
  • [TypeDeclaration] Deprecate ArrayShapeFromConstantArrayReturnRector as uses docblocks that we move away from since 0.15 (#4571)
  • Make ReturnTypeFromStrictNewArrayRector handle only single level arrays (#4575)
  • Fix array mapping (#4576)
  • [Performance] [PostRector] Reduce repetitive resolve uses statements on NameImportingPostRector (#4579)
  • [EarlyReturn] Handle multiple statements in else in ChangeIfElseValueAssignToEarlyReturnRector (#4580), Thanks @dorrogeray!
  • [BUGFIX] Ensure proper reprint with attributes for finalized classes (#4585), Thanks @cngJo!

Removed 💀

  • [DX] Remove AllowEmptyConfigurableRectorInterface to ease interface tree, better handle on particular configure() method inside the rule (#4540)
  • Skip description on same line, remove on next line as based on phpdoc-parser in RemoveUselessParamTagRector (#4551)
  • [Performance][PostRector] Remove alias exists check on NameImporter called from NameImportingPostRector (#4564)
  • [Performance][BetterPhpDocParser] Remove unused ConstExprNode check on ConstExprClassNameDecorator (#4578)
  • [PHPStanStaticTypeMapper] Remove manual type check on PHPStanStaticTypeMapper (#4583)
  • [StaticTypeMapper] Remove standalone false handling on StaticTypeMapper (#4582)

Released Rector 0.17.6

14 Jul 09:55
Compare
Choose a tag to compare

In this release, we narrowed rules from PHPUit and Doctrine to their specific version category. We've detected few outdated and never used rules and cleaned them up to make Rector smaller and easier to use 👍

Be use to always use *SetList constants over specific rules to use the latest version:

use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->sets([
        \Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_100,
    ]);
};

New Features 🥳

  • Add PHPUnit to sets (#4495)
  • [CI] Add PHPUnit 10 to check rules and sets groups (#4500)
  • [CI] Add doctrine rules in set check (#4505)

Bugfixes 🐛

  • [Performance] Only set Attribute on context inside ArrayDimFetch and ArrayItem on specific node used (#4493)
  • [Php52] Use instanceof check instead of compare object $newStmt === $caseStmt on ContinueToBreakInSwitchRector (#4494)
  • Exclude the full docs folder from archives (#4497), Thanks @stof!
  • Cleanup RecastingRemovalRector tests (#4498)
  • Move Rector order test to PHPUnit, as uses its rules (#4499)
  • let phpunit handle its own empty method rule (#4501), Thanks @staabm!
  • Micro optimizations: cheap checks first (#4510), Thanks @staabm!
  • Skip coalsce assign in RemoveUnusedPrivatePropertyRector (#4491)
  • [DeadCode] Skip append += assignment on RemoveUnusedPrivatePropertyRector (#4506)
  • [AstResolver][Performance] Remove unnecessary double File read on AstResolver::parseFileNameToDecoratedNodes() (#4508)

Removed 💀

  • [NodeTypeResolver] Remove unused AttributeKey::INSIDE_ARRAY_ITEM on ContextNodeVisitor (#4496)
  • [NodeTypeResolver] Remove AttributeKey::IS_RETURN_EXPR from ContextNodeVisitor (#4502)
  • [NodeTypeResolver] Remove AttributeKey::IS_ISSET_VAR from ContextNodeVisitor (#4503)
  • [NodeTypeResolver] Remove nestedChainMethodCallLimit() for deep method call counter check (#4504)

Released Rector 0.17.5

12 Jul 08:42
Compare
Choose a tag to compare

Removed 💀

  • [DeadCode] Skip property not exists on RemoveTypedPropertyDeadInstanceOfRector (#4481)
  • [CodeQuality][Php80] Handle infite loop swap params on RemoveUnusedVariableInCatchRector + OptionalParametersAfterRequiredRector (#4484)

Bugfixes 🐛

  • fix(rules): Skip readonly classes from restoring default null value. (#4479), Thanks @scyzoryck!
  • [Php80] Handle crash on ClassOnObjectRector + GetDebugTypeRector (#4483)
  • [Strict] Fix DisallowedEmptyRuleFixerRector on empty string isset (#4485)
  • Fix StrictArrayParamDimFetchRector on is_* calls (#4486), Thanks @staabm!
  • Fix trait rename in Php4ConsturctorRector (#4487)
  • Fix StrictArrayParamDimFetchRector on same named property (#4488), Thanks @staabm!

Released Rector 0.17.4

11 Jul 16:06
Compare
Choose a tag to compare

Bugfixes 🐛

  • [CodeQuality][EarlyReturn] Handle crash Replace Stmt to Expr on FlipTypeControlToUseExclusiveTypeRector+FlipTypeControlToUseExclusiveTypeRector+ReturnBinaryOrToEarlyReturnRector (#4474)
  • Fix ReturnBinaryOrToEarlyReturnRector mixing up returned nodes of array, hook into StmtsAwareInterface instead to keep next Rector rules updated (#4476)

Removed 💀

  • Remove duplicated version_compare ReplaceFuncCallArgumentDefaultValue rule (#4473), Thanks @alexander-schranz!
  • [EarlyReturn] Remove ReturnBinaryAndToEarlyReturnRector as creates code hard to read and flips condition (#4478)

Released Rector 0.17.3

10 Jul 13:34
Compare
Choose a tag to compare

In this release we continue preparing for Rector 1.0 release #7854

This includes removing last parent node connections, to lower node tree memory consumption 🥳️🥳️🥳️

  • [EarlyReturn] Remove findFirstNext() on InvertedIfFactory (#4399)
  • [DX] Remove findParentType() method (#4438)
  • [DX] Remove parent node from AbstractRector (#4465)

New Features 🥳

  • Add float mul integer type to NumericReturnTypeFromStrictScalarReturnsRector (#4376)
  • [TypeDeclaration] Add Encapsed string support to AlwaysStrictScalarExprAnalyzer (#4382)
  • [TypeDeclaration] Add StrictArrayParamDimFetchRector (#4384)
  • [DX] Kick of SimpleParameterProvider (#4405)

Bugfixes 🐛

  • [DeadCode] Skip non typed param numeric check on RecastingRemovalRector (#4390)
  • [Renaming] Handle crash on catch Exception name on RenameClassRector (#4401)
  • Fix NumericReturnTypeFromStrictScalarReturnsRector for non-natively-typed parameters (#4380), Thanks @staabm!
  • [Php82] Skip extends unknown class on ReadonlyClassRector (#4408)
  • [TypeDeclaration] Handle crash on no namespace with + operation on DeclareStrictTypesRector (#4414)
  • [NodeTypeResolver] Reduce duplicated Scope fill on FuncCall (#4428)
  • Make JsonThrowOnErrorRector work with local scope to detect error_json methods (#4451)
  • Deprecate resolveNextNode() to work only in current node tree context (#4455)
  • [Naming] Skip used on next foreach on RenameForeachValueVariableToMatchExprVariableRector (#4469)

Removed 💀

  • Remove duplicate ReturnNeverTypeRector rule (#4381), Thanks @buffcode!
  • [MysqlToMysqli] Deprecate set, as dangerous to use, better handle manually (#4448)
  • [DX] Make use of SimpleParameterProvider directly, deprecate RectorConfigProvider (#4460)
  • [Performance] Immediate remove UnreachableStatementNodeVisitor object after traverse to avoid re-use in next file (#4417)
  • [NodeTypeResolver] Remove ArrayItem scope filling from Array_ and Name filling for Catch types on PHPStanNodeScopeResolver (#4423)
  • [PHP 8] Resources object upgrade - remove 2 rules as the upgrade require wholesome manual work (#4442)
  • [DeadCode] Remove RemoveJustVariableAssignRector as often done on purpose or with side effect (#4450)
  • Remove deprecated resolveNextNode() to embrace local scope node (#4456)
  • [DX] Remove node connecting traverser from AbstractRector (#4463)
  • Remove NodeConnectingTraverser (#4464)
  • [DX] Remove autowrapping of expr/stmt to make return values in the same type and reliable (#4466)

Released Rector 0.17.2

29 Jun 12:57
Compare
Choose a tag to compare

In this release we continue preparing for Rector 1.0 release #7854

This includes:

  • removing more parent node connections, to lower node tree memory consumption

New Features 🥳

  • Add sleep after processPool->quitAll() to give time for all child processes to terminate (#4280), Thanks @dorrogeray!
  • [TypeDeclaration] Add NumericReturnTypeFromStrictScalarReturnsRector (#4296)
  • [Php71] Add Closure support on AssignArrayToStringRector (#4303)
  • Introduces AddSensitiveParameterAttributeRector rule (#4342), Thanks @peterfox!
  • Bump nikic/php-parser to 4.16.0 (#4343)
  • Show error when no files will be processed (#4326), Thanks @staabm!
  • Cache unchanged files on dry run v2 (#4281), Thanks @dorrogeray!

Bugfixes 🐛

  • [CodeQuality] Handle crash on variable variable on OptionalParametersAfterRequiredRector (#4226)
  • Fix LocallyCalledStaticMethodToNonStaticRector with method args (#4233), Thanks @toastedghost!
  • Use FunctionLike contract instead of union of function-like concrete implementations (#4241), Thanks @Wirone!
  • [CodeQuality][Performance] Reduce repetitive NodeTypeResolver->getType() on ExprBoolCaster (#4279)
  • Skip rewindable generator (#4282)
  • [Php55][NodeTypeResolver] Handle crash on dynamic variable concat assign on StringClassNameToClassConstantRector (#4283)
  • [Php55] Clean up FullyQualified assigned to FullyQualified on StringClassNameToClassConstantRector (#4284)
  • [TypeDeclaration] Extend NumericReturnTypeFromStrictScalarReturnsRector (#4297)
  • Skip divide in NumericReturnTypeFromStrictScalarReturnsRector (#4298)
  • [TypeDeclaration] Skip once typed and else return array_map() on ReturnTypeFromStrictTypedCallRector (#4312)
  • Fix command to configure rector (#4314), Thanks @bertramakers!
  • [Performance] [NodeTypeResolver] Reduce callable traverse usage on ContextNodeVisitor (#4317)
  • [CodeQuality] Skip not regex on SimplifyRegexPatternRector (#4322)
  • [TypeDeclaration] Handle crash on object shape on ArrayShapeFromConstantArrayReturnRector (#4323)
  • [Php81] Skip named constructor on ReadOnlyPropertyRector (#4359)
  • Skip argument if value equals default value (#4368), Thanks @stefantalen!
  • [MysqlToMysqli] Handle infinite loop on MysqlQueryMysqlErrorWithLinkRector when no connection instance on first dept stmt (#4375)

Removed 💀

  • Remove removeNode() method from AbstractRector (#4225)
  • Remove Kind from doc mapper, as used just once (#4234)
  • Move LocallyCalledStaticMethodToNonStaticRector to CodeQuality namespace, to avoid dumping removed static set (#4242)
  • Restore RemoveMethodCallParamRector as used (#4244)
  • [Performance] Remove NODES_TO_MATCH constant on RemoveNonExistingVarAnnotationRector (#4267)
  • Remove VarConstantCommentRector as using unreliable docblocks, better use upcoming PHP 8.3 strict type const (#4307)
  • [Naming] Remove BreakingVariableRenameGuard::isUsedInIfAndOtherBranches() to remove previous by types (#4319)
  • [Php81] Remove cast check on NullToStrictStringFuncCallArgRector (#4320)
  • [PhpParser] Remove BetterNodeFinder::findFirstPreviousOfTypes() (#4327)
  • Move AddMethodParentCallRector to Symfony Rector (#4301)

Released Rector 0.17.1

14 Jun 10:14
Compare
Choose a tag to compare

In this release we continue preparing for Rector 1.0 release #7854

This includes:

  • removing more parent node connections, to lower node tree memory consumption
  • replacing removeNode() method with return NodeTraverser::REMOVE_NODE direct constant to make changes happen directly in the Rector rule
  • refactoring node adding from post-process to directly in the rule

New Features 🥳

  • [Docblock] Move DocBlockUpdater service usage from AbstractRector to PhpDocTypeChanger (#4215)
  • Improve string support in Doctrine Annotations (#3645), Thanks @yguedidi!
  • [Php80] Fix add default nullable type on ClassPropertyAssignToConstructorPromotionRector (#4091)
  • Add STRICT_BOOLEANS set (#4116)

Changes

  • [FileProcessor] Add warning instead of skip InlineHTML on PhpFileProcessor (#4058)
  • Remove node adding collector (#4095)
  • Remove propperty to add collector, add them directly or as a constructor dependency (#4131)
  • Move ReturnArrayClassMethodToYieldRector to PHPUnit Rector (#4213)

Bugfixes 🐛

  • [CodeQuality] Exclude first class callable from IntvalToTypeCastRector (#7962) (#4040), Thanks @thbley!
  • [CodingStyle] Skip first class callable on UnSpreadOperatorRector (#4041)
  • Skip StrvalToType for strval first class callable syntax (#4046), Thanks @NicoImparfait!
  • Ensure check isFirstClassCallable() before node->getArgs() on CallLike (#4049)
  • [CodeQuality] Skip multiple assigns append before foreach on ForeachItemsAssignToEmptyArrayToAssignRector (#4052)
  • [CodeQuality] Skip deep append in if foreach before on ForeachItemsAssignToEmptyArrayToAssignRector (#4053)
  • [NodeTypeResolver] Handle crash after next exit() on no namespaced code after removal next attribute (#4074)
  • [FileProcessor] Show warning on has InlineHTML node if file has changed on PhpFileProcessor (#4079)
  • Make SimplifyRegexPatternRector work without parent nodes + deprecate BetterNodeFinder and findParent* methods (#4105)
  • Fix StaticCallOnNonStaticToInstanceCallRector to skip parent's parent's method calls. (#4098), Thanks @klimslim!
  • [CodingStyle] Skip countable object on CountArrayToEmptyArrayComparisonRector (#4108)
  • [DeadCode] Skip used on Closure use next stmt on RemoveUnusedVariableAssignRector (#4042)
  • [CodeQuality] Handle throw after if on ConsecutiveNullCompareReturnsToNullCoalesceQueueRector (#4107)
  • [CodeQuality] Handle return new object and no return on ConsecutiveNullCompareReturnsToNullCoalesceQueueRector (#4112)
  • Make ConvertStaticPrivateConstantToSelfRector work for non-final classes, make part of code-quality set (#4114)
  • StringClassNameToClassConstantRector: cheap checks first (#4151), Thanks @staabm!
  • Reduce memory-consumption by simpler skip-patterns (#4152), Thanks @staabm!
  • Skipping: Use plain string functions instead of regex matching (#4153), Thanks @staabm!
  • Split instance of check to 2 rules (#4165)
  • Performance: Prevent sorting of files in PhpFilesFinder (#4164), Thanks @staabm!
  • Move PreferThisOrSelfMethodCallRector to PHPUnit rector package, to handle exact cases (#4194)
  • [Renaming] Handle crash in trait use on RenameClassRector (#4196)
  • [Php56] Handle infinite loop on big array method call on AddDefaultValueForUndefinedVariableRector (#4142)
  • [Php56] Skip variable variable on AddDefaultValueForUndefinedVariableRector (#4148)

Removed 💀

  • [DeadCode] Remove removeNode() from RemoveDeadReturnRector, merge RemoveLastReturnRector to RemoveDeadReturnRector (#4085)
  • [PHP+HTML cleanup] Remove MixPhpHtmlDecorator (#4054)
  • Remove HTML + PHP support, as must be handled in php-parser first (#4051)
  • Remove MultipleClassFileToPsr4ClassesRector as only PSR4 rule, bit risky and better handled with PHPStan + remove adding/removing files logic, use printer instead (#4117)
  • Remove NormalizeNamespaceByPSR4ComposerAutoloadRector as only moves files to namespaces, does not update any class referenes; better use IDE here (#4057)
  • Remove MultipleClassFileToPsr4ClassesRector as only PSR4 rule, bit risky and better handled with PHPStan + remove adding/removing files logic, use printer instead (#4117)
  • Remove AttributeCompatibleAnnotationRector, as only for one-time migration of private project, not suitable for general use (#4064)
  • Remove RemoveAlwaysTrueConditionSetInConstructor, as overly specific and not practical; better handle with PHPStan (#4065)
  • Remove deprecated UnionTypesRector and NarrowUnionTypeDocRector, use strict-based rules from TypeDeclaration set instead (#4069)
  • Remove TargetRemoveClassMethodRector, as IDE specific (#4076)
  • Remove ArrayKeysAndInArrayToArrayKeyExistsRector as narrow, does not check variable usage and might be on purpose (#4084)
  • Remove ChangeGlobalVariablesToPropertiesRector as the scope might change after the variable is defined, better handle with PHPStan (#4086)
  • Remove NewToConstructorInjectionRector as unused and only for demo purposes (#4087)
  • [NodeTraverser] Remove double apply FileWithoutNamespace, remove recursive lookup stmts on BetterStandardPrinter (#4097)
  • Remove ActionInjectionToConstructorInjectionRector as rather for demo purposes, not practical (#4113)
  • Remove ConstantListClassToEnumRector as custom-made, not practical for enum upgrades (#4115)
  • Remove RemoveMethodCallParamRector, as unused (#4119)
  • Remove RemoveAllowDynamicPropertiesAttributeRector as attribute is a comment on lower PHP versions, also rather downgrade rule (#4120)
  • Remove DoctrineAnnotationClassToAttributeRector as made for custom project, not useful for general use (#4127)
  • Remove UnsetAndIssetToMethodCallRector as unused (#4123)
  • Remove MethodCallToMethodCallRector as unused (#4128)
  • Remove NewArgToMethodCallRector as unused (#4130)
  • Remove RemoveDelegatingParentCallRector as overly complex and usually on purpose (#4136)
  • Remove RemoveEmptyMethodCallRector as better handled by PHPStan (#4161)
  • Remove BetterNodeFinder::findLastInstanceOf() as unused + make resolvePreviousNode() private, as used only locally (#4195)
  • [DeadCode] Remove Assign and AssignRef as node types on RemoveNonExistingVarAnnotationRector (#4209)

Released Rector 0.17

01 Jun 10:29
Compare
Choose a tag to compare

Preparing for Rector 1.0

In this release, we focus on architecture improvements before reaching Rector 1.0. We want to lower the memory usage and make Rector run faster.

This include removing next/previous nodes - this will most likely not affect you, as Rector rules were upgraded, but if you do you use them, switch to StmtsAwareInterface instead

We follow PHPStan 1.6 move from April 2022, where you can learn more: https://phpstan.org/blog/preprocessing-ast-for-custom-rules

  • Replace NodeConnectingVisitor with ParentConnectingVisitor (#3900)

To see how to refactor to StmtsAwareInterface, check these PRs:

  • Remove NEXT_NODE dependency in ChangeAndIfToEarlyReturnRector, narrow to only closed scope function likes (#3913)
  • Remove NEXT_NODE from SimplifyIfReturnBoolRector (#3915)
  • [DeadCode] Remove next attribute on RemoveUnusedVariableAssignRector ([#3917](https://github.com/rectorphp/
  • [CodingStyle] Refactor CatchExceptionNameMatchingTypeRector to use StmtsAwareInterface (#3788)

Add/remove nodes directly 👍

The next improvement focuses on explicit node adding/removal. Thanks to StmtsAwareInterface we can add nodes directly. This makes Rector refactor() method contain all the code you need.

  • Cleanup usage of NodesToAddCollector, return nodes directly instead (#4003)
  • Cleanup removeNodeFromStatements(), removeArg(), removeParam(), removeStmt() methods and remove nodes directly (#4012)
  • Remove unused addNodeAfterNode(), return nodes instead (#4023)
  • Remove unused method addNodesBeforeNode() (#4024)

New Features 🥳

  • [PHP 7.0] Add IfIssetToCoalescingRector (#3878)
  • Support attributes in RemoveFinalFromEntityRector (#3727), Thanks @alexndlm!
  • Add SwapMethodCallArgumentsRector (#3726), Thanks @gaydamakha!
  • [CodeQuality] Add CleanupUnneededNullsafeOperatorRector (#3767)
  • Make ReturnNeverTypeRector work with type declaration, add it to PHP 8.1 set (#3852)
  • [TypeDeclaration] Add BoolReturnTypeFromStrictScalarReturnsRector (#3898)
  • Make ChangeGlobalVariablesToPropertiesRector add properties directly, remove Nette inject methods (#3957)
  • Utilize MinPhpVersionInterface in more rules (#3752), Thanks @staabm!
  • Dump dependency container and re-use it - 35% faster test-suite (#3809), Thanks @staabm!
  • Defer type-resolving in RemoveJustPropertyFetchRector (#3761), Thanks @staabm!

Bugfixes 🐛

  • [TypeDeclaration] Skip Arg unpack on AddMethodCallBasedStrictParamTypeRector (#3787)
  • [CodeQuality] Add typed property support to IssetOnPropertyObjectToPropertyExistsRector (#3876)
  • [CodeQuality] Skip non-array type on SimplifyForeachToArrayFilterRector (#3738)
  • Fix ShortenedObjectType not resolving to correct class reflection (#3397), Thanks @jackbentley!
  • Extend code-quality set (#3773)
  • Don't neon-decode phpstan configs over and over again (#3796), Thanks @staabm!
  • [Console] Allow https url instead of git:// on SetupCICommand (#3799)
  • Fix integer range phpdoc types being treated as useless (#3825), Thanks @jlherren!
  • Fix nullable param in ClassPropertyAssignToConstructorPromotionRector (#3842)
  • Fix PrivatesAccessor: use selectFromArgs() instead (#3923), Thanks @staabm!

Removed rules 💀

We've also remove bunch of rules, that were added in early days of Rector for demo purposes. They were not used as of any set for non-reliable cases. PHPStan and coding standards replace some of those.

  • [CodeQuality] Remove ForToForeachRector, as overly deatiled and not reliable (#3747)
  • [CodeQuality] Remove SimplifyIfExactValueReturnValueRector, as overly defensive + InlineSimplePropertyAnnotationRector as purely coding standard area (#3764)
  • [CodingStyle] Remove RemoveDoubleUnderscoreInMethodNameRector, as naming is not handled for breaking reasons (#3765)
  • Remove RemoveUnusedVariableAssignRector, as could be breaking code in order of excution and hard to do reliable (#3793)
  • [CodingStyle] Remove ConsistentPregDelimiterRector as not much practical, importance of regex is a testing it matches expectationg, area of static analysis (#3797)
  • Remove ToStringToMethodCallRector as not practical and only for demo, FalseReturnClassMethodToNullableRector, as requires detailed custom refactoring (#3854)
  • Remove ChangeOrIfReturnToEarlyReturnRector as makes code harder to read by duplication, rather use PHSPtan and extract method (#3916)
  • [DeadCode] Remove RemoveDuplicatedIfReturnRector as can lead to unexpeced consequences, better use static analysis and contextual handling (#3926)
  • [DeadCode] Remove RemoveDuplicatedInstanceOfRector as hardly practical (#3936)
  • [CodeQuality] Remove ExplicitMethodCallOverMagicGetSetRector designed for nette smart object migration only, not useful for general projects (#3948)
  • Remove GetAndSetToMethodCallRector, as not practical and used for single legacy job (#3953)
  • Remove ChangeReadOnlyVariableWithDefaultValueToConstantRector overly complex and risky, better job for PHPStan (#3954)
  • Remove IsObjectOnIncompleteClassRector as blindly turns all incomplete checks to negated, better examine manually (#3969)
  • Remove ReservedObjectRector as requires explicit configuration and is handled by RenameClassRector already (#3975)
  • Remove ChangeReadOnlyPropertyWithDefaultValueToConstantRector as overly detailed checks, better use PHPStan and refactor individually (#4028)
  • Remove NewToMethodCallRector as unused core and no other extension, niche to use, better handle by PHPStorm (#4029)
  • [CodingStyle] Remove AddFalseDefaultToBoolPropertyRector, as works with unrelaible docblocks (#3856)
  • Remove UpdateFileNameByClassNameFileSystemRector niche rule that was added just for example sake (#3849)
  • [Transform] Remove ArgumentFuncCallToMethodCallRector as never used (#3774)
  • [Transform] Remove DimFetchAssignToMethodCallRector as unused (#3775)
  • [Transform] Remove FileGetContentsAndJsonDecodeToStaticCallRector as only for demo purposes (#3776)
  • [Transform] Remove MethodCallToAnotherMethodCallWithArgumentsRector as unused (#3777)
  • [CodeQuality] Remove SimplifyUselessLastVariableAssignRector as overly complex and should be handled individually (#3784)
  • Remove AddPregQuoteDelimiterRector as very narrow area and has not context awareness, better handle manually (#3927)
  • Remove TokenGetAllToObjectRector, as rare to use and leaky to handle, better handle in controller manual way (#4001)
  • Remove ChangeReflectionTypeToStringToGetNameRector as niche and overly detailed, better refactor reflectio na as a whole (#3976)
  • Remove RenameNamespaceRector, better handle by IDE or explicit RenameClassRector (#3979)
  • [CodeQuality] Deprecate NarrowUnionTypeDocRector as focused on docblocks, and moving to type declarations (#3848)
  • Remove MakeTypedPropertyNullableIfCheckedRector as old fix of TypedPropertyRector rule, removed months ago (#3851)
  • [PHP 8.0] Depre...
Read more