Skip to content

Commit

Permalink
rename use of getStaticType() to getType()
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Oct 7, 2021
1 parent a0fbe15 commit 89086c0
Show file tree
Hide file tree
Showing 28 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$leftStaticType = $this->getStaticType($node->left);
$rightStaticType = $this->getStaticType($node->right);
$leftStaticType = $this->getType($node->left);
$rightStaticType = $this->getType($node->right);

// objects can be different by content
if ($leftStaticType instanceof ObjectType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private function processExplicitIf(Expression $expression): ?Node
/** @var BooleanAnd|BooleanOr $booleanExpr */
$booleanExpr = $expression->expr;

$leftStaticType = $this->getStaticType($booleanExpr->left);
$leftStaticType = $this->getType($booleanExpr->left);
if (! $leftStaticType instanceof BooleanType) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private function shouldSkipForeach(Foreach_ $foreach): bool
return true;
}

$foreachValueStaticType = $this->getStaticType($foreach->expr);
$foreachValueStaticType = $this->getType($foreach->expr);
if ($foreachValueStaticType instanceof ObjectType) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private function removeForeachValueAndUseArrayKeys(Foreach_ $foreach): void

private function isArrayType(Expr $expr): bool
{
$exprType = $this->getStaticType($expr);
$exprType = $this->getType($expr);
if ($exprType instanceof ObjectType) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function refactor(Node $node): ?Node
$firstArg = $node->args[0];

$firstValue = $firstArg->value;
$firstValueStaticType = $this->getStaticType($firstValue);
$firstValueStaticType = $this->getType($firstValue);
if (! $firstValueStaticType instanceof ConstantArrayType) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function refactor(Node $node): ?Node
return null;
}

$firstArgumentStaticType = $this->getStaticType($node->args[0]->value);
$firstArgumentStaticType = $this->getType($node->args[0]->value);
if (! $firstArgumentStaticType instanceof StringType) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private function resolvePropertyFetchType(PropertyFetch $propertyFetch): Type

$defaultValue = $property->props[0]->default;
if ($defaultValue !== null) {
$resolvedTypes[] = $this->getStaticType($defaultValue);
$resolvedTypes[] = $this->getType($defaultValue);
}

$resolveAssignedType = $this->resolveAssignedTypeInStmtsByPropertyName($classLike->stmts, $propertyName);
Expand Down Expand Up @@ -240,7 +240,7 @@ private function resolveAssignedTypeInStmtsByPropertyName(array $stmts, string $
return null;
}

$resolvedTypes[] = $this->getStaticType($node->expr);
$resolvedTypes[] = $this->getType($node->expr);
return null;
});

Expand Down
2 changes: 1 addition & 1 deletion rules/CodeQuality/Rector/If_/ExplicitBoolCompareRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function refactor(Node $node): ?Node
return null;
}

$conditionStaticType = $this->getStaticType($conditionNode);
$conditionStaticType = $this->getType($conditionNode);
if ($conditionStaticType instanceof BooleanType || $conditionStaticType instanceof ConstantIntegerType) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function refactor(Node $node): ?Node
return null;
}

$constType = $this->getStaticType($node->consts[0]->value);
$constType = $this->getType($node->consts[0]->value);
if ($constType instanceof MixedType) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function refactor(Node $node): ?Node

private function isNullableNonScalarType(Node $node): bool
{
$staticType = $this->getStaticType($node);
$staticType = $this->getType($node);
if ($staticType instanceof MixedType) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion rules/DeadCode/Rector/Cast/RecastingRemovalRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function refactor(Node $node): ?Node
return null;
}

$nodeType = $this->getStaticType($node->expr);
$nodeType = $this->getType($node->expr);
if ($nodeType instanceof MixedType) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function refactor(Node $node): ?Node
return null;
}

$conditionStaticType = $this->getStaticType($node->cond);
$conditionStaticType = $this->getType($node->cond);
if (! $conditionStaticType instanceof ConstantBooleanType) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function refactor(Node $node): ?Node
return null;
}

$ifType = $this->getStaticType($node->if);
$ifType = $this->getType($node->if);
if (! $ifType instanceof BooleanType) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private function resolveRecastAssign(Param $param, Function_ | ClassMethod | Clo
$paramName = $this->getName($param->var);
$variable = new Variable($paramName);

$paramType = $this->getStaticType($param);
$paramType = $this->getType($param);
$recastedVariable = $this->recastVariabletIfScalarType($variable, $paramType);
if (! $recastedVariable instanceof Cast) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private function shouldSkip(MethodCall $methodCall): bool
return true;
}

