Skip to content

Commit 2c43183

Browse files
Merge branch '5.1'
* 5.1: [String] Added a help message when translation-contracts is not installed Add: ExcludeList usage for PHPUnit 9.4 [Cache] Fix compat wth DBAL v3 [String] throw when Alpine is used and translit fails
2 parents e67c6d8 + f07b187 commit 2c43183

File tree

6 files changed

+37
-13
lines changed

6 files changed

+37
-13
lines changed

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PHPUnit\Framework\TestSuite;
1919
use PHPUnit\Runner\BaseTestRunner;
2020
use PHPUnit\Util\Blacklist;
21+
use PHPUnit\Util\ExcludeList;
2122
use PHPUnit\Util\Test;
2223
use Symfony\Bridge\PhpUnit\ClockMock;
2324
use Symfony\Bridge\PhpUnit\DnsMock;
@@ -50,7 +51,10 @@ class SymfonyTestsListenerTrait
5051
*/
5152
public function __construct(array $mockedNamespaces = [])
5253
{
53-
if (method_exists(Blacklist::class, 'addDirectory')) {
54+
if (class_exists(ExcludeList::class)) {
55+
(new ExcludeList())->getExcludedDirectories();
56+
ExcludeList::addDirectory(\dirname((new \ReflectionClass(__CLASS__))->getFileName(), 2));
57+
} elseif (method_exists(Blacklist::class, 'addDirectory')) {
5458
(new BlackList())->getBlacklistedDirectories();
5559
Blacklist::addDirectory(\dirname((new \ReflectionClass(__CLASS__))->getFileName(), 2));
5660
} else {

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193
'requires' => ['php' => '*'],
194194
];
195195

196-
if (1 === \count($info['versions'])) {
196+
if (1 === count($info['versions'])) {
197197
$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.*\"");
198198
} else {
199199
$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 @@
251251
define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php');
252252
require PHPUNIT_COMPOSER_INSTALL;
253253
254-
if (!class_exists('SymfonyBlacklistPhpunit', false)) {
255-
class SymfonyBlacklistPhpunit {}
254+
if (!class_exists('SymfonyExcludeListPhpunit', false)) {
255+
class SymfonyExcludeListPhpunit {}
256256
}
257-
if (method_exists('PHPUnit\Util\Blacklist', 'addDirectory')) {
257+
if (method_exists('PHPUnit\Util\ExcludeList', 'addDirectory')) {
258+
(new PHPUnit\Util\Excludelist())->getExcludedDirectories();
259+
PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListPhpunit'))->getFileName()));
260+
PHPUnit\Util\ExcludeList::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListSimplePhpunit'))->getFileName()));
261+
} elseif (method_exists('PHPUnit\Util\Blacklist', 'addDirectory')) {
258262
(new PHPUnit\Util\BlackList())->getBlacklistedDirectories();
259-
PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyBlacklistPhpunit'))->getFileName()));
260-
PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyBlacklistSimplePhpunit'))->getFileName()));
263+
PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListPhpunit'))->getFileName()));
264+
PHPUnit\Util\Blacklist::addDirectory(\dirname((new \ReflectionClass('SymfonyExcludeListSimplePhpunit'))->getFileName()));
261265
} else {
262-
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyBlacklistPhpunit'] = 1;
263-
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyBlacklistSimplePhpunit'] = 1;
266+
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListPhpunit'] = 1;
267+
PHPUnit\Util\Blacklist::$blacklistedClassNames['SymfonyExcludeListSimplePhpunit'] = 1;
264268
}
265269
266270
Symfony\Bridge\PhpUnit\TextUI\Command::main();
@@ -372,8 +376,8 @@ class SymfonyBlacklistPhpunit {}
372376
}
373377
}
374378
} elseif (!isset($argv[1]) || 'install' !== $argv[1] || file_exists('install')) {
375-
if (!class_exists('SymfonyBlacklistSimplePhpunit', false)) {
376-
class SymfonyBlacklistSimplePhpunit
379+
if (!class_exists('SymfonyExcludeListSimplePhpunit', false)) {
380+
class SymfonyExcludeListSimplePhpunit
377381
{
378382
}
379383
}

src/Symfony/Component/Cache/Adapter/PdoAdapter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,16 +445,21 @@ private function getConnection(): object
445445
$this->driver = 'mysql';
446446
break;
447447
case $driver instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver:
448+
case $driver instanceof \Doctrine\DBAL\Driver\PDO\SQLite\Driver:
448449
$this->driver = 'sqlite';
449450
break;
450451
case $driver instanceof \Doctrine\DBAL\Driver\PDOPgSql\Driver:
452+
case $driver instanceof \Doctrine\DBAL\Driver\PDO\PgSQL\Driver:
451453
$this->driver = 'pgsql';
452454
break;
453455
case $driver instanceof \Doctrine\DBAL\Driver\OCI8\Driver:
454456
case $driver instanceof \Doctrine\DBAL\Driver\PDOOracle\Driver:
457+
case $driver instanceof \Doctrine\DBAL\Driver\PDO\OCI\Driver:
455458
$this->driver = 'oci';
456459
break;
457460
case $driver instanceof \Doctrine\DBAL\Driver\SQLSrv\Driver:
461+
case $driver instanceof \Doctrine\DBAL\Driver\PDOSqlsrv\Driver:
462+
case $driver instanceof \Doctrine\DBAL\Driver\PDO\SQLSrv\Driver:
458463
$this->driver = 'sqlsrv';
459464
break;
460465
default:

src/Symfony/Component/Lock/Store/PdoStore.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,16 +328,21 @@ private function getDriver(): string
328328
$this->driver = 'mysql';
329329
break;
330330
case $driver instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver:
331+
case $driver instanceof \Doctrine\DBAL\Driver\PDO\SQLite\Driver:
331332
$this->driver = 'sqlite';
332333
break;
333334
case $driver instanceof \Doctrine\DBAL\Driver\PDOPgSql\Driver:
335+
case $driver instanceof \Doctrine\DBAL\Driver\PDO\PgSQL\Driver:
334336
$this->driver = 'pgsql';
335337
break;
336338
case $driver instanceof \Doctrine\DBAL\Driver\OCI8\Driver:
337339
case $driver instanceof \Doctrine\DBAL\Driver\PDOOracle\Driver:
340+
case $driver instanceof \Doctrine\DBAL\Driver\PDO\OCI\Driver:
338341
$this->driver = 'oci';
339342
break;
340343
case $driver instanceof \Doctrine\DBAL\Driver\SQLSrv\Driver:
344+
case $driver instanceof \Doctrine\DBAL\Driver\PDOSqlsrv\Driver:
345+
case $driver instanceof \Doctrine\DBAL\Driver\PDO\SQLSrv\Driver:
341346
$this->driver = 'sqlsrv';
342347
break;
343348
default:

src/Symfony/Component/String/AbstractUnicodeString.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ public function ascii(array $rules = []): self
140140
} elseif (ICONV_IMPL === 'glibc') {
141141
$s = iconv('UTF-8', 'ASCII//TRANSLIT', $s);
142142
} else {
143-
$s = preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
144-
$c = iconv('UTF-8', 'ASCII//IGNORE//TRANSLIT', $c[0]);
143+
$s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
144+
if ('' === $c = (string) iconv('UTF-8', 'ASCII//IGNORE//TRANSLIT', $c[0])) {
145+
throw new \LogicException(sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class));
146+
}
145147

146148
return 1 < \strlen($c) ? ltrim($c, '\'`"^~') : (\strlen($c) ? $c : '?');
147149
}, $s);

src/Symfony/Component/String/Slugger/AsciiSlugger.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
use Symfony\Component\String\UnicodeString;
1616
use Symfony\Contracts\Translation\LocaleAwareInterface;
1717

18+
if (!interface_exists(LocaleAwareInterface::class)) {
19+
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".');
20+
}
21+
1822
/**
1923
* @author Titouan Galopin <galopintitouan@gmail.com>
2024
*/

0 commit comments

Comments
 (0)