当前位置: 首页>>代码示例>>PHP>>正文


PHP ParameterGenerator::setPassedByReference方法代码示例

本文整理汇总了PHP中Zend\Code\Generator\ParameterGenerator::setPassedByReference方法的典型用法代码示例。如果您正苦于以下问题:PHP ParameterGenerator::setPassedByReference方法的具体用法?PHP ParameterGenerator::setPassedByReference怎么用?PHP ParameterGenerator::setPassedByReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Code\Generator\ParameterGenerator的用法示例。


在下文中一共展示了ParameterGenerator::setPassedByReference方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fromReflection

 /**
  * @param  ParameterReflection $reflectionParameter
  * @return ParameterGenerator
  */
 public static function fromReflection(ParameterReflection $reflectionParameter)
 {
     $param = new ParameterGenerator();
     $param->setName($reflectionParameter->getName());
     if ($reflectionParameter->isArray()) {
         $param->setType('array');
     } elseif (method_exists($reflectionParameter, 'isCallable') && $reflectionParameter->isCallable()) {
         $param->setType('callable');
     } else {
         $typeClass = $reflectionParameter->getClass();
         if ($typeClass) {
             $parameterType = $typeClass->getName();
             $currentNamespace = $reflectionParameter->getDeclaringClass()->getNamespaceName();
             if (!empty($currentNamespace) && substr($parameterType, 0, strlen($currentNamespace)) == $currentNamespace) {
                 $parameterType = substr($parameterType, strlen($currentNamespace) + 1);
             } else {
                 $parameterType = '\\' . trim($parameterType, '\\');
             }
             $param->setType($parameterType);
         }
     }
     $param->setPosition($reflectionParameter->getPosition());
     if ($reflectionParameter->isOptional()) {
         $param->setDefaultValue($reflectionParameter->getDefaultValue());
     }
     $param->setPassedByReference($reflectionParameter->isPassedByReference());
     return $param;
 }
开发者ID:CHRISTOPHERVANDOMME,项目名称:zf2complet,代码行数:32,代码来源:ParameterGenerator.php

示例2: fromReflection

    /**
     * @param  ParameterReflection $reflectionParameter
     * @return ParameterGenerator
     */
    public static function fromReflection(ParameterReflection $reflectionParameter)
    {
        $param = new ParameterGenerator();
        $param->setName($reflectionParameter->getName());

        if ($reflectionParameter->isArray()) {
            $param->setType('array');
        } elseif (method_exists($reflectionParameter, 'isCallable') && $reflectionParameter->isCallable()) {
            $param->setType('callable');
        } else {
            $typeClass = $reflectionParameter->getClass();
            if ($typeClass) {
                $param->setType($typeClass->getName());
            }
        }

        $param->setPosition($reflectionParameter->getPosition());

        if ($reflectionParameter->isOptional()) {
            $param->setDefaultValue($reflectionParameter->getDefaultValue());
        }
        $param->setPassedByReference($reflectionParameter->isPassedByReference());

        return $param;
    }
开发者ID:Robert-Xie,项目名称:php-framework-benchmark,代码行数:29,代码来源:ParameterGenerator.php

示例3: fromReflection

 /**
  * @param  ParameterReflection $reflectionParameter
  * @return ParameterGenerator
  */
 public static function fromReflection(ParameterReflection $reflectionParameter)
 {
     $param = new ParameterGenerator();
     $param->setName($reflectionParameter->getName());
     if ($type = self::extractFQCNTypeFromReflectionType($reflectionParameter)) {
         $param->setType($type);
     }
     $param->setPosition($reflectionParameter->getPosition());
     $variadic = method_exists($reflectionParameter, 'isVariadic') && $reflectionParameter->isVariadic();
     $param->setVariadic($variadic);
     if (!$variadic && $reflectionParameter->isOptional()) {
         try {
             $param->setDefaultValue($reflectionParameter->getDefaultValue());
         } catch (\ReflectionException $e) {
             $param->setDefaultValue(null);
         }
     }
     $param->setPassedByReference($reflectionParameter->isPassedByReference());
     return $param;
 }
开发者ID:postalservice14,项目名称:zend-code,代码行数:24,代码来源:ParameterGenerator.php

