本文整理汇总了PHP中Nette\PhpGenerator\ClassType::getComment方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassType::getComment方法的具体用法?PHP ClassType::getComment怎么用?PHP ClassType::getComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\PhpGenerator\ClassType
的用法示例。
在下文中一共展示了ClassType::getComment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateClassType
/**
* [generateClassType description].
*
* @param string $properties elementi possibili 'fields', 'extend', 'implements'
* @param array $typesReference [description]
* @param array $typesDescription [description]
* @param ClassConfig $config [description]
*/
public function generateClassType(array $properties, $typesReference, $typesDescription, ClassConfig $config)
{
$phpNamespace = $this->currentClass->getNamespace();
if ($config->isInterface) {
$this->info('Passo a interfaccia', [$this->currentClass->getName()]);
$docs = $this->currentClass->getComment();
$this->currentClass = $this->currentFile->addInterface($phpNamespace->getName() . '\\' . ucfirst($this->currentClass->getName()));
$this->currentClass->setComment($docs);
$this->info('Check haveConstructor, in caso metto a false', [$config->haveConstructor]);
$config->haveConstructor = false;
}
$this->info('Generate', ['class' => $this->currentClass->getName(), 'namespace' => $phpNamespace->getName(), 'comment' => $this->currentClass->getComment(), 'properties' => $properties]);
// extend class
if (array_key_exists('extend', $properties)) {
$extendClassName = $properties['extend'];
$this->info('Aggiungo extend', ['class' => $this->currentClass->getName(), 'extend' => $extendClassName]);
$this->currentClass->setExtends($extendClassName);
$this->currentClass->getNamespace()->addUse($extendClassName);
}
// implements class
if (array_key_exists('implements', $properties)) {
$implementsList = [];
if (!is_array($properties['implements'])) {
$implementsList[] = $properties['implements'];
} else {
$implementsList = array_merge($implementsList, $properties['implements']);
}
$this->currentClass->setImplements($implementsList);
foreach ($implementsList as $implementUse) {
$this->info('Aggiungo implement', ['class' => $this->currentClass->getName(), 'implements' => $implementUse]);
$this->currentClass->getNamespace()->addUse($implementUse);
}
}
// traits
if (array_key_exists('traits', $properties)) {
if (is_array($properties['traits'])) {
foreach ($properties['traits'] as $trait) {
$this->addTrait($trait, $typesReference);
}
} else {
$traitObject = $properties['traits'];
$this->addTrait($traitObject, $typesReference);
}
}
if ($config->isFinalClass) {
$this->currentClass->setFinal(true);
}
$first = true;
if (array_key_exists('fields', $properties)) {
/** @var $methodConstructor \Nette\PhpGenerator\Method */
$methodConstructor = null;
if ($config->haveConstructor) {
$methodConstructor = $this->addConstructor();
}
$body = '';
foreach ($properties['fields'] as $name => $fieldProperties) {
$isStatic = false;
$isAutoinizialize = false;
$defaultValue = null;
if (array_key_exists('static', $fieldProperties)) {
$isStatic = $fieldProperties['static'];
}
if (array_key_exists('autoinizialize', $fieldProperties)) {
$isAutoinizialize = boolval($fieldProperties['autoinizialize']);
}
if (array_key_exists('default', $fieldProperties)) {
$defaultValue = $fieldProperties['default'];
}
if (!$isAutoinizialize) {
if (null != $defaultValue) {
//TODO: usare "primitive type per determinare il corretto IF"
//FARE UN TEST PER I BOOLEAN
//@see https://www.virendrachandak.com/techtalk/php-isset-vs-empty-vs-is_null/
$body .= 'if ( empty($' . $name . ') ) { ' . "\n";
if ($isStatic) {
$body .= ' self::$';
} else {
$body .= ' $this->';
}
$body .= $name . ' = ' . $defaultValue . ';' . "\n";
$body .= '} else {';
if ($isStatic) {
$body .= ' self::$';
} else {
$body .= ' $this->';
}
$body .= $name . ' = $' . $name . ';' . "\n";
$body .= '}' . "\n";
} else {
if (!$isStatic) {
$body .= ' $this->' . $name . ' = $' . $name . ';' . "\n";
}
//.........这里部分代码省略.........