control.php getTemplate returns null minibug

Notice: This thread is very old.

6 years ago

Member | 187


i've recently discovered, that getTemplate forces object from createTemplate to be instance of Nette\Templating\ITemplate, but if someone omits return value in createTemplate (for example netbeans' autocreated forgotten method) and null is returned, following code does not force class instance.

$value = $this->createTemplate();
// if $value is null here, minibug appears and strange error is shown (creating default object from empty value whenever $template = $this->getTemplate(); $template->a = 'b'; is used)
if (!$value instanceof Nette\Templating\ITemplate && $value !== NULL) {
$class2 = get_class($value); $class = get_class($this);
throw new Nette\UnexpectedValueException("Object returned by $class::createTemplate() must be instance of Nette\\Templating\\ITemplate, '$class2' given.");
$this->template = $value;

i know it is ok when method returns null instead of object, but i think here it is not the purpose

Last edited by Ascaria (2014-04-01 09:36)