/** * @return array */ public function objectPathOnObjectExpressions() { $obj = new Fixtures\TestObject(); $obj->setProperty('Test'); $nested = new Fixtures\TestObject(); $nested->setProperty($obj); // Wrap an object inside a context $c = new Context(['obj' => $obj, 'nested' => $nested]); return [['obj.property', $c, 'Test'], ['nested.property.property', $c, 'Test'], ['obj.callMe("Foo")', $c, 'Hello, Foo!']]; }
/** * @test */ public function protectedContextAwareInterfaceAllowsCallsDynamicallyWithoutWhitelist() { $securedObject = new TestObject(); $securedObject->setDynamicMethodName('callMe'); $context = new ProtectedContext(['value' => $securedObject]); $evaluator = new CompilingEvaluator(); $result = $evaluator->evaluate('value.callMe("Foo")', $context); $this->assertEquals('Hello, Foo!', $result); }