Releases: rectorphp/rector
Releases · rectorphp/rector
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)
Released Rector 0.12.18
New Features 🎉
- [TypeDeclaration] Add ArrayShapeFromConstantArrayReturnRector (#1908)
- [Transform] Add type matching to MethodCallToPropertyFetchRector (#1905)
- [Arguments] Add RemoveMethodCallParamRector (#1906)
- [CodeQuality] Add InlineConstructorDefaultToPropertyRector (#1935)
- Add StaticCall support to RemoveMethodCallParamRector (#1916)
- [DX] simplify --debug output to the proccessed file path (#1933)
Bugfixes 🐛
- [CodeQuality] Handle default value on CallableThisArrayToAnonymousFunctionRector (#1900), Thanks @samsonasik!
- [TypeDeclaration] Skip ArrayShapeFromConstantArrayReturnRector on class name as key (#1911), Thanks @samsonasik!
- [Php81] Skip override __construct from interface on NewInInitializerRector (#1913), Thanks @samsonasik!
- [Arguments] Handle by pass 2nd argument default value on ArgumentAdderRector (#1946), Thanks @samsonasik!
- [DeadCode] Handle used in anonymous class on RemoveUnusedConstructorParamRector (#1948), Thanks @samsonasik!
- [Transform] Handle property exists via Property Promotion on NewToMethodCallRector (#1915), Thanks @samsonasik!
- [Renaming] Apply rename fully qualified namespace docblock on RenameNamespaceRector (#1917), Thanks @samsonasik!
- [CodingStyle] Handle Interface suffix on CatchExceptionNameMatchingTypeRector (#1918), Thanks @samsonasik!
- [CodingStyle] Use alias name when exists on CatchExceptionNameMatchingTypeRector (#1920), Thanks @samsonasik!
- Fix some minor misprints (#1922), Thanks @bocharsky-bw!
- [Dep] Add PHPUnit\Framework\TestCase stub on target-repository bootstrap.php (#1924), Thanks @samsonasik!
- [TypeDeclaration] Fix parent method param override (#1945)
- [DeadCode][CodingStyle] Handle SplitDoubleAssignRector+RemoveUnusedPrivatePropertyRector (#1944), Thanks @samsonasik!
- [Php81] Skip static property on ReadOnlyPropertyRector (#1939), Thanks @samsonasik!
- [PHP 8.0] Fix skip of silent key in annotation to attribute (#1932)
Deprecations ⌛️
- [MockeryToProphecy] Deprecate micro set as not practical (#1899)
- [PhpSpecToPHPUnit] Deprecate historical set, mostly for experimental in early days (#1901)
- Remove old PHPSpec 3 and 4 sets (#1902)
- [Order] Deprecate rather coding standard related set, use OrderedClassElementsFixer instead (#1910)
- [Transform] Remove AddInterfaceByParentRector as never used (#1935)
- [DeadCode] Skip called by current classname on RemoveUnusedPrivateClassConstantRector (#1931), Thanks @samsonasik!
Released Rector 0.12.17
New Features 🎉
- [DX] Make progress bar less verbose on CI (#1797), #6996
- Remove min php version from
OptionalParametersAfterRequiredRector
(#1814), Thanks @leighman! - [CodeQuality] Extend SimplifyForeachToArrayFilterRector with compare cond (#1820)
- Add Projects using Rector section to README.md (#1881), Thanks @Wirone!
Bugfixes 🐛
- [Php74] Skip mixed type on TypedPropertyRector on auto import enabled (#1798), Thanks @connerbw!
- [Php74] Handle Multiple types with NullType on TypedPropertyRector when PHP 8.0 Feature enabled (#1803), Thanks @samsonasik!
- [Php74] Skip null|false type on TypedPropertyRector on php 8.0 feature enabled (#1804), Thanks @samsonasik!
- [TypeDeclaration] Use @return type on Generator on ReturnTypeDeclarationRector (#1794), Thanks @samsonasik!
- [Php74] Skip variable FuncCall $fn() on ReservedFnFunctionRector (#1815), Thanks @samsonasik!
- [TypeDeclaration] Skip @inheritdoc on PropertyTypeDeclaration (#1752), Thanks @oprypkhantc!
- [Php81] Skip used as ArrayDimFetch on Arg on side effect FuncCall on ReadOnlyPropertyRector (#1822), Thanks @samsonasik!
- Skip removing Psalm PhpDocTagNode (#1829), Thanks @rajyan!
- Fix annotation to attribute rector with doctrine table and nested uniqueConstraints option (#1850), Thanks @acrobat!
- [Php81] Add ConstFetch and ClassConstFetch arg support on NewInInitializerRector (#1848), Thanks @samsonasik!
- Do not prepend a \ to the type, if it is already Fully Qualified (#1863), Thanks @mkrauser!
- [Core] Fixing applied rules not shown when refactor() only change docblock (#1861), Thanks @samsonasik!
- [DowngradePhp72] Handle in assign on DowngradePregUnmatchedAsNullConstantRector (#1872), Thanks @samsonasik!
Changes ⚙️
- Remove deprecated show command (#1796)
- [DX] Deprecate disabling of import options to keep configuration simpler (#1817)
- [DX] Inline PARALLEL_SYSTEM_ERROR_COUNT_LIMIT option to keep user scope outside internal system (#1818)
- Deprecate RemovingStatic rules as very narrow use case in generic rules (#1819)
- [DX] Remove GenericClassMethodParamRector, rather PHPStorm one-time refactoring job (#1830)
- [DX] Remove SingleToManyMethodRector, rather one time job useful for PHPStorm (#1831)
- [DX] Remove MoveValueObjectsToValueObjectDirectoryRector, should be handled by PHPStorm refactoring and PHPStan rule checks (#1832)
- [DX] Remove deprecated constants (#1833)
- [DX] Remove MoveServicesBySuffixToDirectoryRector, better handle by PHPStan + PHPStorm refacor (#1834)
- [DX] Remove MoveInterfacesToContractNamespaceDirectoryRector as breaky, use PHPStan rule instead (#1835)
- [DX] Remove MoveEntitiesToEntityDirectoryRector, use PHPStan rule + PhpStorm refactoring instead (#1836)
Released Rector 0.12.16
New Features 🎉
- [RemoveFinalFromConstRector] (#1732), Thanks @reypm!
- [DeadCode] Add support for removal readonly property on RemoveUnusedPromotedPropertyRector (#1741), Thanks @samsonasik!
- [DowngradePhp80] Add DowngradeStringReturnTypeOnToStringRector (#1750), Thanks @samsonasik!
- [Php74] Add inlinePublic configurable for TypedPropertyRector (#1745), Thanks @samsonasik!
- [DowngradePhp72] Add DowngradePhp72JsonConstRector (#1765), Thanks @samsonasik!
- [DowngradePhp73] Add DowngradePhp73JsonConstRector (#1782), Thanks @samsonasik!
- [DowngradePhp71] Add DowngradePhp71JsonConstRector (#1784), Thanks @samsonasik!
Bugfixes 🐛
- [Php81] Skip dynamic class on NewInInitializerRector (#1736), Thanks @samsonasik!
- [Php81] Do not add final modifier on class constant that the class has children on FinalizePublicClassConstantRector (#1739), Thanks @samsonasik!
- [Php81] Handle non-dynamic + dynamic args (non-array, non-scalar) passed to New_ on NewInInitializerRector (#1737), Thanks @samsonasik!
- [Php81] Skip override abstract method on NewInInitializerRector (#1740), Thanks @samsonasik!
- [Renaming] Fix duplicate namespacing on RenameNamespaceRector (#1761), Thanks @samsonasik!
- [Php80] Fix configure should not remove annotation directly passed bool value (#1761), Thanks @samsonasik!
- [PHP 8.0] Include keys in annotation to attribute transformation (#1766)
- [CodeQuality] Skip ExplicitMethodCallOverMagicGetSetRector on method no param + variadic (#1768), Thanks @samsonasik!
Changes ⤵️
- [DX] Deprecate show command (#1758), use
--debug
option on main command instead
Released Rector 0.12.15
Bugfixes 🐛
- [FinalizePublicClassConstantRector] Ignore final classes (#1730), Thanks @reypm!
- [TypeDeclaration] Skip use return docblock on typed intersection type (#1728), Thanks @samsonasik!
- [types] Add HasPropertyTypeMapepr and HasMethodTypeMapper (#1731)
Released Rector 0.12.14
New Features 🎉
- Add --memory-limit option to pass memory limit to parallel subprocesses (#1726)
- Add option to configure followLinks of finder (#1703), Thanks @sabbelasichon!
Bugfixes 🐛
- [Php71] Skip iterable on CountOnNullRector (#1691), #6947, Thanks @samsonasik!
- [Privatization] Skip ChangeReadOnlyVariableWithDefaultValueToConstantRector when local variable never used (#1693), Thanks @samsonasik!
- Do not run
ChangeReadOnlyPropertyWithDefaultValueToConstantRector
on properties with attributes (#1694), Thanks @simPod! - [Php70] Do not take side effect on IfToSpaceshipRector (#1696), Thanks @samsonasik!
- [Php71] Skip property fetch array assigned in method call on __construct on CountOnNullRector (#1698), Thanks @samsonasik!
- [Php56] Skip AddDefaultValueForUndefinedVariableRector on empty() check (#1697), Thanks @samsonasik!
- [CodingStyle] Handle more than one method contains try catch on CatchExceptionNameMatchingTypeRector (#1706), Thanks @samsonasik!
- [Php74] Skip curly variable in string quoted on CurlyToSquareBracketArrayStringRector (#1707), Thanks @samsonasik!
- [Php80] Handle AnnotationToAttributeRector + ClassPropertyAssignToConstructorPromotionRector (#1712), Thanks @samsonasik!
- [DowngradePhp70][Transform] Add #[\ReturnTypeWillChange] on Downgrade + transform ArrayObject::getIterator() to keep working on php 8.1 (#1711), Thanks @samsonasik!
- [CodeQuality][EarlyReturn] Handle SimplifyIfElseToTernaryRector + ChangeIfElseValueAssignToEarlyReturnRector (#1710), Thanks @samsonasik!
- [Php74] Skip readonly on RestoreDefaultNullToNullableTypePropertyRector (#1713), Thanks @samsonasik!
- [DeadCode] Handle RemoveUnusedConstructorParamRector + RemoveUnusedPrivatePropertyRector (#1714), Thanks @samsonasik!
- [Naming][Php56] Do not add default value init for renamed variable from param on RenameParamToMatchTypeRector+AddDefaultValueForUndefinedVariableRector (#1716), Thanks @samsonasik!
- [Php80] Do not remove true pseudo type on UnionTypesRector (#1715), Thanks @samsonasik!
- [Downgrade 7.0] Strip unnecessary parentheses around expressions (#1617), Thanks @jtojnar!
- [DeadCode] Allow unused private property on Doctrine and JMS Serializable attribute on RemoveUnusedPrivatePropertyRector (#1718), Thanks @samsonasik!
- [DowngradePhp72] Add DowngradeJsonDecodeNullAssociativeArgRector (#1723), Thanks @samsonasik!
- [DowngradePhp72] Fix downgrade json null as true for DowngradeJsonDecodeNullAssociativeArgRector (#1724), Thanks @samsonasik!
- [TypeDeclaration] Skip Prevent object in intersection type on ReturnTypeDeclarationRector (#1727), Thanks @samsonasik!
Released Rector 0.12.13
New Features 🎉
- [DowngradePhp80] Add DowngradeNumberFormatNoFourthArgRector (#1649), Thanks @samsonasik!
- [DowngradePhp80] Use ArgsAnalyzer for has named args check (#1651), Thanks @samsonasik!
- [Parallel] Increase ParallelFileProcessor::TIMEOUT_IN_SECONDS to 120 (#1657), Thanks @samsonasik!
- [Php81] Add NullToStrictStringFuncCallArgRector (#1655), Thanks @samsonasik!
- [Parallel] Add Option PARALLEL_TIMEOUT_IN_SECONDS and PARALLEL_SYSTEM_ERROR_COUNT_LIMIT constant to allow reconfigure it in rector config (#1666), Thanks @simPod!
- Ensure autoloader is loaded in globally installed Rector (#1683), Thanks @PhilETaylor!
Bugfixes 🐛
- [Core] BetterStandardPrinter performance improvement with unnecessary regex check on no Closure Uses and no ClassMethod ReturnType (#1617), Thanks @jtojnar!
- [PhpAttribute] Fix array key of class constant reference (#1659)
- [DX] Use type safe access with PrivatePropertyAccessor (#1660)
- Do not remove final modifier from private constructors (#1663), Thanks @simPod!
- Prevent UnionTypes rule from removing
@param static
in favor foself
-typed $argument (#1655), Thanks @samsonasik! - [Php80] Handle nested attribute with constant on AnnotationAttributeRector (#1661), Thanks @Jean85!
- [CodeQuality] Do not add \ on static on CallableThisArrayToAnonymousFunctionRector (#1671), Thanks @samsonasik!
- [Php81] Skip static call in right expr of Coalesce on NewInInitializerRector (#1670), Thanks @samsonasik!
- Prevent UnionTypes rule from removing literal value scalar types (#1666), Thanks @simPod!
- [Php74] Mirror comment on Closure return to ArrowFunction expr on ClosureToArrowFunctionRector (#1677), Thanks @samsonasik!
- [Php70] Handle reverse sorting check on IfToSpaceshipRector (#1676), Thanks @samsonasik!
- [TypeDeclaration] Skip Throw_ in construct and as Expr on ReturnNeverTypeRector (#1679), Thanks @samsonasik!
- [DowngradePhp74] Do not remove non-null default value on nullable on DowngradeTypedPropertyRector (#1687), Thanks @samsonasik!
- [Naming] Fix property interface and underscore naming (#1689)
Released Rector 0.12.12
Bugfixes 🐛
- Fix memory leak (#1643), Thanks @ondrejmirtes!
- Prevent existing type override by mixed (#1642), Thanks @zingimmick!