From 88e43d4d4ce052a2b880bade7f9b62215fccd4c4 Mon Sep 17 00:00:00 2001 From: Matthias Derer Date: Tue, 5 May 2020 17:01:20 +0200 Subject: [PATCH 1/9] [DI][EventDispatcher] added contract for implementation fixes #36708. --- .../Component/EventDispatcher/EventSubscriberInterface.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php index 824f21599c..741590b1bf 100644 --- a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php +++ b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php @@ -40,6 +40,9 @@ interface EventSubscriberInterface * * ['eventName' => ['methodName', $priority]] * * ['eventName' => [['methodName1', $priority], ['methodName2']]] * + * The code must not depend on runtime state as it will only be called at compile time. + * All logic depending on runtime state must be put into the individual methods handling the events. + * * @return array The event names to listen to */ public static function getSubscribedEvents(); From 227ebd2fe974f532786042e4d336c31f2322190e Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Fri, 8 May 2020 10:53:06 +0200 Subject: [PATCH 2/9] [Mime] fix bad method call on "EmailAddressContains" There is no method `Address` on `MailboxHeader`, but a method `getAddress`. --- .../Component/Mime/Test/Constraint/EmailAddressContains.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Mime/Test/Constraint/EmailAddressContains.php b/src/Symfony/Component/Mime/Test/Constraint/EmailAddressContains.php index 58ef360c50..c751c3d45f 100644 --- a/src/Symfony/Component/Mime/Test/Constraint/EmailAddressContains.php +++ b/src/Symfony/Component/Mime/Test/Constraint/EmailAddressContains.php @@ -48,7 +48,7 @@ final class EmailAddressContains extends Constraint $header = $message->getHeaders()->get($this->headerName); if ($header instanceof MailboxHeader) { - return $this->expectedValue === $header->Address()->getAddress(); + return $this->expectedValue === $header->getAddress()->getAddress(); } elseif ($header instanceof MailboxListHeader) { foreach ($header->getAddresses() as $address) { if ($this->expectedValue === $address->getAddress()) { From 2f305cdc832060205cafeacfb7dae2b8e9789a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 7 May 2020 19:56:37 +0200 Subject: [PATCH 3/9] Remove patches for Doctrine bugs and deprecations --- composer.json | 2 +- phpunit | 10 ---------- src/Symfony/Bridge/Doctrine/composer.json | 2 +- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 2c7dc6e89e..9ad5e39ad2 100644 --- a/composer.json +++ b/composer.json @@ -91,7 +91,7 @@ "doctrine/annotations": "~1.0", "doctrine/cache": "~1.6", "doctrine/data-fixtures": "1.0.*", - "doctrine/dbal": "~2.4,<=2.10.2", + "doctrine/dbal": "~2.4", "doctrine/orm": "~2.4,>=2.4.5", "doctrine/doctrine-bundle": "~1.4", "monolog/monolog": "~1.11", diff --git a/phpunit b/phpunit index fbce26d8ed..713594fc19 100755 --- a/phpunit +++ b/phpunit @@ -21,14 +21,4 @@ if (!getenv('SYMFONY_PATCH_TYPE_DECLARATIONS')) { putenv('SYMFONY_PATCH_TYPE_DECLARATIONS=deprecations=1'); } putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit'); - -if (!getenv('SYMFONY_DEPRECATIONS_HELPER')) { - foreach ($_SERVER['argv'] as $v) { - if (false !== strpos($v, 'Bridge/Doctrine')) { - putenv('SYMFONY_DEPRECATIONS_HELPER=max[indirect]=7'); - break; - } - } -} - require __DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit'; diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 67c0bb938a..1aa2315c60 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -35,7 +35,7 @@ "symfony/validator": "^3.2.5|~4.0", "symfony/translation": "~2.8|~3.0|~4.0", "doctrine/data-fixtures": "1.0.*", - "doctrine/dbal": "~2.4,<=2.10.2", + "doctrine/dbal": "~2.4", "doctrine/orm": "^2.4.5" }, "conflict": { From f177b3d4885ab000e9ed4b2bab758ee45abcbfd2 Mon Sep 17 00:00:00 2001 From: Matthias Larisch Date: Wed, 6 May 2020 14:08:15 +0200 Subject: [PATCH 4/9] [FrameworkBundle] display actual target for error in AssetsInstallCommand When assets:install fails because the target directory does not exist, it should display the actual directory it wanted to have instead of the configuration directive. In most cases, the target directory is retrieved from the kernel config and thus differs from the argument. --- .../Bundle/FrameworkBundle/Command/AssetsInstallCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php index aee869f8fd..199e1ad0da 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php @@ -121,7 +121,7 @@ EOT if (is_dir(\dirname($targetArg).'/web')) { $targetArg = \dirname($targetArg).'/web'; } else { - throw new InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target'))); + throw new InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $targetArg)); } } } From 9d48eedbdca63c93d0fea245751a8f18ae2d1701 Mon Sep 17 00:00:00 2001 From: theravel Date: Fri, 8 May 2020 00:17:19 +0200 Subject: [PATCH 5/9] Queue name is a required parameter --- .../Component/Messenger/Transport/AmqpExt/Connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php b/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php index b2799af03c..fb5ecf76bb 100644 --- a/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php +++ b/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php @@ -326,7 +326,7 @@ class Connection // If we get a 404 for the queue, it means we need to set up the exchange & queue. $this->setupExchangeAndQueues(); - return $this->get(); + return $this->get($queueName); } throw $e; From 66cd9f470c9ff2126b9df62a44022b1e6049868b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 8 May 2020 12:04:23 +0200 Subject: [PATCH 6/9] Disable phpunit verbosity --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e0c417100f..66b0358555 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -82,7 +82,7 @@ jobs: echo "::endgroup::" - name: Run tests - run: ./phpunit --verbose --group integration + run: ./phpunit --group integration env: REDIS_HOST: localhost REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005' @@ -95,6 +95,6 @@ jobs: run: | [ -d .phpunit ] && mv .phpunit .phpunit.bak wget -q https://github.com/symfony/binary-utils/releases/download/v0.1/vulcain_0.1.3_Linux_x86_64.tar.gz -O - | tar xz && mv vulcain /usr/local/bin - docker run --rm -e COMPOSER_ROOT_VERSION -e SYMFONY_VERSION -v $(pwd):/app -v $(which composer):/usr/local/bin/composer -v /usr/local/bin/vulcain:/usr/local/bin/vulcain -w /app php:7.4-alpine ./phpunit --verbose src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php --filter testHttp2Push + docker run --rm -e COMPOSER_ROOT_VERSION -e SYMFONY_VERSION -v $(pwd):/app -v $(which composer):/usr/local/bin/composer -v /usr/local/bin/vulcain:/usr/local/bin/vulcain -w /app php:7.4-alpine ./phpunit src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php --filter testHttp2Push sudo rm -rf .phpunit [ -d .phpunit.bak ] && mv .phpunit.bak .phpunit From 02b378f2486d9f83c237b151b787a5f314f56d6a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 8 May 2020 12:38:31 +0200 Subject: [PATCH 7/9] [3.4] CS fixes --- .../Config/Tests/Definition/Builder/ExprBuilderTest.php | 2 +- src/Symfony/Component/Console/Tests/TerminalTest.php | 2 +- src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php index 85d0d36319..2dfb7a0a39 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Builder/ExprBuilderTest.php @@ -148,7 +148,7 @@ class ExprBuilderTest extends TestCase /** * @dataProvider castToArrayValues */ - public function testcastToArrayExpression($configValue, $expectedValue) + public function testCastToArrayExpression($configValue, $expectedValue) { $test = $this->getTestBuilder() ->castToArray() diff --git a/src/Symfony/Component/Console/Tests/TerminalTest.php b/src/Symfony/Component/Console/Tests/TerminalTest.php index 546d2214c4..cc2632dd18 100644 --- a/src/Symfony/Component/Console/Tests/TerminalTest.php +++ b/src/Symfony/Component/Console/Tests/TerminalTest.php @@ -60,7 +60,7 @@ class TerminalTest extends TestCase $this->assertSame(60, $terminal->getHeight()); } - public function test_zero_values() + public function testZeroValues() { putenv('COLUMNS=0'); putenv('LINES=0'); diff --git a/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php b/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php index 38babded28..16263fa43a 100644 --- a/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php +++ b/src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php @@ -51,7 +51,7 @@ class SemaphoreStoreTest extends AbstractStoreTest private function getOpenedSemaphores() { if ('Darwin' === PHP_OS) { - $lines = explode(PHP_EOL, trim(`ipcs -s`)); + $lines = explode(PHP_EOL, trim(shell_exec('ipcs -s'))); if (-1 === $start = array_search('Semaphores:', $lines)) { throw new \Exception('Failed to extract list of opened semaphores. Expected a Semaphore list, got '.implode(PHP_EOL, $lines)); } @@ -59,7 +59,7 @@ class SemaphoreStoreTest extends AbstractStoreTest return \count(\array_slice($lines, ++$start)); } - $lines = explode(PHP_EOL, trim(`LC_ALL=C ipcs -su`)); + $lines = explode(PHP_EOL, trim(shell_exec('LC_ALL=C ipcs -su'))); if ('------ Semaphore Status --------' !== $lines[0]) { throw new \Exception('Failed to extract list of opened semaphores. Expected a Semaphore status, got '.implode(PHP_EOL, $lines)); } From eba09d47e7909f96a39497dd32c64f6098787dbc Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 8 May 2020 12:36:19 +0200 Subject: [PATCH 8/9] [4.4] CS fixes --- .../Tests/Messenger/DoctrineTransactionMiddlewareTest.php | 2 +- .../Mailer/Bridge/Mailchimp/Transport/MandrillHttpTransport.php | 1 - .../Core/Authentication/Token/UsernamePasswordToken.php | 1 - .../Security/Core/Authorization/AccessDecisionManager.php | 2 +- src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php | 2 +- 5 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrineTransactionMiddlewareTest.php b/src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrineTransactionMiddlewareTest.php index be850277e6..4882a1fee2 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrineTransactionMiddlewareTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrineTransactionMiddlewareTest.php @@ -25,7 +25,7 @@ class DoctrineTransactionMiddlewareTest extends MiddlewareTestCase private $entityManager; private $middleware; - public function setUp(): void + protected function setUp(): void { $this->connection = $this->createMock(Connection::class); diff --git a/src/Symfony/Component/Mailer/Bridge/Mailchimp/Transport/MandrillHttpTransport.php b/src/Symfony/Component/Mailer/Bridge/Mailchimp/Transport/MandrillHttpTransport.php index d2058799ec..82cdcff73f 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailchimp/Transport/MandrillHttpTransport.php +++ b/src/Symfony/Component/Mailer/Bridge/Mailchimp/Transport/MandrillHttpTransport.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Mailer\Bridge\Mailchimp\Transport; use Psr\Log\LoggerInterface; -use Symfony\Component\Mailer\Envelope; use Symfony\Component\Mailer\Exception\HttpTransportException; use Symfony\Component\Mailer\SentMessage; use Symfony\Component\Mailer\Transport\AbstractHttpTransport; diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php index 2b493c70f3..bf35c98d55 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php @@ -26,7 +26,6 @@ class UsernamePasswordToken extends AbstractToken /** * @param string|\Stringable|UserInterface $user The username (like a nickname, email address, etc.) or a UserInterface instance * @param mixed $credentials - * @param string $providerKey * @param string[] $roles * * @throws \InvalidArgumentException diff --git a/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php index 1a6c9cbb81..56ab1dc864 100644 --- a/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php +++ b/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php @@ -59,7 +59,7 @@ class AccessDecisionManager implements AccessDecisionManagerInterface */ public function decide(TokenInterface $token, array $attributes, $object = null/*, bool $allowMultipleAttributes = false*/) { - $allowMultipleAttributes = 3 < func_num_args() && func_get_arg(3); + $allowMultipleAttributes = 3 < \func_num_args() && func_get_arg(3); // Special case for AccessListener, do not remove the right side of the condition before 6.0 if (\count($attributes) > 1 && !$allowMultipleAttributes) { diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index e7a6e32f30..f43bb3693a 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -600,7 +600,7 @@ return function (root, x) { */ return; } - + e.preventDefault(); search.className = search.className.replace(/\bsf-dump-search-hidden\b/, ''); searchInput.focus(); From edb517699a42bf3e5b5557a304f297f7265b639b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 8 May 2020 14:25:07 +0200 Subject: [PATCH 9/9] [PhpUnitBridge] fix bad test --- .../DeprecationTest.php | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php index fd6d059e44..403d23cdd5 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php @@ -22,6 +22,7 @@ class DeprecationTest extends TestCase use SetUpTearDownTrait; private static $vendorDir; + private static $prefixDirsPsr4; private static function getVendorDir() { @@ -151,22 +152,6 @@ class DeprecationTest extends TestCase public function providerGetTypeDetectsSelf() { - foreach (get_declared_classes() as $class) { - if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { - $r = new \ReflectionClass($class); - $v = \dirname(\dirname($r->getFileName())); - if (file_exists($v.'/composer/installed.json')) { - $loader = require $v.'/autoload.php'; - $reflection = new \ReflectionClass($loader); - $prop = $reflection->getProperty('prefixDirsPsr4'); - $prop->setAccessible(true); - $currentValue = $prop->getValue($loader); - $currentValue['Symfony\\Bridge\\PhpUnit\\'] = [realpath(__DIR__.'/../..')]; - $prop->setValue($loader, $currentValue); - } - } - } - return [ 'not_from_vendors_file' => [Deprecation::TYPE_SELF, '', 'MyClass1', __FILE__], 'nonexistent_file' => [Deprecation::TYPE_UNDETERMINED, '', 'MyClass1', 'dummy_vendor_path'], @@ -276,8 +261,32 @@ class DeprecationTest extends TestCase rmdir($dir); } + private static function doSetupBeforeClass() + { + foreach (get_declared_classes() as $class) { + if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { + $r = new \ReflectionClass($class); + $v = \dirname(\dirname($r->getFileName())); + if (file_exists($v.'/composer/installed.json')) { + $loader = require $v.'/autoload.php'; + $reflection = new \ReflectionClass($loader); + $prop = $reflection->getProperty('prefixDirsPsr4'); + $prop->setAccessible(true); + $currentValue = $prop->getValue($loader); + self::$prefixDirsPsr4[] = [$prop, $loader, $currentValue]; + $currentValue['Symfony\\Bridge\\PhpUnit\\'] = [realpath(__DIR__.'/../..')]; + $prop->setValue($loader, $currentValue); + } + } + } + } + private static function doTearDownAfterClass() { + foreach (self::$prefixDirsPsr4 as [$prop, $loader, $prefixDirsPsr4]) { + $prop->setValue($loader, $prefixDirsPsr4); + } + self::removeDir(self::getVendorDir().'/myfakevendor'); } }