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


PHP PropertyGenerator::setName方法代码示例

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


在下文中一共展示了PropertyGenerator::setName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:nfx,项目名称:pugooroo,代码行数:18,代码来源:PhpClass.php

示例2: generate

 public function generate()
 {
     $classGenerator = $this->getClassGenerator();
     $description = $this->getDescription();
     $classGenerator->setName($description->getName());
     $basePathProperty = new CodeGenerator\PropertyGenerator();
     $basePathProperty->setName('basePath');
     $basePathProperty->setDefaultValue($description->getBasePath());
     $classGenerator->addPropertyFromGenerator($basePathProperty);
     foreach ($description->getApis() as $api) {
         foreach ($api->getOperations() as $operation) {
             $function = $this->generateFunction($api, $operation);
             if ($function instanceof CodeGenerator\MethodGenerator) {
                 $classGenerator->addMethodFromGenerator($function);
             }
         }
     }
 }
开发者ID:vmalinovskiy,项目名称:CallFire-PHP-SDK,代码行数:18,代码来源:Service.php

示例3: generateProperty

 protected function generateProperty($type, $name)
 {
     $property = new CodeGenerator\PropertyGenerator();
     $property->setName(lcfirst($name));
     $property->setVisibility($property::VISIBILITY_PROTECTED);
     return $property;
 }
开发者ID:vmalinovskiy,项目名称:CallFire-PHP-SDK,代码行数:7,代码来源:SoapStructure.php

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

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

示例6: testHasProperty

 /**
  * @group ZF-7361
  */
 public function testHasProperty()
 {
     $property = new PropertyGenerator();
     $property->setName('propertyOne');
     $classGenerator = new ClassGenerator();
     $classGenerator->setProperty($property);
     $this->assertTrue($classGenerator->hasProperty('propertyOne'));
 }
开发者ID:rikaix,项目名称:zf2,代码行数:11,代码来源:ClassGeneratorTest.php

示例7: createProperty

 /**
  * Create a property instance
  * @param  string                      $name - property name
  * @return Generator\PropertyGenerator $property
  */
 private function createProperty($name)
 {
     $property = new Generator\PropertyGenerator();
     $property->setName($name);
     $property->setVisibility(Generator\AbstractMemberGenerator::FLAG_PUBLIC);
     return $property;
 }
开发者ID:steve-todorov,项目名称:drest,代码行数:12,代码来源:ClassGenerator.php

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

示例9: generateProxiesMapProp

 private function generateProxiesMapProp()
 {
     $map = new PropertyGenerator();
     $map->setName('proxiesMap');
     $map->setVisibility(PropertyGenerator::VISIBILITY_PROTECTED);
     $map->setDefaultValue($this->buildProxiesMap(), 'array');
     return $map;
 }
开发者ID:brad-jones,项目名称:ppm,代码行数:8,代码来源:AutoLoaderGenerator.php


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