/** * Generate internal method's based on the equivalent PHP methods, * allowing bypassing php userspace for internal method calls */ public function setupOptimized(CompilationContext $compilationContext) { if (!$compilationContext->config->get('internal-call-transformation', 'optimizations')) { return; } $classDefinition = $this->getClassDefinition(); /* Skip for closures */ if ($this->getName() == '__invoke' || $classDefinition->isInterface()) { return; } if (!$this->isInternal() && !$classDefinition->isBundled()) { /* Not supported for now */ if ($this->getNumberOfRequiredParameters() != $this->getNumberOfParameters()) { return $this; } if ($this->isConstructor()) { return $this; } $optimizedName = $this->getName() . '_zephir_internal_call'; $visibility = array('internal'); $statements = null; if ($this->statements) { $statements = new StatementsBlock(json_decode(json_encode($this->statements->getStatements()), true)); } $optimizedMethod = new ClassMethod($classDefinition, $visibility, $optimizedName, $this->parameters, $statements, $this->docblock, null, $this->expression); $optimizedMethod->typeInference = $this->typeInference; $optimizedMethod->setReturnTypes($this->returnTypes); $classDefinition->addMethod($optimizedMethod); } }