X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fpsy%2Fpsysh%2Fsrc%2FPsy%2FCommand%2FListCommand%2FPropertyEnumerator.php;h=f36a582ca1b37e90c0126ac1ec3599182e8b8c6e;hp=c4d86368f1417ba9c3d077ace11bcebfe8c0ab11;hb=eba34333e3c89f208d2f72fa91351ad019a71583;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae diff --git a/vendor/psy/psysh/src/Psy/Command/ListCommand/PropertyEnumerator.php b/vendor/psy/psysh/src/Psy/Command/ListCommand/PropertyEnumerator.php index c4d86368f..f36a582ca 100644 --- a/vendor/psy/psysh/src/Psy/Command/ListCommand/PropertyEnumerator.php +++ b/vendor/psy/psysh/src/Psy/Command/ListCommand/PropertyEnumerator.php @@ -77,7 +77,7 @@ class PropertyEnumerator extends Enumerator } } - // TODO: this should be natcasesort + // @todo this should be natcasesort ksort($properties); return $properties; @@ -155,9 +155,21 @@ class PropertyEnumerator extends Enumerator */ protected function presentValue(\ReflectionProperty $property, $target) { + // If $target is a class, trait or interface (try to) get the default + // value for the property. if (!is_object($target)) { - // TODO: figure out if there's a way to return defaults when target - // is a class/interface/trait rather than an object. + try { + $refl = new \ReflectionClass($target); + $props = $refl->getDefaultProperties(); + if (array_key_exists($property->name, $props)) { + $suffix = $property->isStatic() ? '' : ' '; + + return $this->presentRef($props[$property->name]) . $suffix; + } + } catch (\Exception $e) { + // Well, we gave it a shot. + } + return ''; }