[cs] update variable names

This commit is contained in:
TomasVotruba 2020-05-03 13:38:00 +02:00
parent 163b7831cb
commit ab4fe09dc3
7 changed files with 35 additions and 35 deletions

View File

@ -44,12 +44,12 @@ final class FunctionMethodAndClassNodeVisitor extends NodeVisitorAbstract
/**
* @var ClassLike|null
*/
private $classNode;
private $classLike;
/**
* @var ClassMethod|null
*/
private $methodNode;
private $classMethod;
/**
* @var Function_|null
@ -72,10 +72,10 @@ final class FunctionMethodAndClassNodeVisitor extends NodeVisitorAbstract
*/
public function beforeTraverse(array $nodes): ?array
{
$this->classNode = null;
$this->classLike = null;
$this->className = null;
$this->methodName = null;
$this->methodNode = null;
$this->classMethod = null;
$this->functionNode = null;
return null;
@ -99,7 +99,7 @@ final class FunctionMethodAndClassNodeVisitor extends NodeVisitorAbstract
$this->setClassNodeAndName(array_pop($this->classStack));
}
if ($node instanceof ClassMethod) {
$this->methodNode = array_pop($this->methodStack);
$this->classMethod = array_pop($this->methodStack);
$this->methodName = (string) $this->methodName;
}
return null;
@ -108,30 +108,30 @@ final class FunctionMethodAndClassNodeVisitor extends NodeVisitorAbstract
private function processClass(Node $node): void
{
if ($node instanceof ClassLike) {
$this->classStack[] = $this->classNode;
$this->classStack[] = $this->classLike;
$this->setClassNodeAndName($node);
}
$node->setAttribute(AttributeKey::CLASS_NODE, $this->classNode);
$node->setAttribute(AttributeKey::CLASS_NODE, $this->classLike);
$node->setAttribute(AttributeKey::CLASS_NAME, $this->className);
$node->setAttribute(AttributeKey::CLASS_SHORT_NAME, $this->classShortName);
if ($this->classNode instanceof Class_) {
$this->setParentClassName($this->classNode, $node);
if ($this->classLike instanceof Class_) {
$this->setParentClassName($this->classLike, $node);
}
}
private function processMethod(Node $node): void
{
if ($node instanceof ClassMethod) {
$this->methodStack[] = $this->methodNode;
$this->methodStack[] = $this->classMethod;
$this->methodNode = $node;
$this->classMethod = $node;
$this->methodName = (string) $node->name;
}
$node->setAttribute(AttributeKey::METHOD_NAME, $this->methodName);
$node->setAttribute(AttributeKey::METHOD_NODE, $this->methodNode);
$node->setAttribute(AttributeKey::METHOD_NODE, $this->classMethod);
}
private function processFunction(Node $node): void
@ -145,7 +145,7 @@ final class FunctionMethodAndClassNodeVisitor extends NodeVisitorAbstract
private function setClassNodeAndName(?ClassLike $classLike): void
{
$this->classNode = $classLike;
$this->classLike = $classLike;
if ($classLike === null || $classLike->name === null) {
$this->className = null;
} elseif (isset($classLike->namespacedName)) {

View File

@ -21,7 +21,7 @@ final class ParentAndNextNodeVisitor extends NodeVisitorAbstract
/**
* @var Node|null
*/
private $prev;
private $previousNode;
/**
* @param Node[] $nodes
@ -30,7 +30,7 @@ final class ParentAndNextNodeVisitor extends NodeVisitorAbstract
public function afterTraverse(array $nodes): ?array
{
$this->stack = [];
$this->prev = null;
$this->previousNode = null;
return null;
}
@ -44,11 +44,13 @@ final class ParentAndNextNodeVisitor extends NodeVisitorAbstract
$node->setAttribute(AttributeKey::PARENT_NODE, $this->stack[count($this->stack) - 1]);
}
if ($this->prev &&
$this->prev->getAttribute(AttributeKey::PARENT_NODE) === $node->getAttribute(AttributeKey::PARENT_NODE)
if ($this->previousNode &&
$this->previousNode->getAttribute(AttributeKey::PARENT_NODE) === $node->getAttribute(
AttributeKey::PARENT_NODE
)
) {
$node->setAttribute(AttributeKey::PREVIOUS_NODE, $this->prev);
$this->prev->setAttribute(AttributeKey::NEXT_NODE, $node);
$node->setAttribute(AttributeKey::PREVIOUS_NODE, $this->previousNode);
$this->previousNode->setAttribute(AttributeKey::NEXT_NODE, $node);
}
$this->stack[] = $node;
@ -61,7 +63,7 @@ final class ParentAndNextNodeVisitor extends NodeVisitorAbstract
*/
public function leaveNode(Node $node)
{
$this->prev = $node;
$this->previousNode = $node;
array_pop($this->stack);
return null;

View File

@ -15,7 +15,7 @@ final class StatementNodeVisitor extends NodeVisitorAbstract
/**
* @var Stmt|null
*/
private $previousStatement;
private $previousStmt;
/**
* @param Node[] $nodes
@ -23,7 +23,7 @@ final class StatementNodeVisitor extends NodeVisitorAbstract
*/
public function beforeTraverse(array $nodes): ?array
{
$this->previousStatement = null;
$this->previousStmt = null;
return null;
}
@ -39,9 +39,9 @@ final class StatementNodeVisitor extends NodeVisitorAbstract
throw new ShouldNotHappenException('Only statement can appear at top level');
}
$node->setAttribute(AttributeKey::PREVIOUS_STATEMENT, $this->previousStatement);
$node->setAttribute(AttributeKey::PREVIOUS_STATEMENT, $this->previousStmt);
$node->setAttribute(AttributeKey::CURRENT_STATEMENT, $node);
$this->previousStatement = $node;
$this->previousStmt = $node;
}
if (isset($node->stmts)) {

View File

@ -30,7 +30,7 @@ final class RemoveDeepChainMethodCallNodeVisitor extends NodeVisitorAbstract
/**
* @var Expression|null
*/
private $nodeToRemove;
private $removingExpression;
public function __construct(BetterNodeFinder $betterNodeFinder, int $nestedChainMethodCallLimit)
{
@ -50,7 +50,7 @@ final class RemoveDeepChainMethodCallNodeVisitor extends NodeVisitorAbstract
if ($node->expr instanceof MethodCall && $node->expr->var instanceof MethodCall) {
$nestedChainMethodCalls = $this->betterNodeFinder->findInstanceOf([$node->expr], MethodCall::class);
if (count($nestedChainMethodCalls) > $this->nestedChainMethodCallLimit) {
$this->nodeToRemove = $node;
$this->removingExpression = $node;
return NodeTraverser::DONT_TRAVERSE_CHILDREN;
}
@ -64,7 +64,7 @@ final class RemoveDeepChainMethodCallNodeVisitor extends NodeVisitorAbstract
*/
public function leaveNode(Node $node)
{
if ($node === $this->nodeToRemove) {
if ($node === $this->removingExpression) {
// keep any node, so we don't remove it permanently
$nopNode = new Nop();
$nopNode->setAttributes($node->getAttributes());

View File

@ -1,6 +1,4 @@
parameters:
# is_cache_enabled: true
sets:
- 'coding-style'
- 'code-quality'

View File

@ -54,9 +54,9 @@ final class StrposMatchAndRefactor extends AbstractMatchAndRefactor implements S
/**
* @return FuncCall
*/
public function refactor(StrStartsWithValueObject $StrStartsWithValueObject): ?Node
public function refactor(StrStartsWithValueObject $strStartsWithValueObject): ?Node
{
$strposFuncCall = $StrStartsWithValueObject->getFuncCall();
$strposFuncCall = $strStartsWithValueObject->getFuncCall();
$strposFuncCall->name = new Name('str_starts_with');
return $strposFuncCall;

View File

@ -235,13 +235,13 @@ final class BetterStandardPrinter extends Standard
/**
* Emulates 1_000 in PHP 7.3- version
*/
protected function pScalar_DNumber(DNumber $DNumber): string
protected function pScalar_DNumber(DNumber $dNumber): string
{
if (is_string($DNumber->value)) {
return $DNumber->value;
if (is_string($dNumber->value)) {
return $dNumber->value;
}
return parent::pScalar_DNumber($DNumber);
return parent::pScalar_DNumber($dNumber);
}
/**