8000 Rely on iconv and symfony/polyfill-* · symfony/symfony@0e052da · GitHub
[go: up one dir, main page]

Skip to content

Commit 0e052da

Browse files
Rely on iconv and symfony/polyfill-*
1 parent aa2673b commit 0e052da

File tree

91 files changed

+159
-767
lines changed
  • Resources/stubs
  • Session/Storage
  • HttpKernel/Tests/Profiler
  • Intl
  • Ldap
  • Security
  • Serializer
  • Templating
  • Translation
  • Validator
  • VarDumper
  • Yaml
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    91 files changed

    +159
    -767
    lines changed

    composer.json

    Lines changed: 8 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -21,7 +21,13 @@
    2121
    "twig/twig": "~1.20|~2.0",
    2222
    "psr/log": "~1.0",
    2323
    "symfony/security-acl": "~2.7",
    24-
    "paragonie/random_compat": "~1.0"
    24+
    "symfony/polyfill-intl-icu": "~1.0",
    25+
    "symfony/polyfill-mbstring": "~1.0",
    26+
    "symfony/polyfill-php54": "~1.0",
    27+
    "symfony/polyfill-php55": "~1.0",
    28+
    "symfony/polyfill-php56": "~1.0",
    29+
    "symfony/polyfill-php70": "~1.0",
    30+
    "symfony/polyfill-util": "~1.0"
    2531
    },
    2632
    "replace": {
    2733
    "symfony/asset": "self.version",
    @@ -77,7 +83,6 @@
    7783
    "doctrine/orm": "~2.4,>=2.4.5",
    7884
    "doctrine/doctrine-bundle": "~1.2",
    7985
    "monolog/monolog": "~1.11",
    80-
    "ircmaxell/password-compat": "~1.0",
    8186
    "ocramius/proxy-manager": "~0.4|~1.0",
    8287
    "egulias/email-validator": "~1.2",
    8388
    "phpdocumentor/reflection": "^1.0.7"
    @@ -96,10 +101,8 @@
    96101
    "Symfony\\Component\\": "src/Symfony/Component/"
    97102
    },
    98103
    "classmap": [
    99-
    "src/Symfony/Component/HttpFoundation/Resources/stubs",
    100104
    "src/Symfony/Component/Intl/Resources/stubs"
    101-
    ],
    102-
    "files": [ "src/Symfony/Component/Intl/Resources/stubs/functions.php" ]
    105+
    ]
    103106
    },
    104107
    "minimum-stability": "dev",
    105108
    "extra": {

    src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php

    Lines changed: 3 additions & 10 deletions
    Original file line numberDiff line numberDiff line change
    @@ -99,16 +99,9 @@ private function normalizeParams(array $params)
    9999
    }
    100100

    101101
    // detect if the too long string must be shorten
    102-
    if (function_exists('mb_strlen')) {
    103-
    if (self::MAX_STRING_LENGTH < mb_strlen($params[$index], 'UTF-8')) {
    104-
    $params[$index] = mb_substr($params[$index], 0, self::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]';
    105-
    continue;
    106-
    }
    107-
    } else {
    108-
    if (self::MAX_STRING_LENGTH < strlen($params[$index])) {
    109-
    $params[$index] = substr($params[$index], 0, self::MAX_STRING_LENGTH - 6).' [...]';
    110-
    continue;
    111-
    }
    102+
    if (self::MAX_STRING_LENGTH < iconv_strlen($params[$index], 'UTF-8')) {
    103+
    $params[$index] = iconv_substr($params[$index], 0, self::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]';
    104+
    continue;
    112105
    }
    113106
    }
    114107

    src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php

    Lines changed: 1 addition & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -132,9 +132,6 @@ public function testLogLongString()
    132132
    ));
    133133
    }
    134134

    135-
    /**
    136-
    * @requires extension mbstring
    137-
    */
    138135
    public function testLogUTF8LongString()
    139136
    {
    140137
    $logger = $this->getMock('Psr\\Log\\LoggerInterface');
    @@ -160,7 +157,7 @@ public function testLogUTF8LongString()
    160157
    $dbalLogger
    161158
    ->expects($this->once())
    162159
    ->method('log')
    163-
    ->with('SQL', array('short' => $shortString, 'long' => mb_substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6, mb_detect_encoding($longString)).' [...]'))
    160+
    ->with('SQL', array('short' => $shortString, 'long' => iconv_substr($longString, 0, DbalLogger::MAX_STRING_LENGTH - 6, 'UTF-8').' [...]'))
    164161
    ;
    165162

    166163
    $dbalLogger->startQuery('SQL', array(

    src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -24,7 +24,6 @@ class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
    2424
    private $skippedFile = false;
    2525
    private $wasSkipped = array();
    2626
    private $isSkipped = array();
    27-
    private $testsStack = array();
    2827

    2928
    public function __destruct()
    3029
    {

    src/Symfony/Bridge/Twig/composer.json

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -24,7 +24,7 @@
    2424
    "symfony/finder": "~2.3|~3.0.0",
    2525
    "symfony/form": "~2.8",
    2626
    "symfony/http-kernel": "~2.8|~3.0.0",
    27-
    "symfony/intl": "~2.3|~3.0.0",
    27+
    "symfony/polyfill-intl-icu": "~1.0",
    2828
    "symfony/routing": "~2.2|~3.0.0",
    2929
    "symfony/templating": "~2.1|~3.0.0",
    3030
    "symfony/translation": "~2.7|~3.0.0",

    src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -240,7 +240,7 @@ private function sanitizeString($string, $length = 40)
    240240
    {
    241241
    $string = trim(preg_replace('/\s+/', ' ', $string));
    242242

    243-
    if (function_exists('mb_strlen') && false !== $encoding = mb_detect_encoding($string)) {
    243+
    if (false !== $encoding = mb_detect_encoding($string, null, true)) {
    244244
    if (mb_strlen($string, $encoding) > $length) {
    245245
    return mb_substr($string, 0, $length - 3, $encoding).'...';
    246246
    }

    src/Symfony/Bundle/FrameworkBundle/composer.json

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -24,6 +24,7 @@
    2424
    "symfony/event-dispatcher": "~2.8|~3.0.0",
    2525
    "symfony/http-foundation": "~2.4.9|~2.5,>=2.5.4|~3.0.0",
    2626
    "symfony/http-kernel": "~2.8",
    27+
    "symfony/polyfill-mbstring": "~1.0",
    2728
    "symfony/filesystem": "~2.3|~3.0.0",
    2829
    "symfony/routing": "~2.8|~3.0.0",
    2930
    "symfony/security-core": "~2.6|~3.0.0",
    @@ -40,7 +41,7 @@
    4041
    "symfony/css-selector": "~2.0,>=2.0.5|~3.0.0",
    4142
    "symfony/dom-crawler": "~2.0,>=2.0.5|~3.0.0",
    4243
    "symfony/finder": "~2.0,>=2.0.5|~3.0.0",
    43-
    "symfony/intl": "~2.3|~3.0.0",
    44+
    "symfony/polyfill-intl-icu": "~1.0",
    4445
    "symfony/security": "~2.6|~3.0.0",
    4546
    "symfony/form": "~2.8",
    4647
    "symfony/expression-language": "~2.6|~3.0.0",

    src/Symfony/Bundle/SecurityBundle/composer.json

    Lines changed: 1 addition & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -23,7 +23,6 @@
    2323
    },
    2424
    "require-dev": {
    2525
    "symfony/browser-kit": "~2.4|~3.0.0",
    26-
    "symfony/config": "~2.8|~3.0.0",
    2726
    "symfony/console": "~2.7|~3.0.0",
    2827
    "symfony/css-selector": "~2.0,>=2.0.5|~3.0.0",
    2928
    "symfony/dom-crawler": "~2.0,>=2.0.5|~3.0.0",
    @@ -37,8 +36,7 @@
    3736
    "symfony/yaml": "~2.0,>=2.0.5|~3.0.0",
    3837
    "symfony/expression-language": "~2.6|~3.0.0",
    3938
    "doctrine/doctrine-bundle": "~1.2",
    40-
    "twig/twig": "~1.20|~2.0",
    41-
    "ircmaxell/password-compat": "~1.0"
    39+
    "twig/twig": "~1.20|~2.0"
    4240
    },
    4341
    "autoload": {
    4442
    "psr-4": { "Symfony\\Bundle\\SecurityBundle\\": "" }

    src/Symfony/Component/Console/Application.php

    Lines changed: 2 additions & 10 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1077,11 +1077,7 @@ public function setDefaultCommand($commandName)
    10771077

    10781078
    private function stringWidth($string)
    10791079
    {
    1080-
    if (!function_exists('mb_strwidth')) {
    1081-
    return strlen($string);
    1082-
    }
    1083-
    1084-
    if (false === $encoding = mb_detect_encoding($string)) {
    1080+
    if (false === $encoding = mb_detect_encoding($string, null, true)) {
    10851081
    return strlen($string);
    10861082
    }
    10871083

    @@ -1094,11 +1090,7 @@ private function splitStringByWidth($string, $width)
    10941090
    // additionally, array_slice() is not enough as some character has doubled width.
    10951091
    // we need a function to split string not by character count but by string width
    10961092

    1097-
    if (!function_exists('mb_strwidth')) {
    1098-
    return str_split($string, $width);
    1099-
    }
    1100-
    1101-
    if (false === $encoding = mb_detect_encoding($string)) {
    1093+
    if (false === $encoding = mb_detect_encoding($string, null, true)) {
    11021094
    return str_split($string, $width);
    11031095
    }
    11041096

    src/Symfony/Component/Console/Helper/Helper.php

    Lines changed: 1 addition & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -51,11 +51,7 @@ public function getHelperSet()
    5151
    */
    5252
    public static function strlen($string)
    5353
    {
    54-
    if (!function_exists('mb_strwidth')) {
    55-
    return strlen($string);
    56-
    }
    57-
    58-
    if (false === $encoding = mb_detect_encoding($string)) {
    54+
    if (false === $encoding = mb_detect_encoding($string, null, true)) {
    5955
    return strlen($string);
    6056
    }
    6157

    src/Symfony/Component/Console/Helper/Table.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -351,7 +351,7 @@ private function renderCell(array $row, $column, $cellFormat)
    351351
    }
    352352

    353353
    // str_pad won't work properly with multi-byte strings, we need to fix the padding
    354-
    if (function_exists('mb_strwidth') && false !== $encoding = mb_detect_encoding($cell)) {
    354+
    if (false !== $encoding = mb_detect_encoding($cell, null, true)) {
    355355
    $width += strlen($cell) - mb_strwidth($cell, $encoding);
    356356
    }
    357357

    src/Symfony/Component/Console/Tests/ApplicationTest.php

    Lines changed: 0 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -558,9 +558,6 @@ public function testRenderException()
    558558
    $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception4.txt', $tester->getDisplay(true), '->renderException() wraps messages when they are bigger than the terminal');
    559559
    }
    560560

    561-
    /**
    562-
    * @requires extension mbstring
    563-
    */
    564561
    public function testRenderExceptionWithDoubleWidthCharacters()
    565562
    {
    566563
    $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));

    src/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php

    Lines changed: 0 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -52,9 +52,6 @@ public function testFormatBlock()
    5252
    );
    5353
    }
    5454

    55-
    /**
    56-
    * @requires extension mbstring
    57-
    */
    5855
    public function testFormatBlockWithDiacriticLetters()
    5956
    {
    6057
    $formatter = new FormatterHelper();
    @@ -68,9 +65,6 @@ public function testFormatBlockWithDiacriticLetters()
    6865
    );
    6966
    }
    7067

    71-
    /**
    72-
    * @requires extension mbstring
    73-
    */
    7468
    public function testFormatBlockWithDoubleWidthDiacriticLetters()
    7569
    {
    7670
    $formatter = new FormatterHelper();

    src/Symfony/Component/Console/Tests/Helper/LegacyProgressHelperTest.php

    Lines changed: 0 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -155,9 +155,6 @@ public function testRedrawFrequency()
    155155
    $progress->advance(1);
    156156
    }
    157157

    158-
    /**
    159-
    * @requires extension mbstring
    160-
    */
    161158
    public function testMultiByteSupport()
    162159
    {
    163160
    $progress = new ProgressHelper();

    src/Symfony/Component/Console/Tests/Helper/LegacyTableHelperTest.php

    Lines changed: 0 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -256,9 +256,6 @@ public function testRenderProvider()
    256256
    );
    257257
    }
    258258

    259-
    /**
    260-
    * @requires extension mbstring
    261-
    */
    262259
    public function testRenderMultiByte()
    263260
    {
    264261
    $table = new TableHelper();
    @@ -282,9 +279,6 @@ public function testRenderMultiByte()
    282279
    $this->assertEquals($expected, $this->getOutputContent($output));
    283280
    }
    284281

    285-
    /**
    286-
    * @requires extension mbstring
    287-
    */
    288282
    public function testRenderFullWidthCharacters()
    289283
    {
    290284
    $table = new TableHelper();

    src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php

    Lines changed: 0 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -307,9 +307,6 @@ public function testRedrawFrequency()
    307307
    $bar->advance(1);
    308308
    }
    309309

    310-
    /**
    311-
    * @requires extension mbstring
    312-
    */
    313310
    public function testMultiByteSupport()
    314311
    {
    315312
    $bar = new ProgressBar($output = $this->getOutputStream());
    @@ -541,9 +538,6 @@ public function testMultilineFormat()
    541538
    );
    542539
    }
    543540

    544-
    /**
    545-
    * @requires extension mbstring
    546-
    */
    547541
    public function testAnsiColorsAndEmojis()
    548542
    {
    549543
    $bar = new ProgressBar($output = $this->getOutputStream(), 15);

    src/Symfony/Component/Console/Tests/Helper/TableTest.php

    Lines changed: 0 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -464,9 +464,6 @@ public function testRenderProvider()
    464464
    );
    465465
    }
    466466

    467-
    /**
    468-
    * @requires extension mbstring
    469-
    */
    470467
    public function testRenderMultiByte()
    471468
    {
    472469
    $table = new Table($output = $this->getOutputStream());

    src/Symfony/Component/Console/composer.json

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -16,7 +16,8 @@
    1616
    }
    1717
    ],
    1818
    "require": {
    19-
    "php": ">=5.3.9"
    19+
    "php": ">=5.3.9",
    20+
    "symfony/polyfill-mbstring": "~1.0"
    2021
    },
    2122
    "require-dev": {
    2223
    "symfony/event-dispatcher": "~2.1|~3.0.0",

    src/Symfony/Component/DomCrawler/Crawler.php

    Lines changed: 1 addition & 28 deletions
    Original file line numberDiff line numberDiff line change
    @@ -173,34 +173,7 @@ public function addHtmlContent($content, $charset = 'UTF-8')
    173173

    174174
    try {
    175175
    // Convert charset to HTML-entities to work around bugs in DOMDocument::loadHTML()
    176-
    177-
    if (function_exists('mb_convert_encoding')) {
    178-
    $content = mb_convert_encoding($content, 'HTML-ENTITIES', $charset);
    179-
    } elseif (function_exists('iconv')) {
    180-
    $content = preg_replace_callback(
    181-
    '/[\x80-\xFF]+/',
    182-
    function ($m) {
    183-
    $m = unpack('C*', $m[0]);
    184-
    $i = 1;
    185-
    $entities = '';
    186-
    187-
    while (isset($m[$i])) {
    188-
    if (0xF0 <= $m[$i]) {
    189-
    $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
    190-
    } elseif (0xE0 <= $m[$i]) {
    191-
    $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
    192-
    } else {
    193-
    $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
    194-
    }
    195-
    196-
    $entities .= '&#'.$c.';';
    197-
    }
    198-
    199-
    return $entities;
    200-
    },
    201-
    iconv($charset, 'UTF-8', $content)
    202-
    );
    203-
    }
    176+
    $content = mb_convert_encoding($content, 'HTML-ENTITIES', $charset);
    204177
    } catch (\Exception $e) {
    205178
    }
    206179

    src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php

    Lines changed: 0 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -102,7 +102,6 @@ public function testAddHtmlContentWithBaseTag()
    102102

    103103
    /**
    104104
    * @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent
    105-
    * @requires extension mbstring
    106105
    */
    107106
    public function testAddHtmlContentCharset()
    108107
    {
    @@ -137,7 +136,6 @@ public function testAddHtmlContentUnsupportedCharset()
    137136

    138137
    /**
    139138
    * @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent
    140-
    * @requires extension mbstring
    141139
    */
    142140
    public function testAddHtmlContentCharsetGbk()
    143141
    {

    src/Symfony/Component/DomCrawler/composer.json

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -16,7 +16,8 @@
    1616
    }
    1717
    ],
    1818
    "require": {
    19-
    "php": ">=5.3.9"
    19+
    "php": ">=5.3.9",
    20+
    "symfony/polyfill-mbstring": "~1.0"
    2021
    },
    2122
    "require-dev": {
    2223
    "symfony/css-selector": "~2.8|~3.0.0"

    src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -197,7 +197,7 @@ public function reverseTransform($value)
    197197
    throw new TransformationFailedException('I don\'t have a clear idea what infinity looks like');
    198198
    }
    199199

    200-
    if (function_exists('mb_detect_encoding') && false !== $encoding = mb_detect_encoding($value)) {
    200+
    if (false !== $encoding = mb_detect_encoding($value, null, true)) {
    201201
    $length = mb_strlen($value, $encoding);
    202202
    $remainder = mb_substr($value, $position, $length, $encoding);
    203203
    } else {

    src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php

    Lines changed: 0 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -238,8 +238,6 @@ public function testReverseTransformWithGrouping($to, $from, $locale)
    238238

    239239
    /**
    240240
    * @see https://github.com/symfony/symfony/issues/7609
    241-
    *
    242-
    * @requires extension mbstring
    243241
    */
    244242
    public function testReverseTransformWithGroupingAndFixedSpaces()
    245243
    {
    @@ -583,7 +581,6 @@ public function testReverseTransformDisallowsCenteredExtraCharacters()
    583581
    /**
    584582
    * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
    585583
    * @expectedExceptionMessage The number contains unrecognized characters: "foo8"
    586-
    * @requires extension mbstring
    587584
    */
    588585
    public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte()
    589586
    {
    @@ -600,7 +597,6 @@ public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte()
    600597
    /**
    601598
    * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
    602599
    * @expectedExceptionMessage The number contains unrecognized characters: "foo8"
    603-
    * @requires extension mbstring
    604600
    */
    605601
    public function testReverseTransformIgnoresTrailingSpacesInExceptionMessage()
    606602
    {
    @@ -628,7 +624,6 @@ public function testReverseTransformDisallowsTrailingExtraCharacters()
    628624
    /**
    629625
    * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
    630626
    * @expectedExceptionMessage The number contains unrecognized characters: "foo"
    631-
    * @requires extension mbstring
    632627
    */
    633628
    public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte()
    634629
    {

    src/Symfony/Component/Form/Tests/Util/StringUtilTest.php

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -24,7 +24,6 @@ public function testTrim()
    2424

    2525
    /**
    2626
    * @dataProvider spaceProvider
    27-
    * @requires extension mbstring
    2827
    */
    2928
    public function testTrimUtf8Separators($hex)
    3029
    {

    0 commit comments

    Comments
     (0)
    0