Skip to content

Commit 2ed0921

Browse files
committed
update ConsoleTable & ReflectArray
1 parent 1c6411c commit 2ed0921

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/Ubiquity/devtools/cmd/ConsoleTable.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use Ubiquity\utils\base\UDateTime;
55
use Ubiquity\devtools\utils\arrays\ClassicArray;
6+
use Ubiquity\utils\base\UString;
67

78
class ConsoleTable {
89

@@ -304,7 +305,7 @@ private function calculateColWidths() {
304305
if ($col instanceof \DateTime) {
305306
$col = UDateTime::elapsed($col);
306307
}
307-
if (is_string($col)) {
308+
if (UString::isValid($col)) {
308309
$lines = explode("\n", $col);
309310
$size = sizeof($lines);
310311
if ($size > $this->rowHeight[$y]) {

src/Ubiquity/devtools/utils/arrays/ReflectArray.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public function parse() {
1818
]
1919
];
2020
}
21+
if (! is_object($object)) {
22+
$object = (object) $object;
23+
}
2124
if (! is_array($this->properties)) {
2225
$this->properties = $this->getProperties($object);
2326
}
@@ -48,15 +51,15 @@ public function parse() {
4851
}
4952

5053
private function parseValue($value) {
51-
$result = "-";
52-
if (is_array($value)) {
54+
$result = '-';
55+
if (\is_array($value)) {
5356
return $this->parseArray($value);
5457
} elseif (UString::isValid($value)) {
55-
$result = var_export($value, true);
56-
} elseif (is_callable($value)) {
58+
$result = $value;
59+
} elseif (\is_callable($value)) {
5760
$result = '(x)=>{}';
5861
} else {
59-
$result = $value;
62+
$result = \var_export($value, true);
6063
}
6164
return $result;
6265
}

0 commit comments

Comments
 (0)