Skip to content

Conversation

dewillepl
Copy link

This PR replaces the deprecated usage of utf8_decode() with a PHP 8.2+ compatible approach using mb_strlen() and null coalescing operator for better readability and null handling.

Problem:
With the current Dockerfile (FROM php:fpm-alpine), the container installs PHP 8.2 by default. Running the app produces deprecation warnings:

PHP 8.2: utf8_encode() and utf8_decode() functions are deprecated

Change:
Before:

$shortage = 4 - strlen(utf8_decode($input)) % 4;

After:

$shortage = 4 - (mb_strlen($input ?? '', 'UTF-8') % 4);

Benefit:

  • Removes deprecation warnings on PHP 8.2+
  • Ensures forward compatibility with future PHP versions

@dewillepl
Copy link
Author

Previous PR included extra commits by mistake. This one contains only the intended change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant