mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-26 14:56:03 +03:00
Enhanced Utils::printSafe() to output more information about arrays
This commit is contained in:
parent
3f04d29628
commit
a3b40db0fb
@ -253,6 +253,23 @@ class Utils
|
|||||||
if (is_object($var)) {
|
if (is_object($var)) {
|
||||||
return 'instance of ' . get_class($var);
|
return 'instance of ' . get_class($var);
|
||||||
}
|
}
|
||||||
|
if (is_array($var)) {
|
||||||
|
$count = count($var);
|
||||||
|
if (!isset($var[0]) && $count > 0) {
|
||||||
|
$keys = [];
|
||||||
|
$keyCount = 0;
|
||||||
|
foreach ($var as $key => $value) {
|
||||||
|
$keys[] = $key;
|
||||||
|
if ($keyCount++ > 4) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$msg = "associative array($count) with first keys: " . implode(', ', $keys);
|
||||||
|
} else {
|
||||||
|
$msg = "array($count)";
|
||||||
|
}
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
if ('' === $var) {
|
if ('' === $var) {
|
||||||
return '(empty string)';
|
return '(empty string)';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user