public function getTempVariableForWrite($type, CompilationContext $context, $init = true)
{
$variable = $this->reuseTempVariable($type, 'heap');
if (is_object($variable)) {
$variable->increaseUses();
$variable->increaseMutates();
if ($init && ($type == 'variable' || $type == 'string' || $type == 'array')) {
$variable->initVariant($context);
}
return $variable;
}
$tempVar = $this->getNextTempVar();
$variable = $this->addVariable($type, '_' . $tempVar, $context);
$variable->setIsInitialized(true, $context, array());
$variable->setTemporal(true);
$variable->increaseUses();
$variable->increaseMutates();
if ($type == 'variable' || $type == 'string' || $type == 'array') {
$variable->initVariant($context);
}
$this->registerTempVariable($type, 'heap', $variable);
return $variable;
}