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


PHP Generator\DocBlockGenerator类代码示例

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


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

示例1: createDocblockForMethod

 /**
  * @param string               $requestMethod
  * @param Config               $action
  * @param ParameterGenerator[] $params
  *
  * @return DocBlockGenerator
  */
 private function createDocblockForMethod($requestMethod, $action, $params)
 {
     if (empty($action->doc)) {
         $action->doc = 'TODO';
     }
     /*
      * $action->doc
      * METHOD: /{url:[a-z]+}
      */
     $docblock = new DocBlockGenerator($action->doc, strtoupper($requestMethod) . ': ' . $action->url);
     foreach ($params as $param) {
         /*
          * @param $paramName
          */
         $docblock->setTag(new GenericTag('param', "\${$param->getName()}"));
     }
     if (!empty($action->throws)) {
         /*
          * @throws \Name\Space\Version\Exceptions\EntityName\SomethingException
          */
         $docblock->setTag(new GenericTag('throws', sprintf("\\%s\\%s\\Exceptions\\%s\\%s", Generator::$namespace, $this->version, $this->entityName, $action->throws->exception)));
     }
     if (!empty($action->returns)) {
         /*
          * @returns \Name\Space\Version\EntityName\EntityName(s)?Response
          */
         $docblock->setTag(new GenericTag('returns', sprintf("\\%s\\%s\\Responses\\%s\\%s", Generator::$namespace, $this->version, $this->entityName, $action->returns)));
     }
     return $docblock;
 }
开发者ID:i-am-ains-ly,项目名称:sdk,代码行数:37,代码来源:ControllerGenerator.php

示例2: build

    /**
     * @param  State|\Scaffold\State $state
     * @return State|void
     */
    public function build(State $state)
    {
        $model = $state->getModel('options-factory');
        $generator = new ClassGenerator($model->getName());
        $generator->setImplementedInterfaces(['FactoryInterface']);
        $model->setGenerator($generator);
        $generator->addUse('Zend\\ServiceManager\\FactoryInterface');
        $generator->addUse('Zend\\ServiceManager\\ServiceLocatorInterface');
        $options = $state->getModel('options');
        $key = $options->getServiceName();
        $key = substr($key, 0, -7);
        $body = <<<EOF
\$config = \$serviceLocator->get('Config');
return new {$options->getClassName()}(
    isset(\$config['{$key}'])
        ? \$config['{$key}']
        : []
);
EOF;
        $method = new MethodGenerator('createService');
        $method->setParameter(new ParameterGenerator('serviceLocator', 'ServiceLocatorInterface'));
        $method->setBody($body);
        $doc = new DocBlockGenerator('');
        $doc->setTag(new Tag(['name' => 'inhertidoc']));
        $method->setDocBlock($doc);
        $generator->addMethodFromGenerator($method);
    }
开发者ID:enlitepro,项目名称:zf2-scaffold,代码行数:31,代码来源:OptionsFactoryBuilder.php

示例3: getClassDocBlock

 protected function getClassDocBlock(State $state)
 {
     $repository = $state->getRepositoryModel()->getName();
     $doc = new DocBlockGenerator();
     $doc->setTag(new Tag\GenericTag('ORM\\Entity(repositoryClass="' . $repository . '")'));
     $doc->setTag(new Tag\GenericTag('ORM\\Table(name="' . strtolower($this->config->getName()) . '")'));
     return $doc;
 }
开发者ID:enlitepro,项目名称:zf2-scaffold,代码行数:8,代码来源:EntityBuilder.php

