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


PHP ParameterGenerator::setType方法代码示例

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


在下文中一共展示了ParameterGenerator::setType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
                $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

示例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) {
             $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

示例3: testGenerateIsCorrect

 public function testGenerateIsCorrect()
 {
     $parameterGenerator = new ParameterGenerator();
     $parameterGenerator->setType('Foo');
     $parameterGenerator->setName('bar');
     $parameterGenerator->setDefaultValue(15);
     $this->assertEquals('Foo $bar = 15', $parameterGenerator->generate());
     $parameterGenerator->setDefaultValue('foo');
     $this->assertEquals('Foo $bar = \'foo\'', $parameterGenerator->generate());
 }
开发者ID:rikaix,项目名称:zf2,代码行数:10,代码来源:ParameterGeneratorTest.php

示例4: __construct

 /**
  * Constructor
  *
  * @param PropertyGenerator $initializerProperty
  */
 public function __construct(PropertyGenerator $initializerProperty)
 {
     parent::__construct('setProxyInitializer');
     $initializerParameter = new ParameterGenerator('initializer');
     $initializerParameter->setType(Closure::class);
     $initializerParameter->setDefaultValue(null);
     $this->setParameter($initializerParameter);
     $this->setDocblock('{@inheritDoc}');
     $this->setBody('$this->' . $initializerProperty->getName() . ' = $initializer;');
 }
开发者ID:andywooyay,项目名称:ProxyManager,代码行数:15,代码来源:SetProxyInitializer.php

示例5: __construct

 /**
  * Creates a new {@link \bitExpert\Disco\Proxy\Configuration\MethodGenerator\HasAlias}.
  *
  * @param ReflectionClass $originalClass
  * @param AliasesProperty $aliasesProperty
  * @throws InvalidArgumentException
  */
 public function __construct(ReflectionClass $originalClass, AliasesProperty $aliasesProperty)
 {
     parent::__construct('hasAlias');
     $aliasParameter = new ParameterGenerator('alias');
     $aliasParameter->setType('string');
     $this->setParameter($aliasParameter);
     $this->setVisibility(self::VISIBILITY_PUBLIC);
     $this->setReturnType('bool');
     $this->setBody('return !empty($' . $aliasParameter->getName() . ') && ' . 'isset($this->' . $aliasesProperty->getName() . '[$' . $aliasParameter->getName() . ']);');
 }
开发者ID:bitexpert,项目名称:disco,代码行数:17,代码来源:HasAlias.php

示例6: __construct

 /**
  * Constructor
  *
  * @param PropertyGenerator $suffixInterceptor
  */
 public function __construct(PropertyGenerator $suffixInterceptor)
 {
     parent::__construct('setMethodSuffixInterceptor');
     $interceptor = new ParameterGenerator('suffixInterceptor');
     $interceptor->setType(Closure::class);
     $interceptor->setDefaultValue(null);
     $this->setParameter(new ParameterGenerator('methodName', 'string'));
     $this->setParameter($interceptor);
     $this->setDocblock('{@inheritDoc}');
     $this->setBody('$this->' . $suffixInterceptor->getName() . '[$methodName] = $suffixInterceptor;');
 }
开发者ID:jbafford,项目名称:ProxyManager,代码行数:16,代码来源:SetMethodSuffixInterceptor.php

示例7: __construct

 /**
  * Creates a new {@link \bitExpert\Disco\Proxy\Configuration\MethodGenerator\GetAlias}.
  *
  * @param ReflectionClass $originalClass
  * @param AliasesProperty $aliasesProperty
  * @throws InvalidArgumentException
  */
 public function __construct(ReflectionClass $originalClass, AliasesProperty $aliasesProperty)
 {
     parent::__construct('getAlias');
     $aliasParameter = new ParameterGenerator('alias');
     $aliasParameter->setType('string');
     $body = 'if ($this->hasAlias($' . $aliasParameter->getName() . ')) {' . PHP_EOL;
     $body .= '    $methodname = $this->' . $aliasesProperty->getName() . '[$' . $aliasParameter->getName() . '];' . PHP_EOL;
     $body .= '    return $this->$methodname();' . PHP_EOL;
     $body .= '}' . PHP_EOL . PHP_EOL;
     $body .= 'throw new ' . BeanNotFoundException::class . '(sprintf(\'Alias "%s" is not defined!\', $' . $aliasParameter->getName() . '));' . PHP_EOL;
     $this->setParameter($aliasParameter);
     $this->setVisibility(self::VISIBILITY_PUBLIC);
     $this->setBody($body);
 }
开发者ID:bitexpert,项目名称:disco,代码行数:21,代码来源:GetAlias.php

示例8: __construct

 /**
  * Constructor
  *
  * @param ReflectionClass   $originalClass
  * @param PropertyGenerator $valueHolder
  * @param PropertyGenerator $prefixInterceptors
  * @param PropertyGenerator $suffixInterceptors
  */
 public function __construct(ReflectionClass $originalClass, PropertyGenerator $valueHolder, PropertyGenerator $prefixInterceptors, PropertyGenerator $suffixInterceptors)
 {
     parent::__construct('staticProxyConstructor', [], static::FLAG_PUBLIC | static::FLAG_STATIC);
     $prefix = new ParameterGenerator('prefixInterceptors');
     $suffix = new ParameterGenerator('suffixInterceptors');
     $prefix->setDefaultValue([]);
     $suffix->setDefaultValue([]);
     $prefix->setType('array');
     $suffix->setType('array');
     $this->setParameter(new ParameterGenerator('wrappedObject'));
     $this->setParameter($prefix);
     $this->setParameter($suffix);
     $this->setReturnType($originalClass->getName());
     $this->setDocblock("Constructor to setup interceptors\n\n" . "@param \\" . $originalClass->getName() . " \$wrappedObject\n" . "@param \\Closure[] \$prefixInterceptors method interceptors to be used before method logic\n" . "@param \\Closure[] \$suffixInterceptors method interceptors to be used before method logic\n\n" . "@return self");
     $this->setBody('static $reflection;' . "\n\n" . '$reflection = $reflection ?: $reflection = new \\ReflectionClass(__CLASS__);' . "\n" . '$instance = (new \\ReflectionClass(get_class()))->newInstanceWithoutConstructor();' . "\n\n" . UnsetPropertiesGenerator::generateSnippet(Properties::fromReflectionClass($originalClass), 'instance') . '$instance->' . $valueHolder->getName() . " = \$wrappedObject;\n" . '$instance->' . $prefixInterceptors->getName() . " = \$prefixInterceptors;\n" . '$instance->' . $suffixInterceptors->getName() . " = \$suffixInterceptors;\n\n" . 'return $instance;');
 }
开发者ID:jbafford,项目名称:ProxyManager,代码行数:24,代码来源:StaticProxyConstructor.php

示例9: __construct

 /**
  * Constructor
  *
  * @param ReflectionClass $originalClass
  */
 public function __construct(ReflectionClass $originalClass)
 {
     parent::__construct('staticProxyConstructor', [], static::FLAG_PUBLIC | static::FLAG_STATIC);
     $localizedObject = new ParameterGenerator('localizedObject');
     $prefix = new ParameterGenerator('prefixInterceptors');
     $suffix = new ParameterGenerator('suffixInterceptors');
     $localizedObject->setType($originalClass->getName());
     $prefix->setDefaultValue([]);
     $suffix->setDefaultValue([]);
     $prefix->setType('array');
     $suffix->setType('array');
     $this->setParameter($localizedObject);
     $this->setParameter($prefix);
     $this->setParameter($suffix);
     $this->setDocblock("Constructor to setup interceptors\n\n" . "@param \\" . $originalClass->getName() . " \$localizedObject\n" . "@param \\Closure[] \$prefixInterceptors method interceptors to be used before method logic\n" . "@param \\Closure[] \$suffixInterceptors method interceptors to be used before method logic\n\n" . "@return self");
     $this->setBody('static $reflection;' . "\n\n" . '$reflection = $reflection ?: $reflection = new \\ReflectionClass(__CLASS__);' . "\n" . '$instance   = $reflection->newInstanceWithoutConstructor();' . "\n\n" . '$instance->bindProxyProperties($localizedObject, $prefixInterceptors, $suffixInterceptors);' . "\n\n" . 'return $instance;');
 }
开发者ID:andywooyay,项目名称:ProxyManager,代码行数:22,代码来源:StaticProxyConstructor.php

示例10: 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

示例11: __construct

 /**
  * Creates a new {@link \bitExpert\Disco\Proxy\Configuration\MethodGenerator\Constructor}.
  *
  * @param ReflectionClass $originalClass
  * @param ParameterValuesProperty $parameterValuesProperty
  * @param SessionBeansProperty $sessionBeansProperty
  * @param BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty
  * @param BeanPostProcessorsProperty $beanPostProcessorsProperty
  * @param string[] $beanPostProcessorMethodNames
  */
 public function __construct(ReflectionClass $originalClass, ParameterValuesProperty $parameterValuesProperty, SessionBeansProperty $sessionBeansProperty, BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty, BeanPostProcessorsProperty $beanPostProcessorsProperty, array $beanPostProcessorMethodNames)
 {
     parent::__construct('__construct');
     $beanFactoryConfigurationParameter = new ParameterGenerator('config');
     $beanFactoryConfigurationParameter->setType(BeanFactoryConfiguration::class);
     $parametersParameter = new ParameterGenerator('params');
     $parametersParameter->setDefaultValue([]);
     $body = '$this->' . $parameterValuesProperty->getName() . ' = $' . $parametersParameter->getName() . ';' . PHP_EOL;
     $body .= '$this->' . $beanFactoryConfigurationProperty->getName() . ' = $' . $beanFactoryConfigurationParameter->getName() . ';' . PHP_EOL;
     $body .= '$this->' . $sessionBeansProperty->getName() . ' = $' . $beanFactoryConfigurationParameter->getName() . '->getSessionBeanStore();' . PHP_EOL;
     $body .= '// register {@link \\bitExpert\\Disco\\BeanPostProcessor} instances' . PHP_EOL;
     $body .= '$this->' . $beanPostProcessorsProperty->getName() . '[] = new \\bitExpert\\Disco\\BeanFactoryPostProcessor();' . PHP_EOL;
     foreach ($beanPostProcessorMethodNames as $methodName) {
         $body .= '$this->' . $beanPostProcessorsProperty->getName() . '[] = $this->' . $methodName . '(); ';
         $body .= PHP_EOL;
     }
     $this->setParameter($beanFactoryConfigurationParameter);
     $this->setParameter($parametersParameter);
     $this->setBody($body);
     $this->setDocBlock("@override constructor");
 }
开发者ID:bitExpert,项目名称:disco,代码行数:31,代码来源:Constructor.php

示例12: 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

示例13: viewStub

    protected function viewStub($part)
    {
        /**
         * @var $part \Model\Generator\Part\Model
         */
        /**
         * @var $file \Model\Code\Generator\FileGenerator
         */
        $file = $part->getFile();
        $table = $part->getTable();
        $tableNameAsCamelCase = $table->getNameAsCamelCase();
        $entity = $tableNameAsCamelCase . 'Entity';
        $collection = $tableNameAsCamelCase . 'Collection';
        $p = new \Zend\Code\Generator\ParameterGenerator('cond');
        $p->setType('Cond');
        $p->setDefaultValue(null);
        $params[] = $p;
        $docblock = new DocBlockGenerator('Получить объект условий в виде представления \'Extended\'

$param Cond $cond
$return Cond
        ');
        $method = new MethodGenerator();
        $method->setName('getCondAsExtendedView');
        $method->setVisibility(AbstractMemberGenerator::VISIBILITY_PUBLIC);
        $method->setFinal(false);
        $method->setDocBlock($docblock);
        $method->setParameters($params);
        $method->setBody(<<<EOS
\$cond = \$this->prepareCond(\$cond);
\$cond->where(array('status' => 'active'));
return \$cond;
EOS
);
        $file->getClass()->addMethodFromGenerator($method);
        $p = new \Zend\Code\Generator\ParameterGenerator('cond');
        $p->setType('Cond');
        $p->setDefaultValue(null);
        $params[] = $p;
        $docblock = new DocBlockGenerator('Получить элемент в виде представления \'Extended\'

@param Cond $cond
@return ' . $entity);
        $method = new MethodGenerator();
        $method->setName('getAsExtendedView');
        $method->setVisibility(AbstractMemberGenerator::VISIBILITY_PUBLIC);
        $method->setFinal(false);
        $method->setDocBlock($docblock);
        $method->setParameters($params);
        $method->setBody(<<<EOS
\$cond = \$this->getCondAsExtendedView(\$cond);
return \$this->get(\$cond);
EOS
);
        $file->getClass()->addMethodFromGenerator($method);
        $p = new \Zend\Code\Generator\ParameterGenerator('cond');
        $p->setType('Cond');
        $p->setDefaultValue(null);
        $params[] = $p;
        $docblock = new DocBlockGenerator('Получить коллекцию в виде представления \'Extended\'

@param Cond $cond
@return ' . $collection);
        $method = new MethodGenerator();
        $method->setName('getCollectionAsExtendedView');
        $method->setVisibility(AbstractMemberGenerator::VISIBILITY_PUBLIC);
        $method->setFinal(false);
        $method->setDocBlock($docblock);
        $method->setParameters($params);
        $method->setBody(<<<EOS
\$cond = \$this->getCondAsExtendedView(\$cond);
return \$this->getCollection(\$cond);
EOS
);
        $file->getClass()->addMethodFromGenerator($method);
    }
开发者ID:meniam,项目名称:model,代码行数:76,代码来源:Stubs.php

示例14: 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

示例15: generateMethodsByIndex

    public function generateMethodsByIndex($part)
    {
        /** @var $part \Model\Generator\Part\Model */
        /** @var $file \Model\Code\Generator\FileGenerator */
        $file = $part->getFile();
        $table = $part->getTable();
        $tableName = $table->getName();
        $indexList = $table->getIndex();
        foreach ($indexList as $index) {
            $params = $getBy = array();
            $prepare = '';
            $paramNames = array();
            $checkForEmpty = '';
            $indexColumn = 'id';
            $where = '';
            foreach ($index as $column) {
                if ($index->getName() == 'PRIMARY') {
                    $indexColumn = $column->getName();
                }
                //echo $index->getName() . "\n";
                if ($index->getName() == 'PRIMARY' || $index->count() == 1 && ($link = $table->getLinkByColumn($column, $table->getName()))) {
                    continue 2;
                }
                $link = $table->getLinkByColumn($column, $table->getName());
                if ($link) {
                    $indexColumnName = $link->getForeignEntity();
                    $indexColumnNameAsVar = $link->getForeignEntityAsVar();
                    $indexColumnNameAsCamelCase = $link->getForeignEntityAsCamelCase();
                } else {
                    $indexColumnName = $column->getName();
                    $indexColumnNameAsVar = $column->getNameAsVar();
                    $indexColumnNameAsCamelCase = $column->getNameAsCamelCase();
                }
                $indexColumnField = $column->getName();
                $params[] = new \Zend\Code\Generator\ParameterGenerator($indexColumnNameAsVar);
                $getBy[] = $indexColumnNameAsCamelCase;
                $paramNames[] = '$' . $indexColumnNameAsVar;
                if ($link) {
                    $foreignTableNameAsCamelCase = $link->getForeignTable()->getNameAsCamelCase();
                    $prepare .= <<<EOS
\${$indexColumnNameAsVar}Ids = {$foreignTableNameAsCamelCase}Model::getInstance()->getIdsFromMixed(\${$indexColumnNameAsVar});

EOS;
                } else {
                    $prepare .= <<<EOS
\${$indexColumnNameAsVar}Ids = \$this->filterValue(\${$indexColumnNameAsVar}, '{$indexColumnName}');

EOS;
                }
                $checkForEmpty .= "empty(\${$indexColumnNameAsVar}Ids) || ";
                $where .= "'`{$tableName}`.`{$indexColumnField}`' => \${$indexColumnNameAsVar}Ids,\n";
            }
            //@method int borp() borp(int $int1, int $int2) multiply two integers
            $p = new \Zend\Code\Generator\ParameterGenerator('cond');
            $p->setDefaultValue(null);
            $p->setType('Cond');
            $params[] = $p;
            $where = 'array(' . rtrim($where, " \n,") . ")";
            $checkForEmpty = rtrim($checkForEmpty, "\r\n |");
            $method = new \Zend\Code\Generator\MethodGenerator();
            $method->setName('getBy' . implode('And', $getBy));
            $method->setVisibility(\Zend\Code\Generator\AbstractMemberGenerator::VISIBILITY_PUBLIC);
            //$method->setDocBlock($docblock);
            $method->setParameters($params);
            $method->setBody(<<<EOS
\$cond = \$this->prepareCond(\$cond);

{$prepare}
if ({$checkForEmpty}) {
    return \$cond->getEmptySelectResult();
}

\$cond->where({$where});

return \$this->get(\$cond);
EOS
);
            try {
                $part->getFile()->getClass()->addMethodFromGenerator($method);
            } catch (\Exception $e) {
            }
        }
    }
开发者ID:meniam,项目名称:model,代码行数:83,代码来源:Getter.php


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