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


PHP PropertyGenerator::setDocBlock方法代码示例

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


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

示例1: getProperty

 /**
  * @param  string            $name
  * @param  string            $type
  * @return PropertyGenerator
  */
 protected function getProperty($name, $type)
 {
     $property = new PropertyGenerator($name, null, PropertyGenerator::FLAG_PROTECTED);
     $property->setDocBlock(new DocBlockGenerator());
     $property->getDocBlock()->setTag(new Tag\GenericTag('var', $type));
     return $property;
 }
开发者ID:enlitepro,项目名称:zf2-scaffold,代码行数:12,代码来源:AbstractBuilder.php

示例2: getIdProperty

 /**
  * @return PropertyGenerator
  */
 protected function getIdProperty()
 {
     $id = new PropertyGenerator('id', null, PropertyGenerator::FLAG_PROTECTED);
     $id->setDocBlock(new DocBlockGenerator());
     $id->getDocBlock()->setTag(new Tag\GenericTag('var', 'int'));
     $id->getDocBlock()->setTag(new Tag\GenericTag('ORM\\Id'));
     $id->getDocBlock()->setTag(new Tag\GenericTag('ORM\\GeneratedValue'));
     $id->getDocBlock()->setTag(new Tag\GenericTag('ORM\\Column(type="integer")'));
     return $id;
 }
开发者ID:enlitepro,项目名称:zf2-scaffold,代码行数:13,代码来源:EntityBuilder.php

示例3: handle

 /**
  * @param string $className
  * @return TraitGenerator
  */
 public function handle(string $className)
 {
     if (!preg_match(static::MATCH_PATTERN, $className, $matches)) {
         return null;
     }
     $baseName = $matches[1];
     $namespace = $this->deriveNamespaceFromClassName($className);
     $camelCaseBaseName = $this->stripInterfaceLabelFromName($this->makeClassNameCamelCase($baseName));
     $trait = new TraitGenerator("Needs{$baseName}Trait");
     $trait->setNamespaceName($namespace);
     $docBlock = new DocBlockGenerator(null, null, array(array("name" => "var", "content" => "\\{$namespace}\\{$baseName}")));
     $property = new PropertyGenerator($camelCaseBaseName, null, PropertyGenerator::FLAG_PROTECTED);
     $property->setDocBlock($docBlock);
     $trait->addProperties(array($property));
     $parameter = new ParameterGenerator($camelCaseBaseName, "{$namespace}\\{$baseName}");
     $method = new MethodGenerator("set" . $this->stripInterfaceLabelFromName($baseName), array($parameter), MethodGenerator::FLAG_PUBLIC, sprintf('$this->%1$s = $%1$s;', $camelCaseBaseName));
     $trait->addMethods(array($method));
     return $trait;
 }
开发者ID:djmattyg007,项目名称:autocodeloader,代码行数:23,代码来源:NeedsTraitGenerator.php

示例4: preRun

 /**
  * @param \Model\Generator\Part\Model|\Model\Generator\Part\PartInterface $part
  */
 public function preRun(PartInterface $part)
 {
     /**
      * @var Table $table
      */
     $table = $part->getTable();
     /**
      * @var $file \Model\Code\Generator\FileGenerator
      */
     $file = $part->getFile();
     /** @var array|AbstractLink[] $linkList */
     $linkList = $table->getLink();
     foreach ($linkList as $link) {
         $_name = strtoupper($link->getForeignEntity());
         $name = 'JOIN_' . $_name;
         $property = new PropertyGenerator($name, strtolower($_name), PropertyGenerator::FLAG_CONSTANT);
         $tags = array(array('name' => 'const'), array('name' => 'var', 'description' => 'string'));
         $docblock = new DocBlockGenerator('JOIN сущность ' . $_name);
         $docblock->setTags($tags);
         $property->setDocBlock($docblock);
         $this->_data[$table->getName()][$name] = $property;
     }
 }
开发者ID:meniam,项目名称:model,代码行数:26,代码来源:JoinConst.php

