-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Various fixes and removed deprecations #497
Conversation
We used to have a polyfill for |
b3e26a5
to
a9d6937
Compare
Indeed @derrabus, that's smart. I copied the function and added it to Iconv as a private method. Seems to work really well 👍 |
a9d6937
to
d0869f7
Compare
src/Intl/Idn/bootstrap80.php
Outdated
} | ||
if (!function_exists('idn_to_utf8')) { | ||
function idn_to_utf8(?string $domain, ?int $flags = IDNA_DEFAULT, ?int $variant = INTL_IDNA_VARIANT_UTS46, &$idna_info = null): string|false { return p\Idn::idn_to_utf8((string) $domain, (int) $flags, (int) $variant, $idna_info); } | ||
function idn_to_utf8(string $domain, int $flags = IDNA_DEFAULT, int $variant = INTL_IDNA_VARIANT_UTS46, &$idna_info = null): string|false { return p\Idn::idn_to_utf8($domain, $flags, $variant, $idna_info); } |
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.
Those changes should be reverted, as it makes it incompatible with passing null
in non-strict-types files (which is deprecated in PHP 8.1+ but will only be removed in PHP 9.0)
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.
I reverted the casts
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.
You need to revert the whole change. The most important part of my comment is about the parameter type.
PHP does not support passing null
to a non-nullable userland function parameter. The reason of the PHP 8.1 deprecation is precisely because the behavior of native functions cannot be emulated exactly in userland for now (in PHP 9, they will behave the same than userland functions in that regard)
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.
@nicolas-grekas what do you think about adding legacy tests covering passing null
to all our polyfilled functions (that will have a non-nullable parameter type in PHP 9), so that the testsuite catches such broken changes to the polyfills, as that's not the first time we get such changes in a PR.
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.
I see what you mean, but what about this warning? This is the reason I updated the signature
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.
@alexandre-daubois this should have been fixed by #495 AFAIK
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.
It doesn't seem to be touching anything related to the Incompatible signature for PHP >= 8
warning. Am I missing something?
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.
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.
Oh right I get it now. That wasn't the root cause of the warning message. That's reverted 👍
src/Iconv/Iconv.php
Outdated
@@ -741,4 +741,34 @@ private static function getData($file) | |||
|
|||
return false; | |||
} | |||
|
|||
private static function utf8Decode($s) |
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.
I suggest naming utf8ToLatin1
instead, to reflect what this method actually does (the bad name of utf8_decode
was the main reason why it has been deprecated)
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.
Alternatively, we could drop strlen1
entirely, falling back directly to the strlen2
implementation that was used when the xml
extension was not loaded and so we did not have the native utf8_decode
function. The utf8_decode
fallback was done because using the native function was faster than the userland logic of strlen2
, but this probably does not hold anymore with a userland function doing more work.
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.
I went for the alternative solution, which really clean things up.
dbfb2d5
to
08a7263
Compare
@@ -17,7 +17,7 @@ | |||
/** | |||
* @author Tim Düsterhus <duesterhus@woltlab.com> | |||
*/ | |||
class SensitiveParameterValueTest extends TestCase | |||
class SensitiveParameterValuePolyfillTest extends TestCase |
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.
TestListenerTrait tries to find a polyfill declaration in bootstrap.php
base on the test classname. However, SensitiveParameterValue
is a "special" polyfill that doesn't need any declaration in bootstrap.php
.
So, PHPUnit warned that no polyfill was found, but that's normal. By renaming, the file to not match the SensitiveParametrerValue
classname, we avoid TestListenerTrait
to raise a wrong warning.
fbd5bcb
to
e15b05c
Compare
e15b05c
to
d293634
Compare
d293634
to
12cbaa2
Compare
Thank you @alexandre-daubois. |
First batch of fixes with the "new" CI.