Skip to content

refactor: DOMParser::withString() for PHP 8.2 #6672

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

Merged
merged 5 commits into from
Oct 25, 2022

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Oct 12, 2022

Description
See #6170
See https://php.watch/versions/8.2/mbstring-qprint-base64-uuencode-html-entities-deprecated

  • mb_convert_encoding($str, 'HTML-Entities') is deprecated in PHP 8.2.

Checklist:

  • Securely signed commits
  • [] Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • [] User guide updated
  • Conforms to style guide

@kenjis kenjis added PHP 8.2 refactor Pull requests that refactor code labels Oct 12, 2022
@kenjis kenjis mentioned this pull request Oct 12, 2022
7 tasks
@kenjis kenjis changed the title refactor: DOMParser::withString() refactor: DOMParser::withString() for PHP 8.2 Oct 12, 2022
Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having a hard time finding a clear answer: are you sure these are the same?

@MGatner
Copy link
Member

MGatner commented Oct 12, 2022

Compare: Kristories/symfony@eea3b10

@kenjis
Copy link
Member Author

kenjis commented Oct 13, 2022

The latest code in Symfony is different.

$this->line = htmlspecialchars_decode(utf8_decode(htmlentities($this->line, ENT_COMPAT, 'UTF-8', false)));

https://github.com/Kristories/symfony/blob/eea3b10327c1a9b1298a069ea8f844c70e73b6a7/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php#L981

$this->line = mb_encode_numericentity($this->line, [0x80, 0x10FFFF, 0, 0x1FFFFF], 'UTF-8');

https://github.com/symfony/symfony/blob/b527899f4fb4355fd356eef6f910ea67c5f86192/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php#L939

@kenjis
Copy link
Member Author

kenjis commented Oct 13, 2022

I'm having a hard time finding a clear answer: are you sure these are the same?

No. The following tests fail with this PR.

--- a/tests/system/Test/DOMParserTest.php
+++ b/tests/system/Test/DOMParserTest.php
@@ -80,8 +80,9 @@ final class DOMParserTest extends CIUnitTestCase
     public function provideText()
     {
         return [
-            ['Hello World'],
-            ['Hellö Wörld'],
+            'en' => ['Hello World'],
+            'sv' => ['Hej, världen'],
+            'ja' => ['こんにちは、世界'],
         ];
     }
 

@kenjis
Copy link
Member Author

kenjis commented Oct 13, 2022

I changed the code, and test case.
But I don't understand the need for the conversion. 😓

@MGatner
Copy link
Member

MGatner commented Oct 13, 2022

Have you blamed it for any clues? I can look into it later on desktop, but it is a rather baffling feature.

@kenjis kenjis added the help wanted More help is needed for the proper resolution of an issue or pull request label Oct 17, 2022
@kenjis kenjis mentioned this pull request Oct 22, 2022
5 tasks
@kenjis kenjis force-pushed the fix-DOMParser-withString-php82 branch from b12e15e to d88f555 Compare October 24, 2022 08:41
@kenjis kenjis force-pushed the fix-DOMParser-withString-php82 branch from d88f555 to a83d410 Compare October 24, 2022 23:02
@kenjis
Copy link
Member Author

kenjis commented Oct 24, 2022

I think this PR is ready to merge.

@kenjis kenjis merged commit a88ceea into codeigniter4:develop Oct 25, 2022
@kenjis kenjis deleted the fix-DOMParser-withString-php82 branch October 25, 2022 21:08
@kenjis
Copy link
Member Author

kenjis commented Oct 25, 2022

Thanks for the reviews!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted More help is needed for the proper resolution of an issue or pull request refactor Pull requests that refactor code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants