From 98f5d509451a9a84783ccfccb9d8c37850b1fff9 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 7 Jul 2020 18:09:42 +0200 Subject: [PATCH 1/4] [String] throw when Alpine is used and translit fails --- src/Symfony/Component/String/AbstractUnicodeString.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/String/AbstractUnicodeString.php b/src/Symfony/Component/String/AbstractUnicodeString.php index 9beafe57eb..2d29ce9137 100644 --- a/src/Symfony/Component/String/AbstractUnicodeString.php +++ b/src/Symfony/Component/String/AbstractUnicodeString.php @@ -142,8 +142,10 @@ abstract class AbstractUnicodeString extends AbstractString } elseif (ICONV_IMPL === 'glibc') { $s = iconv('UTF-8', 'ASCII//TRANSLIT', $s); } else { - $s = preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) { - $c = iconv('UTF-8', 'ASCII//IGNORE//TRANSLIT', $c[0]); + $s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) { + if ('' === $c = (string) iconv('UTF-8', 'ASCII//IGNORE//TRANSLIT', $c[0])) { + throw new \LogicException(sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class)); + } return 1 < \strlen($c) ? ltrim($c, '\'`"^~') : (\strlen($c) ? $c : '?'); }, $s); From d08524330a5f0ae9d00d76dd2e6b877ad2ee071f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 7 Jul 2020 19:38:20 +0200 Subject: [PATCH 2/4] [Cache] Fix compat wth DBAL v3 --- src/Symfony/Component/Cache/Traits/PdoTrait.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Symfony/Component/Cache/Traits/PdoTrait.php b/src/Symfony/Component/Cache/Traits/PdoTrait.php index d453904d44..aaf364304f 100644 --- a/src/Symfony/Component/Cache/Traits/PdoTrait.php +++ b/src/Symfony/Component/Cache/Traits/PdoTrait.php @@ -373,19 +373,25 @@ trait PdoTrait case $driver instanceof \Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver: case $driver instanceof \Doctrine\DBAL\Driver\Mysqli\Driver: case $driver instanceof \Doctrine\DBAL\Driver\PDOMySql\Driver: + case $driver instanceof \Doctrine\DBAL\Driver\PDO\MySQL\Driver: $this->driver = 'mysql'; break; case $driver instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver: + case $driver instanceof \Doctrine\DBAL\Driver\PDO\SQLite\Driver: $this->driver = 'sqlite'; break; case $driver instanceof \Doctrine\DBAL\Driver\PDOPgSql\Driver: + case $driver instanceof \Doctrine\DBAL\Driver\PDO\PgSQL\Driver: $this->driver = 'pgsql'; break; case $driver instanceof \Doctrine\DBAL\Driver\OCI8\Driver: case $driver instanceof \Doctrine\DBAL\Driver\PDOOracle\Driver: + case $driver instanceof \Doctrine\DBAL\Driver\PDO\OCI\Driver: $this->driver = 'oci'; break; case $driver instanceof \Doctrine\DBAL\Driver\SQLSrv\Driver: + case $driver instanceof \Doctrine\DBAL\Driver\PDOSqlsrv\Driver: + case $driver instanceof \Doctrine\DBAL\Driver\PDO\SQLSrv\Driver: $this->driver = 'sqlsrv'; break; default: From f59915d9058d53da6c95d57bc89ad504500b385a Mon Sep 17 00:00:00 2001 From: Gennadi Janzen Date: Tue, 7 Jul 2020 17:05:25 +0200 Subject: [PATCH 3/4] Add: ExcludeList usage for PHPUnit 9.4 --- .../Legacy/SymfonyTestsListenerTrait.php | 6 ++++- .../Bridge/PhpUnit/bin/simple-phpunit.php | 24 +++++++++++-------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index a67f028656..5afa18120e 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -17,6 +17,7 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestSuite; use PHPUnit\Runner\BaseTestRunner; use PHPUnit\Util\Blacklist; +use PHPUnit\Util\ExcludeList; use PHPUnit\Util\Test; use Symfony\Bridge\PhpUnit\ClockMock; use Symfony\Bridge\PhpUnit\DnsMock; @@ -48,7 +49,10 @@ class SymfonyTestsListenerTrait */ public function __construct(array $mockedNamespaces = []) { - if (method_exists(Blacklist::class, 'addDirectory')) { + if (class_exists(ExcludeList::class)) { + (new ExcludeList())->getExcludedDirectories(); + ExcludeList::addDirectory(\dirname((new \ReflectionClass(__CLASS__))->getFileName(), 2)); + } elseif (method_exists(Blacklist::class, 'addDirectory')) { (new BlackList())->getBlacklistedDirectories(); Blacklist::addDirectory(\dirname((new \ReflectionClass(__CLASS__))->getFileName(), 2)); } else { diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php index d78e848030..7c1c3123e1 100644 --- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php +++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php @@ -193,7 +193,7 @@ if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationH 'requires' => ['php' => '*'], ]; - if (1 === \count($info['versions'])) { + if (1 === count($info['versions'])) { $passthruOrFail("$COMPOSER create-project --ignore-platform-reqs --no-install --prefer-dist --no-scripts --no-plugins --no-progress -s dev phpunit/phpunit $PHPUNIT_VERSION_DIR \"$PHPUNIT_VERSION.*\""); } else { $passthruOrFail("$COMPOSER create-project --ignore-platform-reqs --no-install --prefer-dist --no-scripts --no-plugins --no-progress phpunit/phpunit $PHPUNIT_VERSION_DIR \"$PHPUNIT_VERSION.*\""); @@ -251,16 +251,20 @@ if (!file_exists("$PHPUNIT_DIR/$PHPUNIT_VERSION_DIR/phpunit") || $configurationH define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php'); require PHPUNIT_COMPOSER_INSTALL; -if (!class_exists('SymfonyBlacklistPhpunit', false)) { - class SymfonyBlacklistPhpunit {} +if (!class_exists('SymfonyExcludeListPhpunit', false)) { + class SymfonyExcludeListPhpunit {} } -if (method_exists('PHPUnit\Util\Blacklist', 'addDirectory')) { +if (method_exists('PHPUnit\Util\ExcludeList', 'addDirectory')) { + (new PHPUnit\Util\Excludelist())->getExcludedDirectories(); + PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListPhpunit'))->getFileName())); + PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListSimplePhpunit'))->getFileName())); +} elseif (method_exists('PHPUnit\Util\Blacklist', 'addDirectory')) { (new PHPUnit\Util\BlackList())->getBlacklistedDirectories(); - PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyBlacklistPhpunit'))->getFileName())); - PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyBlacklistSimplePhpunit'))->getFileName())); + PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListPhpunit'))->getFileName())); + PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListSimplePhpunit'))->getFileName())); } else { - PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyBlacklistPhpunit'] = 1; - PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyBlacklistSimplePhpunit'] = 1; + PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListPhpunit'] = 1; + PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListSimplePhpunit'] = 1; } Symfony\Bridge\PhpUnit\TextUI\Command::main(); @@ -372,8 +376,8 @@ if ($components) { } } } elseif (!isset($argv[1]) || 'install' !== $argv[1] || file_exists('install')) { - if (!class_exists('SymfonyBlacklistSimplePhpunit', false)) { - class SymfonyBlacklistSimplePhpunit + if (!class_exists('SymfonyExcludeListSimplePhpunit', false)) { + class SymfonyExcludeListSimplePhpunit { } } From 904fb1ae21751cb03d0e4c17a8f1126014730b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Tue, 7 Jul 2020 11:07:44 +0200 Subject: [PATCH 4/4] [String] Added a help message when translation-contracts is not installed --- src/Symfony/Component/String/Slugger/AsciiSlugger.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/String/Slugger/AsciiSlugger.php b/src/Symfony/Component/String/Slugger/AsciiSlugger.php index 5a33c465aa..0b8c60c7bf 100644 --- a/src/Symfony/Component/String/Slugger/AsciiSlugger.php +++ b/src/Symfony/Component/String/Slugger/AsciiSlugger.php @@ -15,6 +15,10 @@ use Symfony\Component\String\AbstractUnicodeString; use Symfony\Component\String\UnicodeString; use Symfony\Contracts\Translation\LocaleAwareInterface; +if (!interface_exists(LocaleAwareInterface::class)) { + throw new \LogicException('You cannot use the "Symfony\Component\String\Slugger\AsciiSlugger" as the "symfony/translation-contracts" package is not installed. Try running "composer require symfony/translation-contracts".'); +} + /** * @author Titouan Galopin *