本文整理汇总了PHP中Zend\Code\Generator\DocBlockGenerator::setShortDescription方法的典型用法代码示例。如果您正苦于以下问题:PHP DocBlockGenerator::setShortDescription方法的具体用法?PHP DocBlockGenerator::setShortDescription怎么用?PHP DocBlockGenerator::setShortDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Code\Generator\DocBlockGenerator
的用法示例。
在下文中一共展示了DocBlockGenerator::setShortDescription方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例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: createClass
/**
* @param Tag $tagItem
* @return ClassGenerator
*/
protected function createClass(Tag $tagItem)
{
$className = ucfirst($this->stringToCamelCaseConverter->convert($tagItem->getName()));
$class = new ClassGenerator();
$class->setNamespaceName('Flex\\Code\\Html\\Tag');
$class->setName($className);
$class->addUse('Flex\\Code\\Html\\Tag\\Model\\AbstractTag');
$class->setExtendedClass('AbstractTag');
$implementedInterfaces = [];
if ($tagItem->isGlobalAttributeAware()) {
$implementedInterfaces[] = 'GlobalAttributeAwareInterface';
$class->addUse('Flex\\Code\\Html\\Tag\\Attribute\\GlobalAttributeAwareInterface');
$class->addUse('Flex\\Code\\Html\\Tag\\Attribute\\GlobalAttributeAwareTrait');
$class->addTrait('GlobalAttributeAwareTrait');
}
if ($tagItem->isClipboardEventAware()) {
$implementedInterfaces[] = 'ClipboardEventAwareInterface';
$class->addUse('Flex\\Code\\Html\\Tag\\Event\\ClipboardEventAwareInterface');
$class->addUse('Flex\\Code\\Html\\Tag\\Event\\ClipboardEventAwareTrait');
$class->addTrait('ClipboardEventAwareTrait');
}
if ($tagItem->isFormEventAware()) {
$implementedInterfaces[] = 'FormEventAwareInterface';
$class->addUse('Flex\\Code\\Html\\Tag\\Event\\FormEventAwareInterface');
$class->addUse('Flex\\Code\\Html\\Tag\\Event\\FormEventAwareTrait');
$class->addTrait('FormEventAwareTrait');
}
if ($tagItem->isKeyboardEventAware()) {
$implementedInterfaces[] = 'KeyboardEventAwareInterface';
$class->addUse('Flex\\Code\\Html\\Tag\\Event\\KeyboardEventAwareInterface');
$class->addUse('Flex\\Code\\Html\\Tag\\Event\\KeyboardEventAwareTrait');
$class->addTrait('KeyboardEventAwareTrait');
}
if ($tagItem->isMediaEventAware()) {
$implementedInterfaces[] = 'MediaEventAwareInterface';
$class->addUse('Flex\\Code\\Html\\Tag\\Event\\MediaEventAwareInterface');
$class->addUse('Flex\\Code\\Html\\Tag\\Event\\MediaEventAwareTrait');
$class->addTrait('MediaEventAwareTrait');
}
if ($tagItem->isMiscEventAware()) {
$implementedInterfaces[] = 'MiscEventAwareInterface';
$class->addUse('Flex\\Code\\Html\\Tag\\Event\\MiscEventAwareInterface');
$class->addUse('Flex\\Code\\Html\\Tag\\Event\\MiscEventAwareTrait');
$class->addTrait('MiscEventAwareTrait');
}
if ($tagItem->isMouseEventAware()) {
$implementedInterfaces[] = 'MouseEventAwareInterface';
$class->addUse('Flex\\Code\\Html\\Tag\\Event\\MouseEventAwareInterface');
$class->addUse('Flex\\Code\\Html\\Tag\\Event\\MouseEventAwareTrait');
$class->addTrait('MouseEventAwareTrait');
}
if ($tagItem->isWindowEventAware()) {
$implementedInterfaces[] = 'WindowEventAwareInterface';
$class->addUse('Flex\\Code\\Html\\Tag\\Event\\WindowEventAwareInterface');
$class->addUse('Flex\\Code\\Html\\Tag\\Event\\WindowEventAwareTrait');
$class->addTrait('WindowEventAwareTrait');
}
$class->setImplementedInterfaces($implementedInterfaces);
$docBlock = new DocBlockGenerator();
$docBlock->setTag(new GenericTag('author', 'elnebuloso/flex-code-html-generator'));
$docBlock->setTag(new GenericTag('link', $tagItem->getLink()));
if (!is_null($tagItem->getShortDescription())) {
$docBlock->setShortDescription($tagItem->getShortDescription());
}
if (!is_null($tagItem->getLongDescription())) {
$docBlock->setLongDescription($tagItem->getLongDescription());
}
$class->setDocBlock($docBlock);
return $class;
}
示例4: generate
public function generate()
{
$method = $this->getMethodGenerator();
$api = $this->getApi();
$operation = $this->getOperation();
$method->setName($operation->getNickname());
$parameterClassGenerator = $this->getParameterClassGenerator();
$parameterClassGenerator->setName($operation->getNickname());
$parameterGenerator = $this->getParameterGenerator();
$propertyGenerator = $this->getPropertyGenerator();
$docBlockGenerator = $this->getDocblockGenerator();
$docBlockGenerator->setShortDescription($operation->getSummary());
$docBlockGenerator->setLongDescription(strip_tags($operation->getNotes()));
$hasRequired = false;
$routeParams = array();
foreach ($operation->getParameters() as $swaggerParameter) {
switch ($swaggerParameter->getParamType()) {
case self::PARAM_TYPE_PATH:
if ($swaggerParameter->getRequired()) {
$hasRequired = true;
}
$parameters = $method->getParameters();
if (isset($parameters[$swaggerParameter->getName()])) {
continue;
}
$parameter = clone $parameterGenerator;
$parameter->setName($swaggerParameter->getName());
$method->setParameter($parameter);
$paramTag = new CodeGenerator\DocBlock\Tag\ParamTag();
$paramTag->setDataType($swaggerParameter::getType($swaggerParameter->getDataType()));
$paramTag->setParamName($swaggerParameter->getName());
$paramDescription = $swaggerParameter->getDescription();
$paramTag->setDescription($paramDescription);
$docBlockGenerator->setTag($paramTag);
$routeParams[] = $parameter;
break;
case self::PARAM_TYPE_QUERY:
case self::PARAM_TYPE_FORM:
$propertyName = lcfirst($swaggerParameter->getName());
if (($postParamStart = strpos($propertyName, '[')) !== false) {
$propertyPostParams = substr($propertyName, $postParamStart);
$propertyName = substr($propertyName, 0, $postParamStart);
echo "{$method->getName()}::\${$propertyName} has: {$propertyPostParams}" . PHP_EOL;
}
if ($parameterClassGenerator->hasProperty($propertyName)) {
continue;
}
$property = clone $propertyGenerator;
$property->setName($propertyName);
$propertyDocblock = new CodeGenerator\DocBlockGenerator();
$propertyDocblock->setShortDescription($swaggerParameter->getDescription());
$propertyDescription = '';
if ($allowableValues = $swaggerParameter->getAllowableValues()) {
if ($allowableValues->getValueType() == 'LIST') {
$propertyDescription .= 'Allowable values: [' . implode(', ', $allowableValues->getValues()) . ']' . PHP_EOL;
}
}
$propertyDocblock->setLongDescription($propertyDescription);
if (!$this->isDocBlockEmpty($propertyDocblock)) {
$property->setDocBlock($propertyDocblock);
}
$parameterClassGenerator->addPropertyFromGenerator($property);
$getterGenerator = $this->generateParameterGetter($propertyName, $swaggerParameter);
$setterGenerator = $this->generateParameterSetter($propertyName, $swaggerParameter);
$parameterClassGenerator->addMethods(array($getterGenerator, $setterGenerator));
break;
}
}
if (count($parameterClassGenerator->getProperties())) {
$queryParameter = clone $parameterGenerator;
$queryParameter->setName($operation->getNickname());
$queryParameter->setType(RestGenerator::REQUEST_NAMESPACE_ALIAS . '\\' . $operation->getNickname());
if (!$hasRequired) {
$queryParameter->setDefaultValue(new CodeGenerator\ValueGenerator(null));
}
$paramTag = new CodeGenerator\DocBlock\Tag\ParamTag();
$paramTag->setDataType(RestGenerator::REQUEST_NAMESPACE_ALIAS . '\\' . $operation->getNickname());
$paramTag->setParamName($operation->getNickname());
if (!$hasRequired) {
$paramTag->setDescription(' = null');
}
$docBlockGenerator->setTag($paramTag);
$method->setParameter($queryParameter);
} else {
$queryParameter = null;
}
$method->setDocBlock($docBlockGenerator);
$body = $this->getBody($routeParams, $queryParameter);
$method->setBody($body);
}
示例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);
}
示例6: 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);
}
示例7: 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());
}
示例8: createService
/**
* {@inheritdoc}
*/
public function createService(SimpleXMLElement $service)
{
// read the service name
$serviceName = (string) $service['name'];
$serviceClassName = $serviceName;
$serviceClassName = filter_var($serviceClassName, FILTER_CALLBACK, array('options' => array($this, 'sanitizeVariableName')));
$serviceClassName = filter_var($serviceClassName, FILTER_CALLBACK, array('options' => array($this, 'sanitizeConstantName')));
/*
* CLASS CREATION
*/
// create the class
$class = ClassGenerator::fromReflection(new ClassReflection('\\Sapone\\Template\\ServiceTemplate'));
$class->setName($serviceClassName);
$class->setNamespaceName($this->namespaceInflector->inflectNamespace($service));
// set the correct inheritance
if ($this->config->isBesimpleClient()) {
$class->setExtendedClass('BeSimpleSoapClient');
$class->addUse('BeSimple\\SoapClient\\SoapClient');
} else {
$class->setExtendedClass('\\SoapClient');
}
// read the service documentation
$serviceDoc = new DocBlockGenerator();
$serviceDoc->setTag(new GenericTag('xmlns', '@todo'));
$documentation = new Html2Text((string) current($service->xpath('./wsdl:documentation')));
if ($documentation->getText()) {
$serviceDoc->setShortDescription($documentation->getText());
}
$class->setDocBlock($serviceDoc);
/*
* METHODS CREATION
*/
foreach ($service->xpath('.//wsdl:operation') as $operation) {
$operationName = (string) $operation['name'];
$operationName = filter_var($operationName, FILTER_CALLBACK, array('options' => array($this, 'sanitizeVariableName')));
$operationName = filter_var($operationName, FILTER_CALLBACK, array('options' => array($this, 'sanitizeConstantName')));
$inputMessageType = $this->getTypeFromQualifiedString((string) current($operation->xpath('.//wsdl:input/@message')), $operation);
$outputMessageType = $this->getTypeFromQualifiedString((string) current($operation->xpath('.//wsdl:output/@message')), $operation);
// read the service documentation
$messageDoc = new DocBlockGenerator();
$documentation = new Html2Text((string) current($operation->xpath('./wsdl:documentation')));
$param = new ParameterGenerator('parameters', $inputMessageType);
$messageDoc->setTag(new ParamTag($param->getName(), $this->namespaceInflector->inflectDocBlockQualifiedName($inputMessageType)));
$messageDoc->setTag(new ReturnTag($this->namespaceInflector->inflectDocBlockQualifiedName($outputMessageType)));
if ($documentation->getText()) {
$messageDoc->setShortDescription($documentation->getText());
}
// create the method
$method = new MethodGenerator($operationName);
$method->setDocBlock($messageDoc);
$method->setParameter($param);
$method->setBody("return \$this->__soapCall('{$operation['name']}', array(\$parameters));");
$class->addMethodFromGenerator($method);
}
$this->serializeClass($class);
// register the class in the classmap
$this->classmap[$class->getName()] = $class->getNamespaceName() . '\\' . $class->getName();
return $class->getName();
}