示例5: generateEnumConstantList

 /**
  * @param \Model\Generator\Part\Model $part
  */
 public function generateEnumConstantList($part)
 {
     $file = $part->getFile();
     $table = $part->getTable();
     foreach ($table->getColumn() as $column) {
         if ($column->getColumnType() == 'enum') {
             $enumList = $column->getEnumValuesAsArray();
             // пропускаем флаги и enum поля с числом параметров >10
             if (substr($column->getName(), 0, 3) == 'is_' || $enumList == array('y', 'n') || count($enumList) > 10) {
                 continue;
             }
             foreach ($enumList as $enumValue) {
                 $columnName = $column->getName();
                 $name = strtoupper($columnName . '_' . $enumValue);
                 $property = new PropertyGenerator($name, $enumValue, PropertyGenerator::FLAG_CONSTANT);
                 $tags = array(array('name' => 'const'), array('name' => 'var', 'description' => 'string'));
                 $docblock = new DocBlockGenerator("Значение {$enumValue} поля {$columnName}");
                 $docblock->setTags($tags);
                 $property->setDocBlock($docblock);
                 $file->getClass()->addPropertyFromGenerator($property);
             }
         }
     }
 }
开发者ID:meniam,项目名称:model,代码行数:27,代码来源:ConstantList.php

示例6: preRun

 /**
  * @param \Model\Generator\Part\Model|\Model\Generator\Part\PartInterface $part
  */
 public function preRun(PartInterface $part)
 {
     /**
      * @var $file \Model\Code\Generator\FileGenerator
      */
     $file = $part->getFile();
     /** @var Table $table */
     $table = $part->getTable();
     /** @var string $tableName */
     //$tableName = $table->getName();
     /** @var $linkList|Link[] \Model\Cluster\Schema\Table\Column */
     //$linkList = $table->getLink();
     if ($table->isTree()) {
         $names = array('WITH_CHILD', 'WITH_CHILD_COLLECTION', 'WITH_ALL_CHILD', 'WITH_ALL_CHILD_COLLECTION');
         foreach ($names as $name) {
             $property = new PropertyGenerator($name, strtolower($name), PropertyGenerator::FLAG_CONSTANT);
             $tags = array(array('name' => 'const'), array('name' => 'var', 'description' => 'string'));
             $docblock = new DocBlockGenerator('WITH entity for child list');
             $docblock->setTags($tags);
             $property->setDocBlock($docblock);
             $file->getClass()->addPropertyFromGenerator($property);
         }
     }
 }
开发者ID:meniam,项目名称:model,代码行数:27,代码来源:Tree.php

示例7: addOptionsProperty

 /**
  * @param string           $columnName
  * @param ConstraintObject $foreignKey
  */
 protected function addOptionsProperty($columnName, ConstraintObject $foreignKey)
 {
     $columnName = lcfirst(StaticFilter::execute($columnName, 'Word\\UnderscoreToCamelCase'));
     $property = new PropertyGenerator($columnName . 'Options');
     $property->addFlag(PropertyGenerator::FLAG_PRIVATE);
     $property->setDocBlock(new DocBlockGenerator($columnName . ' options', null, [['name' => 'var', 'description' => 'array']]));
     $this->addPropertyFromGenerator($property);
 }
开发者ID:zfrapid,项目名称:zf2rapid,代码行数:12,代码来源:InputFilterClassGenerator.php

示例8: testPropertyCanHaveDocBlock

    /**
     * @group ZF-7205
     */
    public function testPropertyCanHaveDocBlock()
    {
        $codeGenProperty = new PropertyGenerator('someVal', 'some string value', PropertyGenerator::FLAG_STATIC | PropertyGenerator::FLAG_PROTECTED);
        $codeGenProperty->setDocBlock('@var string $someVal This is some val');
        $expected = <<<EOS
    /**
     * @var string \$someVal This is some val
     */
    protected static \$someVal = 'some string value';
EOS;
        $this->assertEquals($expected, $codeGenProperty->generate());
    }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:15,代码来源:PropertyGeneratorTest.php

