/** * Adds a constant * * @param string|PhpConstant $nameOrConstant constant name or instance * @param string $value * @return $this */ public function setConstant($nameOrConstant, $value = null) { if ($nameOrConstant instanceof PhpConstant) { $name = $nameOrConstant->getName(); $constant = $nameOrConstant; } else { $name = $nameOrConstant; $constant = new PhpConstant($nameOrConstant); $constant->setValue($value); } $this->constants[$name] = $constant; return $this; }
/** * Sets a collection of constants * * @param array|PhpConstant[] $constants * @return $this */ public function setConstants(array $constants) { $normalizedConstants = []; foreach ($constants as $name => $value) { if ($value instanceof PhpConstant) { $name = $value->getName(); } else { $constValue = $value; $value = new PhpConstant($name); $value->setValue($constValue); } $normalizedConstants[$name] = $value; } $this->constants->setAll($normalizedConstants); return $this; }
protected function visitConstant(Const_ $node, Doc $doc = null) { $const = new PhpConstant($node->name, $this->getValue($node)); $const->setValue($this->getValue($node->value)); $this->parseMemberDocblock($const, $doc); $this->struct->setConstant($const); }