[CodeQuality] CodeQuality config set list clean up (#606)

* [CodeQuality] CodeQuality config set list clean up

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Abdul Malik Ikhsan 2021-08-07 03:01:54 +07:00 committed by GitHub
parent 45766e1d95
commit bb384013c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 8 deletions

View File

@ -41,6 +41,7 @@ use Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector;
use Rector\CodeQuality\Rector\FuncCall\UnwrapSprintfOneArgumentRector;
use Rector\CodeQuality\Rector\FunctionLike\RemoveAlwaysTrueConditionSetInConstructorRector;
use Rector\CodeQuality\Rector\Identical\BooleanNotIdenticalToNotIdenticalRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\Identical\GetClassToInstanceOfRector;
use Rector\CodeQuality\Rector\Identical\SimplifyArraySearchRector;
use Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector;
@ -71,6 +72,7 @@ use Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector;
use Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector;
use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
use Rector\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector;
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
use Rector\Php52\Rector\Property\VarToPublicPropertyRector;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
@ -177,4 +179,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services->set(FuncGetArgsToVariadicParamRector::class);
$services->set(CallUserFuncToMethodCallRector::class);
$services->set(CallUserFuncWithArrowFunctionToInlineRector::class);
$services->set(CountArrayToEmptyArrayComparisonRector::class);
$services->set(FlipTypeControlToUseExclusiveTypeRector::class);
};

View File

@ -35,6 +35,11 @@ final class SetList implements SetListInterface
*/
public const CODING_STYLE = __DIR__ . '/../../../config/set/coding-style.php';
/**
* @var string
*/
public const CODING_STYLE_ADVANCED = __DIR__ . '/../../../config/set/coding-style-advanced.php';
/**
* @var string
*/

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Rector\Testing\PHPUnit\Behavior;
use Nette\Utils\FileSystem;
use Rector\Core\Exception\ShouldNotHappenException;
use Symplify\SmartFileSystem\SmartFileInfo;
@ -31,14 +32,14 @@ trait MultipleFilesChangedTrait
if (trim($expectedContent)) {
$fixtureContent .= $separator . $expectedContent;
}
file_put_contents($fixturePath, $fixtureContent);
FileSystem::write($fixturePath, $fixtureContent);
$newFileInfo = new SmartFileInfo($fixturePath);
$this->doTestFileInfo($newFileInfo, $allowMatches);
$this->checkAdditionalChanges($expectedFileChanges);
if (file_exists($fixturePath)) {
unlink($fixturePath);
FileSystem::delete($fixturePath);
}
}
@ -59,7 +60,7 @@ trait MultipleFilesChangedTrait
$input = isset($additionalFileChange[1]) ? trim($additionalFileChange[1]) : null;
if ($input) {
$this->createFixtureDir($fullPath);
file_put_contents($fullPath, $input);
FileSystem::write($fullPath, $input);
}
$expectedFileChanges[$fullPath] = isset($additionalFileChange[2]) ? trim($additionalFileChange[2]) : '';
@ -84,7 +85,7 @@ trait MultipleFilesChangedTrait
$realFileContent = $addedFile ? trim($addedFile->getFileContent()) : null;
$this->assertSame($expectedFileChange, $realFileContent);
if (file_exists($path)) {
unlink($path);
FileSystem::delete($path);
}
}
}

View File

@ -22,8 +22,8 @@ use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (ContainerConfigurator $containerConfigurator): void {
// include sets
$containerConfigurator->import(SetList::CODING_STYLE);
$containerConfigurator->import(SetList::CODING_STYLE_ADVANCED);
$containerConfigurator->import(SetList::CODE_QUALITY);
$containerConfigurator->import(SetList::CODE_QUALITY_STRICT);
$containerConfigurator->import(SetList::DEAD_CODE);
$containerConfigurator->import(SetList::PRIVATIZATION);
$containerConfigurator->import(SetList::NAMING);

View File

@ -2,7 +2,6 @@
declare(strict_types=1);
namespace Rector\DeadCode\NodeAnalyzer;
use PhpParser\Node\Expr\Array_;
@ -13,6 +12,7 @@ use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ClassReflection;
use Rector\Core\PhpParser\AstResolver;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\PhpParser\Node\Value\ValueResolver;
@ -144,7 +144,7 @@ final class IsClassMethodUsedAnalyzer
private function isPrivateAbstractMethodInTrait(ClassMethod $classMethod, ?string $classMethodName): bool
{
if (null === $classMethodName) {
if ($classMethodName === null) {
return false;
}
@ -154,7 +154,7 @@ final class IsClassMethodUsedAnalyzer
}
$classReflection = $scope->getClassReflection();
if (null === $classReflection) {
if (! $classReflection instanceof ClassReflection) {
return false;
}

View File

@ -21,6 +21,9 @@ final class CreateJsonWithNamesForClassRector extends AbstractRector
return new RuleDefinition('Creates json with names for class', []);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes(): array
{
return [Class_::class];