Git Product home page Git Product logo

polyfill's Issues

mb_convert_case die on specific string

Maximum execution time of 60 seconds exceeded in vendor/symfony/polyfill-mbstring/Mbstring.php on line 183

String of death (urlencoded): d?d???d?d%A6%CC??????d%A1%C0d?d?d%A1%E3

My guess - infinite while cycles

Lint check: Fatal error: Cannot declare class CallbackFilterIterator, because the name is already in use

The project fails the PHP lint check. Here are the reproducible steps in the empty folder:

$ composer require symfony/polyfill-php54
...
  - Installing symfony/polyfill-php54 (v1.6.0)
...
$ find vendor -name "*.php" -exec php -l {} ';'
...
No syntax errors detected in vendor/symfony/polyfill-php54/Php54.php
Fatal error: Cannot declare class CallbackFilterIterator, because the name is already in use in vendor/symfony/polyfill-php54/Resources/stubs/CallbackFilterIterator.php on line 28
Errors parsing vendor/symfony/polyfill-php54/Resources/stubs/CallbackFilterIterator.php

I'm using these checks as part of the build for all Composer's libraries to verify whether the files are compatible with my PHP version, however I've got this fatal error instead.

This library was requested by symfony/http-foundation v2.8.32 which was requested by symfony/http-kernel and vipsoft/code-coverage-extension which is used for code coverage tests, so I believe v3.x is not supported yet.

Include stubs from symfony/intl?

I dont understand why symfony/polyfill-intl-icu requires symfony/intl and vice versa.

Shouldnt symfony/polyfill-intl-icu provide all the stubs, making symfony/polyfill-intl-messageformatter obsolete and remove symfony/intl as a polyfill dep.

Effectively symony/intl provides all stubs, except MessageFormatter.

It can be as simple as symfony/polyfill-intl + symfony/intl (specialized lib) no?

Zend Server and APC functionality

Zend Server tries to implement compatibility with apc by registering compatibility functions with the same name as the APC functions.

http://files.zend.com/help/Zend-Server-6/content/zend_data_cache_-_configuration_directives.htm

Specifically, the option is "zend_datacache.apc_compatibility". It looks like it gets aliased to zend_shm_cache_store, which mostly works. Unfortunately, it doesn't support the array form of apc_store(), so every call results in errors:

"apc_store() expects parameter 1 to be string, array given"

It looks like this is a problem that other projects have dealt with, and it looks like it's one that's been going on for 8 years or so, so I'm not expecting Zend to fix it anytime soon.

My inclination would be to add a check to see if the parameter to apcu_add() or apcu_store() is an array, and if so to call the apc function individually for each item in the array. It would maintain compatibility with APC, and fix the issues with Zend Server. It's a little bit of a hack, though, and I figured I'd ask before submitting a PR.

Alternatively, I could add support for Zend Data Cache to the Symfony Cache Component.

hex2bin() returns false if NUL bytes are in decoded string

hex2bin() returns false if NUL bytes are in decoded string. No error or exception is thrown which breaks code written for PHP 5.4+ that does not explicitly test for this condition, or which uses another test such as preg_match('/^([a-f0-9]{2})*$/', $str).

This breaks binary-safety and is inconsistent with PHP's behavior.

[RFC] Apc polyfill

I think it would be useful to have a polyfill for Apc, for the cases that apcu_* functions are available put apc_* is not.

This is the default situation when using Apcu > v5.

The polyfill would mostly be helpful in using older code that relies on apc_* and avoid installing the apcu_bc extension.

It there is agreement that this could be useful I could write it. I imagine it to be basically a complete copy of the Apcu polyfill, but with the u in the opposite place.

I would even be tempted to put it in the same polyfill making it simple to have code work in either situation.

New release for symfony/polyfill-mbstring

The current release of symfony/polyfill-mbstring has an invalid composer.json scheme. This has already been fixed in the master branch, however this change has not yet been released.

This break the composer validation of dependencies for any projects that has this polyfill included:

symfony/polyfill-mbstring is valid for simple usage with composer but has
strict errors that make it unable to be published as a package:
The property - suggests - is not defined and the definition does not allow additional properties

Could you create a new release including this change.

