本文整理汇总了PHP中Zend\Code\Generator\PropertyGenerator::setConst方法的典型用法代码示例。如果您正苦于以下问题:PHP PropertyGenerator::setConst方法的具体用法?PHP PropertyGenerator::setConst怎么用?PHP PropertyGenerator::setConst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Code\Generator\PropertyGenerator
的用法示例。
在下文中一共展示了PropertyGenerator::setConst方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addMessageConstant
/**
* @param $className
*/
protected function addMessageConstant($className)
{
// generate property
$property = new PropertyGenerator();
$property->setName('INVALID');
$property->setDefaultValue('invalid' . $className);
$property->setConst(true);
// check for api docs
if ($this->config['flagAddDocBlocks']) {
$property->setDocBlock(new DocBlockGenerator('', '', [new GenericTag('const')]));
}
// add property
$this->addPropertyFromGenerator($property);
}
示例2: testPropertyCanProduceContstantModifierWithSetter
/**
* @group PR-704
*/
public function testPropertyCanProduceContstantModifierWithSetter()
{
$codeGenProperty = new PropertyGenerator('someVal', 'some string value');
$codeGenProperty->setConst(true);
$this->assertEquals(' const someVal = \'some string value\';', $codeGenProperty->generate());
}
示例3: createEnum
/**
* {@inheritdoc}
*/
public function createEnum(Type $type)
{
$class = $this->createClassFromType($type);
$parentType = $type->getParent()->getBase();
// set the parent class
if ($parentType->getSchema()->getTargetNamespace() !== SchemaReader::XSD_NS) {
// this enum extends another, it will indirectly extend \SplEnum
$class->setExtendedClass($parentType->getName());
} elseif ($this->config->isSplEnums()) {
// this enum has no parent, so make it extend \SplEnum
$class->setExtendedClass('\\SplEnum');
}
// create the class constants
$checks = $type->getRestriction()->getChecks();
foreach ($checks['enumeration'] as $enum) {
$property = new PropertyGenerator();
$property->setName(filter_var($enum['value'], FILTER_CALLBACK, array('options' => array($this, 'sanitizeVariableName'))));
$property->setName(filter_var($property->getName(), FILTER_CALLBACK, array('options' => array($this, 'sanitizeConstantName'))));
$property->setConst(true);
$property->setDefaultValue($enum['value']);
if ($enum['doc']) {
$docDescription = new Html2Text($enum['doc']);
$property->setDocBlock(new DocBlockGenerator($docDescription->getText()));
}
$class->addPropertyFromGenerator($property);
}
$this->serializeClass($class);
// register the class in the classmap
$this->classmap[$class->getName()] = $class->getNamespaceName() . '\\' . $class->getName();
return $class->getName();
}