本文整理汇总了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;
}
示例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);
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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());
}
示例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);
}
示例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;
}
示例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();
}
示例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());
}
示例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);
}
示例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);
}