Support APCUIterator for APCu 4.x

APCu Polyfill currently returns early if the legacy APC extension is missing, even though the APCUIterator wrapper is still useful with APCu 4.x (which is the only APCu that works with PHP 5.6).

iconv_substr(): Detected an illegal character in input string

Hello

I have the same error #63

[2016-08-24 15:03:51] lumen.ERROR: ErrorException: iconv_substr(): Detected an illegal character in input string in /var/www/app-storage/vendor/symfony/polyfill/src/Mbstring/Mbstring.php:417
Stack trace:
#0 [internal function]: Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}(8, 'iconv_substr():...', '/var/www/heaven...', 417, Array)
#1 /var/www/app-storage/vendor/symfony/polyfill/src/Mbstring/Mbstring.php(417): iconv_substr('\x01\x00\x00\x00\x00\x01\xE5', 0, 1, 'ASCII')
#2 /var/www/app-storage/vendor/symfony/polyfill/src/Mbstring/bootstrap.php(36): Symfony\Polyfill\Mbstring\Mbstring::mb_substr('\x01\x00\x00\x00\x00\x01\xE5', 0, 1, 'ASCII')
#3 /var/www/app-storage/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Wire/AMQPReader.php(163): mb_substr('\x01\x00\x00\x00\x00\x01\xE5', 0, 1, 'ASCII')

Tests fail on PHP 7.3

Using PHP 7.3 on Debian unstable, I see the following test failures:

There were 18 failures:

1) Symfony\Polyfill\Tests\Apcu\ApcuTest::testApcu
Failed asserting that false is true.

/home/km/projects/symfony-polyfill/tests/Apcu/ApcuTest.php:27

2) Symfony\Polyfill\Tests\Apcu\ApcuTest::testArrayCompatibility
Failed asserting that false matches expected 'value1'.

/home/km/projects/symfony-polyfill/tests/Apcu/ApcuTest.php:52

3) Symfony\Polyfill\Tests\Apcu\ApcuTest::testAPCUIterator
Failed asserting that false is true.

/home/km/projects/symfony-polyfill/tests/Apcu/ApcuTest.php:71

4) Symfony\Polyfill\Tests\Intl\Idn\IdnTest::testDecodeInvalid2003 with data set #0 ('xn--zcaccffbljjkknnoorrssuuxx...g9g.de', 'xn--zcaccffbljjkknnoorrssuuxx...g9g.de')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'xn--zcaccffbljjkknnoorrssuuxxd5e0a0a3ae9c6a4a9bzdzdxdudwdxd2d2d8d0dse7d6dwe9dxeueweye4eyewe9e5ewkkewc9ftfpfplwexfwf4infvf2f6f6f7f8fpg8fmgngrgrgvgzgygxg3gyg1g3g5gykqg9g.de'
+'äöüßáàăâåãąāæćĉčċçďđéèĕêěëėęēğĝġģĥħíìĭîïĩįīıĵķĺľļłńňñņŋóòŏôőõøōœĸŕřŗśŝšşťţŧúùŭûůűũųūŵýŷÿźžżðþ.de'

/home/km/projects/symfony-polyfill/tests/Intl/Idn/IdnTest.php:83

5) Symfony\Polyfill\Tests\Intl\Idn\IdnTest::testDecodeInvalid2003 with data set #1 ('xn--zcaccffbljjkknnoorrssuuxx...vda.de', 'xn--zcaccffbljjkknnoorrssuuxx...g.þ.de')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'xn--zcaccffbljjkknnoorrssuuxxd5e0a0a3ae9c8c1b0dxdvdvdxdvd3d0d6dyd8d5d4due7dveseuewe2eweue7e3esk9dxc7frf9e7kuevfuf1ilftf5f4f4f5f6fng6f8f9fpgpgtgxgwgvg1g2gzg1g3gvkog7g.þ.de'
+'äöüßáàăâåãąāæćĉčċçďđéèĕêěëėęēğĝġģĥħíìĭîïĩįīıĵķĺľļłńňñņŋóòŏôőõøōœĸŕřŗśŝšşťţŧúùŭûůűũųūŵýŷÿźžżð.þ.de'

