Skip to content

Commit 2bbc5f0

Browse files
committed
HitHighlighter Class: avoid PHP 8 errors
This change should avoid such errors: PHP Fatal error: Uncaught ArgumentCountError: array_merge() does not accept unknown named parameters call_user_func_array() expects a function name and an array of parameters to be unpacked and passed on to the function. In PHP 8, when call_user_func_array() receives an array of parameters with string keys, the keys will be interpreted as parameter names.
1 parent 82e4bdd commit 2bbc5f0

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Changes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes
22

3+
## 3.1.2
4+
5+
- Hit highlighting: avoid errors with PHP 8.
6+
37
## 3.0.0
48

59
- Pass twitter-text conformance 3.0.0

lib/Twitter/Text/HitHighlighter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function highlight($tweet = null, array $hits = null)
141141
$offset = 0;
142142
$start_in_chunk = false;
143143
# Flatten the multidimensional hits array:
144-
$hits_flat = call_user_func_array('array_merge', $hits);
144+
$hits_flat = array_merge(...array_values($hits));
145145
$hits_flat_count = count($hits_flat);
146146
# Loop over the hit indices:
147147
for ($index = 0; $index < $hits_flat_count; $index++) {

0 commit comments

Comments
 (0)