public function visit(Node $node) { if (!$node instanceof Closure) { return; } $ctx = $this->getContext(); $newContext = new FunctionContext(); foreach ($node->uses as $use) { if ($use->byRef) { $ctx->setVariable($use->var, $use); } else { if (!$ctx->getVariable($use->var)) { $this->addError($this->createUndefinedVariableError($use)); } } $newContext->setVariable($use->var, $ctx->createVariable($use)); } foreach ($node->params as $param) { $newContext->setVariable($param->name, $ctx->createVariable($param)); } if (PHP_VERSION_ID >= 50400) { $newContext->setVariable('this', $ctx->getVariable('this')); } $this->recurseWithNewContext($newContext, $node->stmts); }
public function getFunctionNode() { return $this->funcContext->getFunctionNode(); }