Releases: rectorphp/rector
Released Rector 1.0.2
New Features and changes 🥳
- Add minimal memory limit for local run phpstan without result cache (#5624), Thanks @integer!
- Add method RectorConfigBuilder::withSkipPath() (#5626), Thanks @integer!
- Add basic validation for skipped path (#5628), Thanks @integer!
- [Php80] Add DoctrineCoverterterAttributeDecorator to convert "false"/"true" string to false/true on nullable arg on Doctrine\ORM\Mapping\Column (#5629)
- Add const fetch to class const fetch rector. (#5627), Thanks @micaherne!
- [DX] Add error message information for include full path to load internal phpstan bleedingEdge.neon config (#5635)
- [TypeDeclaration] Adds AddParamTypeForFunctionLikeWithinCallLikeArgDeclarationRector rule (#5547), Thanks @peterfox!
- [Php83] Add type to final class constant (#5662), Thanks @philbates35!
Bugfixes 🐛
- [Php83] Early check private method in child before check parent on AddOverrideAttributeToOverriddenMethodsRector (#5622)
- RectorConfigBuilder: skip and rules can be called multiple times (#5623), Thanks @integer!
- [CodeQuality] Skip not autoloaded parent class on CompleteDynamicPropertiesRector (#5636)
- [Transform] Allow transform ruleWithConfiguration() to withConfiguredRule() on RectorConfigBuilderRector (#5637)
- [Rector] Allow transform sets() to withSets() on RectorConfigBuilderRector (#5638)
- [Transform] Allow transform disableParallel() to withoutParallel() on RectorConfigBuilderRector (#5640)
- [Transform] Allow transform fileExtensions() to withFileExtensions() (#5641)
- [Performance] [VendorLocker] Early allow change return type on private method on ClassMethodReturnTypeOverrideGuard::shouldSkipClassMethod() (#5642)
- [VendorLocker] Early return false on private method on ParentClassMethodTypeOverrideGuard::hasParentClassMethod() (#5644)
- [Renaming] Handle crash on RenameFunctionRector with die() and $_SESSION usage (#5646)
- Cleanup scope check on UnreachableStatementNodeVisitor (#5648)
- Keep comments in annotations when converting them to attributes (#5650), Thanks @carlos-granados!
- [Util] Make consistent new line splitter to Util (#5651)
- [TypeDeclaration] Fix abs() returns on ReturnTypeFromStrictTypedCallRector (#5652)
- [TypeDeclaration] Allow abs() to return int when pass int arg on ReturnTypeFromStrictTypedCallRector (#5653)
- [TypeDeclaration] Skip possible returns false on ReturnTypeFromStrictNewArrayRector (#5654)
- [TypeDeclaration] Include MockObject&ClassName docblock with IntersectionTypeNode on TypedPropertyFromStrictSetUpRector (#5655)
- [Renaming] New Rule: RenameFunctionLikeParamWithinCallLikeArgRector (#5554), Thanks @peterfox!
- [PHPStanStaticTypeMapper] Avoid double \ prefix on IntersectionTypeMapper (#5656)
- [BetterPhpDocParser] Clean up unnecessary create new ConstFetchNode() on ArrayItemClassNameDecorator (#5658)
- [Php71] Skip re-assign as string on AssignArrayToStringRector (#5659)
- [Privatization] Skip with suffix "TestCase" on FinalizeTestCaseClassRector (#5660)
- [Php71] Skip re-assign as string on AssignArrayToStringRector part 2 (#5661)
- [DeadCode] Fix infinite loop on RemoveDeadStmtRector + RemoveUnusedVariableAssignRector (#5666)
- [Php81] Skip execution operator on NullToStrictStringFuncCallArgRector (#5667)
- [Naming] Handle crash with numeric-string doc on RenamePropertyToMatchTypeRector (#5670)
- [CodeQuality] Handle crash on named arg on deep closure on OptionalParametersAfterRequiredRector (#5671)
- chore: bump min version of github actions (fix deprecations) (#5675), Thanks @Chris53897!
- [PHP 8.0] Fix case insenstive false positive replacement for str_ends_with (#5677)
- [Transform] Allow transform phpVersion() to withPhpVersion() on RectorConfigBuilderRector (#5678)
- Fix duplicated fixture class name on StaticToSelfStaticMethodCallOnFinalClassRector test (#5679)
- [CodeQuality] Skip nested array on InlineArrayReturnAssignRector (#5680)
- [CodeQuality] Skip combine var with property fetch on InlineArrayReturnAssignRector (#5681)
- [CodeQuality] Handle array destructuring of unpack on ArrayMergeOfNonArraysToSimpleArrayRector (#5682)
- Update README to use the new config syntax (#5674), Thanks @carlos-granados!
- [PostRector] Skip remove use statement on used in annotation on removeUnusedImports() (#5657)
- [DeadCode] Skip implements interface __construct() on RemoveUnusedPromotedPropertyRector (#5669)
- [Performance] [DeadCode] Early check no params in __construct() on RemoveUnusedPromotedPropertyRector (#5672)
Released Rector 1.0.1
New Features 🥳
- [Custom] Add "detect-node" command to help with writing custom rules (#5576)
- [Config] Add registerService() method to allow container extension (#5591)
- [TypeDeclaration] Add AddTestsVoidReturnTypeWhereNoReturnRector (#5611)
- [PHP 8.0] Add always class to AnnotationToAttribute to include string to ::class reference conversion (#5619)
- [CodeQuality] Add StaticToSelfStaticMethodCallOnFinalClassRector (#5621)
Bugfixes 🐛
- ExplicitBoolCompareRector: skip phpdoc (#5567), Thanks @staabm!
- Fix ArrayTypeMapper to handle arrays with UnionType items (#8225) (#5568), Thanks @pkvach!
- [Configuration] Fix detect /vendor on root project on vendor analyzed on VendorMissAnalyseGuard (#5569)
- Fix missing / suffix on VendorMissAnalyseGuard (#5571)
- [PHP81] Skip after is_string on object call on NullToStrictStringFuncCallArgRector (#5572)
- [Config] Make sure only one of type-declaration/dead-code or with*Level() is used to avoid duplicates (#5578)
- Fix undefined MHASH_* constant on running downgrade from php 8.0 (#5585)
- [NodeTypeResolver] Ignore PHPStan internal error on PHPStanNodeScopeResolver on NodeScopeResolver::processNodes() (#5586)
- [Php81] Skip possible array on NullToStrictStringFuncCallArgRector (#5587)
- [Php81] Skip another possible cast array to string on NullToStrictStringFuncCallArgRector (#5589)
- [Transform] Allow class const fetch value on rules() on RectorConfigBuilderRector (#5596)
- [Performance] Use strlen() early before loop on VendorMissAnalyseGuard (#5597)
- Copy subtype phpdoc on ClassPropertyAssignToConstructorPromotionRector (#8438) (#5603), Thanks @pkvach!
- config method must be static, to avoid creating rule before loading related ctor services (#5606)
- fix config for configured rule (rectorphp/rector-src@5edb023)
- [PHP 8.0] Fix annotation to attribute in case of FQN class without () (#5609)
- [Php80] Support windows new line line DoctrineAnnotationDecorator::LONG_ANNOTATION_REGEX (#5610)
- [Php81] Handle after open parentheses on AnnotationToAttributeRector (#5613)
- [BetterPhpDocParser] Move split new line with @\ to regex to support windows new line (#5615)
- [Php81] Handle nested Fqcn UniqueConstraint on NestedAnnotationToAttributeRector (#5614)
- [DX] Accept Y/y for confirmation of init config (#5616)
- [CodeQuality] Skip private static call from static:: on LocallyCalledStaticMethodToNonStaticRector (#5620)
- [PostRector] Skip remove unused imports on used in multiple docs in single node (#5604)
- [DeadCode] Skip sub type false => bool on RemoveUselessVarTagRector (#5588)
Removed 💀
Released Rector 1.0.0 🎉🎉🎉
The stable Rector version is here. It was about time and we've done all planned changes by the end of 2023.
What could be better time and place to release a stable Rector than live on stage during talk 🎉
While this release brings stable API, it will be easier to stay up to date as well. The 1.x versioning behaves as expected with composer update
(compared to special 0.x).
Our main focus is on improving developers experience. This release brings new features that help with custom rules writing, adding Rector to CI and adding Rector to any legacy project in general.
Some features are partially available in previous version, but we'd like to highligh them because since 1.0 you can use them all together.
Zen Config with Autocomplete
If you run Rector for the first time, it will create a rector.php
config with your project paths for you. In past we used various class constants references to add commonly used rule sets. This required knowledge about these classes and was often missed.
We've changed this to work with single configuration class. It provides autocomplete for available sets, including attributes:
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withPreparedSets(codeQuality: true, codingStyle: true)
->withAttributesSets(symfony: true, doctrine: true)
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withRootFiles();
PHP Sets Automated
To keep up to date with you PHP, now you can use single method:
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withPhpSets();
It learns about PHP version from your composer.json
and will always keep sync with your required PHP version. No need to double check rector.php
configuration anymore.
Streamline Integration to Projects
We're also adding 2 experimental methods, that make Rector integration to new projects easier. Before, you could run whole type declaration or read code set, see 1000 changed files and rather close it being overwhelmed. Instead, we want to take it slow, as we do with our custom upgrades as well:
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withTypeCoverageLevel(10)
->withDeadCodeLevel(10)
Now you can improve your code base one rule at a time. The rules are sorted from the easiest to integrate, e.g. add void
to closure, to more complex one. That way you can improve your code base in your own pace. We're collecting feedback on rule order, so the levels will likely change.
New and Improved Commands
- We added a new command to generate bare custom rule files and structure for you:
vendor/bin/rector custom-rule
Call the command, type the rule name and rule, its test and composer autoload is generated for you. So you can focus on the contents of refactor()
method.
- We improve the command, that generates Github and Gitlab CI setup files, so you can let Rector work for you:
vendor/bin/rector setup-ci
The command handles generic setup for you and then guides you to register needed access.
Released Rector 0.19.8
Released Rector 0.19.7
Bugfixes 🐛
- [TypeDeclaration] Skip assign in construct with method call property same name on RestoreDefaultNullToNullableTypePropertyRector (#5556)
- [Privatization] Fix reprint with attribute on FinalizeTestCaseClassRector (#5557)
- [DX] Fix missing Rector\RectorGenerator\Exception\ConfigurationException (#5558)
- Fix platform version resolution, use require first (#5555)
- bump template version (rectorphp/rector-src@02a088c)
Released Rector 0.19.6
New Features and Changes 🥳
- [EarlyReturn] Improve RemoveAlwaysElseRector to handle multiple ElseIfs (#8178) (#5521), Thanks @pkvach!
- [Privatization] Add FinalizeTestCaseClassRector (#5539)
- Add support for YieldFrom into places where Yield_ is checked (#5499), Thanks @integer!
- [Transform] Add RectorConfigBuilderRector (#5551)
- [DX] Warn about run on /vendor directory (#5525)
- [DX] PHP sets should not disable all other version-based rules (#5527)
- [stabilize] Deprecate FinalizeClassesWithoutChildrenRector as causing bugs without full context (#5535)
Bugfixes 🐛
- Fix xdebug handling (#5544), Thanks @staabm!
- Added 4 methods into RectorConfigBuilder (#5524), Thanks @Perf!
- Fix AddMethodCallBasedStrictParamTypeRector if already has a type (#5530)
- [CodingStyle] Return null on no change on StrictArraySearchRector (#5528)
- [Php81] Allow nullable union on NullToStrictStringFuncCallArgRector (#5532)
- [stabilize] Deprecate FinalizePublicClassConstantRector as not reliable and causes uncontroller changed (#5534)
- [TypeDeclaration] Change bool to false or true docblock when union has false/true standalone type on ReturnUnionTypeRector (#5543)
- [EarlyReturn] Skip append variable in PreparedValueToEarlyReturnRector (#8390) (#5545), Thanks @pkvach!
- Fix make ReadOnlyPropertyRector skip if traits are used, as not reliable (#5548)
- Kick off basic rector.php with simpler and more practical rule (#5552)
Removed 💀
- Exclude finalize rule from private set, to keep safer (#5523)
- [Performance] Remove CollectedData on ProcessResult (#5520)
- [stabilize] Remove family tree check from ClassMethodParamVendorLockResolver as not reliable (#5536)
- [stabilize] Remove child classes from MixedTypeRector as not reliable (#5537)
- [stabilize] Remove last children method checks (#5538)
Released Rector 0.19.5
Released Rector 0.19.4
Bugfixes 🐛
- Fix configured rule (#5517)
Released Rector 0.19.3
New Features ahd Changes 🥳
- [Config] Add RectorConfigBuilder (#5503)
- Add gitlab to "setup-ci" command (#5497)
- Add "custom-rule" command to make creating rules easy (#5498)
- [Windows] Rework add windows support on tests CI (#5504)
- make literal separator optional, as rather coding style and not always desired (#5505)
Bugfixes 🐛
- [Php70] Skip inside Encapsed on ThisCallOnStaticMethodToStaticCallRector (#5481)
- [Performance] Cache PHP version features on reading composer.json on PhpVersionProvider (#5484)
- Fix phpstan (#5489)
- [Config] Restore default values for RectorConfig->parallel() config similar to original <=0.18.x version (#5472)
- [Performance][PhpParser] Deprecate InlineCodeParser::parse(), extract into parseFile() and parseString() (#5482)
- [CodeQuality] Skip surplus open square bracket on SimplifyRegexPatternRector (#5494)
- [AutoImport] Skip start with <?= short open tag on auto import (#5496)
- [Testing] Deprecate FileInfoParser, use existing TestingParser instead (#5501)
- custom copy path fix (#5502)
- [DX] Allow Arg in value resolver, as often used and intuitive (#5512)
- [Windows] Support replace \r\n on DocBlockInliner (#5513)
- [Php83] add string type to concat constant (#5516), Thanks @jdohuutin!
Removed 💀
Released Rector 0.19.2
New features and Changes 🎉
- [DX] Depreate heavy and conflicting Symfony/Twig/PHPUnit level sets (#5477)
- Remove collectors, as performance very costly and not practically useful (#5470)
Bugfixes 🐛
- Fix repeated timeouts on CI - #8403, #8396
- Bump PHPStan to 1.10.56 (#5471)
- Remove collector interface and fix SpatieEnumClassToEnumRector already has underscore to double underscore (#5473)
- [DX] Depreate heavy and conflicting Symfony/Twig/PHPUnit level sets (#5477)