/** * 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); }
/** * 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); }
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()); }
public function testIsArray() { $compiledExpression = new CompiledExpression(CompiledExpression::ARR); parent::assertTrue($compiledExpression->isArray()); }