return ! $this->getStaticType($methodCall->args[0]->value) instanceof StringType;
return ! $this->getType($methodCall->args[0]->value) instanceof StringType;
}

private function updateNode(MethodCall $methodCall): MethodCall
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private function isProbablyMysql(Expr $expr): bool
return true;
}

$staticType = $this->getStaticType($expr);
$staticType = $this->getType($expr);
$resourceType = new ResourceType();

if ($staticType->equals($resourceType)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private function renameVariable(VariableAndCallAssign $variableAndCallAssign, st

private function isClassTypeWithChildren(StaticCall | MethodCall | FuncCall $expr): bool
{
$callStaticType = $this->getStaticType($expr);
$callStaticType = $this->getType($expr);
$callStaticType = $this->typeUnwrapper->unwrapNullableType($callStaticType);

if (! $callStaticType instanceof ObjectType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function refactor(Node $node): ?Node
private function isNotThisTypePropertyFetch(Expr $expr): bool
{
if ($expr instanceof PropertyFetch) {
$variableType = $this->getStaticType($expr->var);
$variableType = $this->getType($expr->var);
return ! $variableType instanceof ThisType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private function processContinueStatement(Continue_ $continue): Break_ | Continu

private function processVariableNum(Continue_ $continue, Variable $numVariable): Continue_ | Break_
{
$staticType = $this->getStaticType($numVariable);
$staticType = $this->getType($numVariable);
if (! $staticType instanceof ConstantType) {
return $continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function refactor(Node $node): ?Node

private function processVariableNum(Break_ | Continue_ $stmt, Variable $numVariable): ?Node
{
$staticType = $this->getStaticType($numVariable);
$staticType = $this->getType($numVariable);

if ($staticType instanceof ConstantType) {
if ($staticType instanceof ConstantIntegerType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private function isStringOrStaticNonNumbericString(Expr $expr): bool
}

$value = null;
$exprStaticType = $this->getStaticType($expr);
$exprStaticType = $this->getType($expr);

if ($expr instanceof String_) {
$value = $expr->value;
Expand Down
2 changes: 1 addition & 1 deletion rules/Php71/Rector/FuncCall/CountOnNullRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function refactor(Node $node): ?Node
}

// this can lead to false positive by phpstan, but that's best we can do
$onlyValueType = $this->getStaticType($countedNode);
$onlyValueType = $this->getType($countedNode);
if ($onlyValueType instanceof ArrayType) {
if (! $this->countableAnalyzer->isCastableArrayType($countedNode)) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function refactor(Node $node): ?Node
return null;
}

$firstArgStaticType = $this->getStaticType($node->args[1]->value);
$firstArgStaticType = $this->getType($node->args[1]->value);
if (! $firstArgStaticType instanceof ObjectType) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private function shouldSkipArrayForInvalidTypeOrKeys(Expr $expr): bool
return true;
}

$arrayStaticType = $this->getStaticType($expr);
$arrayStaticType = $this->getType($expr);
if ($this->isConstantArrayTypeWithStringKeyType($arrayStaticType)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function refactor(Node $node): ?Node
return null;
}

$secondArgType = $this->getStaticType($node->args[2]->value);
$secondArgType = $this->getType($node->args[2]->value);
if ($secondArgType instanceof IntegerType) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private function createPrivateClassConst(Variable $variable, Expr $expr): ClassC

$this->mirrorComments($classConst, $variable);

$constantType = $this->getStaticType($classConst->consts[0]->value);
$constantType = $this->getType($classConst->consts[0]->value);
$this->varAnnotationManipulator->decorateNodeWithType($classConst, $constantType);

return $classConst;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function refactor(Node $node): ?MethodCall
}

$arg = $node->args[$position];
$argValueType = $this->getStaticType($arg->value);
$argValueType = $this->getType($arg->value);
if (! $argValueType instanceof ClosureType) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private function hasNeverFuncCall(ClassMethod | Function_ $functionLike): bool
continue;
}

$stmtType = $this->getStaticType($stmt);
$stmtType = $this->getType($stmt);
if ($stmtType instanceof NeverType) {
$hasNeverType = true;
}
Expand Down

0 comments on commit 89086c0

Please sign in to comment.