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


PHP DocBlockGenerator::setTag方法代码示例

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


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

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

示例2: __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

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

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

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

示例6: build

 /**
  * Build generators
  *
  * @param  State|\Scaffold\State $state
  * @return \Scaffold\State|void
  */
 public function build(State $state)
 {
     $model = $this->model;
     $generator = new ClassGenerator($model->getName());
     $generator->addUse('Zend\\ServiceManager\\FactoryInterface');
     $generator->addUse('Zend\\ServiceManager\\ServiceLocatorInterface');
     $generator->addUse('Zend\\ServiceManager\\ServiceManager');
     $generator->addUse($state->getServiceModel()->getName());
     $generator->setImplementedInterfaces(['FactoryInterface']);
     $method = new MethodGenerator('createService');
     $method->setParameter(new ParameterGenerator('serviceLocator', 'ServiceLocatorInterface'));
     $method->setBody('return new ' . $state->getServiceModel()->getClassName() . '($serviceLocator);');
     $doc = new DocBlockGenerator('Create service');
     $doc->setTag(new Tag\GenericTag('param', 'ServiceLocatorInterface|ServiceManager $serviceLocator'));
     $doc->setTag(new Tag\GenericTag('return', $state->getServiceModel()->getClassName()));
     $method->setDocBlock($doc);
     $generator->addMethodFromGenerator($method);
     $model->setGenerator($generator);
 }
开发者ID:enlitepro,项目名称:zf2-scaffold,代码行数:25,代码来源:ServiceFactoryBuilder.php

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

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

示例9: execute

 /**
  * (non-PHPdoc)
  *
  * @see \Symfony\Component\Console\Command\Command::execute()
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $document = $this->getDocument($input->getArgument('document'));
     $directory = $input->getArgument('output');
     $namespace = $input->getArgument('namespace');
     $parentClass = $input->getArgument('parentClass');
     if (!file_exists($directory)) {
         mkdir($directory, 0777, true);
     }
     $name = ucfirst($document->getFileInfo()->getBasename('.dtd'));
     $output->writeln("Generating Document " . $name);
     $filename = sprintf("%s/%s.php", $directory, $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,代码行数:26,代码来源:Document.php

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

示例11: handle

 /**
  * @param string $className
  * @return ClassGenerator
  */
 public function handle(string $className)
 {
     if (!preg_match(static::MATCH_PATTERN, $className, $matches)) {
         return null;
     }
     $baseName = $matches[1];
     $namespace = $this->deriveNamespaceFromClassName($className);
     $typeName = "{$namespace}\\{$baseName}";
     $reflectedClass = new ReflectionClass($typeName);
     if ($reflectedClass->isTrait() === true || $reflectedClass->isAbstract() === true) {
         return null;
     }
     $class = $this->getClassTemplate();
     $class->setNamespaceName($namespace)->setName($baseName . $class->getName());
     $propertyDocBlock = new DocBlockGenerator(null, null, array(array("name" => "var", "content" => "\\{$typeName}")));
     $class->getProperty("_instance")->setDocBlock($propertyDocBlock);
     $methodDocBlock = new DocBlockGenerator();
     $returnTag = new ReturnTag("\\{$typeName}");
     $methodDocBlock->setTag($returnTag);
     $instanceMethod = $class->getMethod("_getInstance");
     $instanceMethod->setDocBlock($methodDocBlock)->setReturnType($typeName);
     if ($reflectedClass->isInterface() === true) {
         $class->setImplementedInterfaces(array("\\{$typeName}"));
     } else {
         $class->setExtendedClass("\\{$typeName}");
     }
     $publicMethods = $reflectedClass->getMethods(ReflectionMethod::IS_PUBLIC);
     $addMethods = array();
     foreach ($publicMethods as $method) {
         if ($method->isConstructor() || $method->isDestructor() || $method->isFinal() || $method->isStatic()) {
             continue;
         }
         if ($method->getName() === "__clone") {
             continue;
         }
         $addMethods[] = $this->getMethodDetails($method);
     }
     $class->addMethods($addMethods);
     $this->makeExtraModifications($class, $typeName);
     return $class;
 }
开发者ID:djmattyg007,项目名称:autocodeloader,代码行数:45,代码来源:AbstractProxyGenerator.php

示例12: createClassmap

 /**
  * {@inheritdoc}
  */
 public function createClassmap()
 {
     /*
      * INI FILE GENERATION
      */
     $outputPath = array($this->config->getOutputPath());
     // if the psr0 autoloader has been selected, transform the class namespace into a filesystem path
     if ($this->config->getAutoloader() === Config::AUTOLOADER_PSR0) {
         $outputPath[] = str_ireplace('\\', DIRECTORY_SEPARATOR, $this->config->getNamespace());
     }
     // append the file name
     $outputPath[] = 'classmap.ini';
     // finalize the output path
     $outputPath = implode(DIRECTORY_SEPARATOR, $outputPath);
     // remove the file if exists
     $fs = new Filesystem();
     $fs->remove($outputPath);
     foreach ($this->classmap as $wsdlType => $phpType) {
         file_put_contents($outputPath, "{$wsdlType} = {$phpType}" . AbstractGenerator::LINE_FEED, FILE_APPEND);
     }
     /*
      * CLASS GENERATION
      */
     // create the class
     $class = ClassGenerator::fromReflection(new ClassReflection('\\Sapone\\Template\\ClassmapTemplate'));
     $class->setName('Classmap');
     $class->setExtendedClass('\\ArrayObject');
     $class->setNamespaceName($this->config->getNamespace());
     $doc = new DocBlockGenerator();
     $doc->setTag(new GenericTag('@service', $this->config->getWsdlDocumentPath()));
     $class->setDocBlock($doc);
     $this->serializeClass($class);
     return $class->getName();
 }
