1--TEST-- 2Twig supports __call() for attributes 3--TEMPLATE-- 4{{ foo.foo }} 5{{ foo.bar }} 6--DATA-- 7class TestClassForMagicCallAttributes 8{ 9 public function getBar() 10 { 11 return 'bar_from_getbar'; 12 } 13 14 public function __call($method, $arguments) 15 { 16 if ('foo' === $method) { 17 return 'foo_from_call'; 18 } 19 20 return false; 21 } 22} 23 24return ['foo' => new TestClassForMagicCallAttributes()] 25--EXPECT-- 26foo_from_call 27bar_from_getbar 28