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


PHP PropertyGenerator::setVisibility方法代码示例

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


在下文中一共展示了PropertyGenerator::setVisibility方法的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: 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

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

示例4: getPropertyGenerator

 public function getPropertyGenerator()
 {
     if (!$this->propertyGenerator) {
         $generator = new CodeGenerator\PropertyGenerator();
         $generator->setVisibility($generator::VISIBILITY_PROTECTED);
         $this->propertyGenerator = $generator;
     }
     return $this->propertyGenerator;
 }
开发者ID:vmalinovskiy,项目名称:CallFire-PHP-SDK,代码行数:9,代码来源:Action.php

示例5: handleProperty

 protected function handleProperty(Generator\ClassGenerator $class, PHPProperty $prop)
 {
     $generatedProp = new PropertyGenerator($prop->getName());
     $generatedProp->setVisibility(PropertyGenerator::VISIBILITY_PROTECTED);
     if (!$class->hasProperty($prop->getName())) {
         $class->addPropertyFromGenerator($generatedProp);
     } else {
         $generatedProp = $class->getProperty($prop->getName());
     }
     $docBlock = new DocBlockGenerator();
     $generatedProp->setDocBlock($docBlock);
     if ($prop->getDoc()) {
         $docBlock->setLongDescription($prop->getDoc());
     }
     $tag = new Generator\DocBlock\Tag();
     $tag->setName("@var {$this->getPropertyType($prop)}");
     $docBlock->setTag($tag);
     $type = $prop->getType();
     if ($type->type && $this->isTypeMapped($type->type->getName())) {
         if (!$class->hasProperty('_typeMap')) {
             $generatedProp = new PropertyGenerator('_typeMap');
             $generatedProp->setDefaultValue([]);
             $generatedProp->setVisibility(PropertyGenerator::VISIBILITY_PROTECTED);
             $class->addPropertyFromGenerator($generatedProp);
         }
         $property = $class->getProperty('_typeMap');
         $defaultValue = $property->getDefaultValue()->getValue();
         $defaultValue[$prop->getName()] = $type->type->getName();
         $property->setDefaultValue($defaultValue);
     }
 }
开发者ID:garethp,项目名称:php-ews,代码行数:31,代码来源:ClassGenerator.php

示例6: handleProperty

 private function handleProperty(Generator\ClassGenerator $class, PHPProperty $prop)
 {
     $generatedProp = new PropertyGenerator($prop->getName());
     $generatedProp->setVisibility(PropertyGenerator::VISIBILITY_PRIVATE);
     $class->addPropertyFromGenerator($generatedProp);
     if ($prop->getType() && (!$prop->getType()->getNamespace() && $prop->getType()->getName() == "array")) {
         // $generatedProp->setDefaultValue(array(), PropertyValueGenerator::TYPE_AUTO, PropertyValueGenerator::OUTPUT_SINGLE_LINE);
     }
     $docBlock = new DocBlockGenerator();
     $generatedProp->setDocBlock($docBlock);
     if ($prop->getDoc()) {
         $docBlock->setLongDescription($prop->getDoc());
     }
     $tag = new PropertyTag($prop->getName(), 'mixed');
     $type = $prop->getType();
     if ($type && $type instanceof PHPClassOf) {
         $tt = $type->getArg()->getType();
         $tag->setTypes($this->getPhpType($tt) . "[]");
         if ($p = $this->isOneType($tt)) {
             if ($t = $p->getType()) {
                 $tag->setTypes($this->getPhpType($t) . "[]");
             }
         }
     } elseif ($type) {
         if ($this->isNativeType($type)) {
             $tag->setTypes($this->getPhpType($type));
         } elseif (($p = $this->isOneType($type)) && ($t = $p->getType())) {
             $tag->setTypes($this->getPhpType($t));
         } else {
             $tag->setTypes($this->getPhpType($prop->getType()));
         }
     }
     $docBlock->setTag($tag);
 }
开发者ID:josedasilva,项目名称:xsd2php,代码行数:34,代码来源:ClassGenerator.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::setVisibility方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。