Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15311837
D21294.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D21294.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 7, 11:37 AM (5 d, 9 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7332326
Default Alt Text
D21294.diff (1 KB)
Attached To
Mode
D21294: Allow PhutilArrayCheck to accept a list of objects as a context
Attached
Detach File
Event Timeline
Log In to Comment