Skip to content
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

Bugfix: mbstring polyfills must not raise value errors in PHP 7 #501

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from

Conversation

derrabus
Copy link
Member

@derrabus derrabus commented Sep 17, 2024

Fixes #499.

This PR changes all new mbstring polyfills on PHP 7 so that they trigger an oldschool PHP warning instead of raising a ValueError. The reason for that is that the ValueError class might not be available on PHP 7 and the behavior is more consitent with the other polyfills of the mbstring extension.

The somewhat weird side-effect is that we now polyfill a behavior that was never implemented in PHP.

tests/Php84/Php84Test.php Outdated Show resolved Hide resolved
@derrabus derrabus mentioned this pull request Sep 17, 2024
@@ -133,27 +133,27 @@ function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstrin
}

if (!function_exists('mb_str_pad')) {
function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); }
Copy link
Member

Choose a reason for hiding this comment

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

what about a bootstrap80.php file to add the return types when running on PHP8+?

Copy link
Member Author

Choose a reason for hiding this comment

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

That file already exists. ✌🏻

Copy link
Member

@nicolas-grekas nicolas-grekas Sep 18, 2024

Choose a reason for hiding this comment

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

ah indeed :)
there are some failures to fix ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you help we with those? Apparently, the test listener is skipping tests at a strange point in time which conflicts with the expectWarning() feature of PHPUnit. How do we solve that usually?

@nicolas-grekas
Copy link
Member

Let's also address #506 here?

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.

ValueError class not available in PHP < 8
3 participants