fabpot/Twig — Issue #601: Twig and magic __get
Author: tiois
Created: 2012-01-16 19:21:12+00:00
State: open

I got a BaseEntity class that implements the __call() and __get() functions. In my Twig template, I call entity.name (name doesn't exists in my entity class). The __get() method never get called by Twig because of this line :

```php
// Template.php line 381
if (isset($object->$item) || array_key_exists($item, $object)) {
```

isset function returns false, while echo($object->$item) returns the appropriate value.

And because of this line :

```php
// Template.php line 406
} elseif (isset(self::$cache[$class]['methods']['__call'])) {
```

Twig is trying to call $entity->$property() instead of $entity->$property, and this is wrong.

Why is __call magic function supported but not __get ?