Page MenuHomePhabricator

D21294.id50708.diff
No OneTemporary

D21294.id50708.diff

diff --git a/src/utils/PhutilArrayCheck.php b/src/utils/PhutilArrayCheck.php
--- a/src/utils/PhutilArrayCheck.php
+++ b/src/utils/PhutilArrayCheck.php
@@ -29,10 +29,24 @@
}
public function setContext($object, $method) {
- if (!is_object($object) && !is_string($object)) {
+ if (is_array($object)) {
+ foreach ($object as $idx => $value) {
+ if (!is_object($value)) {
+ throw new Exception(
+ pht(
+ 'Expected an object, string, or list of objects for "object" '.
+ 'context. Got a list ("%s"), but the list item at index '.
+ '"%s" (with type "%s") is not an object.',
+ phutil_describe_type($object),
+ $idx,
+ phutil_describe_type($value)));
+ }
+ }
+ } else if (!is_object($object) && !is_string($object)) {
throw new Exception(
pht(
- 'Expected an object or string for "object" context, got "%s".',
+ 'Expected an object, string, or list of objects for "object" '.
+ 'context, got "%s".',
phutil_describe_type($object)));
}
@@ -219,7 +233,20 @@
$method = $context['method'];
$argv = $context['argv'];
- if (is_object($object)) {
+ if (is_array($object)) {
+ $classes = array();
+ foreach ($object as $item) {
+ $classes[] = get_class($item);
+ }
+ $classes = array_fuse($classes);
+ $n = count($object);
+
+ $object_display = sprintf(
+ '[%s]<%d>->%s',
+ implode(', ', $classes),
+ $n,
+ $method);
+ } else if (is_object($object)) {
$object_display = sprintf(
'%s->%s',
get_class($object),

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 8, 7:19 AM (4 d, 14 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7332326
Default Alt Text
D21294.id50708.diff (1 KB)

Event Timeline