Skip to content

Instantly share code, notes, and snippets.

@tomasfejfar
Created February 4, 2013 18:24
Show Gist options
  • Save tomasfejfar/4708522 to your computer and use it in GitHub Desktop.
Save tomasfejfar/4708522 to your computer and use it in GitHub Desktop.
Nasty bug/fail in Zend_View_Abstract
<?php
/**
* Clear all assigned variables
*
* Clears all variables assigned to Zend_View either via {@link assign()} or
* property overloading ({@link __set()}).
*
* @return void
*/
public function clearVars()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if ('_' != substr($key, 0, 1)) {
unset($this->$key);
}
}
}
@weierophinney
Copy link

This was a necessary hack in ZF1. Since the coding standards used underscores to indicate non-public visibility, the way to play nice when extending it is to keep non-public members underscore-prefixed.

There's really no clean way to fix this, as the variables are members of the view object itself. We fixed it in ZF2... but only by making architectural changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment