public function preCompile(Context $context)
{
if ($this->statement->uses) {
/**
* Store variables from User to next restore Context
*/
foreach ($this->statement->uses as $variable) {
$variable = $context->getSymbol($variable->var);
if ($variable) {
$variable->incGets();
$this->symbolTable->add(clone $variable);
}
}
}
}
/** * @param \PhpParser\Node\Expr\Closure $expr * @param Context $context * @return mixed */ protected function compile($expr, Context $context) { $closure = new ClosureDefinition($expr); $closure->setFilepath($context->getFilepath()); $closure->preCompile(clone $context); return new CompiledExpression(CompiledExpression::CALLABLE_TYPE, $closure); }