/home/km/projects/symfony-polyfill/tests/Intl/Idn/IdnTest.php:83

6) Symfony\Polyfill\Tests\Intl\Idn\IdnTest::testUppercase2003 with data set #0 ('рф.RU', 'xn--p1ai.RU', 'рф.RU')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'xn--p1ai.RU'
+'xn--p1ai.ru'

/home/km/projects/symfony-polyfill/tests/Intl/Idn/IdnTest.php:93

7) Symfony\Polyfill\Tests\Intl\Idn\IdnTest::testUppercase2003 with data set #1 ('GUANGDONG.广东', 'GUANGDONG.xn--xhq521b', 'GUANGDONG.广东')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'GUANGDONG.xn--xhq521b'
+'guangdong.xn--xhq521b'

/home/km/projects/symfony-polyfill/tests/Intl/Idn/IdnTest.php:93

8) Symfony\Polyfill\Tests\Intl\Idn\IdnTest::testUppercase2003 with data set #2 ('renanGonçalves.COM', 'xn--renangonalves-pgb.COM', 'renangonçalves.COM')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'xn--renangonalves-pgb.COM'
+'xn--renangonalves-pgb.com'

/home/km/projects/symfony-polyfill/tests/Intl/Idn/IdnTest.php:93

9) Symfony\Polyfill\Tests\Intl\Normalizer\NormalizerTest::testConstants
Failed asserting that Array &0 (
    'FORM_C' => 4
    'FORM_D' => 2
    'FORM_KC' => 5
    'FORM_KD' => 3
    'NFC' => 4
    'NFD' => 2
    'NFKC' => 5
    'NFKD' => 3
    'NONE' => 1
) is identical to Array &0 (
    'FORM_C' => 16
    'FORM_D' => 4
    'FORM_KC' => 32
    'FORM_KC_CF' => 48
    'FORM_KD' => 8
    'NFC' => 16
    'NFD' => 4
    'NFKC' => 32
    'NFKC_CF' => 48
    'NFKD' => 8
    'NONE' => 2
).

/home/km/projects/symfony-polyfill/tests/Intl/Normalizer/NormalizerTest.php:37

10) Symfony\Polyfill\Tests\Intl\Normalizer\NormalizerTest::testIsNormalized
Failed asserting that false is true.

/home/km/projects/symfony-polyfill/tests/Intl/Normalizer/NormalizerTest.php:51

11) Symfony\Polyfill\Tests\Intl\Normalizer\NormalizerTest::testNormalize
Failed asserting that false is identical to 'déjà훈쇼™'.

/home/km/projects/symfony-polyfill/tests/Intl/Normalizer/NormalizerTest.php:68

12) Symfony\Polyfill\Tests\Intl\Normalizer\NormalizerTest::testNormalizeConformance
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'Ḋ'
+'Ḋ'

/home/km/projects/symfony-polyfill/tests/Intl/Normalizer/NormalizerTest.php:109

13) Symfony\Polyfill\Tests\Apcu\ApcuTest::testApcu
Polyfills enabled, Failed asserting that false is true.

/home/km/projects/symfony-polyfill/tests/Apcu/ApcuTest.php:27

14) Symfony\Polyfill\Tests\Apcu\ApcuTest::testArrayCompatibility
Polyfills enabled, Failed asserting that false matches expected 'value1'.

/home/km/projects/symfony-polyfill/tests/Apcu/ApcuTest.php:52

15) Symfony\Polyfill\Tests\Apcu\ApcuTest::testAPCUIterator
Polyfills enabled, Failed asserting that false is true.

/home/km/projects/symfony-polyfill/tests/Apcu/ApcuTest.php:71

16) Symfony\Polyfill\Tests\Intl\Normalizer\NormalizerTest::testConstants
Polyfills enabled, Failed asserting that Array &0 (
    'FORM_C' => 4
    'FORM_D' => 2
    'FORM_KC' => 5
    'FORM_KD' => 3
    'NFC' => 4
    'NFD' => 2
    'NFKC' => 5
    'NFKD' => 3
    'NONE' => 1
) is identical to Array &0 (
    'FORM_C' => 16
    'FORM_D' => 4
    'FORM_KC' => 32
    'FORM_KC_CF' => 48
    'FORM_KD' => 8
    'NFC' => 16
    'NFD' => 4
    'NFKC' => 32
    'NFKC_CF' => 48
    'NFKD' => 8
    'NONE' => 2
).

