Skip to content

Releases: rectorphp/rector

Released Rector 0.18.4

25 Sep 17:18
Compare
Choose a tag to compare

New Features and Improvements 🥳

  • Introducing Collectors 🥳 - processing collected data + test case (#4970)
  • Run tests on macos (#5019), Thanks @staabm!
  • Move betterNodeFinder, valueResolver, phpDocInfoFactory dependencies from AbstractRector into rules (#5071)
  • DX: Validate paths in RectorConfig->paths() (#5065), Thanks @staabm!
  • [DX] Make PhpDocInfoFactory explicitly required in Rector rule constructor, if needed (#5051)
  • [DX] Make ValueResolver explicitly required in Rector rules constructor if needed (#5052)

Bugfixes 🐛

  • [DeadCode] RemoveDeadZeroAndOneOperationRector should not remove Constants (#4910), Thanks @TwanVermeulen!
  • [PostRector] Fix unused import not removed on empty generic class name exists (#5012)
  • [Parallel] Handle Spaced root project main script on parallel process (#4813)
  • Fix TypedPropertyFromStrictConstructor* order (#5021), Thanks @staabm!
  • [DX] Lower current node dependency - pass it directly to doc node parsing (#5023)
  • [AutoImport] Fix conflict current namespace auto import (#5024)
  • Simplify UseIdenticalOverEqualWithSameTypeRector (#5029), Thanks @staabm!
  • [Performance][Testing] Use str_contains instead of regex in FixtureSplitter (#5030)
  • Fix ArrayKeyFirstLastRector: Skip exection when pointer is changed (#5038), Thanks @scyzoryck!
  • [TypeDeclaration] Handle fallback from param same type object on ReturnTypeFromReturnNewRector (#5039)
  • [NodeTypeResolver] Use Scope->getType() on ArrayDimFetch on NodeTypeResolver::getNativeType() (#5037)
  • [NodeTypeResolver] pull getType() on ArrayDimFetch when not mixed type from its variable native definition (#5056)
  • [CodingStyle][EarlyReturn] Fix infinite if else on BinarySwitchToIfElseRector+RemoveAlwaysElseRector (#5057)
  • [TypeDeclaration] Skip ArrayDimFetch for return and param types (#5059), Thanks @staabm!
  • [NodeTypeResolver] Handle optional array shape on native function like with ArrayDimFetch (#5062)
  • [Php80] Mirror switch comment to match to ChangeSwitchToMatchRector (#5072)
  • [AutoImport] Skip case insensitive conflict defined class name on $rectorConfig->importNames() (#5076)
  • Docblock fix on ShortNameResolver (#5077)
  • [TypeDeclaration] Add return static property support on ReturnTypeFromStrictTypedPropertyRector (#5050)

Removed and Deprecated 💀

  • [Config] Remove asterisk support in import() for file, use explicit paths instead (#5010)
  • [Performance] Remove regex check on open tag spaced check on FileProcessor (#5073)
  • Deprecate TypedPropertyFromStrictConstructorReadonlyClassRector as based on docblock and public elements; use private elements and property promotion instead (#5049)
  • Deprecate BinarySwitchToIfElseRector as opinionated to allow more suitable match() refactoring (#5064)

Released Rector 0.18.3

12 Sep 22:44
Compare
Choose a tag to compare

New Features and Changes 🥳

  • [BC] docblock changes in custom Rector rules now have to be reprinted directly in the rule - #8201 (comment)
  • [TypeDeclaration] Add return empty string defined support on ReturnTypeFromStrictScalarReturnExprRector (#4919)
  • [TypeDeclaration] Add fallback return direct array support on ReturnTypeFromStrictNewArrayRector (#4928)
  • [TypeDeclaration] Add init assign method call support on ReturnTypeFromStrictNewArrayRector (#4929)
  • [TypeDeclaration] Ensure ArrayType on ReturnTypeFromStrictNewArrayRector::shouldAddReturnArrayDocType() (#4932)
  • [TypeDeclaration] Add test fixture return docblock on init method call assign as skipped on ReturnTypeFromStrictNewArrayRector (#4933)
  • [TypeDeclaration] Add non native function return support on ReturnTypeFromStrictScalarReturnExprRector (#4934)
  • BC: Separated regex matching in NodeNameResolver->isName() (#4951), Thanks @staabm!
  • Add support for Custom Skip Voters (#5002), Thanks @kaczenski!
  • Implement a max jobs per worker budget (#4965), Thanks @staabm!
  • Prevent unnecessary calls to spl_object_id() (#4992), Thanks @staabm!
  • Refactor use import resolving (#4998), Thanks @staabm!
  • NodeNameResolver: Throw exception in BC breaking path (#4980), Thanks @staabm!
  • [Internals] Decouple output from AbstractRector, narrow debugging output to file path (#4976)
  • Update docblock only when changed, directly in rector rule (#4986)

Bugfixes 🐛

  • AddVoidReturnTypeWhereNoReturnRector: fix never type handling (#4918), Thanks @staabm!
  • [TypeDeclaration] Skip return after return closure on AddVoidReturnTypeWhereNoReturnRector (#4930)
  • [TypeDeclaration] Use $type->isScalar()->yes() on AlwaysStrictScalarExprAnalyzer (#4920)
  • Refactor BetterNodeFinder::findFirstInFunctionLikeScoped() to work with SilentVoidResolver (#4931)
  • [NodeTypeResolver] Handle isObjectType() on new $class dynamic variable should return false compare to Object FQCN (#4936)
  • [Testing] Fix running unit test on macOS (#4941)
  • Faster name resolving (#4955), Thanks @staabm!
  • UseImportsTraverser: don't deep traverse (#4994), Thanks @staabm!
  • [tests] Replace wildcard e2e test with unit one (#5000)
  • [DocBlock] Update docblock contents right in the rule (#4999)
  • [PhpParser] Fix crash read jetbrains/phpstorm-stubs included in phpstan.phar on PHP 8.0 and PHP 7.4 (#5001)
  • RenameFunctionRector: prevent repeated isName() calls (#5003), Thanks @staabm!
  • Make PhpDocINfo::removeByType() return bool to inform about changed node (#4979)

Removed 💀

  • [cleanup] Remove deprecated NonPhpRectorInterface, PseudoNamespaceToNamespaceRector and mysql to mysqli sets (#4927)
  • Remove UnSpreadOperatorRector as not clear value and spread used on purpose (#4949)
  • [Naming] Remove matchesStringName() check completely from NodeNameResolver, including endsWith() method - use getName() and compare directly instead (#4954)
  • [Performance][Php55] Remove regex replace e on RegexMatcher (#4974)
  • Remove CurrentRectorProvider and used for docblock changes report, return bool value and node directly in the rector rule instead (#4982)
  • Deprecated PhpDocInfo::markAsChanged() to ensure doc block is changed directly in the Rector rule (#4987)

Released Rector 0.18.2

06 Sep 09:58
Compare
Choose a tag to compare

New Features and Changes 🥳

  • Add MyCLabs enum equals + keeping methods (#4645), Thanks @K0nias!
  • [TypeDeclaration] skip variadic constructor param of mixed type on AddParamTypeFromPropertyTypeRector (#4887), Thanks @Celebrate-Reinhard!
  • [TypeDeclaration] Do not add default value when assigned in __construct() on TypedPropertyFromStrictGetterMethodReturnTypeRector (#4886)
  • [TypeDeclaration] Add ReturnTypeFromStrictFluentReturnRector (#4890)
  • Add single value concat support to EncapsedStringsToSprintfRector (#4897)
  • Add number support to concat EncapsedStringsToSprintfRector (#4898)
  • [DeadCode] Remove @return void on return self on RemoveUselessReturnTagRector (#4894)
  • Add test case for caching $rectorConfig->rules() changed (#4903)
  • [CodeQuality] Add NumberCompareToMaxFuncCallRector (#4914)
  • [TypeDeclaration] Add return self object support on ReturnTypeFromStrictFluentReturnRector (#4915)
  • [TypeDeclaration] Add return static object support on ReturnTypeFromStrictFluentReturnRector (#4916)

Bugfixes 🐛

  • [Caching] Add VersionResolver::PACKAGE_VERSION to FileHashComputer::compute() so cache cleared on composer update got new version (#4904)
  • [TypeDeclaration] Using ClassMethodReturnTypeOverrideGuard on ReturnTypeFromStrictParamRector (#4878)
  • [e2e] $rectorConfig->skip() should not skip inside different path over config (#4882)
  • Fix missing default string in TypedPropertyFromStrictGetterMethodReturnTypeRector (#4885)
  • Fix tests fixture updater (#4892)
  • Fix union type check of object (#4893)
  • Simplify isMatchingUnionType() (#4895), Thanks @staabm!
  • Skip identical to false in SimplifyBoolIdenticalTrueRector, as exact comparison is stronger than negated expression (#4901)
  • Fix Rector invalidation in case of changes sets or rules (#4902)
  • [TypeDeclaration] Skip mixing native + docblock union assign on TypedPropertyFromAssignsRector (#4905)
  • StrictArrayParamDimFetchRector: Skip objects (#4907), Thanks @staabm!
  • FamilyRelationsAnalyzer: final classes can't have children (#4913), Thanks @staabm!
  • [Config] Remove $isBound usage as cause empty configuration on RectorConfig (#4880)

Released Rector 0.18.1

29 Aug 08:52
Compare
Choose a tag to compare

This release is accompanied by 2 posts that explains behind the scenes context:


New Features and Changes 🥳

  • [CI] Narrow tests to single job, as now takes 20 s 🚀 (#4827)
  • [Config] Handle $rectorConfig->import() with wildcards * config (#4832)
  • [DX] Display rule count in list-rules (#4848)
  • Skip PHPDoc return type in AddReturnTypeDeclarationBasedOnParentClassMethodRector (#4809), Thanks @staabm!
  • AddReturnTypeDeclarationBasedOnParentClassMethodRector: don't trust phpdoc types (#4810), Thanks @staabm!
  • [DX] Add optional testdox/pest like output to get exact test metrics per unit test fixture (#4821)
  • [TypeDeclaration] Add new array replaced with array on ReturnTypeFromStrictNewArrayRector (#4825)
  • [DX] Merge PhpRectorInterface to RectorInterface as identical contract and separation no longer needed (#4812)
  • [PHPStan] Avoid removing bleeding edge from phar include, let user handle own phpstan configuration (#4840)

Bugfixes 🐛

  • [Php73][Php80] Handle empty long array syntax default value on SensitiveConstantNameRector+AddParamBasedOnParentClassMethodRector (#4837)
  • [Config] Add merging of rules configuration, call configure() just once (#4838)
  • Fix RenamePropertyToMatchTypeRector to skip Laravel collections and avoid accident rename (#4811)
  • [BetterPhpDocParser] Enable textBetweenTagsBelongsToDescription on BetterPhpDocParser extends PhpDocParser (#4817)
  • [PHPUnit] Fix extreemely slow PHPUnit run on data providers with objects (#4823)
  • [AutoImport] Handle case insensitive name collide on auto import (#4829)
  • [Traverser] Set explicitely nodeConnectingVisitorCompatibility: false config in config/phpstan/static-reflection.neon (#4841)
  • replaces get_headers $associative with bool (#4850), Thanks @mvhirsch!
  • [Php55][Renaming] Handle rename string on combination StringClassNameToClassConstantRector+RenameStringRector (#4869)
  • [Php80] Handle crash parent default empty array/string param on AddParamBasedOnParentClassMethodRector (#4833)

Removed 💀

  • Remove deprecated FileProcessorInterface (#4835)
  • Remove SwapFuncCallArgumentsRector as keeps swaping to infinity, use custom rule instead (#4874)

Released Rector 0.18.0 with Laravel container ⚡️

17 Aug 13:07
Compare
Choose a tag to compare

New Features and Changes 🥳

  • [DI] Switch container to Laravel - final step 🥳 (#4698)
    • do you use $rectorConfig->import('src/*'); with mask?
    • this is removed now, use explicit real paths instead
  • [DI] Remove symfony/dependency-injection dependency (#4796)
  • [DI] Add symfony config BC warnings layer, to inform about an upgrade (#4800)
  • Add possibility to add multiple phpstan configs (#4798), Thanks @alexander-schranz!
  • [DX] Make use of addParameter() (#4801)
  • Add deprecation warning for FileProcessorInterface (#4808)

Bugfixes 🐛

  • [DeadCode] Handle duplicated annotation on space before close parentheses on RemoveUselessParamTagRector (#4795)
  • Fix skip() Rector class, make container forget it comleteely (#4807)

Released Rector 0.17.13

14 Aug 17:22
Compare
Choose a tag to compare

New Features and Changes 🥳

  • [TypeDeclaration] Skip in conditional on AddParamTypeFromPropertyTypeRector (#4779)
  • [DX] Deprecate NonPhpRectorInterface, the only rule and its file processor, to make Rector handle exlusively PHP (#4761)
  • Bump nikic/php-parser to 4.17 (#4781)

Removed 💀

  • Remove SwapMethodCallArgumentsRector as could lead to infinite swapping, use custom rule with type/value check instead (#4766)
  • [Php81] Remove IntersectionTypesRector as rely on docblock (#4784)

Bugfixes 🐛

  • [DeadCode] Skip used by trait on RemoveUnusedPrivateMethodRector (#4770)
  • [DeadCode] Skip used by trait inside Closure on RemoveUnusedPrivateMethodRector (#4773)
  • [e2e] Handle $rectorConfig->paths() with wilcards * config (#4765)
  • [Config] Move from magic loading of all PHPStan extensions, their bootstrap files etc. under control with explicit file listing (#4769)
  • [TypeDeclaration] Handle crash on concat param append returned used on Arg on StrictStringParamConcatRector (#4774)
  • [TypeDeclaration] Skip param re-assign on Strict Param rules (#4775)
  • [TypeDeclaration] Skip param int on StrictStringParamConcatRector (#4780)
  • [PHPStanStaticTypeMapper] Allow Closure type on ClosureTypeMapper based on PHP versions (#4785)
  • [PHPStanStaticTypeMapper] Allow standalone null type on NullTypeMapper on php 8.2 (#4783)
  • Make SimplifyUselessVariableRector run without scope (#4791)
  • Make NullToStrictStringFuncCallArgRector run without scope (#4792)

Released Rector 0.17.11

10 Aug 13:19
Compare
Choose a tag to compare

New Features and Improvements 🥳

  • [TypeDeclaration] Add nullable param from null compare on StrictStringParamConcatRector (#4636)
  • [TypeDeclaration] Add ReturnUnionTypeRector (#4655)
  • [TypeDeclaration] Skip public method on AddMethodCallBasedStrictParamTypeRector (#4659)
  • [CodeQuality][TypeDeclaration] Add string append support on ReturnTypeFromStrictScalarReturnExprRector (#4657)
  • [TypeDeclaration] Handle anonymous class in union on AddArrowFunctionReturnTypeRector (#4676)
  • [Types] Make AddVoidReturnTypeWhereNoReturnRector work only with type-declaration, as reliable (#4720)
  • [TypeDeclaration] Allow change multiple methods on AddParamTypeDeclarationRector (#4727)
  • [DX] Add ProcessConfigureDecorator to avoid superfluous composition (#4734)
  • [Logging] Add RectorOutput logging service (#4736)
  • [DX] Cache rector test config loading by file + class to avoid booting over and over per fixture (#4718)
  • [DX] Validate rules no longer existing rules in $rectorConfig->skip() (#4728)
  • [DX] Merge RectorOutputStyle, OutputStyleInterface to RectorStyle (#4711)

Bugfixes 🐛

  • [TypeDeclaration] Do not change different type defualt value on StrictStringParamConcatRector (#4635)
  • [Strict] Skip docblock on BooleanInTernaryOperatorRuleFixerRector (#4638)
  • [Strict] Skip docblock on DisallowedShortTernaryRuleFixerRector (#4639)
  • [Strict] Skip docblock on BooleanInBooleanNotRuleFixerRector (#4640)
  • [TypeDeclaration] Using native type scope get on ReturnTypeInferer (#4648)
  • [CodingStyle][Php80][Privatization] Handle SeparateMultiUseImportsRector+ClassPropertyAssignToConstructorPromotionRector+FinalizeClassesWithoutChildrenRector cause invalid removal (#4649)
  • [DX] Cleanup ForRepeatedCountToOwnVariableRector counter (#4651)
  • [DX] Make MoneyFormatToNumberFormatRector wrap func call directly to keep simple (#4653)
  • Move ArrayManipulator to rector-symfony, where only used (#4656)
  • [DX] Move FlipNegatedTernaryInstanceofRector to instanceof rules category (#4663)
  • Resolve encapsed values as strings (#4622), Thanks @Bellardia!
  • [Privatization] Skip parent class unknown on PrivatizeFinalClassMethodRector (#4671)
  • [TypeDeclaration] Skip anonymous class and other object on ReturnUnionTypeRector (#4670)
  • [TypeDeclaration] Allow return anonymous class on ReturnTypeFromReturnNewRector (#4669)
  • [TypeDeclaration][CodeQuality] Move ReturnTypeFromStrictScalarReturnExprRector from CodeQuality to TypeDeclaration set (#4668)
  • [TypeDeclaration] Allow __invoke() method for return type changed on ClassMethodReturnTypeOverrideGuard (#4667)
  • [NodeTypeResolver] Clean up anonymous class detection on NodeTypeResolver::getNativeType() (#4673)
  • [NodeAnalyzer] Pass ReflectionProvider to __construct() on CallAnalyzer (#4699)
  • Skip code changes on unresolvable/unknown classes (#4619), Thanks @staabm!
  • [TypeDeclaration] Use return bool for ParentClassMethodTypeOverrideGuard::hasParentClassMethod(), return ?MethodReflection for ParentClassMethodTypeOverrideGuard::getParentClassMethod() (#4703)
  • [TypeDeclaration] Skip param setter method intersection docblock not autoload on ReturnNeverTypeRector (#4721)
  • [TypeDeclaration] Skip non void or never already return typed on ReturnNeverTypeRector (#4723)
  • Make relativeFilePathFromDirectory() private as used only locally (#4735)
  • [DX] Avoid supporting edge-case multi-layered comments, must be covered in php-parser itself (#4743)
  • [TypeDeclaration] Skip void type on caller on ReturnTypeFromStrictTypedCallRector (#4751)
  • Use direct VoidType definition on Return_ expr is null on ReturnedNodesReturnTypeInfererTypeInferer (#4752)
  • [Renaming] Deprecate PseudoNamespaceToNamespaceRector as too dynamic and unreliable, use the RenameClassRector instead (#4755)

Removed 💀

Since Rector 0.15 we declare type stricness and avoid docblock changes, as unreliable and could lead to incorrect assumptions: getrector.com/blog/new-in-rector-015-complete-safe-and-known-type-declarations

Few rules work with unreliable docblocks, and were removed. Instead handle cases yourself with PHPStan help 👍

  • [DX] Remove deprecated RectorConfigProvider, use SimpleParameterProvider instead (#4658)
  • [DX] Remove usage of deprecated symfony parameters (#4674)
  • Remove deprecated ArrayShapeFromConstantArrayReturnRector (#4662)
  • Remove RemoveParentRector as never used and only for demo purposes, handle custom way where needed (#4679)
  • [DX] Remove *AnnotationIncorrectNullableRector rules as works with unreliable docblocks and can have 2 solutions (#4719)
  • Remove appendArgs() method on AbstractRector (#4732)
  • [Renaming] Remove callables from class renames to avoid missed rename bugs, better handle with PHSPtan and custom rule (#4745)
  • [DX] Remove NullifyUnionNullableRector, let cs tools handle it (#4660)
  • [DX] Remove RemoveJustPropertyFetchRector as used for one time job, not practical for general use (#4661)
  • [TypeDeclaration] Remove AddClosureReturnTypeRector (#4637)
  • [DX] Remove AddDefaultValueForUndefinedVariableRector as can generate broken code and depends on context (#4729)

Released Rector 0.17.10

03 Aug 14:21
Compare
Choose a tag to compare

New Features 🥳

  • [TypeDeclaration] Add Closure support on NumericReturnTypeFromStrictScalarReturnsRector (#4631)
  • [TypeDeclaration] Add Closure support on StrictArrayParamDimFetchRector (#4632)
  • [TypeDeclaration] Add Closure support on ReturnTypeFromStrictParamRector (#4633)
  • [TypeDeclaration] Add Closure support on StrictStringParamConcatRector (#4634)

Bugfixes 🐛

  • [Downgrade] [FIX] Fix infinite loop in DowngradeArrayFilterNullableCallbackRector (#150)

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)