public function visitProperty(PhpProperty $property) { $this->writer->write($property->getVisibility() . ' ' . ($property->isStatic() ? 'static ' : '') . '$' . $property->getName()); if ($property->hasDefaultValue()) { $this->writer->write(' = ' . var_export($property->getDefaultValue(), true)); } $this->writer->writeln(';'); }
/** * setProperty() * * @param array|\Zend\CodeGenerator\Php\PhpProperty $property * @return \Zend\CodeGenerator\Php\PhpClass */ public function setProperty($property) { if (is_array($property)) { $property = new PhpProperty($property); $propertyName = $property->getName(); } elseif ($property instanceof PhpProperty) { $propertyName = $property->getName(); } else { throw new Exception\InvalidArgumentException('setProperty() expects either an array of property options or an instance of Zend_CodeGenerator_Php_Property'); } if (isset($this->_properties[$propertyName])) { throw new Exception\InvalidArgumentException('A property by name ' . $propertyName . ' already exists in this class.'); } $this->_properties[$propertyName] = $property; return $this; }
/** * setConstant() * * @param array|\Zend\CodeGenerator\Php\PhpProperty $const * @return Zend\CodeGenerator\Php\PhpClass */ public function setConstant($const) { if (is_array($const)) { $const = new PhpProperty($const); $constName = $const->getName(); } elseif ($const instanceof PhpProperty) { $constName = $const->getName(); } else { throw new Exception\InvalidArgumentException('setConstant() expects either an array of property options or an instance of Zend_CodeGenerator_Php_Property'); } if (!$const->isConst()) { throw new Exception\InvalidArgumentException('setProperty() expects argument to define a constant'); } if (isset($this->_constants[$constName])) { throw new Exception\InvalidArgumentException('A constant by name ' . $constName . ' already exists in this class.'); } $this->_constants[$constName] = $const; return $this; }