-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix PHP8.2 str_split function returns empty arrays for empty strings #588
base: main
Are you sure you want to change the base?
Fix PHP8.2 str_split function returns empty arrays for empty strings #588
Conversation
Unfortunately mb_str_split() was only introduced in php7.4 which will make swapping this out trickier. |
Thanks for the hint! |
or maybe just |
1a5a931
to
c5ed6b2
Compare
c5ed6b2
to
ae4f2e8
Compare
Thanks, everyone. |
I think this is not a valid fix as mb_str_split() behaves the same way as str_split() in PHP 8.2 and above. |
@@ -638,7 +638,8 @@ public function __construct($code, $eclevel = 'L') { | |||
$barcode_array['bcode'] = array(); | |||
foreach ($qrTab as $line) { | |||
$arrAdd = array(); | |||
foreach (str_split($line) as $char) { | |||
$chars = function_exists('mb_str_split') ? mb_str_split($line) : str_split($line); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like incorrect indentation, project uses tabs while this code introduces spaces. Same can be said about all other new lines in this MR.
Please try to resolve the conflicts. |
Hi Nicola, Thanks, |
Hi, |
Very good idead This PR should be marked as draft for now |
In PHP 8.2, the str_split function will returns empty arrays for empty strings.
See: https://php.watch/versions/8.2/str_split-empty-string-empty-array
We can use mb_str_split() instead