Method can be whitelisted on the root level of the context or
for arbitrary paths. A special method "*" will allow all methods
to be called.
Examples:
$context->whitelist('myMethod');
$context->whitelist('*');
$context->whitelist(array('String.*', 'Array.reverse'));
/** * @test */ public function chainedCallsArePossibleWithExplicitContextWrapping() { $context = new ProtectedContext(['q' => function ($value) { $context = new ProtectedContext(['count' => function () use($value) { return count($value); }]); $context->whitelist('*'); return $context; }, 'value' => ['Foo', 'Bar']]); $context->whitelist('q'); $evaluator = new CompilingEvaluator(); $result = $evaluator->evaluate('q(value).count()', $context); $this->assertEquals(2, $result); }