示例4: generate

 public function generate(Generator\ClassGenerator $class, PHPClass $type)
 {
     $class = $this->fixInterfaces($class);
     if (!($extends = $type->getExtends()) && class_exists($type->getNamespace())) {
         $extendNamespace = $type->getNamespace();
         $extendNamespace = explode('\\', $extendNamespace);
         $extendClass = array_pop($extendNamespace);
         $extendNamespace = implode('\\', $extendNamespace);
         $extends = new PHPClass();
         $extends->setName($extendClass);
         $extends->setNamespace($extendNamespace);
         $class->setExtendedClass($extends);
     }
     if ($type->getNamespace() == Enumeration::class) {
         $extendNamespace = $type->getNamespace();
         $extendNamespace = explode('\\', $extendNamespace);
         $extendClass = array_pop($extendNamespace);
         $extendNamespace = implode('\\', $extendNamespace);
         $extends = new PHPClass();
         $extends->setName($extendClass);
         $extends->setNamespace($extendNamespace);
         $class->setExtendedClass($extends);
     }
     if ($extends->getName() == "string" && $extends->getNamespace() == "" && class_exists($type->getNamespace() . '\\String')) {
         $extends->setName('String');
         $extends->setNamespace($type->getNamespace());
     } elseif ($extends->getName() == "string" && $extends->getNamespace() == "" && class_exists($type->getNamespace())) {
         $extendNamespace = $type->getNamespace();
         $extendNamespace = explode('\\', $extendNamespace);
         $extendClass = array_pop($extendNamespace);
         $extendNamespace = implode('\\', $extendNamespace);
         $extends = new PHPClass();
         $extends->setName($extendClass);
         $extends->setNamespace($extendNamespace);
         $class->setExtendedClass($extends);
     }
     $docblock = new DocBlockGenerator("Class representing " . $type->getName());
     if ($type->getDoc()) {
         $docblock->setLongDescription($type->getDoc());
     }
     $class->setNamespaceName($type->getNamespace());
     $class->setName($type->getName());
     $class->setDocblock($docblock);
     $class->setExtendedClass($extends->getName());
     if ($extends->getNamespace() != $type->getNamespace()) {
         if ($extends->getName() == $type->getName()) {
             $class->addUse($type->getExtends()->getFullName(), $extends->getName() . "Base");
             $class->setExtendedClass($extends->getName() . "Base");
         } else {
             $class->addUse($extends->getFullName());
         }
     }
     if ($this->handleBody($class, $type)) {
         return true;
     }
 }
开发者ID:garethp,项目名称:php-ews,代码行数:56,代码来源:ClassGenerator.php

示例5: buildFactory

 /**
  * Build method factory
  *
  * @param ClassGenerator  $generator
  * @param \Scaffold\State $state
  */
 public function buildFactory(ClassGenerator $generator, State $state)
 {
     $repository = ucfirst($state->getRepositoryModel()->getClassName());
     $docBlock = new DocBlockGenerator();
     $docBlock->setTag(new Tag\GenericTag('return', $this->config->getName()));
     $factory = new MethodGenerator();
     $factory->setDocBlock($docBlock);
     $factory->setName('factory');
     $factory->setBody('return $this->get' . $repository . '()->factory();');
     $generator->addMethodFromGenerator($factory);
 }
开发者ID:enlitepro,项目名称:zf2-scaffold,代码行数:17,代码来源:ServiceBuilder.php

示例6: __construct

 /**
  * FileGenerator constructor.
  */
 public function __construct()
 {
     parent::__construct();
     $mockTag = new GenericTag();
     $mockTag->setName('mock');
     $author = new AuthorTag('ClassMocker');
     $docBlock = new DocBlockGenerator();
     $docBlock->setShortDescription("Auto generated file by ClassMocker, do not change");
     $docBlock->setTag($author);
     $docBlock->setTag($mockTag);
     $this->setDocBlock($docBlock);
 }
开发者ID:jsiefer,项目名称:class-mocker,代码行数:15,代码来源:FileGenerator.php

示例7: addProperty

 /**
  * @param type $name
  * @param type $type
  * @param type $docString
  * @return PhpProperty
  */
 public function addProperty($name, $type, $docString)
 {
     $property = new PropertyGenerator();
     $docblock = new DocBlockGenerator();
     $property->setName($name);
     $property->setVisibility(PropertyGenerator::VISIBILITY_PROTECTED);
     $docblock->setShortDescription($docString);
     $docblock->setTag(new Tag(array('name' => 'var', 'description' => $type)));
     $property->setDocblock($docblock);
     $this->addPropertyFromGenerator($property);
     return $property;
 }
开发者ID:nfx,项目名称:pugooroo,代码行数:18,代码来源:PhpClass.php

