Fix PHP8.2 str_split function returns empty arrays for empty strings#588
Fix PHP8.2 str_split function returns empty arrays for empty strings#588HuongNV13 wants to merge 1 commit intotecnickcom:mainfrom
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. |
| 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.
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 |
|
Thank you very much, @HuongNV13, for tracking down the PHP 8.2 TCPDF 6 is now deprecated and no further changes will be merged into this repository. Please see the pinned issue Thank You - and the Future of TCPDF for the full explanation and the path forward. The empty-string edge case you identified is handled correctly in the modern PHP string utilities used by tc-lib-pdf. If you encounter a related issue there, feel free to open a PR or issue in that repository. If you need any help adapting your fix to the new library, please open a discussion and I will do my best to assist. I am leaving this PR open in case you or anyone else wishes to continue the discussion, but it is unlikely that this PR will ever be merged. Thank you again for your patience and understanding. |
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