Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15415507
D13572.id32807.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
D13572.id32807.diff
View Options
diff --git a/src/symbols/PhutilClassMapQuery.php b/src/symbols/PhutilClassMapQuery.php
--- a/src/symbols/PhutilClassMapQuery.php
+++ b/src/symbols/PhutilClassMapQuery.php
@@ -41,6 +41,7 @@
private $ancestorClass;
private $expandMethod;
+ private $filterNull = false;
private $uniqueMethod;
private $sortMethod;
@@ -75,12 +76,15 @@
*
* You must provide a method here to use @{method:setExpandMethod}.
*
- * @param string Name of the unique key method.
+ * @param string Name of the unique key method.
+ * @param bool If true, then classes which return `null` will be filtered
+ * from the results.
* @return this
* @task config
*/
- public function setUniqueMethod($unique_method) {
+ public function setUniqueMethod($unique_method, $filter_null = false) {
$this->uniqueMethod = $unique_method;
+ $this->filterNull = $filter_null;
return $this;
}
@@ -224,6 +228,11 @@
$map = array();
foreach ($list as $object) {
$key = call_user_func(array($object, $unique));
+
+ if ($key === null && $this->filterNull) {
+ continue;
+ }
+
if (empty($map[$key])) {
$map[$key] = $object;
continue;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 21, 6:19 AM (16 h, 16 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7694778
Default Alt Text
D13572.id32807.diff (1 KB)
Attached To
Mode
D13572: Allow PhutilClassMapQuery to filter null
Attached
Detach File
Event Timeline
Log In to Comment