declareVariable() public method

public declareVariable ( PhpParser\Node\Expr\Variable $expr, mixed $value = null, integer $type = CompiledExpression::UNKNOWN ) : CompiledExpression
$expr PhpParser\Node\Expr\Variable
$value mixed
$type integer
return PHPSA\CompiledExpression
コード例 #1
0
ファイル: ForeachSt.php プロジェクト: sekjun9878/phpsa
 /**
  * @param \PhpParser\Node\Stmt\Foreach_ $stmt
  * @param Context $context
  * @return CompiledExpression
  */
 public function compile($stmt, Context $context)
 {
     $expression = new Expression($context);
     $expression->compile($stmt->expr);
     if ($stmt->keyVar) {
         $keyExpression = new Expression($context);
         $keyExpression->declareVariable($stmt->keyVar);
     }
     if ($stmt->valueVar) {
         $valueExpression = new Expression($context);
         $valueExpression->declareVariable($stmt->valueVar);
     }
     if (count($stmt->stmts) > 0) {
         foreach ($stmt->stmts as $statement) {
             \PHPSA\nodeVisitorFactory($statement, $context);
         }
     } else {
         return $context->notice('not-implemented-body', 'Missing body', $stmt);
     }
 }