ZF-2934: CLONE -Zend_View_Interface sample causes Warning

Issue Type: Docs: Improvement Created: 2008-03-20T10:26:29.000+0000 Last Updated: 2012-03-28T02:17:57.000+0000 Status: Resolved Fix version(s): - 1.7.2 (23/Dec/08)

Reporter: Alex Peterson (alx) Assignee: Satoru Yoshida (satoruyoshida) Tags: - Zend_View

Related issues: Attachments:


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:


<pre class="highlight">
    public function __get($key)

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



<pre class="highlight">
    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.


Posted by Alex Peterson (alx) on 2008-03-20T12:17:42.000+0000

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?

Posted by Alex Peterson (alx) on 2008-03-20T14:40:28.000+0000

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.

Posted by Wil Sinclair (wil) on 2008-04-18T12:47:47.000+0000

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

Posted by Matthew Weier O'Phinney (matthew) on 2008-04-22T13:33:39.000+0000

Scheduling for next minor release.

Posted by old of Satoru Yoshida ( on 2008-11-30T23:37:54.000+0000

Now, Zend_View_Interface has no __get() function.

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

Posted by old of Satoru Yoshida ( on 2008-12-01T04:34:37.000+0000

Solved in SVN 12965

Posted by old of Satoru Yoshida ( on 2008-12-01T21:43:59.000+0000

This fix will be released in ver. 1.7.2

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.