/home/km/projects/symfony-polyfill/tests/Intl/Normalizer/NormalizerTest.php:37

17) Symfony\Polyfill\Tests\Intl\Normalizer\NormalizerTest::testIsNormalized
Polyfills enabled, Failed asserting that true is false.

/home/km/projects/symfony-polyfill/tests/Intl/Normalizer/NormalizerTest.php:53

18) Symfony\Polyfill\Tests\Intl\Normalizer\NormalizerTest::testNormalize
Polyfills enabled, Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'déjà 훈쇼™'
+'déjà 훈쇼™'

/home/km/projects/symfony-polyfill/tests/Intl/Normalizer/NormalizerTest.php:78

FAILURES!
Tests: 1100, Assertions: 364410, Failures: 18, Skipped: 12.

Unsilenced deprecation notices (5)

  5x: Normalizer::NONE is obsolete with ICU 56 and above and will be removed in later PHP versions
    3x in NormalizerTest::testNormalize from Symfony\Polyfill\Tests\Intl\Normalizer
    2x in NormalizerTest::testIsNormalized from Symfony\Polyfill\Tests\Intl\Normalizer

Legacy deprecation notices (136)

There's also a Debian bug report at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911832

The polyfill should get released

This library is now used as a dependency in Twig 1.23 (and other projects are starting to use it too).
Not having a stable release means that Twig 1.23 is not installable by default in a composer project (you have to change the minimum stability or to require dev versions of symfony/polyfill-mbstring in your project to whitelist it)

Iconv polyfill doesn't support //TRANSLIT//IGNORE

Q A
Bug report? yes
Feature request? yes
BC Break report? no

The PHP function iconv() of the iconv extension allows both options to be specified at the same time. However, symfony/polyfill-iconv does not support that.

Example code:

$conv = function ($item) {
    return chr($item);
};

$isoString= implode(array_map($conv, [0x54,0xe4,0x73,0x74,0xdf]));

var_dump(iconv('ISO-8859-1', 'ASCII//IGNORE', $isoString));
var_dump(iconv('ISO-8859-1', 'ASCII//TRANSLIT', $isoString));
var_dump(iconv('ISO-8859-1', 'ASCII//TRANSLIT//IGNORE', $isoString));

Expected output (as with glibc iconv 2.19):

string(3) "Tst"
string(6) "Tastss"
string(6) "Tastss"

Actual output:

string(3) "Tst"
string(6) "Tastss"
PHP Notice:  iconv(): Wrong charset, conversion from `iso-8859-1' to `ascii//translit' is not allowed in /home/user/pdfparser/vendor/symfony/polyfill-iconv/Iconv.php on line 176
bool(false)

Tested with:

  • symfony/polyfill-iconv (v1.5.0)
  • symfony/polyfill-iconv (dev-master 1ea0e08)

Normalizer::recompose() should reset the last combining class on ASCII.

This can be seen using the string "\xcc\x83\xc3\x92\xd5\x9b", which gets decomposed into "\xcc\x83\x4f\xcc\x80\xd5\x9b". On recompose, $lastUcls isn't reset on the ASCII "\x4f" so the string gets left in this decomposed form instead of the expected NFC normalized "\xcc\x83\xc3\x92\xd5\x9b".

The fix is reset the $lastUcls variable to zero on ASCII, see for instance the version of "Normalizer.php" I'm using in a fork of the WordPress plugin "tl-normalizer" https://github.com/gitlost/tl-normalizer/blob/master/Symfony/Normalizer.php#L184

intl NumberFormatter

This package could polyfill the NumberFormatter. This is something symfony/intl never tried to do, but what we've mostly accomplished in commerceguys/intl.
We don't try to replicate the rounding behavior, but that could be done, at least partially.

Happy to discuss it via other channels as well.

PHPCompatibility rulesets for the Symfony polyfill-php#.# packages

Hi all,

This is just a "service message".

