public function testEmptyFunction() { $function = $this->emptyFunction(); $this->assertSame('CALLABLE!!', $function->getCallableId()); $this->assertSame(0, $function->getParameters()->count()); $this->assertEquals([], $function->getParameters()->getAll()); $this->assertEquals([], $function->getParameterScopedVariableMap()); $this->assertSame(false, $function->hasScopeType()); $this->assertSame(null, $function->getScopeType()); $this->assertSame(false, $function->hasNamespace()); $this->assertSame(null, $function->getNamespace()); $this->assertSame(0, $function->countBodyExpressions()); $this->assertSame(0, $function->countBodyExpressionsUntilReturn()); $this->assertEquals([], $function->getBodyExpressions()); $this->assertEquals([], $function->getBodyExpressionsUntilReturn()); $this->assertEquals(['CALLABLE!!'], $function->getParameterIds()); $this->assertEquals(O\EvaluationContext::globalScope(), $function->getEvaluationContextFactory()->getEvaluationContext(ResolvedParameterRegistry::none())); }
public function testVariableSuperGlobalExpressionSimplifiesCorrectly() { $this->assertEquals(O\Expression::value($_POST), O\Expression::variable(O\Expression::value('_POST'))->simplify(O\EvaluationContext::globalScope())); }
protected function __construct(IEvaluationContext $context = null) { $this->context = $context ?: EvaluationContext::globalScope(); $this->requiredVariables = array_keys($this->context->getVariableTable()); }
public function testWithSpecialVariableNames() { $this->assertSame('1,2,3', O\CompiledEvaluator::fromExpressions([O\Expression::returnExpression(O\Expression::variable(O\Expression::value('a special var--')))], O\EvaluationContext::globalScope(null, ['a special var--' => '1,2,3']))->evaluate()); }