symfony2中不寻常的Php语法

I saw an interesting syntax in symfony 2.x and i am not sure how to call it and what type of variable it is.

In the view, There is a helper variable called $view and it can be used in for many things and here is what i don't understand

Sometimes it is used like an array:

$view['action']->someMethod();

and other times it is used as an object

$view->generateUrl(...);

Both in the same file. Dumping variables using var_dump() in symfony is not a very good idea .

So What kind of object is this, and how can I create it.

With ArrayAccess you can access to the object as array with associative keys

http://php.net/manual/en/class.arrayaccess.php