-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Utils - Add multibyte and UTF-8 support #6054
Conversation
cf5b6ed
to
47b6116
Compare
Hi and thanks for the PR! Currently we don't require the |
if we need mb_* support, i would require polyfill |
I have no strong opinion about this. Requiring the polyfill would increase the tool's weight but the extension might not be widespread enough to avoid it. Anyway, whatever choice we make, it should be required in |
I know this looks like scope creep, yet I feel like if we go this way we should take care of some other points in the code effected by this as well. There are a few spots we do Places are:
For the last one, Btw. nice work on updating the regex, so close to RTM from me :) |
3092f14
to
88471a3
Compare
88471a3
to
d3637aa
Compare
Thank you @paulbalandan. |
@@ -58,7 +58,7 @@ public function __construct() | |||
$this->functions = array_filter( | |||
self::$functionsMap, | |||
static function (array $mapping): bool { | |||
return \function_exists($mapping['alternativeName']) && (new \ReflectionFunction($mapping['alternativeName']))->isInternal(); | |||
return (new \ReflectionFunction($mapping['alternativeName']))->isInternal(); |
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.
Any reason for why the check with function_exists
was removed? This seems to be a BC break on PHP 7.3.
Uncaught ReflectionException: Function mb_str_split() does not exist in vendor/friendsofphp/php-cs-fixer/src/Fixer/Alias/MbStrFunctionsFixer.php:61
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.
symfony/polyfill-mbstring
was added as a dependency so this should not happen. How did you install PHP CS Fixer?
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.
Hello @julienfalque,
Well I'm removing polyfills when the extension is mandatory. I'm the only one who is doing this?
For example
{
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^7.3",
"ext-ctype": "*",
"ext-mbstring": "*",
"friendsofphp/php-cs-fixer": "^3.3"
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-mbstring": "*",
"symfony/polyfill-php56": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php73": "*"
}
}
I know it's a weird configuration, but I'm just curious about the reasoning.
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.
If you remove a requirement from the application there is nothing much we can do to help you, I mean these are in there for the reason that they are required. If you share how you installed the app like Julien asked we might be able to help, but otherwise not sure what we can do here.
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.
@SpacePossum I already shared my composer.json
. That should be enough.
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, then the check is still required indeed. If you don't mind, please submit a PR to fix that.
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.
how is the check still required, is it not in the polyfil?
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.
Without the polyfill, we would have to check whether the function exists even with ext-mbstring
installed because the function was added in PHP 7.4. But the polyfill has a different behavior because it creates it regardless of the PHP version.
I'm actually not sure about this being a BC break. We can:
- consider using the polyfill is safe and we don't add the check back: people removing the polyfill do it at their own risk, but it means we rely on the polyfill's specific behavior, which one could considerer a bit risky
- or we consider the poolyfill's specific behavior a quirk and we need to add the check back because we still support some PHP versions before 7.4
- or we drop PHP 7.2 and 7.3 support, removing the problem entirely 😁️
I would go with last option but I'm fine with any.
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.
extention evolves over time, they add new functionality. we don't version the extension, but we can version the polyfill. i would expect nobody messing up with PHP CS Fixer requirements.
If you have extension in place, but old one (eg for PHP 7.1), then the polyfill will add only missing functionalities.
(drop of PHP 7.2/7.3 support is short term solution, the same concern would reappear later)
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.
So option 1: we keep current situation and don't add the check back?
Fixes #5297