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

Creates a variable from a symbol and adds it to the context.
public addSymbol ( string $name ) : Variable
$name string
Результат Variable
Пример #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);
     }
 }
Пример #2
0
 /**
  * @param Context $context
  * @return bool
  */
 public function compile(Context $context)
 {
     if ($this->st->getDocComment() === null) {
         return $context->notice('missing-docblock', sprintf('Missing docblock for %s() method', $this->name), $this->st);
     }
     if (count($this->ast) == 0) {
         return $context->notice('not-implemented-method', sprintf('Method %s() is not implemented', $this->name), $this->st);
     }
     if (count($this->st->params) > 0) {
         /** @var  Node\Param $parameter */
         foreach ($this->st->params as $parameter) {
             $context->addSymbol($parameter->name);
         }
     }
     foreach ($this->ast as $st) {
         $result = \PHPSA\nodeVisitorFactory($st, $context);
     }
 }
Пример #3
0
 /**
  * Compile function to check it
  *
  * @param Context $context
  * @return bool
  */
 public function compile(Context $context)
 {
     $this->compiled = true;
     $context->scopePointer = $this->getPointer();
     $context->setScope(null);
     if (count($this->statement->stmts) == 0) {
         return $context->notice('not-implemented-function', sprintf('Function %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);
     }
     return true;
 }