Replaced is_array() check and set of $keys in array with cast to array of $keys in array_filter()

Replaced assignment of $key and $dir through list() with each() with simply key() and current() per tenkoma's suggestion. Resolves # 11827

each() advances the pointer similar to next() but is being negated this particular case by array_shift() which resets the pointer
This commit is contained in:
Trent Renshaw 2018-05-31 15:42:48 +10:00
parent fc061a55c4
commit adefb973aa

View file

@ -3043,15 +3043,12 @@ class DboSource extends DataSource {
* @return string ORDER BY clause
*/
public function order($keys, $direction = 'ASC', Model $Model = null) {
if (!is_array($keys)) {
$keys = array($keys);
}
$keys = array_filter($keys);
$keys = array_filter((array) $keys);
$result = array();
while (!empty($keys)) {
list($key, $dir) = each($keys);
$key = key($keys);
$dir = current($keys);
array_shift($keys);
if (is_numeric($key)) {