示例4: buildClass

 private function buildClass($replacement)
 {
     $type = $this->splitNsandClass($replacement['originalFullyQualifiedType']);
     $class = new ClassGenerator();
     $class->setName($type['class']);
     $class->setNamespaceName($type['ns']);
     $class->setExtendedClass('\\Brads\\Ppm\\Proxy');
     $properties = [];
     $methods = [];
     $implementedInterfaces = [];
     foreach ($versions as $version => $info) {
         foreach ($info['files'] as $file) {
             echo "Parsing: " . $this->vendorDir . '/' . $package . '/' . $version . '/' . $file . "\n";
             $parsedFile = new ReflectionFile($this->vendorDir . '/' . $package . '/' . $version . '/' . $file);
             $parsedClass = $parsedFile->getFileNamespace($info['toNs'])->getClass($info['toNs'] . '\\' . $type['class']);
             if ($parsedClass->getInterfaceNames() != null) {
                 $implementedInterfaces = array_merge($implementedInterfaces, $parsedClass->getInterfaceNames());
             }
             foreach ($parsedClass->getMethods() as $method) {
                 if ($method->isPublic()) {
                     $generatedMethod = new MethodGenerator();
                     $generatedMethod->setName($method->name);
                     $generatedMethod->setBody('echo "Hello world!";');
                     $generatedMethod->setAbstract($method->isAbstract());
                     $generatedMethod->setFinal($method->isFinal());
                     $generatedMethod->setStatic($method->isStatic());
                     $generatedMethod->setVisibility(MethodGenerator::VISIBILITY_PUBLIC);
                     foreach ($method->getParameters() as $param) {
                         $generatedParam = new ParameterGenerator();
                         $generatedParam->setName($param->name);
                         if ($param->hasType()) {
                             $generatedParam->setType($param->getType());
                         }
                         //$generatedParam->setDefaultValue($param->getDefaultValue());
                         $generatedParam->setPosition($param->getPosition());
                         $generatedParam->setVariadic($param->isVariadic());
                         $generatedParam->setPassedByReference($param->isPassedByReference());
                         $generatedMethod->setParameter($generatedParam);
                     }
                     $existingMethod = Linq::from($methods)->firstOrDefault(null, function (MethodGenerator $v) use($method) {
                         return $v->getName() == $method->name;
                     });
                     if ($existingMethod != null) {
                         $existingParams = $existingMethod->getParameters();
                         foreach ($generatedMethod->getParameters() as $newParam) {
                             $existingParam = Linq::from($existingParams)->firstOrDefault(function (ParameterGenerator $v) {
                                 return $v->getName() == $newParam->getName();
                             });
                             if ($existingParam == null) {
                                 $existingMethod->setParameter($newParam);
                             }
                         }
                     } else {
                         $methods[] = $generatedMethod;
                     }
                 }
             }
             foreach ($parsedClass->getProperties() as $prop) {
                 //$properties[] = PropertyGenerator::fromReflection($prop);
             }
         }
     }
     $class->setImplementedInterfaces($implementedInterfaces);
     $class->addMethods($methods);
     $class->addProperties($properties);
     return (new FileGenerator(['classes' => [$class]]))->generate();
 }
开发者ID:brad-jones,项目名称:ppm,代码行数:67,代码来源:ProxyGenerator.php

示例5: generateMethod

 /**
  * Generate method
  *
  * @param string $methodName
  * @return void
  */
 protected function generateMethod($methodName)
 {
     $methodReflection = $this->_method[$methodName];
     $docBlock = new DocBlockGenerator();
     $docBlock->setShortDescription("Delicate {$methodName}() to __call() method ");
     if ($methodReflection->getDocComment()) {
         $docBlockReflection = new DocBlockReflection($methodReflection);
         $docBlock->fromReflection($docBlockReflection);
     }
     $method = new MethodGenerator();
     $method->setName($methodName);
     $method->setDocBlock($docBlock);
     $method->setBody(sprintf(self::METHOD_TEMPLATE, $methodName));
     if ($methodReflection->isPublic()) {
         $method->setVisibility(MethodGenerator::VISIBILITY_PUBLIC);
     } else {
         if ($methodReflection->isProtected()) {
             $method->setVisibility(MethodGenerator::VISIBILITY_PROTECTED);
         } else {
             if ($methodReflection->isPrivate()) {
                 $method->setVisibility(MethodGenerator::VISIBILITY_PRIVATE);
             }
         }
     }
     foreach ($methodReflection->getParameters() as $parameter) {
         $parameterGenerator = new ParameterGenerator();
         $parameterGenerator->setPosition($parameter->getPosition());
         $parameterGenerator->setName($parameter->getName());
         $parameterGenerator->setPassedByReference($parameter->isPassedByReference());
         if ($parameter->isDefaultValueAvailable()) {
             $parameterGenerator->setDefaultValue($parameter->getDefaultValue());
         }
         if ($parameter->isArray()) {
             $parameterGenerator->setType('array');
         }
         if ($typeClass = $parameter->getClass()) {
             $parameterGenerator->setType($typeClass->getName());
         }
         $method->setParameter($parameterGenerator);
     }
     $this->addMethodFromGenerator($method);
 }
开发者ID:jsiefer,项目名称:class-mocker,代码行数:48,代码来源:ClassGenerator.php

