getParameters() public méthode

Returns the parameters
public getParameters ( ) : ClassMethodParameters
Résultat ClassMethodParameters
Exemple #1
0
 private function parseMethodParameters(ClassMethod $method)
 {
     $parameters = $method->getParameters();
     if (!$parameters) {
         return;
     }
     foreach ($method->getParameters() as $parameter) {
         if (isset($parameter['data-type'])) {
             if ($parameter['data-type'] == 'variable') {
                 $type = 'mixed';
             } else {
                 $type = $parameter['data-type'];
             }
         } elseif (isset($parameter['cast'])) {
             $type = $parameter['cast']['value'];
         } else {
             $type = 'mixed';
         }
         $this->parameters['$' . $parameter['name']] = array($type, '');
     }
 }
Exemple #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;
 }
Exemple #3
0
 /**
  * Returns the signature of an internal method
  */
 public function getInternalSignature(ClassMethod $method, CompilationContext $context)
 {
     if ($method->isInitializer() && !$method->isStatic()) {
         return 'static zend_object *' . $method->getName() . '(zend_class_entry *class_type TSRMLS_DC)';
     }
     if ($method->isInitializer() && $method->isStatic()) {
         return 'void ' . $method->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':
                 case 'string':
                 case 'array':
                     $signatureParameters[] = 'zval *' . $parameter['name'] . '_param_ext';
                     break;
                 default:
                     $signatureParameters[] = 'zval *' . $parameter['name'] . '_ext ';
                     break;
             }
         }
     }
     if (count($signatureParameters)) {
         return 'void ' . $method->getInternalName() . '(int ht, zval *return_value, zval *this_ptr, int return_value_used, ' . join(', ', $signatureParameters) . ')';
     }
     return 'void ' . $method->getInternalName() . '(int ht, zval *return_value, zval *this_ptr, int return_value_used)';
 }
Exemple #4
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)';
 }
Exemple #5
0
 /**
  * @param ClassMethod $method
  *
  * @param bool        $isInterface
  *
  * @return string
  */
 protected function buildMethod(ClassMethod $method, $isInterface)
 {
     $modifier = implode(' ', array_diff($method->getVisibility(), $this->ignoreModifiers));
     $docBlock = new MethodDocBlock($method, 4);
     $parameters = array();
     $methodParameters = $method->getParameters();
     if ($methodParameters) {
         foreach ($methodParameters->getParameters() as $parameter) {
             $paramStr = '$' . $parameter['name'];
             if (isset($parameter['default'])) {
                 $paramStr .= ' = ' . $this->wrapPHPValue($parameter);
             }
             $parameters[] = $paramStr;
         }
     }
     $methodBody = "\t" . $modifier . ' function ' . $method->getName() . '(' . implode(', ', $parameters) . ')';
     if ($isInterface || $method->isAbstract()) {
         $methodBody .= ';';
     } else {
         $methodBody .= ' {}';
     }
     return $docBlock . "\n" . $methodBody;
 }