symfony / polyfill

PHP polyfills

Home Page:https://symfony.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

idn-polyfill is not working for php < 7.2 without the symfony mb-polyfill

voku opened this issue · comments

I saw today a very strange error, because of using php 7.1 + this exclusion in the composer config...

{
    "replace": {
        "symfony/polyfill-php70": "1.99",
        "symfony/polyfill-php71": "1.99",
        "symfony/polyfill-mbstring": "1.99"
    }
}

... another library required symfony/polyfill-idn but that is using mb_ord() (=> PHP 7.2). This was only a local problem, so we switched the php version and everything was good. But I wanted to create an issue here, so that someone else can find it, if he/she had the same issue.

Well, if your own composer.json has a replace rule for symfony/polyfill-mbstring, it should also have a requirement on ext-mbstring to ensure that you still have a working mbstring setup (the non-polyfilled one).

The IDN polyfill already requires the mbstring polyfill to be sure we can use mbstring functions. But your own project is forcing composer to skip the mbstring polyfill, considering that the project already provides it. If your project does not actually provides the mbstring features (by forcing it to run with the mbstring extension, or by requiring a different polyfill), you are lying to composer, and then you cannot complain to us about that. We already do everything we need so that composer installs what is needed.

I have already added "ext-mbstring": "*", into the composer.json, but the problem is that you need the polyfill anyway because of mb_ord() (>= PHP 7.2) in this case. Anyway it was only a local problem, so maybe only a special case.

hmm, we might need to require the php72 polyfill package then indeed

Hm, symfony/polyfill-intl-idn already requires the PHP 7.2 polyfill: https://github.com/symfony/polyfill/blob/master/src/Intl/Idn/composer.json#L21

But the PHP 7.2 polyfill supports mb_ord() only since v1.10:

v1.10.0: duplicated mb_ord(), mb_chr() and mb_scrub() polyfills in the php72 one