Skip to content

Commit abf38cf

Browse files
committed
Show defaults for properties
1 parent 5fff8d4 commit abf38cf

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/PHPFUI/InstaDoc/Section/Doc.php

+13-5
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ protected function getContent(string $accessType) : \PHPFUI\Table
350350
}
351351

352352
$table->addNextRowAttribute('class', $this->getRowClasses($property));
353-
$table->addRow([$this->getProperty($property)]);
353+
$table->addRow([$this->getProperty($property, $this->reflection)]);
354354
}
355355
}
356356
}
@@ -427,7 +427,7 @@ protected function getNameScope(\ReflectionProperty|\ReflectionMethod|\Reflectio
427427
return '';
428428
}
429429

430-
protected function getProperty(\ReflectionProperty $property) : string
430+
protected function getProperty(\ReflectionProperty $property, \ReflectionClass $class) : string
431431
{
432432
$property->setAccessible(true);
433433
$docBlock = $this->getDocBlock($property);
@@ -448,13 +448,21 @@ protected function getProperty(\ReflectionProperty $property) : string
448448

449449
if ($property->isStatic())
450450
{
451-
$value = $property->getValue();
452-
453-
if ($value)
451+
if ($property->hasDefaultValue())
454452
{
453+
$value = $property->getValue();
455454
$info .= ' = ' . $this->getValueString($value);
456455
}
457456
}
457+
else
458+
{
459+
$defaults = $class->getDefaultProperties();
460+
461+
if (\array_key_exists($property->getName(), $defaults))
462+
{
463+
$info .= ' = ' . $this->getValueString($defaults[$property->getName()]);
464+
}
465+
}
458466

459467
$info .= $this->getComments($docBlock);
460468

0 commit comments

Comments
 (0)