Exemple #1
0
 /**
  * Tests echo $stmtTest = 2; creates the variable
  */
 public function testEchoCreatesVar()
 {
     $context = $this->getContext();
     $statement = new Node\Stmt\Echo_([new Node\Expr\Assign(new Node\Expr\Variable(new Node\Name("stmtTest")), $this->newScalarExpr(2))]);
     \PHPSA\nodeVisitorFactory($statement, $context);
     $variable = $context->getSymbol("stmtTest");
     parent::assertTrue($variable instanceof Variable);
 }
Exemple #2
0
 /**
  * Tests if (1 == 1) { $stmtTest = 2; } creates the variable
  */
 public function testIfStatementCreatesVar()
 {
     $context = $this->getContext();
     $statement = new Node\Stmt\If_(new Node\Expr\BinaryOp\Equal($this->newScalarExpr(1), $this->newScalarExpr(1)), ["stmts" => [new Node\Expr\Assign(new Node\Expr\Variable(new Node\Name("stmtTest")), $this->newScalarExpr(2))]]);
     \PHPSA\nodeVisitorFactory($statement, $context);
     $variable = $context->getSymbol("stmtTest");
     parent::assertTrue($variable instanceof Variable);
 }
Exemple #3
0
 public function testEmptyVarInt()
 {
     $context = $this->getContext();
     $context->addVariable(new Variable("name", 10, CompiledExpression::INTEGER));
     $baseExpression = new Node\Expr\Empty_(new Node\Expr\Variable(new Node\Name("name")));
     $compiledExpression = $this->compileExpression($baseExpression, $context);
     parent::assertInstanceOfCompiledExpression($compiledExpression);
     parent::assertSame(CompiledExpression::BOOLEAN, $compiledExpression->getType());
     parent::assertTrue($compiledExpression->getValue());
 }
Exemple #4
0
 public function testIsArray()
 {
     $compiledExpression = new CompiledExpression(CompiledExpression::ARR);
     parent::assertTrue($compiledExpression->isArray());
 }