示例8: method

 /**
  * @param                          $name
  * @param ParameterGenerator[]     $params
  * @param string                   $visibility
  * @param string                   $body
  * @param string|DocBlockGenerator $docblock
  *
  * @return \Zend\Code\Generator\MethodGenerator
  */
 public static function method($name, $params = [], $visibility = 'public', $body = '//todo', $docblock = '')
 {
     if (empty($docblock)) {
         if (!empty($params)) {
             $docblock = new DocBlockGenerator();
             foreach ($params as $param) {
                 $tag = new Tag('param', $param->getType() . ' $' . $param->getName());
                 $docblock->setTag($tag);
             }
         }
     }
     return (new MethodGenerator($name, $params))->setBody($body)->setVisibility($visibility)->setDocBlock($docblock)->setIndentation(Generator::$indentation);
 }
开发者ID:shinichi81,项目名称:sdk,代码行数:22,代码来源:ClassGen.php

示例9: generate

 /**
  *
  * @param DTDDocument $document        	
  * @param string $outputDirectory        	
  * @param string $namespace        	
  * @param string $parentClass        	
  */
 public function generate(DTDDocument $document, $outputDirectory, $namespace, $parentClass)
 {
     if (!file_exists($outputDirectory)) {
         mkdir($outputDirectory, 0777, true);
     }
     $name = ucfirst($document->getFileInfo()->getBasename('.dtd'));
     $filename = sprintf("%s/%s.php", $outputDirectory, $name);
     $classGenerator = new ClassGenerator($name, $namespace, null, $parentClass);
     $fileGenerator = new FileGenerator();
     $fileGenerator->setClass($classGenerator);
     $fileDocblock = new DocBlockGenerator(sprintf("%s %s", str_replace("\\", " ", $namespace), $name));
     $fileDocblock->setTag(new Tag("author", "Generator"));
     $fileDocblock->setTag(new Tag("licence", "LGPL"));
     $fileGenerator->setDocBlock($fileDocblock);
     file_put_contents($filename, $fileGenerator->generate());
 }
开发者ID:slavomirkuzma,项目名称:itc-bundle,代码行数:23,代码来源:Document.php

示例10: fromReflection

    /**
     * fromReflection()
     *
     * @param  MethodReflection $reflectionMethod
     * @return MethodGenerator
     */
    public static function fromReflection(MethodReflection $reflectionMethod)
    {
        $method = new self();

        $method->setSourceContent($reflectionMethod->getContents(false));
        $method->setSourceDirty(false);

        if ($reflectionMethod->getDocComment() != '') {
            $method->setDocBlock(DocBlockGenerator::fromReflection($reflectionMethod->getDocBlock()));
        }

        $method->setFinal($reflectionMethod->isFinal());

        if ($reflectionMethod->isPrivate()) {
            $method->setVisibility(self::VISIBILITY_PRIVATE);
        } elseif ($reflectionMethod->isProtected()) {
            $method->setVisibility(self::VISIBILITY_PROTECTED);
        } else {
            $method->setVisibility(self::VISIBILITY_PUBLIC);
        }

        $method->setStatic($reflectionMethod->isStatic());

        $method->setName($reflectionMethod->getName());

        foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
            $method->setParameter(ParameterGenerator::fromReflection($reflectionParameter));
        }

        $method->setBody($reflectionMethod->getBody());

        return $method;
    }
开发者ID:necrogami,项目名称:zf2,代码行数:39,代码来源:MethodGenerator.php

示例11: fromArray

 /**
  * Generate from array
  *
  * @configkey name           string        [required] Class Name
  * @configkey filegenerator  FileGenerator File generator that holds this class
  * @configkey namespacename  string        The namespace for this class
  * @configkey docblock       string        The docblock information
  * @configkey properties
  * @configkey methods
  *
  * @throws Exception\InvalidArgumentException
  * @param  array $array
  * @return TraitGenerator
  */
 public static function fromArray(array $array)
 {
     if (!isset($array['name'])) {
         throw new Exception\InvalidArgumentException('Class generator requires that a name is provided for this object');
     }
     $cg = new static($array['name']);
     foreach ($array as $name => $value) {
         // normalize key
         switch (strtolower(str_replace(array('.', '-', '_'), '', $name))) {
             case 'containingfile':
                 $cg->setContainingFileGenerator($value);
                 break;
             case 'namespacename':
                 $cg->setNamespaceName($value);
                 break;
             case 'docblock':
                 $docBlock = $value instanceof DocBlockGenerator ? $value : DocBlockGenerator::fromArray($value);
                 $cg->setDocBlock($docBlock);
                 break;
             case 'properties':
                 $cg->addProperties($value);
                 break;
             case 'methods':
                 $cg->addMethods($value);
                 break;
         }
     }
     return $cg;
 }
