getClassDefinition() public method

Returns the class definition where the method was declared
public getClassDefinition ( ) : ClassDefinition
return ClassDefinition
Example #1
0
 /**
  * Returns the signature of an internal method
  *
  * @return string
  */
 private function getInternalSignature(ClassMethod $method)
 {
     if ($method->getName() == 'zephir_init_properties') {
         return 'static zend_object_value ' . $method->getName() . '(zend_class_entry *class_type TSRMLS_DC)';
     }
     if ($method->getName() == 'zephir_init_static_properties') {
         $classDefinition = $method->getClassDefinition();
         return 'void ' . $method->getName() . '_' . $classDefinition->getCNamespace() . '_' . $classDefinition->getName() . '(TSRMLS_D)';
     }
     $signatureParameters = array();
     $parameters = $method->getParameters();
     if (is_object($parameters)) {
         foreach ($parameters->getParameters() as $parameter) {
             switch ($parameter['data-type']) {
                 case 'int':
                 case 'uint':
                 case 'long':
                 case 'double':
                 case 'bool':
                 case 'char':
                 case 'uchar':
                     $signatureParameters[] = 'zval *' . $parameter['name'] . '_param_ext';
                     break;
                 default:
                     $signatureParameters[] = 'zval *' . $parameter['name'] . '_ext';
                     break;
             }
         }
     }
     if (count($signatureParameters)) {
         return 'static void ' . $method->getInternalName() . '(int ht, zval *return_value, zval **return_value_ptr, zval *this_ptr, int return_value_used, ' . join(', ', $signatureParameters) . ' TSRMLS_DC)';
     }
     return 'static void ' . $method->getInternalName() . '(int ht, zval *return_value, zval **return_value_ptr, zval *this_ptr, int return_value_used TSRMLS_DC)';
 }
Example #2
0
 /**
  * @param ClassMethod $method
  * @param bool $isInterface
  * @param string $indent
  *
  * @return string
  */
 protected function buildMethod(ClassMethod $method, $isInterface, $indent)
 {
     $modifier = implode(' ', array_diff($method->getVisibility(), $this->ignoreModifiers));
     $methodParameters = $method->getParameters();
     $aliasManager = $method->getClassDefinition()->getAliasManager();
     $docBlock = new MethodDocBlock($method, $aliasManager, $indent);
     $parameters = array();
     if ($methodParameters) {
         foreach ($methodParameters->getParameters() as $parameter) {
             $paramStr = '';
             if (isset($parameter['cast'])) {
                 if ($aliasManager->isAlias($parameter['cast']['value'])) {
                     $cast = '\\' . $aliasManager->getAlias($parameter['cast']['value']);
                 } else {
                     $cast = $parameter['cast']['value'];
                 }
                 $paramStr .= $cast . ' ';
             }
             $paramStr .= '$' . $parameter['name'];
             if (isset($parameter['default'])) {
                 $paramStr .= ' = ' . $this->wrapPHPValue($parameter);
             }
             $parameters[] = $paramStr;
         }
     }
     $methodBody = $indent . $modifier . ' function ' . $method->getName() . '(' . implode(', ', $parameters) . ')';
     if ($isInterface || $method->isAbstract()) {
         $methodBody .= ';';
     } else {
         $methodBody .= ' {}';
     }
     return $docBlock . "\n" . $methodBody;
 }
Example #3
0
 private function parseMethodParameters(ClassMethod $method)
 {
     $parameters = $method->getParameters();
     $aliasManager = $method->getClassDefinition()->getAliasManager();
     if (!$parameters) {
         return;
     }
     foreach ($method->getParameters() as $parameter) {
         if (isset($parameter['cast'])) {
             if ($aliasManager->isAlias($parameter['cast']['value'])) {
                 $type = '\\' . $aliasManager->getAlias($parameter['cast']['value']);
             } else {
                 $type = $parameter['cast']['value'];
             }
         } elseif (isset($parameter['data-type'])) {
             if ($parameter['data-type'] == 'variable') {
                 $type = 'mixed';
             } else {
                 $type = $parameter['data-type'];
             }
         } else {
             $type = 'mixed';
         }
         $this->parameters['$' . $parameter['name']] = array($type, '');
     }
 }