Zephir\Call::getSymbolVariable PHP Method

getSymbolVariable() public method

Returns the symbol variable that must be returned by the call
public getSymbolVariable ( boolean $useTemp = false, zephir\CompilationContext $compilationContext = null ) : Variable
$useTemp boolean
$compilationContext zephir\CompilationContext
return Variable
    public function getSymbolVariable($useTemp = false, CompilationContext $compilationContext = null)
    {
        $symbolVariable = $this->_symbolVariable;
        if ($useTemp && !is_object($symbolVariable)) {
            return $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext);
        }
        return $symbolVariable;
    }

Usage Example

 /**
  * @param array $expression
  * @param Call $call
  * @param CompilationContext $context
  * @return CompiledExpression|mixed
  * @throws CompilerException
  */
 public function optimize(array $expression, Call $call, CompilationContext $context)
 {
     if (isset($expression['parameters'])) {
         if (count($expression['parameters']) != 0) {
             throw new CompilerException("This function doesn't require parameters", $expression);
         }
     }
     /**
      * Process the expected symbol to be returned
      */
     $call->processExpectedReturn($context);
     $symbolVariable = $call->getSymbolVariable(true, $context);
     if ($symbolVariable) {
         if (!$symbolVariable->isVariable()) {
             throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
         }
     }
     if ($call->mustInitSymbolVariable()) {
         $symbolVariable->initVariant($context);
     }
     $context->headersManager->add('kernel/memory');
     $context->codePrinter->output('zephir_create_symbol_table(TSRMLS_C);');
     $context->codePrinter->output('');
     return new CompiledExpression('null', null, $expression);
 }
All Usage Examples Of Zephir\Call::getSymbolVariable