开发者ID:Flesh192,项目名称:magento,代码行数:43,代码来源:TraitGenerator.php

示例12: fromReflection

    /**
     * fromReflection()
     *
     * @param PropertyReflection $reflectionProperty
     * @return PropertyGenerator
     */
    public static function fromReflection(PropertyReflection $reflectionProperty)
    {
        $property = new self();

        $property->setName($reflectionProperty->getName());

        $allDefaultProperties = $reflectionProperty->getDeclaringClass()->getDefaultProperties();

        $property->setDefaultValue($allDefaultProperties[$reflectionProperty->getName()]);

        if ($reflectionProperty->getDocComment() != '') {
            $property->setDocBlock(DocBlockGenerator::fromReflection($reflectionProperty->getDocComment()));
        }

        if ($reflectionProperty->isStatic()) {
            $property->setStatic(true);
        }

        if ($reflectionProperty->isPrivate()) {
            $property->setVisibility(self::VISIBILITY_PRIVATE);
        } elseif ($reflectionProperty->isProtected()) {
            $property->setVisibility(self::VISIBILITY_PROTECTED);
        } else {
            $property->setVisibility(self::VISIBILITY_PUBLIC);
        }

        $property->setSourceDirty(false);

        return $property;
    }
开发者ID:necrogami,项目名称:zf2,代码行数:36,代码来源:PropertyGenerator.php

示例13: generate

 private function generate($version)
 {
     $generator = new ClassGenerator();
     $docblock = DocBlockGenerator::fromArray(array('shortDescription' => 'PDO Simple Migration Class', 'longDescription' => 'Add your queries below'));
     $generator->setName('PDOSimpleMigration\\Migrations\\Migration' . $version)->setExtendedClass('AbstractMigration')->addUse('PDOSimpleMigration\\Library\\AbstractMigration')->setDocblock($docblock)->addProperties(array(array('description', 'Migration description', PropertyGenerator::FLAG_STATIC)))->addMethods(array(MethodGenerator::fromArray(array('name' => 'up', 'parameters' => array(), 'body' => '//$this->addSql(/*Sql instruction*/);', 'docblock' => DocBlockGenerator::fromArray(array('shortDescription' => 'Migrate up', 'longDescription' => null)))), MethodGenerator::fromArray(array('name' => 'down', 'parameters' => array(), 'body' => '//$this->addSql(/*Sql instruction*/);', 'docblock' => DocBlockGenerator::fromArray(array('shortDescription' => 'Migrate down', 'longDescription' => null))))));
     $file = FileGenerator::fromArray(array('classes' => array($generator)));
     return $file->generate();
 }
开发者ID:fabiopaiva,项目名称:PDOSimpleMigration,代码行数:8,代码来源:MigrationGenerateCommand.php

示例14: testGenerateWithWordWrapDisabled

 /**
  * @group #3753
  */
 public function testGenerateWithWordWrapDisabled()
 {
     $largeStr = '@var This is a very large string that will not be wrapped if it contains more than 80 characters';
     $this->docBlockGenerator->setLongDescription($largeStr);
     $this->docBlockGenerator->setWordWrap(false);
     $expected = '/**' . DocBlockGenerator::LINE_FEED . ' * @var This is a very large string that will not be wrapped if it contains more than' . ' 80 characters' . DocBlockGenerator::LINE_FEED . ' */' . DocBlockGenerator::LINE_FEED;
     $this->assertEquals($expected, $this->docBlockGenerator->generate());
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:11,代码来源:DocBlockGeneratorTest.php

示例15: addCustomFiltersMethod

 private function addCustomFiltersMethod()
 {
     $body = 'return $inputFilter;';
     $inputFilterParm = new ParameterGenerator('inputFilter', null, null, null, true);
     $docBlock = DocBlockGenerator::fromArray(array('shortDescription' => 'You may customize the filters behaviours using this method'));
     $result = new MethodGenerator('addCustomFilters', array($inputFilterParm, 'factory'), MethodGenerator::FLAG_PUBLIC, $body, $docBlock);
     return $result;
 }
开发者ID:jaguevara1978,项目名称:ZF2_REST_OAuth2_Postgres_Backend,代码行数:8,代码来源:ModelGenerator.php


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