示例9: getTypesCode

 /**
  * @return ClassGenerator[]
  */
 private function getTypesCode()
 {
     $generator = $this;
     return array_map(function (Structure\TypeStructure $type) use($generator) {
         $code = new ClassGenerator($type->getClassName());
         $code->setNamespaceName($generator->getFullNamespace($type->getClassName(), true));
         foreach ($type->getMembers() as $member) {
             $tag = new Tag();
             $tag->setName('var');
             if ($member->isPrimitive()) {
                 $tag->setDescription($member->getType());
             } else {
                 $tag->setDescription("\\" . $generator->getFullNamespace($member->getType()));
             }
             $docBlock = new DocBlockGenerator(null, null, [$tag]);
             $property = new PropertyGenerator();
             $property->setName($member->getName());
             $property->setDocBlock($docBlock);
             $code->addPropertyFromGenerator($property);
         }
         return $code;
     }, $this->service->getTypes()->getArrayCopy());
 }
开发者ID:mlebkowski,项目名称:wsdl-generator,代码行数:26,代码来源:WSDLGenerator.php

示例10: getStackProperty

 /**
  * @return PropertyGenerator
  */
 protected function getStackProperty()
 {
     $property = new PropertyGenerator('stack', null, PropertyGenerator::FLAG_PROTECTED);
     $property->setDocBlock(new DocBlockGenerator('Tokens stack', '', array(array('name' => 'var', 'description' => '\\SplStack'))));
     return $property;
 }
开发者ID:ftdebugger,项目名称:jungle,代码行数:9,代码来源:Builder.php

示例11: addMessageTemplates

 /**
  * @param $className
  */
 protected function addMessageTemplates($className)
 {
     // generate property
     $property = new PropertyGenerator();
     $property->setName('messageTemplates');
     $property->setDefaultValue(['invalid' . $className => 'Value "%value%" is not valid']);
     $property->setVisibility(PropertyGenerator::FLAG_PROTECTED);
     // check for api docs
     if ($this->config['flagAddDocBlocks']) {
         $property->setDocBlock(new DocBlockGenerator('Validation failure message template definitions', '', [new GenericTag('var', 'array')]));
     }
     // add property
     $this->addPropertyFromGenerator($property);
 }
开发者ID:zfrapid,项目名称:zf2rapid,代码行数:17,代码来源:ValidatorClassGenerator.php

示例12: createDTO

 /**
  * {@inheritdoc}
  */
 public function createDTO(Type $type)
 {
     $class = $this->createClassFromType($type);
     $parentType = $type->getParent();
     // set the parent class
     if ($parentType) {
         $parentType = $parentType->getBase();
         if ($parentType->getSchema()->getTargetNamespace() !== SchemaReader::XSD_NS) {
             $class->setExtendedClass($parentType->getName());
         }
     }
     // check if the type is abstract
     $class->setAbstract($type->isAbstract());
     // create the constructor
     $constructor = new MethodGenerator('__construct');
     $constructorDoc = new DocBlockGenerator();
     $constructorBody = '';
     $constructor->setDocBlock($constructorDoc);
     $class->addMethodFromGenerator($constructor);
     /* @var \Goetas\XML\XSDReader\Schema\Type\ComplexType $type */
     foreach ($type->getElements() as $element) {
         /* @var \Goetas\XML\XSDReader\Schema\Element\Element $element */
         $docElementType = $this->namespaceInflector->inflectDocBlockQualifiedName($element->getType());
         $elementName = $element->getName();
         // create a param and a param tag used in constructor and setter docs
         $param = new ParameterGenerator($elementName, $this->namespaceInflector->inflectName($element->getType()));
         $paramTag = new ParamTag($elementName, $docElementType);
         // if the param type is not a PHP primitive type and its namespace is different that the class namespace
         if ($type->getSchema()->getTargetNamespace() === SchemaReader::XSD_NS and $class->getNamespaceName() !== $this->namespaceInflector->inflectNamespace($element->getType())) {
             $class->addUse($this->namespaceInflector->inflectQualifiedName($element->getType()));
         }
         // set the parameter nullability
         if ($element->isNil() or $this->config->isNullConstructorArguments()) {
             $param->setDefaultValue(new ValueGenerator(null, ValueGenerator::TYPE_NULL));
         }
         /*
          * PROPERTY CREATION
          */
         $docDescription = new Html2Text($type->getDoc());
         $doc = new DocBlockGenerator();
         $doc->setShortDescription($docDescription->getText());
         $doc->setTag(new GenericTag('var', $docElementType));
         $property = new PropertyGenerator();
         $property->setDocBlock($doc);
         $property->setName(filter_var($elementName, FILTER_CALLBACK, array('options' => array($this, 'sanitizeVariableName'))));
         $property->setVisibility($this->config->isAccessors() ? AbstractMemberGenerator::VISIBILITY_PROTECTED : AbstractMemberGenerator::VISIBILITY_PUBLIC);
         $class->addPropertyFromGenerator($property);
         /*
          * IMPORTS
          */
         if ($element->getType()->getSchema()->getTargetNamespace() !== SchemaReader::XSD_NS and $this->namespaceInflector->inflectNamespace($element->getType()) !== $class->getNamespaceName()) {
             $class->addUse($this->namespaceInflector->inflectQualifiedName($element->getType()));
         }
         /*
          * CONSTRUCTOR PARAM CREATION
          */
         $constructorDoc->setTag($paramTag);
         $constructorBody .= "\$this->{$elementName} = \${$elementName};" . AbstractGenerator::LINE_FEED;
         $constructor->setParameter($param);
         /*
          * ACCESSORS CREATION
          */
         if ($this->config->isAccessors()) {
             // create the setter
             $setterDoc = new DocBlockGenerator();
             $setterDoc->setTag($paramTag);
             $setter = new MethodGenerator('set' . ucfirst($elementName));
             $setter->setParameter($param);
             $setter->setDocBlock($setterDoc);
             $setter->setBody("\$this->{$elementName} = \${$elementName};");
             $class->addMethodFromGenerator($setter);
             // create the getter
             $getterDoc = new DocBlockGenerator();
             $getterDoc->setTag(new ReturnTag($docElementType));
             $getter = new MethodGenerator('get' . ucfirst($elementName));
             $getter->setDocBlock($getterDoc);
             $getter->setBody("return \$this->{$elementName};");
             $class->addMethodFromGenerator($getter);
         }
     }
     // finalize the constructor body
     $constructor->setBody($constructorBody);
     $this->serializeClass($class);
     // register the class in the classmap
     $this->classmap[$class->getName()] = $class->getNamespaceName() . '\\' . $class->getName();
     return $class->getName();
 }
