public function optimize(array $expression, Call $call, CompilationContext $context)
{
if (!isset($expression['parameters'])) {
return false;
}
$charlist = 'NULL ';
if (count($expression['parameters']) == 2) {
if ($expression['parameters'][1]['parameter']['type'] == 'null') {
unset($expression['parameters'][1]);
}
}
/**
* Process the expected symbol to be returned
*/
$call->processExpectedReturn($context);
$symbolVariable = $call->getSymbolVariable(true, $context);
if ($symbolVariable->isNotVariableAndString()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}
$context->headersManager->add('kernel/string');
$symbolVariable->setDynamicTypes('string');
$resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression);
if (isset($resolvedParams[1])) {
$charlist = $resolvedParams[1];
}
if ($call->mustInitSymbolVariable()) {
$symbolVariable->initVariant($context);
}
$symbol = $context->backend->getVariableCode($symbolVariable);
$context->codePrinter->output('zephir_fast_trim(' . $symbol . ', ' . $resolvedParams[0] . ', ' . $charlist . ', ' . static::$TRIM_WHERE . ' TSRMLS_CC);');
return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
}