For those people who use this library and use PHPCompatibility in their CI process, there is now a set of custom rulesets available which can be used to prevent false positives being thrown by PHPCompatibility for the native PHP functionality being polyfilled by the various Symfony polyfill-php#.# packages.

You can find the repo for the Symfony polyfill rulesets here on Github as well as on Packagist.

Hope someone will find it useful 😄

P.S.: If anyone is interested in helping us maintaining the rulesets and/or adding rulesets for the other Symfony polyfill packages, please open an issue in the repo.

MessageFormatter should explicitly not support non-English locales

Currently, for plural rules, the MessageFormatter polyfills uses the English rules for all locales (it ignores the locale).
To be consistent with what we do in symfony/intl (used by symfony/polyfill-intl-icu to implement NumberFormatter and DateFormatter), we should rather fail explicitly here (using the English rules for a different locale would not give the right result anyway)

IMAP extension polyfill

Is anyone aware of a polyfill for thr IMAP extension? Specifically the imap_mime_header_decode function, which is critical to properly decoding email headers.

Support APCu 5.x-style increment and decrement

In APCu 4.x, attempting to increment or decrement a key that doesn't exist fails. The workaround is storing a value of 1 or -1 to initialize the key after failing on inc/dec. I'm not sure if it would be part of the mission of this project to support things like that, but it's one of the APCu 4.x vs. 5.x challenges I deal with in LCache (in addition to the iterator).

mb_strlen exists but mb_check_encoding undefined

Hi. I trying to use this amazing library in my work but still not understand what happens. I manually disable mbstring module in my php-7 setup for testing purposes. But all of this functions from this library still not defined.

I debug into the bootstrap.php and see that function_exists('mb_strlen') returns true. I hope that I'm doing something wrong but I can't explain that happening.

Why mb_strlen() defined if mbstring module is disabled?

$exists = function_exists('mb_strlen');
(bool)true

$phpVersion = phpversion();
7.0.12-1+deb.sury.org~trusty+1

$extensions = get_loaded_extensions();
array (
  0 => 'Core',
  1 => 'date',
  2 => 'libxml',
  3 => 'openssl',
  4 => 'pcre',
  5 => 'zlib',
  6 => 'filter',
  7 => 'hash',
  8 => 'Reflection',
  9 => 'SPL',
  10 => 'session',
  11 => 'standard',
  12 => 'cgi-fcgi',
  13 => 'mysqlnd',
  14 => 'PDO',
  15 => 'xml',
  16 => 'bcmath',
  17 => 'calendar',
  18 => 'ctype',
  19 => 'curl',
  20 => 'dom',
  21 => 'exif',
  22 => 'fileinfo',
  23 => 'ftp',
  24 => 'gd',
  25 => 'gettext',
  26 => 'iconv',
  27 => 'imagick',
  28 => 'imap',
  29 => 'json',
  30 => 'mcrypt',
  31 => 'memcache',
  32 => 'mysqli',
  33 => 'pdo_mysql',
  34 => 'Phar',
  35 => 'posix',
  36 => 'readline',
  37 => 'shmop',
  38 => 'SimpleXML',
  39 => 'soap',
  40 => 'sockets',
  41 => 'ssh2',
  42 => 'sysvmsg',
  43 => 'sysvsem',
  44 => 'sysvshm',
  45 => 'tokenizer',
  46 => 'wddx',
  47 => 'xmlreader',
  48 => 'xmlwriter',
  49 => 'xsl',
  50 => 'zip',
  51 => 'Zend OPcache',
  52 => 'xdebug',
)

polyfill-mbstring should require polyfill-iconv or ext-iconv

The polyfill-mbstring library depends on iconv, but does not require the polyfill-iconv library or ext-iconv. This can be an issue for things such as minimal PHP docker installs that include --configure = --disable-all before listing specific extensions to build.

Note: This is really for the subtree repo as installing the entire polyfill repo would not have this issue. symphony/console only installs polyfill-mbstring.

mb_strlen: iconv_strlen triggering notice in certain situations

As suggested by @stof in php-amqplib/php-amqplib#72 (comment), I'm opening this ticket.

I can't really tell how to replicate this - I ran into it when installing RabbitMQ and not having mbstring extension installed.

