Zephir\ClassDefinition::getClassEntry PHP Method

getClassEntry() public method

Returns the name of the zend_class_entry according to the class name
public getClassEntry ( zephir\CompilationContext $compilationContext = null ) : string
$compilationContext zephir\CompilationContext
return string
    public function getClassEntry(CompilationContext $compilationContext = null)
    {
        if ($this->external) {
            if (!is_object($compilationContext)) {
                throw new Exception('A compilation context is required');
            }
            $this->compiler = $compilationContext->compiler;
            /**
             * Automatically add the external header
             */
            $compilationContext->headersManager->add($this->getExternalHeader(), HeadersManager::POSITION_LAST);
        }
        return strtolower(str_replace('\\', '_', $this->namespace) . '_' . $this->name) . '_ce';
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Calls static methods on the some class context
  *
  * @param string $methodName
  * @param array $expression
  * @param Variable $symbolVariable
  * @param boolean $mustInit
  * @param boolean $isExpecting
  * @param ClassDefinition $classDefinition
  * @param CompilationContext $compilationContext
  * @param ClassMethod $method
  */
 protected function callFromClass($methodName, array $expression, $symbolVariable, $mustInit, $isExpecting, ClassDefinition $classDefinition, CompilationContext $compilationContext, $method)
 {
     $codePrinter = $compilationContext->codePrinter;
     if ($classDefinition->isInternal()) {
         $variableName = str_replace('\\', '_', $classDefinition->getSCName('local'));
         if (!$compilationContext->symbolTable->hasVariable($variableName)) {
             $classEntryVariable = $compilationContext->symbolTable->addVariable('zend_class_entry', $variableName, $compilationContext);
             $codePrinter->output($classEntryVariable->getName() . ' = zend_fetch_class(SL("\\\\' . str_replace('\\', '\\\\', $classDefinition->getName()) . '"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);');
         }
         $classEntryVariable = $compilationContext->symbolTable->getVariableForWrite($variableName, 'zend_class_entry', $compilationContext);
         $classEntry = $classEntryVariable->getName();
     } else {
         $classEntry = $classDefinition->getClassEntry();
     }
     /**
      * Call static methods must grown the stack
      */
     $compilationContext->symbolTable->mustGrownStack(true);
     if ($mustInit) {
         $symbolVariable->setMustInitNull(true);
         $symbolVariable->trackVariant($compilationContext);
     }
     /**
      * Check if the  method call can have an inline cache
      */
     $methodCache = $compilationContext->cacheManager->getStaticMethodCache();
     $cachePointer = $methodCache->get($compilationContext, isset($method) ? $method : null);
     if (isset($expression['parameters']) && count($expression['parameters'])) {
         $params = $this->getResolvedParams($expression['parameters'], $compilationContext, $expression);
     } else {
         $params = array();
     }
     if (!count($params)) {
         if ($isExpecting) {
             if ($symbolVariable->getName() == 'return_value') {
                 $codePrinter->output('ZEPHIR_RETURN_CALL_CE_STATIC(' . $classEntry . ', "' . $methodName . '", ' . $cachePointer . ');');
             } else {
                 $codePrinter->output('ZEPHIR_CALL_CE_STATIC(&' . $symbolVariable->getName() . ', ' . $classEntry . ', "' . $methodName . '", ' . $cachePointer . ');');
             }
         } else {
             $codePrinter->output('ZEPHIR_CALL_CE_STATIC(NULL, ' . $classEntry . ', "' . $methodName . '", ' . $cachePointer . ');');
         }
     } else {
         if ($isExpecting) {
             if ($symbolVariable->getName() == 'return_value') {
                 $codePrinter->output('ZEPHIR_RETURN_CALL_CE_STATIC(' . $classEntry . ', "' . $methodName . '", ' . $cachePointer . ', ' . join(', ', $params) . ');');
             } else {
                 $codePrinter->output('ZEPHIR_CALL_CE_STATIC(&' . $symbolVariable->getName() . ', ' . $classEntry . ', "' . $methodName . '", ' . $cachePointer . ', ' . join(', ', $params) . ');');
             }
         } else {
             $codePrinter->output('ZEPHIR_CALL_CE_STATIC(NULL, ' . $classEntry . ', "' . $methodName . '", ' . $cachePointer . ', ' . join(', ', $params) . ');');
         }
     }
     /**
      * Temporary variables must be copied if they have more than one reference
      */
     foreach ($this->getMustCheckForCopyVariables() as $checkVariable) {
         $codePrinter->output('zephir_check_temp_parameter(' . $checkVariable . ');');
     }
     $this->addCallStatusOrJump($compilationContext);
 }
All Usage Examples Of Zephir\ClassDefinition::getClassEntry