Differential D25170 Diff 611 src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
Show First 20 Lines • Show All 201 Lines • ▼ Show 20 Lines | if ($this->prefixLength) { | ||||
return self::PHASE_PREFIX; | return self::PHASE_PREFIX; | ||||
} | } | ||||
} | } | ||||
return self::PHASE_CONTENT; | return self::PHASE_CONTENT; | ||||
} | } | ||||
protected function sliceResults(array $results) { | protected function sliceResults(array $results) { | ||||
if ($this->getOffset()) { | |||||
$offset = $this->getOffset(); | $offset = $this->getOffset(); | ||||
} else { | |||||
$offset = 0; | |||||
} | |||||
$limit = $this->getLimit(); | $limit = $this->getLimit(); | ||||
valerio.bozzolan: ✅ FINALLY the IDEAL usage of a simple `if()` in PHP. Since the value `"0"` is assumed as false… | |||||
if ($offset || $limit) { | if ($offset || $limit) { | ||||
if (!$limit) { | if (!$limit) { | ||||
$limit = count($results); | $limit = count($results); | ||||
} | } | ||||
$results = array_slice($results, $offset, $limit, $preserve_keys = true); | $results = array_slice($results, $offset, $limit, $preserve_keys = true); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
✅ FINALLY the IDEAL usage of a simple if() in PHP. Since the value "0" is assumed as false for weird reasons related to PHP, but here it's converted to the numerical 0 and it has LOT of sense.
Thanks for this.