ZF-2934: CLONE -Zend_View_Interface sample causes Warning


In Zend_View_Smarty, when using an array append operation (eg. $view->myArray[] = 'foo';) the __get overload function produces this notice: Notice: Indirect modification of overloaded property ...

To fix this you have to pass by reference - but the Zend_View_Interface/Zend_View_Abstract __get method doesn't pass by reference so I fixed it like this:


    public function __get($key)

        return $this->_smarty->get_template_vars($key);



    public function __get($key)

        return is_array($this->_smarty->get_template_vars($key)) ? new ArrayObject($this->_smarty->get_template_vars($key)) : $this->_smarty->get_template_vars($key);


I'm sure there's some way to make this more pretty by using a temp var or something, but I wanted it to be fast and simple.


OK, this get's rid of the notice but it still doesn't work (it doesn't append to the array still). Any ideas how to make this work right?

This should work: First, make sure that Zend_View_Smarty doesn't extend Zend_View_Abstract and then change:

public function __get($key)


public function &__get($key)

By passing by reference you no longer have the issues with appending to array's etc. The ArrayObject method i tested above didn't work because Smarty wouldn't iterate over the ArrayObject like an array in my testing.

Fixing obviously incorrect fix for version (fix version < affects version).

Scheduling for next minor release.

Now, Zend_View_Interface has no __get() function.

So, __get() function should be removed from zend.view.scripts.html#zend.view.scripts.templates.interface .

Solved in SVN 12965

This fix will be released in ver. 1.7.2