mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 17:00:51 +00:00
apply specific bool on code
This commit is contained in:
parent
8515839d8f
commit
3175a8857a
|
@ -70,7 +70,7 @@ CODE_SAMPLE
|
|||
{
|
||||
$this->returnNode = null;
|
||||
|
||||
if (! $node->keyVar) {
|
||||
if ($node->keyVar === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ CODE_SAMPLE
|
|||
$checkedNode
|
||||
), $this->returnNode && $this->returnNode->expr !== null ? $this->returnNode->expr : $checkedNode);
|
||||
|
||||
if ($this->returnNode) {
|
||||
if ($this->returnNode !== null) {
|
||||
return new Return_($coalesceNode);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ CODE_SAMPLE
|
|||
while ($currentNode !== null) {
|
||||
if ($currentNode instanceof If_) {
|
||||
$comparedNode = $this->ifMaintainer->matchIfNotNullReturnValue($currentNode);
|
||||
if ($comparedNode) {
|
||||
if ($comparedNode !== null) {
|
||||
$this->coalescingNodes[] = $comparedNode;
|
||||
$this->nodesToRemove[] = $currentNode;
|
||||
|
||||
|
|
|
@ -67,10 +67,15 @@ CODE_SAMPLE
|
|||
}
|
||||
|
||||
/**
|
||||
* @param If_|ElseIf_ $node
|
||||
* @param If_|ElseIf_|Ternary $node
|
||||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
// skip short ternary
|
||||
if ($node instanceof Ternary && $node->if === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($node->cond instanceof BooleanNot) {
|
||||
$conditionNode = $node->cond->expr;
|
||||
$isNegated = true;
|
||||
|
@ -124,7 +129,7 @@ CODE_SAMPLE
|
|||
}
|
||||
|
||||
/**
|
||||
* @return Smaller|Greater
|
||||
* @return Identical|Greater
|
||||
*/
|
||||
private function resolveCount(bool $isNegated, Expr $conditionNode): BinaryOp
|
||||
{
|
||||
|
|
|
@ -58,7 +58,7 @@ CODE_SAMPLE
|
|||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
$comparedNode = $this->ifMaintainer->matchIfNotNullReturnValue($node);
|
||||
if ($comparedNode) {
|
||||
if ($comparedNode !== null) {
|
||||
$insideIfNode = $node->stmts[0];
|
||||
|
||||
$nextNode = $node->getAttribute(Attribute::NEXT_NODE);
|
||||
|
@ -75,7 +75,7 @@ CODE_SAMPLE
|
|||
}
|
||||
|
||||
$comparedNode = $this->ifMaintainer->matchIfValueReturnValue($node);
|
||||
if ($comparedNode) {
|
||||
if ($comparedNode !== null) {
|
||||
$nextNode = $node->getAttribute(Attribute::NEXT_NODE);
|
||||
if (! $nextNode instanceof Return_) {
|
||||
return null;
|
||||
|
|
|
@ -7,6 +7,8 @@ final class Ternary
|
|||
public function run(int $item)
|
||||
{
|
||||
return $item ? 1 : 0;
|
||||
|
||||
return $item ?: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +23,8 @@ final class Ternary
|
|||
public function run(int $item)
|
||||
{
|
||||
return $item !== 0 ? 1 : 0;
|
||||
|
||||
return $item ?: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ CODE_SAMPLE
|
|||
return $ifNode;
|
||||
}
|
||||
|
||||
if ($secondCase->cond) {
|
||||
if ($secondCase->cond !== null) {
|
||||
// has condition
|
||||
$equalNode = new Equal($node->cond, $secondCase->cond);
|
||||
$ifNode->elseifs[] = new ElseIf_($equalNode, $this->removeBreakNodes($secondCase->stmts));
|
||||
|
|
|
@ -127,7 +127,7 @@ final class ConfigurationFactory
|
|||
|
||||
private function resolveLevelConfig(string $level): ?string
|
||||
{
|
||||
if (! $level) {
|
||||
if ($level === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ final class ConfigurationFactory
|
|||
|
||||
/** @var SplFileInfo[] $fileInfos */
|
||||
$fileInfos = iterator_to_array($finder->getIterator());
|
||||
if (! count($fileInfos)) {
|
||||
if (count($fileInfos) === 0) {
|
||||
// assume new one is created
|
||||
$match = Strings::match($level, '#(?<name>[a-zA-Z_-]+])#');
|
||||
if (isset($match['name'])) {
|
||||
|
|
|
@ -99,7 +99,7 @@ final class MarkdownOutputFormatter implements OutputFormatterInterface
|
|||
$this->symfonyStyle->writeln(sprintf('- class: `%s`', get_class($rector)));
|
||||
|
||||
$rectorDefinition = $rector->getDefinition();
|
||||
if ($rectorDefinition->getDescription()) {
|
||||
if ($rectorDefinition->getDescription() !== '') {
|
||||
$this->symfonyStyle->newLine();
|
||||
$this->symfonyStyle->writeln($rectorDefinition->getDescription());
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ final class TemplateVariablesFactory
|
|||
*/
|
||||
private function createSourceDocBlock(array $source): string
|
||||
{
|
||||
if (! $source) {
|
||||
if ($source === []) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ CODE_SAMPLE
|
|||
|
||||
$uselessAssigns = $this->resolveUselessAssignNode($propertyFetches);
|
||||
|
||||
if (count($uselessAssigns)) {
|
||||
if (count($uselessAssigns) > 0) {
|
||||
$this->removeNode($node);
|
||||
foreach ($uselessAssigns as $uselessAssign) {
|
||||
$this->removeNode($uselessAssign);
|
||||
|
|
|
@ -49,7 +49,7 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
|
||||
if ($node->getComments()) {
|
||||
if ($node->getComments() !== []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ final class RouteTagValueNode implements PhpDocChildNode
|
|||
$string .= sprintf(', name="%s"', $this->name);
|
||||
}
|
||||
|
||||
if ($this->methods) {
|
||||
if ($this->methods !== []) {
|
||||
$string .= sprintf(', methods={"%s"}', implode('", "', $this->methods));
|
||||
}
|
||||
|
||||
|
|
|
@ -311,7 +311,7 @@ CODE_SAMPLE
|
|||
}
|
||||
|
||||
$methodReflection = new ReflectionMethod($className, $methodName);
|
||||
if ($methodReflection->getReturnType()) {
|
||||
if ($methodReflection->getReturnType() !== null) {
|
||||
$staticCallReturnType = (string) $methodReflection->getReturnType();
|
||||
if (is_a($staticCallReturnType, $this->routerClass, true)) {
|
||||
return true;
|
||||
|
|
|
@ -74,7 +74,7 @@ final class FunctionLikeNodeCollector
|
|||
public function isStaticMethod(string $methodName, string $className): bool
|
||||
{
|
||||
$methodNode = $this->findMethod($methodName, $className);
|
||||
if ($methodNode) {
|
||||
if ($methodNode !== null) {
|
||||
return $methodNode->isStatic();
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ final class ComplexNodeTypeResolver
|
|||
$types = [];
|
||||
|
||||
$propertyDefault = $propertyNode->props[0]->default;
|
||||
if ($propertyDefault) {
|
||||
if ($propertyDefault !== null) {
|
||||
$types[] = $this->nodeToStringTypeResolver->resolver($propertyDefault);
|
||||
}
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ final class NodeTypeAnalyzer
|
|||
$itemTypes[$key] = $itemType . '[]';
|
||||
}
|
||||
|
||||
if (count($itemTypes)) {
|
||||
if (count($itemTypes) > 0) {
|
||||
return [implode('|', $itemTypes)];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ final class NamespaceNodeVisitor extends NodeVisitorAbstract
|
|||
public function enterNode(Node $node): ?Node
|
||||
{
|
||||
if ($node instanceof Namespace_) {
|
||||
$this->namespaceName = $node->name ? $node->name->toString() : null;
|
||||
$this->namespaceName = $node->name !== null ? $node->name->toString() : null;
|
||||
$this->namespaceNode = $node;
|
||||
$this->useNodes = $this->betterNodeFinder->findInstanceOf($node, Use_::class);
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ final class DocBlockAnalyzer
|
|||
|
||||
public function addTag(Node $node, PhpDocChildNode $phpDocChildNode): void
|
||||
{
|
||||
if ($node->getDocComment()) {
|
||||
if ($node->getDocComment() !== null) {
|
||||
$phpDocInfo = $this->createPhpDocInfoFromNode($node);
|
||||
$phpDocNode = $phpDocInfo->getPhpDocNode();
|
||||
$phpDocNode->children[] = $phpDocChildNode;
|
||||
|
@ -209,7 +209,7 @@ final class DocBlockAnalyzer
|
|||
public function addVarTag(Node $node, string $type): void
|
||||
{
|
||||
// there might be no phpdoc at all
|
||||
if ($node->getDocComment()) {
|
||||
if ($node->getDocComment() !== null) {
|
||||
$phpDocInfo = $this->createPhpDocInfoFromNode($node);
|
||||
$phpDocNode = $phpDocInfo->getPhpDocNode();
|
||||
|
||||
|
@ -265,7 +265,7 @@ final class DocBlockAnalyzer
|
|||
}
|
||||
|
||||
$phpDoc = $this->phpDocInfoPrinter->printFormatPreserving($phpDocInfo);
|
||||
if ($phpDoc) {
|
||||
if ($phpDoc !== '') {
|
||||
$node->setDocComment(new Doc($phpDoc));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -96,11 +96,11 @@ CODE_SAMPLE
|
|||
|
||||
private function getDocContent(Node $node): string
|
||||
{
|
||||
if ($node->getDocComment()) {
|
||||
if ($node->getDocComment() !== null) {
|
||||
return $node->getDocComment()->getText();
|
||||
}
|
||||
|
||||
if ($node->getComments()) {
|
||||
if ($node->getComments() !== []) {
|
||||
$docContent = '';
|
||||
foreach ($node->getComments() as $comment) {
|
||||
$docContent .= $comment->getText();
|
||||
|
|
|
@ -95,7 +95,7 @@ CODE_SAMPLE
|
|||
]);
|
||||
|
||||
// is key included? add it to foreach
|
||||
if (count($listNode->items)) {
|
||||
if (count($listNode->items) > 0) {
|
||||
/** @var ArrayItem $keyItem */
|
||||
$keyItem = array_pop($listNode->items);
|
||||
$foreachNode->keyVar = $keyItem->value;
|
||||
|
|
|
@ -105,7 +105,7 @@ CODE_SAMPLE
|
|||
$anonymousFunctionNode->params[] = new Param($parameter);
|
||||
}
|
||||
|
||||
if ($body) {
|
||||
if ($body !== []) {
|
||||
$anonymousFunctionNode->stmts = $body;
|
||||
}
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ CODE_SAMPLE
|
|||
}
|
||||
|
||||
$classConstNode = $this->constantNodeCollector->findConstant($constantName, $className);
|
||||
if ($classConstNode) {
|
||||
if ($classConstNode !== null) {
|
||||
if ($classConstNode->consts[0]->value instanceof String_) {
|
||||
/** @var String_ $stringNode */
|
||||
$stringNode = $classConstNode->consts[0]->value;
|
||||
|
|
|
@ -91,11 +91,11 @@ abstract class AbstractTypeDeclarationRector extends AbstractRector
|
|||
|
||||
if ($parentClassName !== null) {
|
||||
$parentClassNode = $this->classLikeNodeCollector->findClass($parentClassName);
|
||||
if ($parentClassNode) {
|
||||
if ($parentClassNode !== null) {
|
||||
$parentMethodNode = $parentClassNode->getMethod($methodName);
|
||||
// @todo validate type is conflicting
|
||||
// parent class method in local scope → it's ok
|
||||
if ($parentMethodNode) {
|
||||
if ($parentMethodNode !== null) {
|
||||
// parent method has no type → we cannot change it here
|
||||
return isset($parentMethodNode->params[$paramPosition]) && $parentMethodNode->params[$paramPosition]->type === null;
|
||||
}
|
||||
|
@ -120,10 +120,10 @@ abstract class AbstractTypeDeclarationRector extends AbstractRector
|
|||
$interfaceNames = $this->getClassLikeNodeParentInterfaceNames($classNode);
|
||||
foreach ($interfaceNames as $interfaceName) {
|
||||
$interface = $this->classLikeNodeCollector->findInterface($interfaceName);
|
||||
if ($interface) {
|
||||
if ($interface !== null) {
|
||||
// parent class method in local scope → it's ok
|
||||
// @todo validate type is conflicting
|
||||
if ($interface->getMethod($methodName)) {
|
||||
if ($interface->getMethod($methodName) !== null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
|
||||
if ($node->else) {
|
||||
if ($node->else !== null) {
|
||||
if (count($node->else->stmts) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ CODE_SAMPLE
|
|||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
$varTypeInfo = $this->docBlockAnalyzer->getVarTypeInfo($node);
|
||||
if ($varTypeInfo) {
|
||||
if ($varTypeInfo !== null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ final class TemplateGuesser
|
|||
{
|
||||
$bundle = Strings::match($namespace, '#(?<bundle>[\w]*Bundle)#')['bundle'] ?? '';
|
||||
$bundle = Strings::replace($bundle, '#Bundle$#');
|
||||
$bundle = $bundle ? '@' . $bundle . '/' : '';
|
||||
$bundle = $bundle !== '' ? '@' . $bundle . '/' : '';
|
||||
|
||||
$controller = $this->resolveControllerVersion5($class);
|
||||
$action = Strings::replace($method, '#Action$#');
|
||||
|
@ -96,6 +96,6 @@ final class TemplateGuesser
|
|||
$controller = strtolower($controller);
|
||||
$controller = str_replace('\\', '/', $controller);
|
||||
|
||||
return $controller ? $controller . '/' : '';
|
||||
return $controller !== '' ? $controller . '/' : '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ CODE_SAMPLE
|
|||
$renderArguments = $this->resolveRenderArguments($node, $returnNode);
|
||||
$thisRenderMethodCall = $this->createMethodCall('this', 'render', $renderArguments);
|
||||
|
||||
if (! $returnNode) {
|
||||
if ($returnNode === null) {
|
||||
// or add as last statement in the method
|
||||
$node->stmts[] = new Return_($thisRenderMethodCall);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ CODE_SAMPLE
|
|||
private function resolveRenderArguments(ClassMethod $classMethodNode, ?Return_ $returnNode): array
|
||||
{
|
||||
$arguments = [$this->resolveTemplateName($classMethodNode)];
|
||||
if (! $returnNode) {
|
||||
if ($returnNode === null) {
|
||||
return $this->createArgs($arguments);
|
||||
}
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
|
||||
if (count($newNode->args)) {
|
||||
if (count($newNode->args) > 0) {
|
||||
$methodCallNode = $this->moveArgumentsToOptions(
|
||||
$methodCallNode,
|
||||
$position,
|
||||
|
@ -230,7 +230,7 @@ CODE_SAMPLE
|
|||
$reflectionClass = new ReflectionClass($className);
|
||||
$constructorReflectionMethod = $reflectionClass->getConstructor();
|
||||
|
||||
if (! $constructorReflectionMethod) {
|
||||
if ($constructorReflectionMethod === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ CODE_SAMPLE
|
|||
|
||||
private function addBuildFormMethod(Class_ $classNode, ClassMethod $formTypeConstructorMethodNode): void
|
||||
{
|
||||
if ($classNode->getMethod('buildForm')) {
|
||||
if ($classNode->getMethod('buildForm') !== null) {
|
||||
// @todo
|
||||
return;
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
private function addConfigureOptionsMethod(Class_ $classNode, array $namesToArgs): void
|
||||
{
|
||||
if ($classNode->getMethod('configureOptions')) {
|
||||
if ($classNode->getMethod('configureOptions') !== null) {
|
||||
// @todo
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ CODE_SAMPLE
|
|||
{
|
||||
if ($firstArgument instanceof Concat) {
|
||||
$arrayNode = $this->nodeTransformer->transformConcatToStringArray($firstArgument);
|
||||
if ($arrayNode) {
|
||||
if ($arrayNode !== null) {
|
||||
$node->args[$argumentPosition] = new Arg($arrayNode);
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ CODE_SAMPLE
|
|||
|
||||
if ($firstArgument instanceof FuncCall && $this->isName($firstArgument, 'sprintf')) {
|
||||
$arrayNode = $this->nodeTransformer->transformSprintfToArray($firstArgument);
|
||||
if ($arrayNode) {
|
||||
if ($arrayNode !== null) {
|
||||
$node->args[$argumentPosition]->value = $arrayNode;
|
||||
}
|
||||
} elseif ($firstArgument instanceof String_) {
|
||||
|
@ -155,7 +155,7 @@ CODE_SAMPLE
|
|||
'sprintf'
|
||||
)) {
|
||||
$arrayNode = $this->nodeTransformer->transformSprintfToArray($createdNode->expr);
|
||||
if ($arrayNode) {
|
||||
if ($arrayNode !== null) {
|
||||
$createdNode->expr = $arrayNode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ CODE_SAMPLE
|
|||
private function processArrayItem(ArrayItem $node, array $newNodeTypes): ?Node
|
||||
{
|
||||
$matchedOldClasses = array_intersect(array_keys($this->oldToNewClasses), $newNodeTypes);
|
||||
if (! $matchedOldClasses) {
|
||||
if ($matchedOldClasses === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ final class AdditionalAutoloader
|
|||
*/
|
||||
private function autoloadDirectories(array $directories): void
|
||||
{
|
||||
if (! count($directories)) {
|
||||
if (count($directories) === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ final class CallableCollectorPopulator
|
|||
|
||||
private function ensureParameterHasType(string $type): void
|
||||
{
|
||||
if ($type) {
|
||||
if ($type !== '') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ final class ProcessCommand extends AbstractCommand
|
|||
|
||||
$this->processCommandReporter->reportRemovedFiles();
|
||||
|
||||
if ($this->errorAndDiffCollector->getErrors()) {
|
||||
if ($this->errorAndDiffCollector->getErrors() !== []) {
|
||||
$this->processCommandReporter->reportErrors($this->errorAndDiffCollector->getErrors());
|
||||
return Shell::CODE_ERROR;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ final class ProcessCommandReporter
|
|||
$this->symfonyStyle->writeln($fileDiff->getDiff());
|
||||
$this->symfonyStyle->newLine();
|
||||
|
||||
if ($fileDiff->getAppliedRectorClasses()) {
|
||||
if ($fileDiff->getAppliedRectorClasses() !== []) {
|
||||
$this->symfonyStyle->writeln('Applied rectors:');
|
||||
$this->symfonyStyle->newLine();
|
||||
$this->symfonyStyle->listing($fileDiff->getAppliedRectorClasses());
|
||||
|
|
|
@ -68,7 +68,7 @@ final class RectorServiceParametersShifter
|
|||
$nonReservedNonVariables = $this->resolveRectorConfiguration($serviceDefinition);
|
||||
|
||||
// nothing to change
|
||||
if (! count($nonReservedNonVariables)) {
|
||||
if (count($nonReservedNonVariables) === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,12 +82,12 @@ final class FilesFinder
|
|||
*/
|
||||
private function findInDirectories(array $directories, array $suffixes): array
|
||||
{
|
||||
if (! count($directories)) {
|
||||
if (count($directories) === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$absoluteDirectories = $this->filesystemTweaker->resolveDirectoriesWithFnmatch($directories);
|
||||
if (! $absoluteDirectories) {
|
||||
if ($absoluteDirectories === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ final class FilesFinder
|
|||
|
||||
private function addFilterWithExcludedPaths(Finder $finder): void
|
||||
{
|
||||
if (! $this->excludePaths) {
|
||||
if ($this->excludePaths === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ final class RectorGuard
|
|||
|
||||
public function ensureSomeRectorsAreRegistered(): void
|
||||
{
|
||||
if ($this->rectorNodeTraverser->getRectorCount()) {
|
||||
if ($this->rectorNodeTraverser->getRectorCount() !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ final class BetterNodeFinder
|
|||
public function findLastInstanceOf($nodes, string $type): ?Node
|
||||
{
|
||||
$foundInstances = $this->nodeFinder->findInstanceOf($nodes, $type);
|
||||
if (! $foundInstances) {
|
||||
if ($foundInstances === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ final class BetterNodeFinder
|
|||
|
||||
$foundNode = $this->findFirst([$node], $filter);
|
||||
// we found what we need
|
||||
if ($foundNode) {
|
||||
if ($foundNode !== null) {
|
||||
return $foundNode;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ final class CallMaintainer
|
|||
$reflectionFunctionAbstract->getDeclaringClass()->getName()
|
||||
);
|
||||
|
||||
if ($classMethodNode) {
|
||||
if ($classMethodNode !== null) {
|
||||
return $this->containsFuncGetArgsFuncCall($classMethodNode);
|
||||
}
|
||||
return $this->isExternalScopeVariadic($reflectionFunctionAbstract, $callNode);
|
||||
|
|
|
@ -47,7 +47,7 @@ final class ChildAndParentClassMaintainer
|
|||
|
||||
// not in analyzed scope, nothing we can do
|
||||
$parentClassNode = $this->classLikeNodeCollector->findClass($parentClassName);
|
||||
if (! $parentClassNode) {
|
||||
if ($parentClassNode === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ final class ChildAndParentClassMaintainer
|
|||
return;
|
||||
}
|
||||
|
||||
if (! $firstParentConstructMethodNode->params) {
|
||||
if ($firstParentConstructMethodNode->params === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ final class ChildAndParentClassMaintainer
|
|||
$childClassNodes = $this->classLikeNodeCollector->findChildrenOfClass($className);
|
||||
|
||||
foreach ($childClassNodes as $childClassNode) {
|
||||
if (! $childClassNode->getMethod('__construct')) {
|
||||
if ($childClassNode->getMethod('__construct') === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ final class ChildAndParentClassMaintainer
|
|||
{
|
||||
while ($classNode !== null) {
|
||||
$constructMethodNode = $classNode->getMethod('__construct');
|
||||
if ($constructMethodNode) {
|
||||
if ($constructMethodNode !== null) {
|
||||
return $constructMethodNode;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ final class ClassMaintainer
|
|||
): void {
|
||||
$constructorMethod = $classNode->getMethod('__construct');
|
||||
/** @var ClassMethod $constructorMethod */
|
||||
if ($constructorMethod) {
|
||||
if ($constructorMethod !== null) {
|
||||
$this->addParameterAndAssignToMethod($constructorMethod, $variableInfo, $assignNode);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -33,21 +33,21 @@ final class NameResolver
|
|||
Empty_::class => 'empty',
|
||||
// more complex
|
||||
function (ClassConst $classConstNode): ?string {
|
||||
if (! count($classConstNode->consts)) {
|
||||
if (count($classConstNode->consts) === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->resolve($classConstNode->consts[0]);
|
||||
},
|
||||
function (Property $propertyNode): ?string {
|
||||
if (! count($propertyNode->props)) {
|
||||
if (count($propertyNode->props) === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->resolve($propertyNode->props[0]);
|
||||
},
|
||||
function (Use_ $useNode): ?string {
|
||||
if (! count($useNode->uses)) {
|
||||
if (count($useNode->uses) === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ final class NodeTransformer
|
|||
|
||||
foreach ($arrayNode->items as $arrayItem) {
|
||||
$expressionNode = new Expression(new Yield_($arrayItem->value, $arrayItem->key));
|
||||
if ($arrayItem->getComments()) {
|
||||
if ($arrayItem->getComments() !== []) {
|
||||
$expressionNode->setAttribute('comments', $arrayItem->getComments());
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ final class NodeTransformer
|
|||
$arrayItems = [];
|
||||
$parts = $this->splitBySpace($node->value);
|
||||
foreach ($parts as $part) {
|
||||
if (trim($part)) {
|
||||
if (trim($part) !== '') {
|
||||
$arrayItems[] = new String_($part);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
if (! $node->extends) {
|
||||
if ($node->extends === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
if (! $node->implements) {
|
||||
if ($node->implements === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
if (! $node->implements) {
|
||||
if ($node->implements === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ CODE_SAMPLE
|
|||
}
|
||||
|
||||
$newNode = $this->processArrayDimFetchNode($node, $arrayDimFetchNode, $transformation);
|
||||
if ($newNode) {
|
||||
if ($newNode !== null) {
|
||||
return $newNode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ CODE_SAMPLE
|
|||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
// no name → skip
|
||||
if (! $node->toString()) {
|
||||
if ($node->toString() === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ CODE_SAMPLE
|
|||
private function shouldSkip(SmartFileInfo $smartFileInfo, array $nodes, array $namespaceNodes): bool
|
||||
{
|
||||
// process only namespaced file
|
||||
if (! $namespaceNodes) {
|
||||
if ($namespaceNodes === []) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ CODE_SAMPLE
|
|||
});
|
||||
|
||||
// only process file with multiple classes || class with non PSR-4 format
|
||||
if (! $nonAnonymousClassNodes) {
|
||||
if ($nonAnonymousClassNodes === []) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ abstract class AbstractRectorTestCase extends TestCase
|
|||
|
||||
protected function provideConfig(): string
|
||||
{
|
||||
if ($this->getRectorClass()) { // use local if not overloaded
|
||||
if ($this->getRectorClass() !== '') { // use local if not overloaded
|
||||
$hash = Strings::substring(
|
||||
md5($this->getRectorClass() . Json::encode($this->getRectorConfiguration())),
|
||||
0,
|
||||
|
|
Loading…
Reference in New Issue
Block a user