mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 13:28:18 +01:00
Updated Rector to commit f5d809ca431215d512bb0ba3894bab4543afb396
f5d809ca43
[CodingStyle] Remove AddFalseDefaultToBoolPropertyRector, as works with unrelaible docblocks (#3856)
This commit is contained in:
parent
89439d883f
commit
dca2603280
@ -26,7 +26,6 @@ use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector;
|
||||
use Rector\CodingStyle\Rector\If_\NullableCompareToNullRector;
|
||||
use Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector;
|
||||
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
|
||||
use Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector;
|
||||
use Rector\CodingStyle\Rector\Property\SplitGroupedPropertiesRector;
|
||||
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
|
||||
use Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector;
|
||||
@ -39,5 +38,5 @@ use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
||||
use Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->ruleWithConfiguration(FuncCallToConstFetchRector::class, ['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']);
|
||||
$rectorConfig->rules([SeparateMultiUseImportsRector::class, PostIncDecToPreIncDecRector::class, UnSpreadOperatorRector::class, NewlineAfterStatementRector::class, RemoveFinalFromConstRector::class, NullableCompareToNullRector::class, BinarySwitchToIfElseRector::class, ConsistentImplodeRector::class, TernaryConditionVariableAssignmentRector::class, SymplifyQuoteEscapeRector::class, StringClassNameToClassConstantRector::class, CatchExceptionNameMatchingTypeRector::class, UseIncrementAssignRector::class, SplitDoubleAssignRector::class, VarConstantCommentRector::class, EncapsedStringsToSprintfRector::class, WrapEncapsedVariableInCurlyBracesRector::class, NewlineBeforeNewAssignSetRector::class, AddArrayDefaultToArrayPropertyRector::class, AddFalseDefaultToBoolPropertyRector::class, MakeInheritedMethodVisibilitySameAsParentRector::class, CallUserFuncArrayToVariadicRector::class, VersionCompareFuncCallToConstantRector::class, StaticArrowFunctionRector::class, StaticClosureRector::class, CountArrayToEmptyArrayComparisonRector::class, CallUserFuncToMethodCallRector::class, FuncGetArgsToVariadicParamRector::class, StrictArraySearchRector::class, UseClassKeywordForClassNameResolutionRector::class, SplitGroupedPropertiesRector::class, SplitGroupedClassConstantsRector::class]);
|
||||
$rectorConfig->rules([SeparateMultiUseImportsRector::class, PostIncDecToPreIncDecRector::class, UnSpreadOperatorRector::class, NewlineAfterStatementRector::class, RemoveFinalFromConstRector::class, NullableCompareToNullRector::class, BinarySwitchToIfElseRector::class, ConsistentImplodeRector::class, TernaryConditionVariableAssignmentRector::class, SymplifyQuoteEscapeRector::class, StringClassNameToClassConstantRector::class, CatchExceptionNameMatchingTypeRector::class, UseIncrementAssignRector::class, SplitDoubleAssignRector::class, VarConstantCommentRector::class, EncapsedStringsToSprintfRector::class, WrapEncapsedVariableInCurlyBracesRector::class, NewlineBeforeNewAssignSetRector::class, AddArrayDefaultToArrayPropertyRector::class, MakeInheritedMethodVisibilitySameAsParentRector::class, CallUserFuncArrayToVariadicRector::class, VersionCompareFuncCallToConstantRector::class, StaticArrowFunctionRector::class, StaticClosureRector::class, CountArrayToEmptyArrayComparisonRector::class, CallUserFuncToMethodCallRector::class, FuncGetArgsToVariadicParamRector::class, StrictArraySearchRector::class, UseClassKeywordForClassNameResolutionRector::class, SplitGroupedPropertiesRector::class, SplitGroupedClassConstantsRector::class]);
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
# 406 Rules Overview
|
||||
# 405 Rules Overview
|
||||
|
||||
<br>
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
- [CodeQuality](#codequality) (76)
|
||||
|
||||
- [CodingStyle](#codingstyle) (35)
|
||||
- [CodingStyle](#codingstyle) (34)
|
||||
|
||||
- [Compatibility](#compatibility) (1)
|
||||
|
||||
@ -1865,25 +1865,6 @@ Adds array default value to property to prevent foreach over null error
|
||||
|
||||
<br>
|
||||
|
||||
### AddFalseDefaultToBoolPropertyRector
|
||||
|
||||
Add false default to bool properties, to prevent null compare errors
|
||||
|
||||
- class: [`Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector`](../rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php)
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
- private $isDisabled;
|
||||
+ private $isDisabled = false;
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### BinarySwitchToIfElseRector
|
||||
|
||||
Changes switch with 2 options to if-else
|
||||
|
@ -1,90 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\CodingStyle\Rector\Property;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PhpParser\Node\Stmt\Trait_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Tests\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector\AddFalseDefaultToBoolPropertyRectorTest
|
||||
*/
|
||||
final class AddFalseDefaultToBoolPropertyRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector
|
||||
*/
|
||||
private $constructorAssignDetector;
|
||||
public function __construct(ConstructorAssignDetector $constructorAssignDetector)
|
||||
{
|
||||
$this->constructorAssignDetector = $constructorAssignDetector;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Add false default to bool properties, to prevent null compare errors', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isDisabled;
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
class SomeClass
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isDisabled = false;
|
||||
}
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [Property::class];
|
||||
}
|
||||
/**
|
||||
* @param Property $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (\count($node->props) !== 1) {
|
||||
return null;
|
||||
}
|
||||
$onlyProperty = $node->props[0];
|
||||
if ($onlyProperty->default instanceof Expr) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isBoolDocType($node)) {
|
||||
return null;
|
||||
}
|
||||
$classLike = $this->betterNodeFinder->findParentByTypes($node, [Class_::class, Trait_::class]);
|
||||
if (!$classLike instanceof ClassLike) {
|
||||
return null;
|
||||
}
|
||||
$propertyName = $this->nodeNameResolver->getName($onlyProperty);
|
||||
if ($this->constructorAssignDetector->isPropertyAssigned($classLike, $propertyName)) {
|
||||
return null;
|
||||
}
|
||||
$onlyProperty->default = $this->nodeFactory->createFalse();
|
||||
return $node;
|
||||
}
|
||||
private function isBoolDocType(Property $property) : bool
|
||||
{
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property);
|
||||
return $phpDocInfo->getVarType()->isBoolean()->yes();
|
||||
}
|
||||
}
|
@ -10,7 +10,6 @@ use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Rector\AbstractScopeAwareRector;
|
||||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\Core\ValueObject\MethodName;
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '95b1789a871adeb6b6555949d3cf32b0b4060613';
|
||||
public const PACKAGE_VERSION = 'f5d809ca431215d512bb0ba3894bab4543afb396';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-05-15 10:47:28';
|
||||
public const RELEASE_DATE = '2023-05-15 12:15:45';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit2fc8f3f560d57b6aed8370ebb6017e13::getLoader();
|
||||
return ComposerAutoloaderInit0b1c1df6018da3caffb4cb03f14fa863::getLoader();
|
||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -1340,7 +1340,6 @@ return array(
|
||||
'Rector\\CodingStyle\\Rector\\MethodCall\\PreferThisOrSelfMethodCallRector' => $baseDir . '/rules/CodingStyle/Rector/MethodCall/PreferThisOrSelfMethodCallRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Plus\\UseIncrementAssignRector' => $baseDir . '/rules/CodingStyle/Rector/Plus/UseIncrementAssignRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\PostInc\\PostIncDecToPreIncDecRector' => $baseDir . '/rules/CodingStyle/Rector/PostInc/PostIncDecToPreIncDecRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\AddFalseDefaultToBoolPropertyRector' => $baseDir . '/rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\NullifyUnionNullableRector' => $baseDir . '/rules/CodingStyle/Rector/Property/NullifyUnionNullableRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\SplitGroupedPropertiesRector' => $baseDir . '/rules/CodingStyle/Rector/Property/SplitGroupedPropertiesRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Stmt\\NewlineAfterStatementRector' => $baseDir . '/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php',
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit2fc8f3f560d57b6aed8370ebb6017e13
|
||||
class ComposerAutoloaderInit0b1c1df6018da3caffb4cb03f14fa863
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit2fc8f3f560d57b6aed8370ebb6017e13
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit2fc8f3f560d57b6aed8370ebb6017e13', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit0b1c1df6018da3caffb4cb03f14fa863', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit2fc8f3f560d57b6aed8370ebb6017e13', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit0b1c1df6018da3caffb4cb03f14fa863', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit2fc8f3f560d57b6aed8370ebb6017e13::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit0b1c1df6018da3caffb4cb03f14fa863::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit2fc8f3f560d57b6aed8370ebb6017e13::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit0b1c1df6018da3caffb4cb03f14fa863::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit2fc8f3f560d57b6aed8370ebb6017e13
|
||||
class ComposerStaticInit0b1c1df6018da3caffb4cb03f14fa863
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -1582,7 +1582,6 @@ class ComposerStaticInit2fc8f3f560d57b6aed8370ebb6017e13
|
||||
'Rector\\CodingStyle\\Rector\\MethodCall\\PreferThisOrSelfMethodCallRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/MethodCall/PreferThisOrSelfMethodCallRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Plus\\UseIncrementAssignRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Plus/UseIncrementAssignRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\PostInc\\PostIncDecToPreIncDecRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/PostInc/PostIncDecToPreIncDecRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\AddFalseDefaultToBoolPropertyRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Property/AddFalseDefaultToBoolPropertyRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\NullifyUnionNullableRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Property/NullifyUnionNullableRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Property\\SplitGroupedPropertiesRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Property/SplitGroupedPropertiesRector.php',
|
||||
'Rector\\CodingStyle\\Rector\\Stmt\\NewlineAfterStatementRector' => __DIR__ . '/../..' . '/rules/CodingStyle/Rector/Stmt/NewlineAfterStatementRector.php',
|
||||
@ -3106,9 +3105,9 @@ class ComposerStaticInit2fc8f3f560d57b6aed8370ebb6017e13
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit2fc8f3f560d57b6aed8370ebb6017e13::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit2fc8f3f560d57b6aed8370ebb6017e13::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit2fc8f3f560d57b6aed8370ebb6017e13::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit0b1c1df6018da3caffb4cb03f14fa863::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit0b1c1df6018da3caffb4cb03f14fa863::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit0b1c1df6018da3caffb4cb03f14fa863::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user