github rectorphp/rector 2.2.0
Released Rector 2.2

latest release: 2.2.1
one day ago

This release includes dozens of fixes, new PHP and Type Declaration rules, many Symfony Console rules improvements...

...and one brand new set: type coverage docblocks 🎉 🎉 🎉

Read the gist on our blog - Rector 2.2: New rules for Array Docblocks


New Features and Improvements 🚀

New rules for Type Coverage Docblocks:

  • Add AddReturnDocblockForCommonObjectDenominatorRector (#7249)
  • Add AddParamArrayDocblockFromDimFetchAccessRector (#7253)
  • Add AddParamArrayDocblockFromDataProviderRector (#7257)
  • Add ClassMethodArrayDocblockParamFromLocalCallsRector (#7259)
  • Add AddReturnDocblockDataProviderRector (#7266)
  • Add fixture for data provider return options (#7268)
  • Add AddReturnDocblockForArrayDimAssignedObjectRector (#7302)
  • Add DocblockVarArrayFromPropertyDefaultsRector (#7311)
  • Add DocblockVarArrayFromGetterReturnRector (#7313)
  • Add AddReturnDocblockForJsonArrayRector (#7320)
  • Add AddParamArrayDocblockFromAssignsParamToParamReferenceRector (#7323)
  • [dx] add withTypeCoverageDocblockLevel() (#7363)

  • [dead-code] Add RemoveUnusedVariableUseRector (#7430)
  • [Php 8.5] Add WakeupToUnserializeRector (#7242), Thanks @arshidkv12!
  • [code-quality] Add RepeatedOrEqualToInArrayRector (#7400)
  • [Php 8.1] Add NullToStrictIntPregSlitFuncCallLimitArgRector (#7240)
  • feat: add greater and smaller support to StrlenZeroToIdenticalEmptyStringRector (#7329), Thanks @calebdw!
  • [TypeDeclaration] Allow empty array to native array on AddMethodCallBasedStrictParamTypeRector (#7342)
  • [TypeDeclaration] Allow named arg on AddArrayFunctionClosureParamTypeRector (#7397)
  • [type-declarations] Add KnownMagicClassMethodTypeRector (#7419)
  • Add rector to migrate __sleep() to __serialize() (#7212), Thanks @arshidkv12!
  • [type-declaration] Add AddParamFromDimFetchKeyUseRector (#7424)
  • Add first class callable support to CallUserFuncArrayToVariadicRector (#7428)

Bugfixes 🐛

  • fix: remove empty construct when parent has no construct (#7239), Thanks @calebdw!
  • fix: overly strict ArraySpreadInsteadOfArrayMergeRector (#7247), Thanks @calebdw!
  • [CodingStyle] Skip non-native array type on PHP 7.4 for ArraySpreadInsteadOfArrayMergeRector (#7248)
  • fix: FunctionLikeToFirstClassCallableRector (#7265), Thanks @calebdw!
  • fix: EnumCaseToPascalCaseRector skips existing pascal case (#7264), Thanks @calebdw!
  • [CodeQuality] Skip init not empty array on InlineArrayReturnAssignRector (#7276)
  • fix: EnumCaseToPascalCaseRector bugs (#7278), Thanks @calebdw!
  • Avoid complex nesting in ConstantArrayTypeGeneralizer (#7282)
  • [TypeDeclaration] Fix return by variable anonymous on ReturnTypeFromReturnNewRector (#7292)
  • [Php84] Allow early return on ForeachToArrayAllRector (#7316), Thanks @Orest-Divintari!
  • [TypeDeclaration] Fix configurable on IncreaseDeclareStrictTypesRector to show on getrector.com (#7327)
  • Skip nested array dim fetch assigns in InlineArrayReturnAssignRector (#7380)
  • [CodeQuality] Fix escape character on SimplifyRegexPatternRector (#7390)
  • Try use double quote on SimplifyRegexPatternRector (#7392)
  • [type-declarations] Open isset check in StrictArrayParamDimFetchRectorTest, move to last position in type-declaration level (#7388)
  • [CodeQuality] allow coalesce not on full variable, but dim fetch in StrictArrayParamDimFetchRector (#7404)
  • [CodeQuality] Skip bool equal integer on UseIdenticalOverEqualWithSameTypeRector (#7411)
  • update comment on fixtures (#7413)
  • [CodeQuality] Use ->isBoolean() check on compare boolean and constant bool on UseIdenticalOverEqualWithSameTypeRector (#7415)

Removed 💀

  • [Differ] Remove ConsoleDiffer, use DefaultDiffer that utilize ColorConsoleDiffFormatter instead to avoid double diffing process (#7309)

Rector Symfony 🎵

  • [Symfony61] Handle already exists attributes name on CommandConfigureToAttributeRector (#849)
  • [Symfony 6.2] Move symfony/security-core to security-http and security-bundle as target class/contant exists there (#848)
  • [Symfony73] Remove extends AbstractExtension after apply change on GetFunctionsToAsTwigFunctionAttributeRector (#846)
  • [code-quality] keep attribute in InlineClassRoutePrefixRector if it contains other metadata (#845)
  • [console] [7.3] Add implicit boolean type in InputOption::VALUE_NONE option (#844)
  • [console] [7.3] Add type declaration based on default value type in InvokableCommandInputAttributeRector (#843)
  • [console] [7.3] add array argument support to /InvokableCommandInputAttributeRector (#842)
  • [console] [7.3] Add support for default values in InvokableCommandInputAttributeRector (#841)
  • [console] [7.3] Add const names in InvokableCommandInputAttributeRector + fix -_ naming to camel case (#840)
  • [console] [7.3] Fix missing options in InvokableCommandInputAttributeRector (#839)
  • [console] [7.3] Replace input/output with symfony style if used in InvokableCommandInputAttributeRector (#838)

Rector Doctrine 🟠

  • [dbal] [4.0] remove constant rename, as will be turned into enum right away and required manaul upgrade (#467)
  • Fix PHPStan notice on PHPStan 2.1.23 (#466)

Rector PHPUnit 🟢

  • [CodeQuality] Ensure verify ClassReflection->hasConstructor() on MethodParametersAndReturnTypesResolver (#550)
  • [CodeQuality] Skip not match position named argument part 2 (#548)
  • [code-quality] add New_ support to ScalarArgumentToExpectedParamTypeRector (#547)
  • [phpunit] [9.0] resolve WithConsecutiveRector naming ad-hoc to PHPUnit real code (#546)

Don't miss a new rector release

NewReleases is sending notifications on new releases.