开发者ID:xstefanox,项目名称:sapone,代码行数:90,代码来源:ClassFactory.php

示例13: addFormProperty

 /**
  * Add form property
  *
  * @param $formClass
  */
 protected function addFormProperty($formClass)
 {
     $property = new PropertyGenerator(lcfirst($formClass));
     $property->addFlag(PropertyGenerator::FLAG_PRIVATE);
     $property->setDocBlock(new DocBlockGenerator(null, null, [['name' => 'var', 'description' => $formClass]]));
     $this->addPropertyFromGenerator($property);
 }
开发者ID:pgiacometto,项目名称:zf2rapid,代码行数:12,代码来源:ControllerClassGenerator.php

示例14: addOptionsProperty

 /**
  * @param string $columnName
  */
 protected function addOptionsProperty($columnName)
 {
     $columnName = lcfirst($this->filterUnderscoreToCamelCase($columnName));
     $property = new PropertyGenerator($columnName . 'Options');
     $property->addFlag(PropertyGenerator::FLAG_PRIVATE);
     $property->setDocBlock(new DocBlockGenerator($columnName . ' options', null, [['name' => 'var', 'description' => 'array']]));
     $this->addPropertyFromGenerator($property);
 }
开发者ID:zfrapid,项目名称:zf2rapid,代码行数:11,代码来源:DataFormClassGenerator.php

