當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PropertyGenerator::setConst方法代碼示例

本文整理匯總了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);
 }
開發者ID:zfrapid,項目名稱:zf2rapid,代碼行數:17,代碼來源:ValidatorClassGenerator.php

示例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());
 }
開發者ID:rajanlamic,項目名稱:IntTest,代碼行數:9,代碼來源:PropertyGeneratorTest.php

示例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();
 }
開發者ID:xstefanox,項目名稱:sapone,代碼行數:34,代碼來源:ClassFactory.php


注:本文中的Zend\Code\Generator\PropertyGenerator::setConst方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。