PHPStan\Analyser\Scope::getClass PHP Method

getClass() public method

public getClass ( ) : null | string
return null | string
    public function getClass()
    {
        return $this->class;
    }

Usage Example

 /**
  * @param \PhpParser\Node\Stmt\ClassMethod $node
  * @param \PHPStan\Analyser\Scope $scope
  * @return string[]
  */
 public function processNode(Node $node, Scope $scope) : array
 {
     if ($node->name !== '__construct') {
         return [];
     }
     $unusedParameters = [];
     foreach ($node->params as $parameter) {
         $unusedParameters[$parameter->name] = true;
     }
     foreach ($this->getUsedVariables($node) as $variableName) {
         if (isset($unusedParameters[$variableName])) {
             unset($unusedParameters[$variableName]);
         }
     }
     $errors = [];
     if ($scope->getClass() !== null) {
         $message = sprintf('Constructor of class %s has an unused parameter $%%s.', $scope->getClass());
     } else {
         $message = 'Constructor of an anonymous class has an unused parameter $%s.';
     }
     foreach ($unusedParameters as $name => $bool) {
         $errors[] = sprintf($message, $name);
     }
     return $errors;
 }
All Usage Examples Of PHPStan\Analyser\Scope::getClass