Releases: rectorphp/rector
Releases · rectorphp/rector
Released Rector 0.13.4
New Features 🎉
- Update to php-parser 4.14.0 to work with literal _ number separator (#2321)
- Update to PHPStan 1.7.10 (#2424)
- [DowngradePhp82] Add DowngradeReadonlyClassRector to downgrade readonly class (#2322)
- [PHP 8.0] Add ConstantListClassToEnumRector (#2404)
- [DowngradePhp80] Add DowngradeEnumToConstantListClassRector (#2416)
- [DeadCode] Add RemoveJustPropertyFetchForAssignRector (#2423)
Bugfixes 🐛
- [PHP 8.0] Fix double annotation change on annotation to attribute (#2403)
- [Attribute] Fix UseAliasNameMatcher for the last part of use import rename (#2402)
- [Core] Fix bootstrap stubs load on PHP 7.2 when vendor/ excluded via skip() (#2394)
- [Php74] Skip nullable mixed on Php 8.0 feature enabled on TypedPropertyRector (#2414)
- [Php80] Mirror additional docblock on importNames() on ClassPropertyAssignToConstructorPromotionRector (#2410)
- [Renaming] Skip docblock rename different namespace on RenameClassRector (#2419)
Released Rector 0.13.3
Rector release downgrade is now handled in single run and with parallel run ⚡ It's faster and vendor includes only the packages it really uses.
New Features 🎉
- [Laravel] Add set for Laravel 9.x (#49), Thanks @hirenkeraliya
- [Attribures] Add annotation to attribute core rename in AnnotationToAttributeRector (#2384)
This now allows annotation to attribute rename with change in the namespace:
-use Project\Annotation\Security as SC;
+use Project\Attribute\Security as SC;
-/**
- * @SC\LoggedIn
- */
+#[SC\LoggedIn]
final class PrivateController
{
}
Bugfixes 🐛
- [Transform] Skip different method on CallableInMethodCallToVariableRector (#2395)
- [CodeQuality] Add empty array support to InlineArrayReturnAssignRector (#2397)
- [PHP 8.2] Skip readonly class on property without type in ReadOnlyClassRector (#2398)
- Add annotation to attribute core rename in AnnotationToAttributeRector (#2380)
- [DowngradePhp81] Handle crash parent Arg is missing scope on DowngradeFirstClassCallableSyntaxRector (#2387)
Changes 📆
- remove
working-dir
option as not compatible with parallel run, better handle via CI working-dir options (#2387)
Released Rector 0.13.2
Bugfixes 🐛
- Fix missing
ReflectionUnionType
class by moving stub loader to RectorContainerFactory (#2382)
Released Rector 0.13.1
New Features 🎉
- [CodeQuality] Add InlineIsAInstanceOfRector (#2364)
- [DX] Move configure to direct call in RectorConfig (#2367)
- [DX] Various config merge, improve RectorConfig methods (#2371)
- [DX] Remove non-PHP file formatting based on editorconfig, rather let external coding standard tools handle the file format (#2378)
Bugfixes 🐛
- [Php73] Skip Encapsed on StringifyStrNeedlesRector (#2352), Thanks @samsonasik!
- [TypeDeclaration] Skip curly {@inheritdoc} on AddArrayReturnDocTypeRector (#2359), Thanks @samsonasik!
- Allow to rename method if in interface (#2362)
- [Php81] Skip ArrayDimFetch from ArrayObject in Assign var on ReadOnlyPropertyRector (#2363), Thanks @samsonasik!
- [PhpDocInfo] Fixes Partial value update got duplicated on DoctrineAnnotationTagValueNode change (#1862), Thanks @samsonasik!
Released Rector 0.13 with Scope Refresh and StmtsAwareInterface
New Features 🎉
- [Php82] Add ReadOnlyClassRector (#2296), Thanks @samsonasik!
- [Order] Add a-z ordering feature to OrderAttributesRector (#2243), Thanks @Lenny4!
- [Symfony] Add CommandPropertyToAttributeRector (#163), Thanks @stephanvierkant
- [Experimental] Add refactorWithScope() method to get typed Scope easily and required (#2227)
- Add Scope refresh for changed or new nodes (#2292)
From YAML routes to Annotations 🚀
- [Symfony] Add new rule to add annotations from router configuration to symfony controllers (#169), Thanks @malteschlueter
-foo_baz:
- path: /foo/{baz}
- defaults: { _controller: FooBundle:Bar:baz, _format: json }
- methods: [ GET, POST ]
+/**
+ * @Route(name="foo_baz", path="/foo/{baz}", methods={"GET","POST"}, defaults={_format="json"})
+ */
public function bazAction(string $baz)
New StmtsAwareInterface
node
- [DX] Add StmtsAwareInterface to catch node by type (#2269)
Do you need to iterface all rules with stmts in them? Hook in one node type:
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes(): array
{
return [StmtsAwareInterface::class];
}
Bugfixes 🐛
- [CodeQuality] Skip CallableThisArrayToAnonymousFunctionRector when inside of Attribute (#2212), #6910, Thanks @samsonasik!
- Added new functions to NullToStrictStringFuncCallArgRector (#2217), Thanks @FlorinProfeanu!
- [Parallel] Fix --debug not working in parallel (#2307), Thanks @samsonasik!
- [DowngradePhp80] Handle match inside ArrowFunction on DowngradeMatchToSwitchRector (#2330), Thanks @samsonasik!
- [DowngradePhp80] Add in arrow function in return support on DowngradeMatchToSwitchRector (#2331), Thanks @samsonasik!
- [DowngradePhp80] Apply PHPStan 1.7.x-dev compatible for PhpParameterReflection (#2336), Thanks @samsonasik!
- [DeadCode] Skip used in Closure use on RemoveUnusedConstructorParamRector (#2341), Thanks @samsonasik!
- [Naming] Move collecting param names method to FunctionLikeManipulator (#2347), Thanks @samsonasik!
- [Naming] Handle Grouped use import on UseImportsResolver (#2348), Thanks @samsonasik!
Released Rector 0.12.23
This release fixes major slowdown on find parents node rules in stmts: #7144, thanks for report and provided detailed info @bobvandevijver and @jrmcpeek 🙇
Update as soon as possible to enjoy the speed again 👍
- [Code] Improve BetterNodeFinder::findFirstPrevious() to only locate previous of parent if no previous of Node (#2209), Thanks @samsonasik!
New Features 🎉
- [CodeQuality] Add InlineArrayReturnAssignRector (#2183)
- Add RectorConfigProvider to ask for configuration behave for 3rd party packages (#2187)
- [Core] Add $seconds, $maxNumberOfProcess, and $jobSize parameters to RectorConfig::parallel() method (#2188), Thanks @samsonasik!
- [DX] Move PhpVersionProvider from AbstractRector to particular services (#2189)
- [DowngradePhp80] Support match as array item in DowngradeMatchToSwitchRector (#2178), Thanks @jrstanley!
Bugfixes 🐛
- [DeadCode] Improve RemoveUnreachableStatementRector performance by return after array_splice early (#2193), Thanks @samsonasik!
- [DeadCode] Register array_splice into impure functions on PureFunctionDetector (#2194), Thanks @samsonasik!
- [CodingStyle] Skip readonly type property on AddArrayDefaultToArrayPropertyRector (#2196), Thanks @samsonasik!
- [DeadCode] Remove RemoveCodeAfterReturnRector, already handled at RemoveUnreachableStatementRector (#2199), Thanks @samsonasik!
Released Rector 0.12.22
This release slowly moves towards RectorConfig
to improve Rector isolation from your project and ease to configuration. You can read more about it here: https://getrector.org/blog/new-in-rector-012-introducing-rector-config-with-autocomplete
New Features 🎉
- [DX] Update super old configure to RectorConfig (#2121)
- [DX] Add RectorConfig upgrade rule to make upgrade easier :) (#2098)
- Improve BetterNodeFinder::findFirstPrevious() to work without statements (#2136)
- Invalidate errored files in cache, to avoid hiding errors (#2138)
- [NodeCollector] Remove CurrentStmtResolver service (#2143), Thanks @samsonasik!
- [DX] Add note warning about using old config (#2177), Thanks @dritter!
- DowngradeMatchToSwitchRector adds Method and Function call support (#2173), Thanks @jrstanley!
Bugfixes 🐛
- [Fix][InlineSimplePropertyAnnotationRector] Add test case and minor fix (#2096), Thanks @dorrogeray!
- [TypeDeclaration] Skip union param type on AddArrayParamDocTypeRector (#2119), Thanks @samsonasik!
- [TypeDeclaration] Skip return property not exists by ClassReflection on ReturnTypeDeclarationRector (#2134), Thanks @samsonasik!
- [Php80] Handle named type on JMS\AccessType on AnnotationToAttributeRector (#2141), Thanks @samsonasik!
- [DeadCode] Skip remove variable on switch use return after break on RemoveUnusedVariableAssignRector (#2145), Thanks @samsonasik!
- [Php80] Skip different type cases cond on ChangeSwitchToMatchRector (#2147), Thanks @samsonasik!
- Remove PREVIOUS_STATEMENT from StatementNodeVisitor (#2146)
- Remove CURRENT_STATEMENT where not needed (#2149)
- [Php74] Allow change protected property of final class when property only in current class on TypedPropertyRector (#2153), Thanks @samsonasik!
- Remove uses nodes attribute - part #1 (#2155)
- Disable StatementNodeVisitor (#2154)
- Remove NamespaceNodeVisitor (#2167)
- Decouple aliased object type specifier + updgrade to PHPStan 1.6 (#2170)
- [DowngradePhp80] Add Static Call Support on DowngradeMatchToSwitchRector (#2175), Thanks @samsonasik!
- Adds test for DowngradeMatchToSwitchRector match having true subject expression (#2176), Thanks @jrstanley!
- [TypeDeclaration] Skip return type defined Closure on ReturnTypeDeclarationRector (#2179), Thanks @samsonasik!
- [Doc] Document deprecated USE_NODES and CURRENT_STATEMENT constant to use existing method call when needed (#2181), Thanks @samsonasik!
- [Doctrine][Nette][TypeDeclaration] Handle add __construct with no Scope on InitializeDefaultEntityCollectionRector+RenderMethodParamToTypeDeclarationRector (#2180), Thanks @samsonasik!
Released Rector 0.12.21
New RectorConfig
to configure your rector.php
Without Effort!
Before
use Rector\Core\Configuration\Option;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PARALLEL, true);
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
$services = $containerConfigurator->services();
$services->set(TypedPropertyRector::class);
};
Now
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
$rectorConfig->importNames();
$rectorConfig->rule(TypedPropertyRector::class);
};
New Features 🎉
- Add new rule to add explicit public scope to unscoped class methods (#2022), Thanks @Firehed!
- [Transform] Add FileGetContentsAndJsonDecodeToStaticCallRector (#2059)
- Add VarAnnotationIncorrectNullableRector for fixing incorrect null type in @var (#2053), Thanks @dorrogeray!
- Add ReturnAnnotationIncorrectNullableRector for fixing incorrect null type in @return (#2060), Thanks @dorrogeray!
- [TypeDeclaration] Make TypedPropertyFromAssignsRector configurable with INLINE_PUBLIC (#2052), Thanks @samsonasik!
- Add ParamAnnotationIncorrectNullableRector for fixing incorrect null type in @param (#2069), Thanks @dorrogeray!
- Add configurable InlineSimplePropertyAnnotationRector for inlining of simple annotations (#2070), Thanks @dorrogeray!
- [Php74] Handle standalone false on php >=8 feature enabled on TypedPropertyRector (#2084), Thanks @samsonasik!
Bugfixes 🐛
- [Strict] Skip ArrayDimFetch on DisallowedEmptyRuleFixerRector (#2023), Thanks @samsonasik!
- [TypeDeclaration] Skip default type value different with type assigned (#2027), Thanks @samsonasik!
- [Php74] Skip array var type filled default null in __construct on TypedPropertyRector (#2029), Thanks @samsonasik!
- [Php74] Skip by ref used by inner Closure use on ClosureToArrowFunctionRector (#2031), Thanks @samsonasik!
- [Naming] Add Closure and Function_ on RenameParamToMatchTypeRector (#2042), Thanks @samsonasik!
- [Php56] Skip with coalesce assign on AddDefaultValueForUndefinedVariableRector (#2078), Thanks @samsonasik!
- [Php81] Skip multiple assign on __construct on ReadOnlyPropertyRector (#2088), Thanks @samsonasik!
Changes 📊
- [DX] Replace global BetterStandardPrinter from AbstractRector with autowired NodePrinterInterface for easier and specific re-use (#2036)
- Move RemovedAndAddedFilesCollector, ParameterProvider from AbstractRector to rules that actually use it (#2038)
- [DX] Remove deprecated attributes (#2039)
- Merge SimplifyDuplicatedTernaryRector to UnnecessaryTernaryExpressionRector, almost identical rule (#2046)
- Merge InArrayAndArrayKeysToArrayKeyExistsRector to ArrayKeysAndInArrayToArrayKeyExistsRector with almost identical behavior (#2047)
- Merge FollowRequireByDirRector to almost identical AbsolutizeRequireAndIncludePathRector (#2048)
- [build] fix tagging on release (rectorphp/rector-src@4519646)
Released Rector 0.12.20
- Bump min to PHP 7.2 (#1955) - following PHPStan 1.5 bump, PHP 7.1 usage of Rector is only ~0.2 %
New Features 🎉
- [DX] Remove different php version rector reporting to make run more clean (#1959)
- Re-use NeighbourClassLikePrinter (#1957)
- [Php74] Add GetCalledClassToSelfClassRector (#1971), Thanks @samsonasik!
- [Php55] Move GetCalledClassToSelfClassRector + GetCalledClassToStaticClassRector from php 7.4 to 5.5 SetList (#1972), Thanks @samsonasik!
- [DowngradePhp81] Add DowngradeArrayIsListRector (#1996), Thanks @samsonasik!
- [DowngradePhp54] Add DowngradeThisInClosureRector (#1995), Thanks @samsonasik!
- [Removing] Add RemoveNamespaceRector (#2013), #7093, Thanks @samsonasik!
Bugfixes 🐛
- Fix bug with handling bad symlinks (#1938), Thanks @inderpreet99!
- Fix stub PHPUnit\Framework\TestCase (#1960), Thanks @samsonasik!
- [TypeDeclaration] Skip ArrayShapeFromConstantArrayReturnRector on key has colon (#1962), Thanks @samsonasik!
- [TypeDeclaration] Skip key has bracket {}[] on ArrayShapeFromConstantArrayReturnRector (#1968), Thanks @samsonasik!
- [CodeQuality] Handle not identical return false then true on SimplifyIfReturnBoolRector (#1969), Thanks @samsonasik!
- [Php81] Skip anonymous class on FinalizePublicClassConstantRector (#1970), Thanks @samsonasik!
- Handle annotation import with enable AUTO_IMPORT_NAMES not changed (for non-namespaced file) (#1973), Thanks @samsonasik!
- [CodeQuality] Handle Param by reference in target method on CallableThisArrayToAnonymousFunctionRector (#1974), Thanks @samsonasik!
- [TypeDeclaration] Skip return inside array_map on ArrayShapeFromConstantArrayReturnRector (#1977), #7079, Thanks @samsonasik!
- [Privatization] Skip parent static property used by parent method on PrivatizeFinalClassPropertyRector (#1978), Thanks @samsonasik!
- [Php80] Skip empty default on ChangeSwitchToMatchRector (#1980), Thanks @samsonasik!
- [TypeDeclaration] Fix AddMethodCallBasedStrictParamTypeRector for offset type (#1982)
- Fix AddClosureReturnTypeRector for union types of mutually related classes (#1984), Thanks @samsonasik!
- [CodingStyle] Skip AddFalseDefaultToBoolPropertyRector on assigned in __construct (#1998), Thanks @samsonasik!
- [TypeDeclaration] Handle default value on not inlined assignment in __construct on TypedPropertyFromStrictConstructorRector (#2008), Thanks @samsonasik!
- [TypeDeclaration] Handle multiple methods define __construct later on TypedPropertyFromStrictConstructorRector (#2009), Thanks @samsonasik!
- [TypeDeclaration] Skip __construct in inner class on TypedPropertyFromStrictConstructorRector (#2010), Thanks @samsonasik!
- [PHPStan] Fix PHPStan notice on ParallelFileProcessor (#2011), Thanks @samsonasik!
Released Rector 0.12.19
New Features 🎉
- [DX] simplify --debug output to the proccessed file path (#1933)
- [Php80] Handle return match no default on ChangeSwitchToMatchRector (#1949), Thanks @samsonasik!
- [Php80] Handle init in before else on ChangeSwitchToMatchRector (#1952), Thanks @samsonasik!
Bugfixes 🐛
- [Php81] Skip has unset property fetch on ReadOnlyPropertyRector (#1954), Thanks @samsonasik!
- Fix stub PHPUnit\Framework\TestCase (#1954), Thanks @samsonasik!
- [TypeDeclaration] Avoid adding param type in case of different default type (#1956)