PHPSA\Context::addSymbol PHP Метод

addSymbol() публичный Метод

Creates a variable from a symbol and adds it to the context.
public addSymbol ( string $name ) : Variable
$name string
Результат Variable
    public function addSymbol($name)
    {
        $variable = new Variable($name);
        $this->symbols[$name] = $variable;
        return $variable;
    }

Usage Example

Пример #1
0
 /**
  * @param Context $context
  * @return boolean|null
  */
 public function compile(Context $context)
 {
     $this->compiled = true;
     $context->scopePointer = $this->getPointer();
     if ($this->statement->getDocComment() === null) {
         $context->notice('missing-docblock', sprintf('Missing docblock for %s() method', $this->name), $this->statement);
     }
     /**
      * It's not needed to compile empty method via it's abstract
      */
     if ($this->isAbstract()) {
         /** @var ClassDefinition $scope */
         $scope = $context->scope;
         if (!$scope->isAbstract()) {
             $context->notice('not-abstract-class-with-abstract-method', 'Class must be an abstract', $this->statement);
         }
         return true;
     }
     if (count($this->statement->stmts) == 0) {
         return $context->notice('not-implemented-method', sprintf('Method %s() is not implemented', $this->name), $this->statement);
     }
     if (count($this->statement->params) > 0) {
         /** @var  Node\Param $parameter */
         foreach ($this->statement->params as $parameter) {
             $context->addSymbol($parameter->name);
         }
     }
     foreach ($this->statement->stmts as $st) {
         \PHPSA\nodeVisitorFactory($st, $context);
     }
 }
All Usage Examples Of PHPSA\Context::addSymbol