示例15: addProperties

 /**
  * Append Properties, Getter and Setter to Model class
  *
  * @param Generator\ClassGenerator $class
  * @param array                    $properties
  * @param array                    $hydratorStrategy
  */
 protected function addProperties(Generator\ClassGenerator &$class, array $properties)
 {
     foreach ($properties as $metadata) {
         $propertyInfos = $this->getNormalizedFilterOrProperty($metadata);
         $name = $propertyInfos['name'];
         $required = $propertyInfos['required'];
         $lazyLoading = $propertyInfos['lazyLoading'];
         $dataType = $propertyInfos['dataType'];
         $defaultValue = $propertyInfos['defaultValue'];
         $description = $propertyInfos['description'];
         $flags = Generator\PropertyGenerator::FLAG_PROTECTED;
         foreach ($propertyInfos['uses'] as $use) {
             $class->addUse($use);
         }
         $property = new Generator\PropertyGenerator($name);
         $property->setFlags($flags);
         if (!empty($defaultValue) or 'bool' === $dataType) {
             $property->setDefaultValue($defaultValue, $dataType);
         }
         $property->setDocBlock(new Generator\DocBlockGenerator($description));
         $class->addPropertyFromGenerator($property);
         // Add Setter method
         $setterParam = new Generator\ParameterGenerator($name, true === $lazyLoading ? null : $dataType);
         if (!$required) {
             $setterParam->setDefaultValue(null);
         }
         $setterBody = '';
         if (true === $lazyLoading) {
             if ($dataType == "ResultSet") {
                 $class->addUse('Mailjet\\Api\\ResultSet\\Exception');
                 $setterBody .= sprintf('if (! ($%s instanceof \\Closure || $%s instanceof %s)) {' . PHP_EOL . '   throw new Exception\\InvalidArgumentException("%s must be an instance of \'%s\' or \\Closure");' . PHP_EOL . '}' . PHP_EOL . PHP_EOL, $name, $name, $dataType, $name, $dataType);
             } else {
                 $setterBody .= sprintf('if (! ($%s instanceof \\Closure || $%s instanceof %s)) {' . PHP_EOL . '   throw new Exception\\InvalidArgumentException("$%s must be an instance of \'%s\' or \\Closure");' . PHP_EOL . '}' . PHP_EOL . PHP_EOL, $name, $name, $dataType, $name, $dataType);
             }
         }
         $setterBody .= sprintf('$this->%s = $%s;' . PHP_EOL . 'return $this;' . PHP_EOL, $name, $name);
         $class->addMethod('set' . ucfirst($name), array($setterParam), Generator\MethodGenerator::FLAG_PUBLIC, $setterBody, new Generator\DocBlockGenerator("Sets the " . $property->getDocBlock()->getShortDescription(), '', array(new ParamTag(array('name' => $name, 'datatype' => $dataType)), new ReturnTag(array('datatype' => $class->getName())))));
         // Add Getter method
         $getterBody = '';
         if (true === $lazyLoading) {
             $getterBody .= sprintf('if ($this->%s instanceof \\Closure) {' . PHP_EOL . '   $this->%s = call_user_func($this->%s);' . PHP_EOL . '}' . PHP_EOL . 'if (! $this->%s instanceof %s) {' . PHP_EOL . '    $this->%s = new %s();' . PHP_EOL . '}' . PHP_EOL . PHP_EOL, $name, $name, $name, $name, $dataType, $name, $dataType);
         }
         $getterBody .= sprintf('return $this->%s;', $name);
         $class->addMethod('get' . ucfirst($name), array(), Generator\MethodGenerator::FLAG_PUBLIC, $getterBody, new Generator\DocBlockGenerator('Gets the ' . $property->getDocBlock()->getShortDescription(), '', array(new ReturnTag(array('datatype' => $dataType)))));
         // If DataType Resulset => add/remove methods
         if ('ResultSet' === $dataType) {
             $class->addMethod('add' . ucfirst($name) . 'Item', array(new Generator\ParameterGenerator('item', $propertyInfos['model'])), Generator\MethodGenerator::FLAG_PUBLIC, sprintf('return $this->get%s()->add($item);' . PHP_EOL, ucfirst($name)), new Generator\DocBlockGenerator('Add new item to ' . ucfirst($name), '', array(new ReturnTag(array('datatype' => 'bool')))));
             $class->addMethod('remove' . ucfirst($name) . 'Item', array(new Generator\ParameterGenerator('item', $propertyInfos['model'])), Generator\MethodGenerator::FLAG_PUBLIC, sprintf('return $this->get%s()->remove($item);' . PHP_EOL, ucfirst($name)), new Generator\DocBlockGenerator('Remove $item from ' . ucfirst($name), '', array(new ReturnTag(array('datatype' => 'bool')))));
         }
     }
 }
开发者ID:progrupa,项目名称:MailjetBundle,代码行数:58,代码来源:ApiController.php


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