示例#1
0
 /**
  * Adds a constant to the definition
  *
  * @param ClassConstant $constant
  * @throws CompilerException
  */
 public function addConstant(ClassConstant $constant)
 {
     if (isset($this->constants[$constant->getName()])) {
         throw new CompilerException("Constant '" . $constant->getName() . "' was defined more than one time");
     }
     $this->constants[$constant->getName()] = $constant;
 }
示例#2
0
 /**
  * @param ClassConstant $constant
  * @param string $indent
  *
  * @return string
  */
 protected function buildConstant(ClassConstant $constant, $indent)
 {
     $source = 'const ' . $constant->getName();
     $value = $this->wrapPHPValue(array('default' => $constant->getValue()));
     $docBlock = new DocBlock($constant->getDocBlock(), $indent);
     return $docBlock . "\n" . $indent . $source . ' = ' . $value . ';';
 }
示例#3
0
 /**
  * @param ClassConstant $constant
  *
  * @return string
  */
 protected function buildConstant(ClassConstant $constant)
 {
     $source = 'const ' . $constant->getName();
     $value = $constant->getValueValue();
     switch ($constant->getType()) {
         case 'null':
             $value .= 'null';
             break;
         case 'string':
             $value = '"' . $value . '"';
             break;
     }
     $docBlock = new DocBlock($constant->getDocBlock(), 4);
     return $docBlock . "\n    " . $source . ' = ' . $value . ';';
 }