开发者ID:xstefanox,项目名称:sapone,代码行数:37,代码来源:ClassFactory.php

示例13: writeModuleConfig

 /**
  * writes module config
  *
  * @param array $config
  * @param string $path
  */
 protected function writeModuleConfig(array $config, $path)
 {
     $moduleName = $this->params->getParam('moduleName');
     $generatorConfig = new FileGenerator();
     $docBlock = new DocBlockGenerator();
     $docBlock->setTag(new GenericTag('author', $this->params->getParam('author')));
     $docBlock->setTag(new GenericTag('project', $this->params->getParam('project')));
     $docBlock->setTag(new GenericTag('license', $this->params->getParam('license')));
     $docBlock->setTag(new GenericTag('copyright', $this->params->getParam('copyright')));
     $docBlock->setShortDescription(sprintf($this->codeLibrary()->get('module.generatedConfigDescription'), $moduleName));
     $generatorConfig->setDocBlock($docBlock);
     $configString = var_export($config, true);
     $configString = str_replace("'/../view'", '__DIR__ . \'/../view\'', $configString);
     $generatorConfig->setBody('return ' . $configString . ';');
     file_put_contents($path, $generatorConfig->generate());
 }
开发者ID:renatosalvatori,项目名称:visio-crud-zf2,代码行数:22,代码来源:ControllerGenerator.php

示例14: handleAdder

 private function handleAdder(Generator\ClassGenerator $generator, PHPProperty $prop, PHPClass $class)
 {
     $type = $prop->getType();
     $propName = $type->getArg()->getName();
     $docblock = new DocBlockGenerator();
     $docblock->setShortDescription("Adds as {$propName}");
     if ($prop->getDoc()) {
         $docblock->setLongDescription($prop->getDoc());
     }
     $return = new ReturnTag();
     $return->setTypes("self");
     $docblock->setTag($return);
     $patramTag = new ParamTag($propName, $this->getPhpType($type->getArg()->getType()));
     $docblock->setTag($patramTag);
     $method = new MethodGenerator("addTo" . Inflector::classify($prop->getName()));
     $parameter = new ParameterGenerator($propName);
     $tt = $type->getArg()->getType();
     if (!$this->isNativeType($tt)) {
         if ($p = $this->isOneType($tt)) {
             if ($t = $p->getType()) {
                 $patramTag->setTypes($this->getPhpType($t));
                 if (!$this->isNativeType($t)) {
                     $parameter->setType($this->getPhpType($t));
                 }
             }
         } elseif (!$this->isNativeType($tt)) {
             $parameter->setType($this->getPhpType($tt));
         }
     }
     $methodBody = "\$this->" . $prop->getName() . "[] = \$" . $propName . ";" . PHP_EOL;
     $methodBody .= "return \$this;";
     $method->setBody($methodBody);
     $method->setDocBlock($docblock);
     $method->setParameter($parameter);
     $generator->addMethodFromGenerator($method);
 }
开发者ID:josedasilva,项目名称:xsd2php,代码行数:36,代码来源:ClassGenerator.php

示例15: addAttribute

 /**
  * @param ClassGenerator $class
  * @param Attribute $tagAttribute
  */
 protected function addAttribute(ClassGenerator $class, Attribute $tagAttribute)
 {
     $methodName = str_replace(':', '-', $tagAttribute->getName());
     $methodName = ucfirst($this->stringToCamelCaseConverter->convert($methodName, '-'));
     $method = new MethodGenerator();
     if ($tagAttribute->isFlag()) {
         $method->setName('is' . $methodName);
         $method->setParameter(new ParameterGenerator('v', 'bool', true));
     } else {
         $method->setName('set' . $methodName);
         $method->setParameter(new ParameterGenerator('v', 'string'));
     }
     $body = [];
     $body[] = '$this->attributes[\'' . $tagAttribute->getName() . '\'] = $v;';
     $body[] = 'return $this;';
     $method->setBody(implode(PHP_EOL, $body));
     $docBlock = new DocBlockGenerator();
     $docBlock->setTag(new GenericTag('var', 'string'));
     $docBlock->setTag(new GenericTag('return', '$this'));
     if (!is_null($tagAttribute->getDescription())) {
         $docBlock->setLongDescription($tagAttribute->getDescription());
     }
     $method->setDocBlock($docBlock);
     $class->addMethodFromGenerator($method);
 }
开发者ID:elnebuloso,项目名称:flex-code-html,代码行数:29,代码来源:Generator.php


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