Skip to content

Commit a0362df

Browse files
committed
MessageCollector: remove polyfill for PHP < 7.2
1 parent 425803e commit a0362df

File tree

1 file changed

+2
-31
lines changed

1 file changed

+2
-31
lines changed

src/Util/MessageCollector.php

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function add($message, $type=self::NOTICE)
124124
*/
125125
public function containsBlockingErrors()
126126
{
127-
$seenTypes = $this->arrayColumn($this->cache, 'type');
127+
$seenTypes = array_column($this->cache, 'type');
128128
$typeFrequency = array_count_values($seenTypes);
129129
return isset($typeFrequency[self::ERROR]);
130130

@@ -156,7 +156,7 @@ public function display($order=self::ORDERBY_SEVERITY)
156156
$this->clearCache();
157157

158158
if ($order === self::ORDERBY_RECEIVED) {
159-
$messages = $this->arrayColumn($messageInfo, 'message');
159+
$messages = array_column($messageInfo, 'message');
160160
} else {
161161
$messages = $this->sortBySeverity($messageInfo);
162162
}
@@ -278,33 +278,4 @@ private function clearCache()
278278
}//end clearCache()
279279

280280

281-
/**
282-
* Return the values from a single column in the input array.
283-
*
284-
* Polyfill for the PHP 5.5+ native array_column() function (for the functionality needed here).
285-
*
286-
* @param array<array<string, string|int>> $input A multi-dimensional array from which to pull a column of values.
287-
* @param string $columnKey The name of the column of values to return.
288-
*
289-
* @link https://www.php.net/function.array-column
290-
*
291-
* @return array<string|int>
292-
*/
293-
private function arrayColumn(array $input, $columnKey)
294-
{
295-
if (function_exists('array_column') === true) {
296-
// PHP 5.5+.
297-
return array_column($input, $columnKey);
298-
}
299-
300-
// PHP 5.4.
301-
$callback = function ($row) use ($columnKey) {
302-
return $row[$columnKey];
303-
};
304-
305-
return array_map($callback, $input);
306-
307-
}//end arrayColumn()
308-
309-
310281
}//end class

0 commit comments

Comments
 (0)