Skip to content

Releases: rectorphp/rector

Released: Rector 2.0.9

10 Feb 08:14
Compare
Choose a tag to compare

Bugfixes 🐛

  • [Php81] Exclude Doctrine ODM MongoDB Document and EmbeddedDocument from ReadOnlyPropertyRector (#6721), Thanks @mickverm!
  • [PostRector] Handle with FQCN docblock on UnusedImportRemovingPostRector (#6722)
  • Type hint array reduce closure (#6725), Thanks @peterfox!
  • [PHPStan 2.1.3] Add ReflectionAttribute and ReflectionIntersectionType stub for PHPStan 2.1.3 (#6723)

Released: Rector 2.0.8

06 Feb 14:10
Compare
Choose a tag to compare

New Features 🥳


Bugfixes 🐛

  • [CodeQuality] Skip with comment inside on SimplifyIfElseToTernaryRector (#6683)
  • [CodeQuality] Skip windows absolute path on AbsolutizeRequireAndIncludePathRector (#6684)
  • [Strict] Handle in assign on BooleanInIfConditionRuleFixerRector (#6685)
  • Replace ambiguous wrapped_with_brackets with existing attribute wrapped_in_parentheses (#6691)
  • [NodeTypeResolver] Clean up wrap in parentheses check ReprintNodeVisitor (#6692)
  • [Php80][TypeDeclaration] Fix crash on ClassPropertyAssignToConstructorPromotionRector + ReturnNeverTypeRector (#6694)
  • CodeClimate output format (#6697), Thanks @VitalyArt!
  • Exclude node modules path (#6702), Thanks @vaishnavyogesh!
  • Fix str_getcsv() escape argument on PHP 8.4 (#6704)
  • [Php74] Handle crash curly based array on trait on CurlyToSquareBracketArrayStringRector (#6706)
  • [Php73] Handle infinite cast on StringifyStrNeedlesRector (#6707)
  • Clean up unused use (#6708)
  • fix: NewlineBeforeNewAssignSetRector variable as same name like property (#6705), Thanks @guideloince!
  • [TypeDeclaration] Skip override trait method on StrictStringParamConcatRector (#6711)
  • [Test] Clean up test on WorkerCommandLineFactoryTest (#6714)
  • [DX] Move isWindows() method from AbstractRectorTestCase to AbstractLazyTestCase (#6715)
  • [Performance] Use exactly equal or append / file path check on RealpathMatcher (#6716)
  • [TypeDeclaration] Allow union with closure type on property on TypedPropertyFromAssignsRector (#6717)
  • [DeadCode] Skip union falsy mixed on trait on RecastingRemovalRector (#6718)
  • Skip hexa chars in EncapsedStringsToSprintfRector (#6719)
  • [CodingStyle] Rename method: containsASCIIChar to containsControlASCIIChar on EncapsedStringsToSprintfRector (#6720)

Released Rector 2.0.7

19 Jan 10:35
Compare
Choose a tag to compare

New Features 🥳


Bugfixes 🐛

  • [type-declaration] Add typed property, if traits do not duplicate the property (#6663)
  • [removing] Add interface support to RemoveInterfaceRector (#6681)
  • fix: add Symfony support as a composer-based option (#6673), Thanks @ayedbelsem!
  • [CodeQuality] Handle on assign on FlipTypeControlToUseExclusiveTypeRector (#6653)
  • [Performance] Early return FullyQualifiedObjectType on FQCN on ObjectTypeSpecifier (#6658)
  • [CodeQuality] Skip indirect return on SimplifyIfReturnBoolRector (#6660)
  • [Php83] Handle concat in first argument on CombineHostPortLdapUriRector (#6661)
  • [TypeDeclaration] Skip unset by trait on TypedPropertyFromStrictConstructorRector (#6664)
  • [Renaming] Skip used by trait as property promotion on RenamePropertyToMatchTypeRector (#6665)
  • [TypeDeclaration] Skip changed by ref from trait on TypedPropertyFromStrictConstructorRector (#6666)
  • [CodeQuality] Handle with assign missing parentheses on ExplicitBoolCompareRector (#6668)
  • use ->ignoreVCSIgnored() on RectorConfigBuilder::withRootFiles() over custom logic (#6669)
  • [BetterPhpDocParser] Check for closing brace in text content (#8977) (#6670), Thanks @andrewnicols!
  • [AutoImport] Handle FQCN with sub namespace (#6672)
  • [BetterPhpDocParser] Use str_contains() for DoctrineAnnotationDecorator (#6671) (#6674), Thanks @andrewnicols!
  • [AutoImport] Handle inner with sub namespace on auto import (#6679)
  • [DeadCode] Skip dynamic name on RemoveParentCallWithoutParentRector (#6659)



rectorphp/rector-symfony 🎵

  • Back to require-dev rector-src:dev-main (#697)
  • Update GetBySymfonyStringToConstructorInjectionRector fixture test to cover rector-srv:tv-readonly-add-ctor (#696)

rectorphp/rector-doctrine 🟠


rectorphp/rector-phpunit 🟢

  • [PHPUnit 10] Register PropertyExistsWithoutAssertRector to phpunit100.php (#443)
  • Added testcase to demonstrate rector#8977 (#440), Thanks @andrewnicols
  • [PHPUnit10] Replace deleted PHPUnit methods (#438), Thanks @66Ton99

Released: Rector 2.0.6

06 Jan 10:48
Compare
Choose a tag to compare

New Features 🥳

  • [dx] Add --only-suffix to filter files by suffixes (#6647)
  • [DeadCode] Add ReplaceBlockToItsStmtsRector (#6641)
  • [DeadCode] Add RemoveUselessAssignFromPropertyPromotionRector (#6643)
  • Add readonly by default on new promoted property (#6650)
  • Use autowired method if exists in adding new dependency (#6652)

Bugfixes 🐛

  • [CodeQuality] Handle crash inside block statement with unreachable statement on OptionalParametersAfterRequiredRector (#6640)
  • [DX] Use Param->isPromoted() over param->flags !== 0 check on promotion property check (#6646)
  • [Php80] Keep numeric string, string "true", "false" as is on StringAnnotationToAttributeMapper (#6610)
  • [PHPStan ^2.1.1] Handle next unreachable statement via UnreachableStatementNode->getNextUnreachableStatements() (#6642)

Removed 💀

  • [Parser] Remove SmartPhpParserFactory and SmartPhpParser (#6651)

Released: Rector 2.0.5

31 Dec 13:15
Compare
Choose a tag to compare

This release support PHP-Parser 5.4.0 and PHPStan 2.1.0

Feature

  • Bump to PHP-Parser ^5.4.0 with use patches fix-patch-php-parser-54 patches (#6637)
  • Bump to PHPStan ^2.1.0 (#6639)
  • [DeadCode] Allow remove useless @ var on typed class constant as well on RemoveUselessVarTagRector (#6633)

Removed 💀

  • Remove unused AssignVariableNameResolverInterface instances (#6631)

Bugfixes 🐛

  • [DX] Warn about ->withPhpSets() called multiple times, to avoid invalid set mix (#6632)
  • [CodeQuality] Skip fopen() or die() on LogicalToBooleanRector on assign (#6635)
  • use vendor-patches main branch that already include php-parser 5.4.0 patch (#6638)

Released Rector 2.0.4

26 Dec 23:19
Compare
Choose a tag to compare

New Features 🥳

  • [PHP 8.0] Add lcfirst annotation to attribute support (#6577)
  • Add multiline comment fixture (#6580)
  • [TypeDeclaration] Add param type to array map closure (#6377), Thanks @peterfox!
  • [deprecation] Add message about deprecated MixedTypeRector rule, Remove deprecated SetListInterface as no longer used (#6590)
  • [Php81][php82] Add AttributeGroupNewLiner to make new line based on token on ReadOnlyPropertyRector and ReadOnlyClassRector (#6618)
  • [Php84] Add rule for RoundingMode enum (#6369), Thanks @jorgsowa!

Bugfixes 🐛

  • [dx] polyfill sets is running out of the box in php sets (#6591)
  • [phpstan] Fix var assumed ignored errors (#6571)
  • [phpstan] fix next ingored errors (#6572)
  • [CodeQuality] Handle crash on property hook on OptionalParametersAfterRequiredRector (#6575)
  • [PHP 8.0] Make AnnotationToAttributeRector return after 1st newline without slash (#6578)
  • [Php80] Fix end slash regex on AttributeValueResolver (#6579)
  • Fix annotation on doctrine one (#6582)
  • [Comments] Move left over clean empty doc handling to DocBlockUpdater (#6584)
  • fix: replace getKey method for name property (#6583), Thanks @carlosvinicius!
  • fix: replace getKey/getValue methods when enum is a variable (#6585), Thanks @carlosvinicius!
  • [Php80] Handle comment multi line on AttributeValueResolver (#6586)
  • [Php80] Use more proper check for doc comment multi lines on AttributeValueResolver (#6587)
  • [Php80] Handle value as argument with keep description as comment on AttributeValueResolver (#6589)
  • withRootFiles now apply rector for dotfiles too (#6592), Thanks @andrew-demb!
  • 📦 Ignore .phpstorm.meta.php because this is not PHP file (#6594), Thanks @andrew-demb!
  • [Php81] Skip reassign on array destruct on ReadOnlyPropertyRector (#6596)
  • [Php80] Handle crash on multi next stmts on ChangeSwitchToMatchRector (#6597)
  • [CodingStyle] Handle crash on pass args on CallUserFuncToMethodCallRector (#6598)
  • [Php81] Skip with next required on NewInInitializerRector (#6599)
  • Move FunctionLike reindex under StmtsAwareInterface on NodeAttributeReIndexer (#6605)
  • [DeadCode] Skip value variable used in throw stmts in catch on UnusedForeachValueToArrayKeysRector (#6607)
  • Revert "[Php80] Keep numeric string as is on StringAnnotationToAttributeMappe…" (#6609)
  • [Php54] Use token base replace on LongArrayToShortArrayRector (#6616)
  • [Performance] Only register WrappedNodeRestoringNodeVisitor() when there is found AlwaysRememberedExpr or Match_ node on processNodes() (#6620)
  • [Fix] Renamed gzwrites (undefined function) to gzwrite (#6622), Thanks @Vqcheslav!
  • [FunctionLike] Skip return by ref with switch on SimplifyUselessVariableRector (#6623)
  • Rollback SimpleCallableNodeTraverser usage on ByRefReturnNodeVisitor (#6624)
  • [TypeDeclaration] Skip assign on while cond on WhileNullableToInstanceofRector (#6628)
  • [TypeDeclaration] Skip assign in if condition on BinaryOpNullableToInstanceofRector (#6629)
  • Clean up ignore phpstan errors (#6630)
  • [DeadCode] Skip @return positive-int|0 on RemoveUselessReturnTagRector (#6576)
  • [DeadCode] Skip key variable used in throw stmts in catch on RemoveUnusedForeachKeyRector (#6606)

Removed 💀

  • Remove TypeNormalizer as type comparison is handled well by PHPStan (#6570)
  • Removed unused method ClassChildAnalyzer-> hasParentClassMethod() (#6595), Thanks @staabm!
  • [Experiment] Remove WrappedNodeRestoringNodeVisitor (#6626)

Released Rector 2.0

12 Dec 10:52
Compare
Choose a tag to compare

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)
    *...
Read more

Released Rector 1.2.10

08 Nov 14:03
Compare
Choose a tag to compare

New Features 🥳

  • [PHP8.3] add new rectors for get_class()/get_parent_class() without arguments (#6405), Thanks @cabbey!

Bugfixes 🐛

  • Fix ClassDependencyManipulator to add dependency on right position (#6413)
  • [Php81] Skip Doctrine Embeddable on ReadOnlyPropertyRector (#6411)
  • [Privatization] Skip with parameter on PrivatizeLocalGetterToPropertyRector (#6412)

Removed 💀

  • [DeadCode] Skip nullable @ template on RemoveUselessReturnTagRector (#6409)



rectorphp/rector-phpunit 🟢

  • [PHPUnit 10] Skip with Magic __get() on AssertIssetToAssertObjectHasPropertyRector (#403)
  • [CodeQuality] Add CreateMockToDirectNewRector (#402)
  • [CodeQuality] Add SingleMockPropertyTypeRector (#401)
  • [CodeQuality] Skip used by trait and multiple props on NarrowUnusedSetUpDefinedPropertyRector (#400)
  • Skip property with default value in NarrowUnusedSetUpDefinedPropertyRector (#398)
  • [CodeQuality] Add FlipAssertRector (#397)
  • Add count() support to AssertCompareOnCountableWithMethodToAssertCountRector (#395)
  • Add enum/const fetch support to AssertEqualsToSameRector (#394)
  • skip static property in NarrowUnusedSetUpDefinedPropertyRector (#393)

Released Rector 1.2.9

04 Nov 18:30
Compare
Choose a tag to compare

Bugfixes 🐛

  • [Strict] Using in_array() on CallLike instead of double call on Strict Rules (#6388)
  • [CodeQuality] Handle If cond as assign on ExplicitBoolCompareRector (#6389)
  • [CodeQuality] Skip append non empty array on ForeachItemsAssignToEmptyArrayToAssignRector (#6390)
  • [Php80] Mirror return comment on ChangeSwitchToMatchRector (#6394)
  • [TypeDeclaration] Skip union intersection types on php 8.1, allow on php 8.2+ (#6395)
  • [Php80] Skip @template T as mixed on MixedTypeRector (#6399)
  • [DeadCode] Check TemplateType instance check on Dead*TagValueNodeAnalyzer (#6400)
  • [CodeQuality] Skip multiple lines on JoinStringConcatRector (#6404)
  • [CodingStyle] Skip equal modifier on direct parent method compatible on MakeInheritedMethodVisibilitySameAsParentRector (#6406)

Removed 💀

  • [DeadCode] Handle consecutive equal case stmts on RemoveDuplicatedCaseInSwitchRector (#6392)
  • [DeadCode] Handle handle consecutive equal with jump different case on RemoveDuplicatedCaseInSwitchRector (#6393)
  • [DeadCode] Skip @template tag on RemoveUselessVarTagRector (#6396)
  • [DeadCode] Support multiple templates in RemoveUselessVarTagRector (#6402), Thanks @dragosprotung!



rectorphp/rector-symfony 🎵

  • [CodeQuality] Skip Request param used by caller method on RemoveUnusedRequestParamRector (#675)
  • Better note highlighting (#674), Thanks @OskarStark
  • remove extra character (#673), Thanks @IndraGunawan

rectorphp/rector-phpunit 🟢

  • [code-quality] Add NarrowUnusedSetUpDefinedPropertyRector (#388)
  • Add enum/const fetch support to AssertEqualsToSameRector (#394)
  • Add count() support to AssertCompareOnCountableWithMethodToAssertCountRector (#395)
  • [AnnotationsToAttribute] Skip not in test on AnnotationWithValueToAttributeRector (#387)
  • Add ReplaceTestFunctionPrefixWithAttributeRector (#386), Thanks @blackwolf12333

Released Rector 1.2.8

18 Oct 11:57
Compare
Choose a tag to compare

Bugfixes 🐛

  • [UnusedImport] Fix removing multiple uses (#6376), Thanks @jorgsowa!
  • [PostRector] Clean up variables and conditional usage on UnusedImportRemovingPostRector (#6378)
  • [PostRector] Reduce repetitive toString() on loop on UnusedImportRemovingPostRector (#6379)
  • [CodeQuality] Skip no @ property doc on DynamicDocBlockPropertyToNativePropertyRector (#6380)
  • [CodeQuality] Handle with other attributes on DynamicDocBlockPropertyToNativePropertyRector (#6381)
  • [CodeQuality] Use existing PhpAttributeAnalyzer service instead of AttributeFinder from Doctrine package on DynamicDocBlockPropertyToNativePropertyRector (#6382)
  • Fix duplicated register ContinueToBreakInSwitchRector in php52.php and php73.php (#6385)
  • [AutoImport] Fix missing @ in deep annotation auto import (#6386)
  • [DeadCode] Skip non FullyQualified property type on RemoveTypedPropertyNonMockDocblockRector (#6383)

New Features 🥳

  • [CodeQuality] Add DynamicDocBlockPropertyToNativePropertyRector (#5691)
  • [DX] [Experimental] Add withPhpLevel() to raise PHP level one rule at a time (#6261)