Seems like theres being passed an "illegal" character in the string and its not being considered. This triggers a Notice, and in RabbitMQ case, it throws an exception.

PHP Notice:  iconv_strlen(): Detected an illegal character in input string in …/vendor/symfony/polyfill-mbstring/Mbstring.php on line 338
    public static function mb_strlen($s, $encoding = null)
    {
        $encoding = self::getEncoding($encoding);
        var_dump($s);

        return iconv_strlen($s, $encoding);
    }
string(14) "\000\000\000\000�\000
\000
\000    \000"

Installing the mbstring module prevents RabbitMQ from throwing the Exception, which I guess means this polyfill method is not really replacing the module (?)

Replace the extensions

Is it possible to add all the replaced PHP extensions in "replace"? In our case it is the 'mbstring' extension. If a package requires the mbstring extension, and I am installing this package, it should work.

Ref composer/composer#6525

composer Fatal error Call to undefined function Symfony\Polyfill\Mbstring\iconv()

phar:///usr/local/Cellar/composer/1.0.0-beta1/libexec/composer.phar/vendor/symfony/polyfill-mbstring/Mbstring.php undefined function Symfony\Polyfill\Mbstring\iconv() when called by composer cmd on oxs 10.10.5,I had checked the phar that it had add mbstring/iconv check, How to solve this problem?
Fatal error: Call to undefined function Symfony\Polyfill\Mbstring\iconv() in phar:///usr/local/Cellar/composer/1.0.0-beta1/libexec/composer.phar/vendor/symfony/polyfill-mbstring/Mbstring.php on line 513

Support ICU 58.1

The current homebrew icu4c package is on version 58.1, while the Symfony intl polyfill package supports 57.1. This results in the following recommendation while running ./bin/symfony_requirements: intl ICU version installed on your system (58.1) does not match the ICU data bundled with Symfony (57.1).

Is it possible to support version 58.1 from icu4c?

is_countable, not Big Endian safe?

Hello, I see a possible endianess issue on is_countable testsuite and latest polyfill release 1.8.0
https://autopkgtest.ubuntu.com/packages/php-symfony-polyfill/cosmic/s390x

Setting up autopkgtest-satdep (0) ...
(Reading database ... 73688 files and directories currently installed.)
Removing autopkgtest-satdep (0) ...
autopkgtest [16:09:03]: test command1: phpunit --bootstrap /usr/share/php/Symfony/Polyfill/autoload.php
autopkgtest [16:09:03]: test command1: [-----------------------
PHPUnit 7.2.7 by Sebastian Bergmann and contributors.

SSS............................................................  63 / 766 (  8%)
............................................................... 126 / 766 ( 16%)
............................................................... 189 / 766 ( 24%)
............................................................... 252 / 766 ( 32%)
............................................................... 315 / 766 ( 41%)
..............................................................S 378 / 766 ( 49%)
SS..F.SSS...................................................... 441 / 766 ( 57%)
............................................................... 504 / 766 ( 65%)
............................................................... 567 / 766 ( 74%)
............................................................... 630 / 766 ( 82%)
............................................................... 693 / 766 ( 90%)
............................................................... 756 / 766 ( 98%)
.....SSS..                                                      766 / 766 (100%)

Time: 2.22 seconds, Memory: 18.22MB

There was 1 failure:

1) Symfony\Polyfill\Tests\Php73\Php73Test::testIsCountable
Failed asserting that false is true.

/tmp/autopkgtest.Lf6G0W/build.nrL/src/tests/Php73/Php73Test.php:27

FAILURES!
Tests: 778, Assertions: 726412, Failures: 1, Skipped: 12.

I'm tempted to disable this part of the testsuite, since php 7.3 is not yet a real thing, and nothing is using is_countable in the archive, and this is a new test... but can you please have a look, or tell me if this is not a real issue?

the architecture is s390x

Latest change to bootstrap.php broke composer update process

Not sure if it's me or everyone, but when running composer update with minimum-stability:dev I now receive this error:

Script php aritsan clear-compiled handling the post-update-cmd event returned with an error

[RuntimeException]
  Error Output: PHP Fatal error:  Class 'APCIterator' not found in /path/to/app/vendor/symfony/polyfill-apcu/bootstrap.php on line 32

