hasVariableType() public method

public hasVariableType ( string $variableName ) : boolean
$variableName string
return boolean
 /**
  * @param \PhpParser\Node\Expr\ClosureUse $node
  * @param \PHPStan\Analyser\Scope $scope
  * @return string[]
  */
 public function processNode(Node $node, Scope $scope) : array
 {
     if ($node->byRef) {
         return [];
     }
     if (!$scope->hasVariableType($node->var)) {
         return [sprintf('Undefined variable: $%s', $node->var)];
     }
     return [];
 }
Ejemplo n.º 2
0
 /**
  * @param \PhpParser\Node\Expr\Variable $node
  * @param \PHPStan\Analyser\Scope $scope
  * @return string[]
  */
 public function processNode(Node $node, Scope $scope) : array
 {
     if (!is_string($node->name)) {
         return [];
     }
     if (in_array($node->name, ['GLOBALS', '_SERVER', '_GET', '_POST', '_FILES', '_COOKIE', '_SESSION', '_REQUEST', '_ENV'], true)) {
         return [];
     }
     if ($scope->isInVariableAssign($node->name)) {
         return [];
     }
     if (!$scope->hasVariableType($node->name)) {
         return [sprintf('Undefined variable: $%s', $node->name)];
     }
     return [];
 }