示例6: generateApiOperationFromMetadata

 /**
  * Append methods to Api class
  *
  * @param Generator\ClassGenerator $class
  * @param string                   $operation
  * @param mixed                    $apiMetadata
  * @param FileGenerator            $demoFile
  */
 protected function generateApiOperationFromMetadata(Generator\ClassGenerator &$class, $httpMethod, $apiMetadata)
 {
     $console = $this->getServiceLocator()->get('console');
     $modelClassName = 'Mailjet\\Model\\' . $class->getName();
     $model = $class->getName();
     $class->addUse('Zend\\Json\\Json')->addUse('Zend\\InputFilter');
     $httpMethod = strtoupper($httpMethod);
     switch ($httpMethod) {
         case 'GET':
             if ($apiMetadata->Filters) {
                 $class->addMethods(array(new Generator\MethodGenerator('getList', array(new Generator\ParameterGenerator('filters', 'array', array())), Generator\MethodGenerator::FLAG_PUBLIC, 'return parent::_list($filters);', new Generator\DocBlockGenerator("Return list of {$modelClassName}", "Return list of {$modelClassName} filtered by \$filters if provided" . PHP_EOL, array(new ParamTag(array('name' => 'filters', 'datatype' => 'array', 'description' => 'key/val filters')), new ReturnTag(array('datatype' => 'ResultSet\\ResultSet', 'description' => "List of {$modelClassName}")))))));
                 foreach ($apiMetadata->Filters as $filterInfo) {
                     try {
                         $filterName = $filterInfo->Name;
                         $dataTypeInfos = $this->getNormalizedFilterOrProperty($filterInfo);
                         $dataType = $dataTypeInfos['dataType'];
                         foreach ($dataTypeInfos['uses'] as $use) {
                             $class->addUse($use);
                         }
                         $isKey = $filterName == $apiMetadata->UniqueKey;
                         if ($isKey) {
                             $bodyMethod = sprintf('return $this->_get($%s);' . PHP_EOL, $filterName);
                         } else {
                             $bodyMethod = sprintf('$result = $this->getList(array(\'%s\' => $%s));' . PHP_EOL . 'return $result;', $filterName, $filterName);
                         }
                         $class->addMethods(array(new Generator\MethodGenerator('getBy' . $filterName, array(new Generator\ParameterGenerator($filterName, $dataType)), Generator\MethodGenerator::FLAG_PUBLIC, $bodyMethod, new Generator\DocBlockGenerator($isKey ? "Return {$modelClassName}" : "Return list of {$modelClassName} with {$filterName} = \${$filterName}", '', array(new ParamTag(array('name' => $filterName, 'datatype' => $dataType)), new ReturnTag(array('datatype' => $isKey ? $modelClassName : 'ResultSet\\ResultSet')))))));
                     } catch (\Exception $e) {
                         $console->writeLine('[' . $class->getName() . ']' . $e->getMessage(), Color::YELLOW);
                     }
                 }
                 $param = new Generator\ParameterGenerator('id', 'int');
                 $class->addMethods(array(new Generator\MethodGenerator('get', array($param), Generator\MethodGenerator::FLAG_PUBLIC, 'if (empty($id)) {' . PHP_EOL . '    throw new Exception\\InvalidArgumentException("You must specify the ID");' . PHP_EOL . '}' . PHP_EOL . PHP_EOL . 'return parent::_get($id);', new Generator\DocBlockGenerator("Return {$modelClassName} with id = \$id", '', array(new ParamTag(array('name' => 'id', 'datatype' => 'int', 'description' => 'Id of resource to get')), new ReturnTag(array('datatype' => $modelClassName)))))));
             } else {
                 $class->addMethods(array(new Generator\MethodGenerator('current', array(), Generator\MethodGenerator::FLAG_PUBLIC, 'return parent::_get();', new Generator\DocBlockGenerator("Return current {$modelClassName}", '', array(new ReturnTag(array('datatype' => $modelClassName)))))));
             }
             break;
         case 'DELETE':
             $class->addMethods(array(new Generator\MethodGenerator('delete', array(new Generator\ParameterGenerator('id')), Generator\MethodGenerator::FLAG_PUBLIC, 'return parent::_delete($id);', new Generator\DocBlockGenerator("Delete the {$model} with id = \$id", '', array(new ParamTag(array('name' => 'id', 'datatype' => 'integer', 'description' => 'Id to delete')), new ReturnTag(array('datatype' => 'bool', 'description' => 'True on success')))))));
             break;
         case 'POST':
             $modelParameter = new Generator\ParameterGenerator($model, $modelClassName);
             $modelParameter->setPassedByReference(true);
             $class->addMethods(array(new Generator\MethodGenerator('create', array($modelParameter), Generator\MethodGenerator::FLAG_PUBLIC, "return parent::_create(\${$model});", new Generator\DocBlockGenerator("Create a new {$model}", '', array(new ParamTag(array('name' => $model, 'datatype' => $modelClassName)), new ReturnTag(array('datatype' => "{$modelClassName}|false", 'description' => 'Object created or false')))))));
             break;
         case 'PUT':
             $modelParameter = new Generator\ParameterGenerator($model, $modelClassName);
             $modelParameter->setPassedByReference(true);
             $class->addMethods(array(new Generator\MethodGenerator('update', array($modelParameter), Generator\MethodGenerator::FLAG_PUBLIC, "return parent::_update(\${$model});", new Generator\DocBlockGenerator("Update existing {$model}", '', array(new ParamTag(array('name' => $model, 'datatype' => $modelClassName)), new ReturnTag(array('datatype' => "{$modelClassName}|false", 'description' => 'Object created or false')))))));
             break;
         default:
             break;
     }
 }
开发者ID:progrupa,项目名称:MailjetBundle,代码行数:61,代码来源:ApiController.php


注:本文中的Zend\Code\Generator\ParameterGenerator::setPassedByReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。