Skip to content

Improve UTF8 encoding process#641

Merged
kylekatarnls merged 2 commits intopdepend:masterfrom
niconoe-:patch-1
Jan 16, 2023
Merged

Improve UTF8 encoding process#641
kylekatarnls merged 2 commits intopdepend:masterfrom
niconoe-:patch-1

Conversation

@niconoe-
Copy link
Contributor

Type: Deprecation warning removal
Issue: None (yet?)
Breaking change: no

Due to PHP 8.2 deprecating functions utf8_encode and utf8_decode, the utils method Utf8Util::ensureEncoding can create deprecation warnings when ran with PHP 8.2 without the "iconv" extension loaded.

image

In this PR, I want to offer 2 new ways to ensure about the encoding in UTF-8 in case "iconv" is not enabled:

  1. The usage of "mbstring" extension's functions mb_convert_encoding (and mb_list_encodings to prevent wrongly forced encodings) in case "iconv" wasn't used
  2. The prevention of usage of utf8_encode in PHP 8.2 (and more recent versions) that is replaced by a polyfill Symfony is already providing since quite a long time.

I did not added some unit tests to cover my case as I don't know how to simulate the non-existance of iconv extension nor the existance of mbstring extension, nor how to detect there are no more deprecated message in PHP 8.2. I just ran this modified version of pdepend on one of my project and I got the exact same values but without the deprecation messages.
If someone can help me to provide unit tests if this is mandatory on this class, I would be really gladful to provide them.

@kylekatarnls kylekatarnls merged commit e485e04 into pdepend:master Jan 16, 2023
@kylekatarnls kylekatarnls added this to the 2.13.0 milestone Jan 16, 2023
@niconoe-
Copy link
Contributor Author

Thank you very much for this fast approval! 🚀

@niconoe- niconoe- deleted the patch-1 branch January 16, 2023 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants