本文整理汇总了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;
}
示例2: generateProperty
protected function generateProperty($type, $name)
{
$property = new CodeGenerator\PropertyGenerator();
$property->setName(lcfirst($name));
$property->setVisibility($property::VISIBILITY_PROTECTED);
return $property;
}
示例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);
}
示例4: getPropertyGenerator
public function getPropertyGenerator()
{
if (!$this->propertyGenerator) {
$generator = new CodeGenerator\PropertyGenerator();
$generator->setVisibility($generator::VISIBILITY_PROTECTED);
$this->propertyGenerator = $generator;
}
return $this->propertyGenerator;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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();
}
示例9: generateProxiesMapProp
private function generateProxiesMapProp()
{
$map = new PropertyGenerator();
$map->setName('proxiesMap');
$map->setVisibility(PropertyGenerator::VISIBILITY_PROTECTED);
$map->setDefaultValue($this->buildProxiesMap(), 'array');
return $map;
}