I'm guessing this has something to do with this recent commit

Increasing the minimum stability bypasses the issue. However, I would like to work in dev stability, is there any workaround or fix?

polyfill-iconv: infinite loop on transliterating U+0096 character

If I try to transliterate the U+0096 character from UTF-8 (0xC2 0x96) to e.g. ASCII, the Iconv::iconv() function hangs due to an infinite loop.

Minimal example:

<?php
require_once('vendor/autoload.php');
use Symfony\Polyfill\Iconv\Iconv;
$text = "the \xC2\x96 character causes problems";
$converted = Iconv::iconv("UTF-8", "ASCII//TRANSLIT", $text);

I have identified that the problem is due to this line.

I tried the following patch, which makes it work and doesn't break any tests, but I don't fully understand how this function works, so it may have unintended consequences.

From 2e8ac7c206166a38526d10bb4df8eaa9c8bdc568 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Koszta=20D=C3=A1niel?= <[email protected]>
Date: Wed, 1 Aug 2018 16:44:38 +0200
Subject: [PATCH] Avoid infinite loop

---
 src/Iconv/Iconv.php | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/Iconv/Iconv.php b/src/Iconv/Iconv.php
index b9abecb..4d0ebba 100644
--- a/src/Iconv/Iconv.php
+++ b/src/Iconv/Iconv.php
@@ -695,6 +695,8 @@ final class Iconv
                     } else {
                         return false;
                     }
+                } else {
+                    continue;
                 }
 
                 $str = $uchr.substr($str, $i);
-- 
2.18.0

gzopen() / gzopen64()

On 32bit builds of Ubuntu 14.04LTS (PHP 5.5.9), three functions are created with the wrong names.
See one of many bug reports.
There seems to be no plans to fix this in Ubuntu, so users of this LTS release cannot use the GZIP library.

Is there a place in this package for the necessary polyfills?

if (!function_exists('gzopen') && function_exists('gzopen64')) {
    function gzopen($filename , $mode = 'r', $use_include_path = 0 ) {
        return gzopen64($filename, $mode, $use_include_path);
    }
}
if (!function_exists('gzseek') && function_exists('gzseek64')) {
    function gzseek($zp , $offset, $whence = SEEK_SET) {
        return gzseek64($zp, $offset, $whence);
    }
}
if (!function_exists('gztell') && function_exists('gztell64')) {
    function gztell($zp) {
        return gztell64($zp);
    }
}

APCU polyfill register a class to be autoloadable without taking into account dependency

The \APCUIterator stubs is register to be autoloadable but it extend a class that may very well not exist.
Therfore calling :
class_exists('\APCUIterator');
will trigger a Fatal Error when \APCIterator isnt available.

For exemple, \Stash\Driver\Apc::isAvailable() rely on such a call.

I think, the stubs should only be know by Composer's autoloader if it's instanciable.

Add support for JSON_THROW_ON_ERROR for the PHP 7.3 polyfill

If feels like it's something that could be provided by the polyfill as well. I can try to do a PR if that's ok.

Note that there is also the exception JsonException missing.

Also the doc for the PHP 7.3 polyfill is outdated, given the entry of the docs for the polyfills, maybe those could be automated somehow to keep them in sync.

Normalizer::decompose() should check that reordered sequences aren't themselves reordered.

This can be seen using the string "\xe0\xbd\xb6\xe0\xbe\x81", which currently gets decomposed into "\xe0\xbe\xb2\xe0\xbe\x80\xe0\xbd\xb1\xe0\xbe\x80", but the reordered sequences "\xe0\xbe\x80" and "\xe0\xbd\xb1" should themselves be reordered, to give the expected NFD form "\xe0\xbe\xb2\xe0\xbd\xb1\xe0\xbe\x80\xe0\xbe\x80".

I've put in a hacky fix for this on the version of "Normalizer.php" I'm using in the "tl-normalizer" WP plugin fork, which recurses when a reordered sequence has a reordering combining class, see https://github.com/gitlost/tl-normalizer/blob/master/Symfony/Normalizer.php#L237 passim, but I'm sure there's a better way of doing it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.