also these two line:
$subForm = $this->{$spec}
$subForm = $spec;
public function prepareSubForm($spec)
{
if (is_string($spec)) {
$subForm = $this->{$spec};
} elseif ($spec instanceof Zend_Form_SubForm) {
$subForm = $spec;
} else {
throw new Exception('Invalid argument passed to ' .
__FUNCTION__ . '()');
}
$this->setSubFormDecorators($subForm)
->addSubmitButton($subForm)
->addSubFormActions($subForm);
return $subForm;
}
It’s said in the Variable Variables part of the documentation:
In this code there’s no syntax-related reason to use
$this->{$spec}instead of$this->$spec.But:
the first form may be more readable to some teams (= enforced by the code conventions)
perhaps in the past there was an expression here (like
$this->{'_' . $spec}), for example. And if you try to use an expression as ‘variable property name’, you need to use curve braces to delimit it.As for difference between
$specand$this->$spec, it’s more clear. This method can work with two types of its single argument:if
$specis ofStringtype, it’s viewed as the name of property; this property is what will be processed (decorated) later;if
$specisZend_Form_SubFormobject, this object will be decorated instead.