From a4efa2752f46c2fd3fdb85db4337d46c0bd3de4b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Nov 2021 09:40:00 +0100 Subject: [PATCH 01/37] Update CHANGELOG for 4.4.35 --- CHANGELOG-4.4.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG-4.4.md b/CHANGELOG-4.4.md index 669b5dccca4d..10a473cffdec 100644 --- a/CHANGELOG-4.4.md +++ b/CHANGELOG-4.4.md @@ -7,6 +7,13 @@ in 4.4 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.4.0...v4.4.1 +* 4.4.35 (2021-11-24) + + * security #cve-2021-41270 [Serializer] Use single quote to escape formulas (jderusse) + * bug #44232 [Cache] fix connecting to local Redis sockets (nicolas-grekas) + * bug #44204 [HttpClient] fix closing curl multi handle when destructing client (nicolas-grekas) + * bug #44208 [Process] exclude argv/argc from possible default env vars (nicolas-grekas) + * 4.4.34 (2021-11-22) * bug #44188 [VarExporter] fix exporting declared but unset properties when __sleep() is implemented (nicolas-grekas) From dd1deaa5ec273cc329d45c271a579b1178635c7d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Nov 2021 09:40:08 +0100 Subject: [PATCH 02/37] Update CONTRIBUTORS for 4.4.35 --- CONTRIBUTORS.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 92b9b528b9c5..b5e87ad1280f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -12,8 +12,8 @@ The Symfony Connect username in parenthesis allows to get more information - Tobias Schultze (tobion) - Robin Chalas (chalas_r) - Christophe Coevoet (stof) - - Wouter De Jong (wouterj) - Jérémy DERUSSÉ (jderusse) + - Wouter De Jong (wouterj) - Grégoire Pineau (lyrixx) - Maxime Steinhausser (ogizanagi) - Kévin Dunglas (dunglas) @@ -58,9 +58,9 @@ The Symfony Connect username in parenthesis allows to get more information - Diego Saint Esteben (dosten) - Grégoire Paris (greg0ire) - Alexandre Salomé (alexandresalome) + - Jérôme Tamarelle (gromnan) - William Durand (couac) - ornicar - - Jérôme Tamarelle (gromnan) - Konstantin Myakshin (koc) - Dany Maillard (maidmaid) - Francis Besset (francisbesset) @@ -116,11 +116,11 @@ The Symfony Connect username in parenthesis allows to get more information - John Wards (johnwards) - Tomas Norkūnas (norkunas) - Baptiste Clavié (talus) + - HypeMC (hypemc) - Antoine Hérault (herzult) - Paráda József (paradajozsef) - Alexandre Daubois (alexandre-daubois) - Vincent Langlet (deviling) - - HypeMC (hypemc) - Massimiliano Arione (garak) - Arnaud Le Blanc (arnaud-lb) - Przemysław Bogusz (przemyslaw-bogusz) @@ -825,6 +825,7 @@ The Symfony Connect username in parenthesis allows to get more information - Rodrigo Borrego Bernabé (rodrigobb) - Emanuele Iannone - Jörn Lang (j.lang) + - Petr Duda (petrduda) - Marcos Rezende (rezehnde) - Denis Gorbachev (starfall) - Peter van Dommelen @@ -1350,7 +1351,6 @@ The Symfony Connect username in parenthesis allows to get more information - Simon Leblanc (leblanc_simon) - Matthieu Mota (matthieumota) - Mikhail Prosalov (mprosalov) - - Petr Duda (petrduda) - Ronny López (ronnylt) - abdul malik ikhsan (samsonasik) - Henry Snoek (snoek09) From 9ef799c625e0ca1c50d114df101e2b337a07ec1e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Nov 2021 09:40:10 +0100 Subject: [PATCH 03/37] Update VERSION for 4.4.35 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 8149c1b6c07f..3f5a3314ab88 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.35-DEV'; + public const VERSION = '4.4.35'; public const VERSION_ID = 40435; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 35; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 2e567f1114bf8f1722be7aa1b4f357a61afc8752 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Nov 2021 09:45:16 +0100 Subject: [PATCH 04/37] Bump Symfony version to 4.4.36 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 3f5a3314ab88..398f4c102cca 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -76,12 +76,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '4.4.35'; - public const VERSION_ID = 40435; + public const VERSION = '4.4.36-DEV'; + public const VERSION_ID = 40436; public const MAJOR_VERSION = 4; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 35; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 36; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2022'; public const END_OF_LIFE = '11/2023'; From 8f21aa8b0c54104a063bd3d86c8daa7180000de9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Nov 2021 09:46:39 +0100 Subject: [PATCH 05/37] Update CHANGELOG for 5.3.12 --- CHANGELOG-5.3.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG-5.3.md b/CHANGELOG-5.3.md index f73800bc11f8..ceeefa8cad09 100644 --- a/CHANGELOG-5.3.md +++ b/CHANGELOG-5.3.md @@ -7,6 +7,15 @@ in 5.3 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v5.3.0...v5.3.1 +* 5.3.12 (2021-11-24) + + * security #cve-2021-41268 [SecurityBundle] Default signature_properties to the previous behavior (wouterj) + * security #cve-2021-41267 [HttpKernel] Fix missing extra trusted header in sub-request (jderusse) + * security #cve-2021-41270 [Serializer] Use single quote to escape formulas (jderusse) + * bug #44232 [Cache] fix connecting to local Redis sockets (nicolas-grekas) + * bug #44204 [HttpClient] fix closing curl multi handle when destructing client (nicolas-grekas) + * bug #44208 [Process] exclude argv/argc from possible default env vars (nicolas-grekas) + * 5.3.11 (2021-11-22) * bug #44188 [VarExporter] fix exporting declared but unset properties when __sleep() is implemented (nicolas-grekas) From ecbc47b1cef0cb5db4d9349153b07e0f684f4e75 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Nov 2021 09:46:46 +0100 Subject: [PATCH 06/37] Update VERSION for 5.3.12 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index d7d01dca5502..ec7d23f26d94 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -75,12 +75,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '5.3.12-DEV'; + public const VERSION = '5.3.12'; public const VERSION_ID = 50312; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 3; public const RELEASE_VERSION = 12; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '01/2022'; public const END_OF_LIFE = '01/2022'; From dc68bf54811f539d5d1e72144a5309ea95df5220 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Nov 2021 09:50:11 +0100 Subject: [PATCH 07/37] Bump Symfony version to 5.3.13 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index ec7d23f26d94..68d6d31a653b 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -75,12 +75,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private static $freshCache = []; - public const VERSION = '5.3.12'; - public const VERSION_ID = 50312; + public const VERSION = '5.3.13-DEV'; + public const VERSION_ID = 50313; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 3; - public const RELEASE_VERSION = 12; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 13; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '01/2022'; public const END_OF_LIFE = '01/2022'; From 48182bd12f59d712257abbb52891d7be99fd10a4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Nov 2021 09:51:38 +0100 Subject: [PATCH 08/37] Update CHANGELOG for 5.4.0-RC1 --- CHANGELOG-5.4.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG-5.4.md b/CHANGELOG-5.4.md index 22eace057214..98ea5ab9c9e7 100644 --- a/CHANGELOG-5.4.md +++ b/CHANGELOG-5.4.md @@ -7,6 +7,25 @@ in 5.4 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v5.4.0...v5.4.1 +* 5.4.0-RC1 (2021-11-24) + + * security #cve-2021-41268 [SecurityBundle] Default signature_properties to the previous behavior (wouterj) + * security #cve-2021-41267 [HttpKernel] Fix missing extra trusted header in sub-request (jderusse) + * security #cve-2021-41270 [Serializer] Use single quote to escape formulas (jderusse) + * bug #44230 [Console] Add Suggestion class for more advanced completion suggestion (wouterj) + * bug #44232 [Cache] fix connecting to local Redis sockets (nicolas-grekas) + * bug #44204 [HttpClient] fix closing curl multi handle when destructing client (nicolas-grekas) + * bug #44208 [Process] exclude argv/argc from possible default env vars (nicolas-grekas) + * bug #44188 [VarExporter] fix exporting declared but unset properties when __sleep() is implemented (nicolas-grekas) + * bug #44176 [Console] Default ansi option to null (jderusse) + * bug #44179 [WebProfilerBundle] Fix JS error when toolbar is reloaded (jderusse) + * bug #44172 [Security] Guard is incompatible with Symfony 6 (derrabus) + * bug #44119 [HttpClient][Mime] Add correct IDN flags for IDNA2008 compliance (j-bernard) + * bug #44139 [WebProfilerBundle] Prevent installation of incompatible mailer component versions (Anne-Julia Seitz) + * bug #43917 Allow autodetecting mapping type for any object (franmomu) + * bug #44131 [Yaml] properly parse quoted strings tagged with !!str (xabbuh) + * bug #42323 [TwigBridge] do not merge label classes into expanded choice labels (xabbuh) + * 5.4.0-BETA3 (2021-11-18) * feature #44125 Add a setter on DateTimeNormalizer to change the default context at runtime (Seldaek) From 7fe5a0aec256f4402a94ce7a26ac0675628d32e0 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Nov 2021 09:51:45 +0100 Subject: [PATCH 09/37] Update VERSION for 5.4.0-RC1 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 1f8a2c37b5d8..f55f5f693dce 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.0-DEV'; + public const VERSION = '5.4.0-RC1'; public const VERSION_ID = 50400; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = 'RC1'; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From 1809f4e862c2063c9d661fc308d1b7121a1c33a2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Nov 2021 09:56:56 +0100 Subject: [PATCH 10/37] Bump Symfony version to 5.4.0 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index f55f5f693dce..1f8a2c37b5d8 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.0-RC1'; + public const VERSION = '5.4.0-DEV'; public const VERSION_ID = 50400; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = 'RC1'; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From 63196d2ddd6aacd5b54fa16881a3c70ea5c9d8a9 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 24 Nov 2021 10:05:11 +0100 Subject: [PATCH 11/37] Bump Symfony version to 6.0.0 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 4fdfde448b00..28c499510d98 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.0.0-RC1'; + public const VERSION = '6.0.0-DEV'; public const VERSION_ID = 60000; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 0; public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = 'RC1'; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '07/2022'; public const END_OF_LIFE = '07/2022'; From 3b612362220281ce71c422a3a703caca00ffea66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin?= Date: Wed, 24 Nov 2021 10:27:48 +0100 Subject: [PATCH 12/37] [String] Add conflict with symfony/translation-contracts >= 3 --- src/Symfony/Component/String/composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Symfony/Component/String/composer.json b/src/Symfony/Component/String/composer.json index 6dc1c46fe31b..2b88fd529e8b 100644 --- a/src/Symfony/Component/String/composer.json +++ b/src/Symfony/Component/String/composer.json @@ -29,6 +29,9 @@ "symfony/translation-contracts": "^1.1|^2", "symfony/var-exporter": "^4.4|^5.0|^6.0" }, + "conflict": { + "symfony/translation-contracts": ">=3.0" + }, "autoload": { "psr-4": { "Symfony\\Component\\String\\": "" }, "files": [ "Resources/functions.php" ], From 9ce61e128f20156830ac708cb27db2b0db0fdc74 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 24 Nov 2021 14:16:06 +0100 Subject: [PATCH 13/37] [appveyor] Bump apcu to 5.1.18 --- .appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index c125ea3afb20..f342e252ec34 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -20,8 +20,8 @@ install: - appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php-7.1.3-Win32-VC14-x86.zip - 7z x php-7.1.3-Win32-VC14-x86.zip -y >nul - cd ext - - appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_apcu-5.1.8-7.1-ts-vc14-x86.zip - - 7z x php_apcu-5.1.8-7.1-ts-vc14-x86.zip -y >nul + - appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_apcu-5.1.18-7.1-ts-vc14-x86.zip + - 7z x php_apcu-5.1.18-7.1-ts-vc14-x86.zip -y >nul - cd .. - copy /Y php.ini-development php.ini-min - echo memory_limit=-1 >> php.ini-min From e066c3e8247bad9803a7fea9d98986f7ff2d1502 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 24 Nov 2021 15:26:51 +0100 Subject: [PATCH 14/37] Fix merge --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index ecc09eaed132..38b6b1c6c1d5 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -21,7 +21,7 @@ install: - 7z x php-7.2.5-Win32-VC15-x86.zip -y >nul - cd ext - appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_apcu-5.1.19-7.2-ts-vc15-x86.zip - - 7z x php_apcu-5.1.18-7.2-ts-vc15-x86.zip -y >nul + - 7z x php_apcu-5.1.19-7.2-ts-vc15-x86.zip -y >nul - cd .. - copy /Y php.ini-development php.ini-min - echo memory_limit=-1 >> php.ini-min From 327b46abc2ee06a5b45b85dc97318b994cf30f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my?= Date: Thu, 25 Nov 2021 10:55:10 +0100 Subject: [PATCH 15/37] Implement abstract process method --- .../Messenger/Handler/BatchHandlerTrait.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Component/Messenger/Handler/BatchHandlerTrait.php b/src/Symfony/Component/Messenger/Handler/BatchHandlerTrait.php index d197d07e559a..c400947dd52c 100644 --- a/src/Symfony/Component/Messenger/Handler/BatchHandlerTrait.php +++ b/src/Symfony/Component/Messenger/Handler/BatchHandlerTrait.php @@ -11,13 +11,18 @@ namespace Symfony\Component\Messenger\Handler; -use Symfony\Component\Messenger\Exception\LogicException; - /** * @author Nicolas Grekas */ trait BatchHandlerTrait { + /** + * Completes the jobs in the list. + * + * @list $jobs A list of pairs of messages and their corresponding acknowledgers + */ + abstract private function process(array $jobs): void; + private array $jobs = []; /** @@ -62,14 +67,4 @@ private function shouldFlush(): bool { return 10 <= \count($this->jobs); } - - /** - * Completes the jobs in the list. - * - * @list $jobs A list of pairs of messages and their corresponding acknowledgers - */ - private function process(array $jobs): void - { - throw new LogicException(sprintf('"%s" should implement abstract method "process()".', get_debug_type($this))); - } } From a1e22dc9874c5326041893b9ef306f138e7424c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 25 Nov 2021 11:18:20 +0100 Subject: [PATCH 16/37] Revert "[DoctrineBridge] add support for the JSON type" This reverts commit 1e218c5a6aa684ea2ebd15b7b6635de5d8af58b9. --- .../Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php | 2 -- .../Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php index 072fa91affa2..879e87979499 100644 --- a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php +++ b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php @@ -189,7 +189,6 @@ public function getTypes($class, $property, array $context = []) case self::$useDeprecatedConstants ? DBALType::TARRAY : Types::ARRAY: // no break case 'json_array': - case 'json': return [new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true)]; case self::$useDeprecatedConstants ? DBALType::SIMPLE_ARRAY : Types::SIMPLE_ARRAY: @@ -317,7 +316,6 @@ private function getPhpType(string $doctrineType): ?string case self::$useDeprecatedConstants ? DBALType::SIMPLE_ARRAY : Types::SIMPLE_ARRAY: // no break case 'json_array': - case 'json': return Type::BUILTIN_TYPE_ARRAY; } diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php index 71eaf31ca7f8..7e256eb77e2d 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php @@ -254,11 +254,11 @@ public function typesProvider() new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, DoctrineRelation::class) )]], - ['json', [new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)]], + ['json', null], ]; if (class_exists(Types::class)) { - $provider[] = ['json', [new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)]]; + $provider[] = ['json', null]; } return $provider; From 376b3e526bbf0dfa577f27aa25bdea9f25584eed Mon Sep 17 00:00:00 2001 From: Alexandre Fiocre Date: Thu, 25 Nov 2021 16:25:42 +0100 Subject: [PATCH 17/37] [Notifier] Fix AllMySms bridge body content --- .../Component/Notifier/Bridge/AllMySms/AllMySmsTransport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/AllMySms/AllMySmsTransport.php b/src/Symfony/Component/Notifier/Bridge/AllMySms/AllMySmsTransport.php index fab94304bf01..28508bdde350 100644 --- a/src/Symfony/Component/Notifier/Bridge/AllMySms/AllMySmsTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/AllMySms/AllMySmsTransport.php @@ -64,7 +64,7 @@ protected function doSend(MessageInterface $message): SentMessage $endpoint = sprintf('https://%s/sms/send/', $this->getEndpoint()); $response = $this->client->request('POST', $endpoint, [ 'auth_basic' => $this->login.':'.$this->apiKey, - 'body' => [ + 'json' => [ 'from' => $this->from, 'to' => $message->getPhone(), 'text' => $message->getSubject(), From e724d5ae4809c87536b135f529e8cadc4da9a671 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Thu, 25 Nov 2021 13:05:50 +0100 Subject: [PATCH 18/37] Fix redundant type casts --- ...ExtensionBootstrap3HorizontalLayoutTest.php | 18 +++++++++--------- .../FormExtensionBootstrap3LayoutTest.php | 18 +++++++++--------- ...ExtensionBootstrap4HorizontalLayoutTest.php | 18 +++++++++--------- .../FormExtensionBootstrap4LayoutTest.php | 18 +++++++++--------- .../Extension/FormExtensionDivLayoutTest.php | 18 +++++++++--------- .../Extension/FormExtensionTableLayoutTest.php | 18 +++++++++--------- .../Tests/Templating/TimedPhpEngineTest.php | 14 ++------------ .../DependencyInjection/SecurityExtension.php | 2 +- .../Controller/ExceptionController.php | 2 +- .../Config/Resource/ClassExistenceResource.php | 2 +- src/Symfony/Component/Config/Util/XmlUtils.php | 4 ++-- .../Loader/XmlFileLoader.php | 6 +++--- .../Component/ErrorHandler/ErrorHandler.php | 2 +- .../Iterator/RecursiveDirectoryIterator.php | 2 +- .../Component/HttpFoundation/Request.php | 2 +- .../Session/Flash/AutoExpireFlashBag.php | 2 +- .../Storage/Proxy/SessionHandlerProxy.php | 14 +++++++------- .../DataCollector/RequestDataCollector.php | 2 +- .../Intl/NumberFormatter/NumberFormatter.php | 4 +--- .../AbstractNumberFormatterTest.php | 8 ++++---- .../Transport/RedisExt/Connection.php | 2 +- .../Component/Templating/Storage/Storage.php | 2 +- src/Symfony/Component/Yaml/Inline.php | 2 +- 23 files changed, 84 insertions(+), 96 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php index d8e8468c3f4b..9f0b0c070a2d 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php @@ -57,7 +57,7 @@ protected function setUp(): void protected function renderForm(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form', $vars); + return $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = []) @@ -66,42 +66,42 @@ protected function renderLabel(FormView $view, $label = null, array $vars = []) $vars += ['label' => $label]; } - return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); + return $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderHelp(FormView $view) { - return (string) $this->renderer->searchAndRenderBlock($view, 'help'); + return $this->renderer->searchAndRenderBlock($view, 'help'); } protected function renderErrors(FormView $view) { - return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); + return $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); + return $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); + return $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); + return $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form_start', $vars); + return $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form_end', $vars); + return $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php index 0735cc2973e6..38c445f92772 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php @@ -107,7 +107,7 @@ public function testMoneyWidgetInIso() protected function renderForm(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form', $vars); + return $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = []) @@ -116,42 +116,42 @@ protected function renderLabel(FormView $view, $label = null, array $vars = []) $vars += ['label' => $label]; } - return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); + return $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderHelp(FormView $view) { - return (string) $this->renderer->searchAndRenderBlock($view, 'help'); + return $this->renderer->searchAndRenderBlock($view, 'help'); } protected function renderErrors(FormView $view) { - return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); + return $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); + return $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); + return $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); + return $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form_start', $vars); + return $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form_end', $vars); + return $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php index da0564851229..5c2e5afcfdf9 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php @@ -59,7 +59,7 @@ protected function setUp(): void protected function renderForm(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form', $vars); + return $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = []) @@ -68,42 +68,42 @@ protected function renderLabel(FormView $view, $label = null, array $vars = []) $vars += ['label' => $label]; } - return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); + return $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderHelp(FormView $view) { - return (string) $this->renderer->searchAndRenderBlock($view, 'help'); + return $this->renderer->searchAndRenderBlock($view, 'help'); } protected function renderErrors(FormView $view) { - return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); + return $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); + return $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); + return $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); + return $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form_start', $vars); + return $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form_end', $vars); + return $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php index f62e903473ca..7dda79420ca1 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php @@ -111,7 +111,7 @@ public function testMoneyWidgetInIso() protected function renderForm(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form', $vars); + return $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = []) @@ -120,42 +120,42 @@ protected function renderLabel(FormView $view, $label = null, array $vars = []) $vars += ['label' => $label]; } - return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); + return $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderHelp(FormView $view) { - return (string) $this->renderer->searchAndRenderBlock($view, 'help'); + return $this->renderer->searchAndRenderBlock($view, 'help'); } protected function renderErrors(FormView $view) { - return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); + return $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); + return $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); + return $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); + return $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form_start', $vars); + return $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form_end', $vars); + return $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index 9e7b1684b826..ff9357627579 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -298,7 +298,7 @@ public function testHelpHtmlIsTrue() protected function renderForm(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form', $vars); + return $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = []) @@ -307,42 +307,42 @@ protected function renderLabel(FormView $view, $label = null, array $vars = []) $vars += ['label' => $label]; } - return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); + return $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderHelp(FormView $view) { - return (string) $this->renderer->searchAndRenderBlock($view, 'help'); + return $this->renderer->searchAndRenderBlock($view, 'help'); } protected function renderErrors(FormView $view) { - return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); + return $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); + return $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); + return $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); + return $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form_start', $vars); + return $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form_end', $vars); + return $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php index ecf3597b311a..301a74ed9444 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php @@ -184,7 +184,7 @@ public function testHelpHtmlIsTrue() protected function renderForm(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form', $vars); + return $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = []) @@ -193,42 +193,42 @@ protected function renderLabel(FormView $view, $label = null, array $vars = []) $vars += ['label' => $label]; } - return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); + return $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderHelp(FormView $view) { - return (string) $this->renderer->searchAndRenderBlock($view, 'help'); + return $this->renderer->searchAndRenderBlock($view, 'help'); } protected function renderErrors(FormView $view) { - return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); + return $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); + return $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); + return $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = []) { - return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); + return $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form_start', $vars); + return $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = []) { - return (string) $this->renderer->renderBlock($view, 'form_end', $vars); + return $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php index 4951b46c4513..2db6d689530f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php @@ -31,7 +31,7 @@ public function testThatRenderLogsTime() $container = $this->createMock(Container::class); $templateNameParser = $this->getTemplateNameParser(); $globalVariables = $this->getGlobalVariables(); - $loader = $this->getLoader($this->getStorage()); + $loader = $this->getLoader(new StringStorage('foo')); $stopwatch = new Stopwatch(); @@ -60,17 +60,7 @@ private function getGlobalVariables(): GlobalVariables return $this->createMock(GlobalVariables::class); } - private function getStorage(): StringStorage - { - return $this->getMockBuilder(StringStorage::class) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - } - - /** - * @param StringStorage $storage - */ - private function getLoader($storage): Loader + private function getLoader(StringStorage $storage): Loader { $loader = $this->getMockForAbstractClass(Loader::class); $loader->expects($this->once()) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index 22f3a8fa5435..1996249a7207 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -730,7 +730,7 @@ private function createExpression(ContainerBuilder $container, string $expressio private function createRequestMatcher(ContainerBuilder $container, string $path = null, string $host = null, int $port = null, array $methods = [], array $ips = null, array $attributes = []): Reference { if ($methods) { - $methods = array_map('strtoupper', (array) $methods); + $methods = array_map('strtoupper', $methods); } if (null !== $ips) { diff --git a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php index a5127a25d823..dda4ae6e82f3 100644 --- a/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php @@ -64,7 +64,7 @@ public function showAction(Request $request, FlattenException $exception, DebugL $code = $exception->getStatusCode(); return new Response($this->twig->render( - (string) $this->findTemplate($request, $request->getRequestFormat(), $code, $showException), + $this->findTemplate($request, $request->getRequestFormat(), $code, $showException), [ 'status_code' => $code, 'status_text' => Response::$statusTexts[$code] ?? '', diff --git a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php index 8179ce7fb4f1..f04b767e7f70 100644 --- a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php +++ b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php @@ -38,7 +38,7 @@ public function __construct(string $resource, bool $exists = null) { $this->resource = $resource; if (null !== $exists) { - $this->exists = [(bool) $exists, null]; + $this->exists = [$exists, null]; } } diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index 12caa486bfc4..41fb5a9e6259 100644 --- a/src/Symfony/Component/Config/Util/XmlUtils.php +++ b/src/Symfony/Component/Config/Util/XmlUtils.php @@ -239,12 +239,12 @@ public static function phpize($value) $raw = $value; $cast = (int) $value; - return '0' == $value[0] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw); + return '0' == $value[0] ? octdec($value) : (($raw === (string) $cast) ? $cast : $raw); case isset($value[1]) && '-' === $value[0] && ctype_digit(substr($value, 1)): $raw = $value; $cast = (int) $value; - return '0' == $value[1] ? octdec($value) : (((string) $raw === (string) $cast) ? $cast : $raw); + return '0' == $value[1] ? octdec($value) : (($raw === (string) $cast) ? $cast : $raw); case 'true' === $lowercaseValue: return true; case 'false' === $lowercaseValue: diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 968a3f5eebff..fdf4fa1f4c88 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -197,7 +197,7 @@ private function parseDefinition(\DOMElement $service, string $file, array $defa if ($alias = $service->getAttribute('alias')) { $this->validateAlias($service, $file); - $this->container->setAlias((string) $service->getAttribute('id'), $alias = new Alias($alias)); + $this->container->setAlias($service->getAttribute('id'), $alias = new Alias($alias)); if ($publicAttr = $service->getAttribute('public')) { $alias->setPublic(XmlUtils::phpize($publicAttr)); } elseif (isset($defaults['public'])) { @@ -345,7 +345,7 @@ private function parseDefinition(\DOMElement $service, string $file, array $defa } if ('' === $tag->getAttribute('name')) { - throw new InvalidArgumentException(sprintf('The tag name for service "%s" in "%s" must be a non-empty string.', (string) $service->getAttribute('id'), $file)); + throw new InvalidArgumentException(sprintf('The tag name for service "%s" in "%s" must be a non-empty string.', $service->getAttribute('id'), $file)); } $definition->addTag($tag->getAttribute('name'), $parameters); @@ -374,7 +374,7 @@ private function parseDefinition(\DOMElement $service, string $file, array $defa } elseif ('null' === $decorationOnInvalid) { $invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE; } else { - throw new InvalidArgumentException(sprintf('Invalid value "%s" for attribute "decoration-on-invalid" on service "%s". Did you mean "exception", "ignore" or "null" in "%s"?', $decorationOnInvalid, (string) $service->getAttribute('id'), $file)); + throw new InvalidArgumentException(sprintf('Invalid value "%s" for attribute "decoration-on-invalid" on service "%s". Did you mean "exception", "ignore" or "null" in "%s"?', $decorationOnInvalid, $service->getAttribute('id'), $file)); } $renameId = $service->hasAttribute('decoration-inner-name') ? $service->getAttribute('decoration-inner-name') : null; diff --git a/src/Symfony/Component/ErrorHandler/ErrorHandler.php b/src/Symfony/Component/ErrorHandler/ErrorHandler.php index e6e21d601700..4c4d7dc361cb 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/ErrorHandler.php @@ -342,7 +342,7 @@ public function scopeAt(int $levels, bool $replace = false): int public function traceAt(int $levels, bool $replace = false): int { $prev = $this->tracedErrors; - $this->tracedErrors = (int) $levels; + $this->tracedErrors = $levels; if (!$replace) { $this->tracedErrors |= $prev; } diff --git a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php index a18e6185beee..8508ab707b9a 100644 --- a/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php +++ b/src/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php @@ -64,7 +64,7 @@ public function current() // the logic here avoids redoing the same work in all iterations if (null === $subPathname = $this->subPath) { - $subPathname = $this->subPath = (string) $this->getSubPath(); + $subPathname = $this->subPath = $this->getSubPath(); } if ('' !== $subPathname) { $subPathname .= $this->directorySeparator; diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index e2586f9a91a6..b6e6c3036b80 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1907,7 +1907,7 @@ protected function preparePathInfo() return '/'; } - return (string) $pathInfo; + return $pathInfo; } /** diff --git a/src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php b/src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php index 6502f3d50155..facbe102d540 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php +++ b/src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php @@ -78,7 +78,7 @@ public function peek($type, array $default = []) */ public function peekAll() { - return \array_key_exists('display', $this->flashes) ? (array) $this->flashes['display'] : []; + return \array_key_exists('display', $this->flashes) ? $this->flashes['display'] : []; } /** diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php index 5535bc96441d..9b0cdeb7fe1d 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php @@ -21,7 +21,7 @@ class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterf public function __construct(\SessionHandlerInterface $handler) { $this->handler = $handler; - $this->wrapper = ($handler instanceof \SessionHandler); + $this->wrapper = $handler instanceof \SessionHandler; $this->saveHandlerName = $this->wrapper ? ini_get('session.save_handler') : 'user'; } @@ -41,7 +41,7 @@ public function getHandler() #[\ReturnTypeWillChange] public function open($savePath, $sessionName) { - return (bool) $this->handler->open($savePath, $sessionName); + return $this->handler->open($savePath, $sessionName); } /** @@ -50,16 +50,16 @@ public function open($savePath, $sessionName) #[\ReturnTypeWillChange] public function close() { - return (bool) $this->handler->close(); + return $this->handler->close(); } /** - * @return string + * @return string|false */ #[\ReturnTypeWillChange] public function read($sessionId) { - return (string) $this->handler->read($sessionId); + return $this->handler->read($sessionId); } /** @@ -68,7 +68,7 @@ public function read($sessionId) #[\ReturnTypeWillChange] public function write($sessionId, $data) { - return (bool) $this->handler->write($sessionId, $data); + return $this->handler->write($sessionId, $data); } /** @@ -77,7 +77,7 @@ public function write($sessionId, $data) #[\ReturnTypeWillChange] public function destroy($sessionId) { - return (bool) $this->handler->destroy($sessionId); + return $this->handler->destroy($sessionId); } /** diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index 2a3f6ce514f4..1fb226d13c38 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -150,7 +150,7 @@ public function collect(Request $request, Response $response/*, \Throwable $exce 'method' => $request->getMethod(), 'controller' => $this->parseController($request->attributes->get('_controller')), 'status_code' => $statusCode, - 'status_text' => Response::$statusTexts[(int) $statusCode], + 'status_text' => Response::$statusTexts[$statusCode], ]), 0, '/', null, $request->isSecure(), true, false, 'lax' )); diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index 0424d5e20f4c..3ec7eb343e04 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -272,7 +272,7 @@ public function __construct(?string $locale = 'en', int $style = null, $pattern throw new MethodArgumentNotImplementedException(__METHOD__, 'pattern'); } - $this->style = null !== $style ? (int) $style : null; + $this->style = $style; } /** @@ -796,8 +796,6 @@ private function isInitializedAttribute(string $attr): bool */ private function convertValueDataType($value, int $type) { - $type = (int) $type; - if (self::TYPE_DOUBLE === $type) { $value = (float) $value; } elseif (self::TYPE_INT32 === $type) { diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index f392b3da50ba..7feb599fc567 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -674,12 +674,12 @@ public function parseProvider() return [ ['prefix1', false, '->parse() does not parse a number with a string prefix.', 0], ['prefix1', false, '->parse() does not parse a number with a string prefix.', 0, false], - ['1.4suffix', (float) 1.4, '->parse() parses a number with a string suffix.', 3], - ['1.4suffix', (float) 1.4, '->parse() parses a number with a string suffix.', 3, false], + ['1.4suffix', 1.4, '->parse() parses a number with a string suffix.', 3], + ['1.4suffix', 1.4, '->parse() parses a number with a string suffix.', 3, false], ['1,234.4suffix', 1234.4, '->parse() parses a number with a string suffix.', 7], ['1,234.4suffix', 1.0, '->parse() parses a number with a string suffix.', 1, false], - ['-.4suffix', (float) -0.4, '->parse() parses a negative dot float with suffix.', 3], - ['-.4suffix', (float) -0.4, '->parse() parses a negative dot float with suffix.', 3, false], + ['-.4suffix', -0.4, '->parse() parses a negative dot float with suffix.', 3], + ['-.4suffix', -0.4, '->parse() parses a negative dot float with suffix.', 3, false], [',4', false, '->parse() does not parse when invalid grouping used.', 0], [',4', false, '->parse() does not parse when invalid grouping used.', 0, false], ['123,4', false, '->parse() does not parse when invalid grouping used.', 0], diff --git a/src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php b/src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php index 340cd792d3c0..4e372eecd72f 100644 --- a/src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php +++ b/src/Symfony/Component/Messenger/Transport/RedisExt/Connection.php @@ -267,7 +267,7 @@ public function add(string $body, array $headers, int $delayInMs = 0): void throw new TransportException(json_last_error_msg()); } - $score = (int) ($this->getCurrentTimeInMilliseconds() + $delayInMs); + $score = $this->getCurrentTimeInMilliseconds() + $delayInMs; $added = $this->connection->zadd($this->queue, ['NX'], $score, $message); } else { $message = json_encode([ diff --git a/src/Symfony/Component/Templating/Storage/Storage.php b/src/Symfony/Component/Templating/Storage/Storage.php index 8c817ba5b018..459c45c947d5 100644 --- a/src/Symfony/Component/Templating/Storage/Storage.php +++ b/src/Symfony/Component/Templating/Storage/Storage.php @@ -35,7 +35,7 @@ public function __construct(string $template) */ public function __toString() { - return (string) $this->template; + return $this->template; } /** diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index cb6875540422..24c802bcfa33 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -653,7 +653,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer // no break case '+' === $scalar[0] || '-' === $scalar[0] || '.' === $scalar[0] || is_numeric($scalar[0]): if (Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar)) { - $scalar = str_replace('_', '', (string) $scalar); + $scalar = str_replace('_', '', $scalar); } switch (true) { From d7fbbfd84257b7e5daaa920c0c89fc3b7a05caca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20REYNAUD?= Date: Fri, 26 Nov 2021 14:06:04 +0100 Subject: [PATCH 19/37] Reorganize abstract private method --- .../Messenger/Handler/BatchHandlerTrait.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Messenger/Handler/BatchHandlerTrait.php b/src/Symfony/Component/Messenger/Handler/BatchHandlerTrait.php index c400947dd52c..292665c6bfe7 100644 --- a/src/Symfony/Component/Messenger/Handler/BatchHandlerTrait.php +++ b/src/Symfony/Component/Messenger/Handler/BatchHandlerTrait.php @@ -16,13 +16,6 @@ */ trait BatchHandlerTrait { - /** - * Completes the jobs in the list. - * - * @list $jobs A list of pairs of messages and their corresponding acknowledgers - */ - abstract private function process(array $jobs): void; - private array $jobs = []; /** @@ -67,4 +60,11 @@ private function shouldFlush(): bool { return 10 <= \count($this->jobs); } + + /** + * Completes the jobs in the list. + * + * @list $jobs A list of pairs of messages and their corresponding acknowledgers + */ + abstract private function process(array $jobs): void; } From 66a3c035d132f48c36f6b44d292883bc6c43d356 Mon Sep 17 00:00:00 2001 From: Mathieu Santostefano Date: Sun, 21 Nov 2021 23:11:05 +0100 Subject: [PATCH 20/37] Fix idempotency of LocoProvider write method --- .../Translation/Bridge/Loco/LocoProvider.php | 26 ++++++++++++++----- .../Bridge/Loco/Tests/LocoProviderTest.php | 4 +-- .../Command/TranslationPushCommandTest.php | 3 +-- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/Translation/Bridge/Loco/LocoProvider.php b/src/Symfony/Component/Translation/Bridge/Loco/LocoProvider.php index b5544070a567..3882176d8d54 100644 --- a/src/Symfony/Component/Translation/Bridge/Loco/LocoProvider.php +++ b/src/Symfony/Component/Translation/Bridge/Loco/LocoProvider.php @@ -75,8 +75,15 @@ public function write(TranslatorBagInterface $translatorBag): void } foreach ($catalogue->all() as $domain => $messages) { - $ids = $this->getAssetsIds($domain); - $this->translateAssets(array_combine($ids, array_values($messages)), $locale); + $keysIdsMap = []; + + foreach ($this->getAssetsIds($domain) as $id) { + $keysIdsMap[$this->retrieveKeyFromId($id, $domain)] = $id; + } + + $ids = array_intersect_key($keysIdsMap, $messages); + + $this->translateAssets(array_combine(array_values($ids), array_values($messages)), $locale); } } } @@ -122,11 +129,7 @@ public function read(array $domains, array $locales): TranslatorBag $catalogue = new MessageCatalogue($locale); foreach ($locoCatalogue->all($domain) as $key => $message) { - if (str_starts_with($key, $domain.'__')) { - $key = substr($key, \strlen($domain) + 2); - } - - $catalogue->set($key, $message, $domain); + $catalogue->set($this->retrieveKeyFromId($key, $domain), $message, $domain); } $translatorBag->addCatalogue($catalogue); @@ -289,4 +292,13 @@ private function getLocales(): array return $carry; }, []); } + + private function retrieveKeyFromId(string $id, string $domain): string + { + if (str_starts_with($id, $domain.'__')) { + return substr($id, \strlen($domain) + 2); + } + + return $id; + } } diff --git a/src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderTest.php b/src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderTest.php index 09c779324310..2a2183abf110 100644 --- a/src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderTest.php +++ b/src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderTest.php @@ -148,7 +148,7 @@ public function testCompleteWriteProcess() $this->assertSame(['filter' => 'messages'], $options['query']); $this->assertSame($expectedAuthHeader, $options['normalized_headers']['authorization'][0]); - return new MockResponse('[{"id":"messages__a"}]'); + return new MockResponse('[{"id":"messages__foo.existing_key"},{"id":"messages__a"}]'); }, 'translateAsset1' => function (string $method, string $url, array $options = []) use ($expectedAuthHeader): ResponseInterface { $this->assertSame('POST', $method); @@ -164,7 +164,7 @@ public function testCompleteWriteProcess() $this->assertSame(['filter' => 'validators'], $options['query']); $this->assertSame($expectedAuthHeader, $options['normalized_headers']['authorization'][0]); - return new MockResponse('[{"id":"validators__post.num_comments"}]'); + return new MockResponse('[{"id":"validators__foo.existing_key"},{"id":"validators__post.num_comments"}]'); }, 'translateAsset2' => function (string $method, string $url, array $options = []) use ($expectedAuthHeader): ResponseInterface { $this->assertSame('POST', $method); diff --git a/src/Symfony/Component/Translation/Tests/Command/TranslationPushCommandTest.php b/src/Symfony/Component/Translation/Tests/Command/TranslationPushCommandTest.php index 1f0db90d3fbf..eb975afbd883 100644 --- a/src/Symfony/Component/Translation/Tests/Command/TranslationPushCommandTest.php +++ b/src/Symfony/Component/Translation/Tests/Command/TranslationPushCommandTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Bundle\FrameworkBundle\Tests\Command; +namespace Symfony\Component\Translation\Tests\Command; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; @@ -18,7 +18,6 @@ use Symfony\Component\Translation\Loader\XliffFileLoader; use Symfony\Component\Translation\Provider\ProviderInterface; use Symfony\Component\Translation\Reader\TranslationReader; -use Symfony\Component\Translation\Tests\Command\TranslationProviderTestCase; use Symfony\Component\Translation\TranslatorBag; /** From 396b3f847dca21b731a3591aa7d12773436fca05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Egyed?= Date: Fri, 26 Nov 2021 21:54:30 +0100 Subject: [PATCH 21/37] [FrameworkBundle] Fix property-info phpstan extractor discovery --- .../FrameworkBundle/DependencyInjection/FrameworkExtension.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 22517ad5c7d3..7ec3589a4c39 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -16,6 +16,7 @@ use Doctrine\Common\Annotations\Reader; use Http\Client\HttpClient; use phpDocumentor\Reflection\DocBlockFactoryInterface; +use phpDocumentor\Reflection\Types\ContextFactory; use PHPStan\PhpDocParser\Parser\PhpDocParser; use Psr\Cache\CacheItemPoolInterface; use Psr\Container\ContainerInterface as PsrContainerInterface; @@ -1849,7 +1850,7 @@ private function registerPropertyInfoConfiguration(ContainerBuilder $container, if ( ContainerBuilder::willBeAvailable('phpstan/phpdoc-parser', PhpDocParser::class, ['symfony/framework-bundle', 'symfony/property-info'], true) - && ContainerBuilder::willBeAvailable('phpdocumentor/type-resolver', PhpDocParser::class, ['symfony/framework-bundle', 'symfony/property-info'], true) + && ContainerBuilder::willBeAvailable('phpdocumentor/type-resolver', ContextFactory::class, ['symfony/framework-bundle', 'symfony/property-info'], true) ) { $definition = $container->register('property_info.phpstan_extractor', PhpStanExtractor::class); $definition->addTag('property_info.type_extractor', ['priority' => -1000]); From cde5ec7b5f27732b701cbd0f4e892734fd598eea Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 27 Nov 2021 19:45:19 +0100 Subject: [PATCH 22/37] Leverage DBAL's getNativeConnection() method --- .../Bridge/Doctrine/Transport/PostgreSqlConnection.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php index d59e7b52c15e..6efcb21c3723 100644 --- a/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php +++ b/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php @@ -73,9 +73,13 @@ public function get(): ?array $this->listening = true; } - $wrappedConnection = $this->driverConnection->getWrappedConnection(); - if (!$wrappedConnection instanceof \PDO && $wrappedConnection instanceof DoctrinePdoConnection) { - $wrappedConnection = $wrappedConnection->getWrappedConnection(); + if (method_exists($this->driverConnection, 'getNativeConnection')) { + $wrappedConnection = $this->driverConnection->getNativeConnection(); + } else { + $wrappedConnection = $this->driverConnection->getWrappedConnection(); + if (!$wrappedConnection instanceof \PDO && $wrappedConnection instanceof DoctrinePdoConnection) { + $wrappedConnection = $wrappedConnection->getWrappedConnection(); + } } $notification = $wrappedConnection->pgsqlGetNotify(\PDO::FETCH_ASSOC, $this->configuration['get_notify_timeout']); From db043aa478cf603ad64699c8d79ab706aaea88b2 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 26 Nov 2021 16:37:56 +0100 Subject: [PATCH 23/37] [Serializer] fix support for lazy/unset properties --- .../PropertyAccess/PropertyAccessor.php | 6 ++++ .../Normalizer/AbstractObjectNormalizer.php | 30 ++++++++++++++++++- .../Normalizer/ObjectNormalizer.php | 10 +------ .../Normalizer/PropertyNormalizer.php | 26 +++++++++++----- .../Component/Serializer/composer.json | 2 +- 5 files changed, 55 insertions(+), 19 deletions(-) diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index 061e6d71cba9..4df3d7891389 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -385,6 +385,7 @@ private function readProperty(array $zval, string $property, bool $ignoreInvalid $result = self::RESULT_PROTO; $object = $zval[self::VALUE]; + $class = \get_class($object); $access = $this->getReadAccessInfo(\get_class($object), $property); try { @@ -406,6 +407,11 @@ private function readProperty(array $zval, string $property, bool $ignoreInvalid throw $e; } } elseif (self::ACCESS_TYPE_PROPERTY === $access[self::ACCESS_TYPE]) { + $name = $access[self::ACCESS_NAME]; + if (!method_exists($object, '__get') && !isset($object->$name) && !\array_key_exists($name, (array) $object) && (\PHP_VERSION_ID < 70400 || !(new \ReflectionProperty($class, $name))->hasType())) { + throw new AccessException(sprintf('The property "%s::$%s" is not initialized.', $class, $name)); + } + $result[self::VALUE] = $object->{$access[self::ACCESS_NAME]}; if ($access[self::ACCESS_REF] && isset($zval[self::REF])) { diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php index 3c790d03d6f7..57df0b6b8e52 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Serializer\Normalizer; +use Symfony\Component\PropertyAccess\Exception\AccessException; use Symfony\Component\PropertyAccess\Exception\InvalidArgumentException; use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException; use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface; @@ -181,7 +182,23 @@ public function normalize($object, $format = null, array $context = []) continue; } - $attributeValue = $this->getAttributeValue($object, $attribute, $format, $context); + try { + $attributeValue = $this->getAttributeValue($object, $attribute, $format, $context); + } catch (AccessException $e) { + if (sprintf('The property "%s::$%s" is not initialized.', \get_class($object), $attribute) === $e->getMessage()) { + continue; + } + if (($p = $e->getPrevious()) && 'Error' === \get_class($p) && $this->isUninitializedValueError($p)) { + continue; + } + throw $e; + } catch (\Error $e) { + if ($this->isUninitializedValueError($e)) { + continue; + } + throw $e; + } + if ($maxDepthReached) { $attributeValue = $maxDepthHandler($attributeValue, $object, $attribute, $format, $context); } @@ -637,4 +654,15 @@ private function getCacheKey(?string $format, array $context) return false; } } + + /** + * This error may occur when specific object normalizer implementation gets attribute value + * by accessing a public uninitialized property or by calling a method accessing such property. + */ + private function isUninitializedValueError(\Error $e): bool + { + return \PHP_VERSION_ID >= 70400 + && str_starts_with($e->getMessage(), 'Typed property') + && str_ends_with($e->getMessage(), 'must not be accessed before initialization'); + } } diff --git a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php index 874b4788d929..758611a5d7ad 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php @@ -104,16 +104,8 @@ protected function extractAttributes($object, $format = null, array $context = [ } // properties - $propertyValues = !method_exists($object, '__get') ? (array) $object : null; foreach ($reflClass->getProperties() as $reflProperty) { - if (null !== $propertyValues && !\array_key_exists($reflProperty->name, $propertyValues)) { - if ($reflProperty->isPublic() - || ($reflProperty->isProtected() && !\array_key_exists("\0*\0{$reflProperty->name}", $propertyValues)) - || ($reflProperty->isPrivate() && !\array_key_exists("\0{$reflProperty->class}\0{$reflProperty->name}", $propertyValues)) - ) { - unset($attributes[$reflProperty->name]); - } - + if (!$reflProperty->isPublic()) { continue; } diff --git a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php index 8ecd34081669..14017726aa58 100644 --- a/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Serializer\Normalizer; +use Symfony\Component\PropertyAccess\Exception\AccessException; + /** * Converts between objects and arrays by mapping properties. * @@ -101,17 +103,10 @@ protected function extractAttributes($object, $format = null, array $context = [ { $reflectionObject = new \ReflectionObject($object); $attributes = []; - $propertyValues = !method_exists($object, '__get') ? (array) $object : null; do { foreach ($reflectionObject->getProperties() as $property) { - if ((null !== $propertyValues && ( - ($property->isPublic() && !\array_key_exists($property->name, $propertyValues)) - || ($property->isProtected() && !\array_key_exists("\0*\0{$property->name}", $propertyValues)) - || ($property->isPrivate() && !\array_key_exists("\0{$property->class}\0{$property->name}", $propertyValues)) - )) - || !$this->isAllowedAttribute($reflectionObject->getName(), $property->name, $format, $context) - ) { + if (!$this->isAllowedAttribute($reflectionObject->getName(), $property->name, $format, $context)) { continue; } @@ -138,6 +133,21 @@ protected function getAttributeValue($object, $attribute, $format = null, array $reflectionProperty->setAccessible(true); } + if (\PHP_VERSION_ID >= 70400 && $reflectionProperty->hasType()) { + return $reflectionProperty->getValue($object); + } + + if (!method_exists($object, '__get') && !isset($object->$attribute)) { + $propertyValues = (array) $object; + + if (($reflectionProperty->isPublic() && !\array_key_exists($reflectionProperty->name, $propertyValues)) + || ($reflectionProperty->isProtected() && !\array_key_exists("\0*\0{$reflectionProperty->name}", $propertyValues)) + || ($reflectionProperty->isPrivate() && !\array_key_exists("\0{$reflectionProperty->class}\0{$reflectionProperty->name}", $propertyValues)) + ) { + throw new AccessException(sprintf('The property "%s::$%s" is not initialized.', \get_class($object), $reflectionProperty->name)); + } + } + return $reflectionProperty->getValue($object); } diff --git a/src/Symfony/Component/Serializer/composer.json b/src/Symfony/Component/Serializer/composer.json index 324c30edffdd..ad876e13b911 100644 --- a/src/Symfony/Component/Serializer/composer.json +++ b/src/Symfony/Component/Serializer/composer.json @@ -29,7 +29,7 @@ "symfony/error-handler": "^4.4|^5.0", "symfony/http-foundation": "^3.4|^4.0|^5.0", "symfony/mime": "^4.4|^5.0", - "symfony/property-access": "^3.4.41|^4.4.9|^5.0.9", + "symfony/property-access": "^4.4.36|^5.3.13", "symfony/property-info": "^3.4.13|~4.0|^5.0", "symfony/validator": "^3.4|^4.0|^5.0", "symfony/yaml": "^3.4|^4.0|^5.0" From d78bc24940fa44623a6c5dceb7f545adde941bd1 Mon Sep 17 00:00:00 2001 From: Kirill Lazarev Date: Wed, 24 Nov 2021 02:20:44 +0300 Subject: [PATCH 24/37] [Process] intersect with getenv() in case-insensitive manner to get default envs - since environment variables are case-insensitive in Windows, all envs should be compared in case-insensitive manner --- src/Symfony/Component/Process/Process.php | 8 ++++---- src/Symfony/Component/Process/Tests/ProcessTest.php | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index d5c697cf9c2d..c0b638aabda1 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -304,10 +304,10 @@ public function start(callable $callback = null, array $env = []) $descriptors = $this->getDescriptors(); if ($this->env) { - $env += $this->env; + $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->env, $env, 'strcasecmp') : $this->env; } - $env += $this->getDefaultEnv(); + $env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->getDefaultEnv(), $env, 'strcasecmp') : $this->getDefaultEnv(); if (\is_array($commandline = $this->commandline)) { $commandline = implode(' ', array_map([$this, 'escapeArgument'], $commandline)); @@ -1659,8 +1659,8 @@ private function replacePlaceholders(string $commandline, array $env) private function getDefaultEnv(): array { $env = getenv(); - $env = array_intersect_key($env, $_SERVER) ?: $env; + $env = ('\\' === \DIRECTORY_SEPARATOR ? array_intersect_ukey($env, $_SERVER, 'strcasecmp') : array_intersect_key($env, $_SERVER)) ?: $env; - return $_ENV + $env; + return $_ENV + ('\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($env, $_ENV, 'strcasecmp') : $env); } } diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 70b8e0513902..806afbab0948 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -1522,6 +1522,18 @@ public function testWaitStoppedDeadProcess() $this->assertFalse($process->isRunning()); } + public function testEnvCaseInsensitiveOnWindows() + { + $p = $this->getProcessForCode('print_r([$_SERVER[\'PATH\'] ?? 1, $_SERVER[\'Path\'] ?? 2]);', null, ['PATH' => 'bar/baz']); + $p->run(null, ['Path' => 'foo/bar']); + + if ('\\' === \DIRECTORY_SEPARATOR) { + $this->assertSame('Array ( [0] => 1 [1] => foo/bar )', preg_replace('/\s++/', ' ', trim($p->getOutput()))); + } else { + $this->assertSame('Array ( [0] => bar/baz [1] => foo/bar )', preg_replace('/\s++/', ' ', trim($p->getOutput()))); + } + } + /** * @param string|array $commandline * @param mixed $input From 325d19c35a5c3c5723a92c583f6261be4a519e83 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 28 Nov 2021 19:02:56 +0100 Subject: [PATCH 25/37] [DoctrineBridge] Add DbalLoggerTest to group legacy --- .appveyor.yml | 1 - .github/workflows/integration-tests.yml | 1 - .github/workflows/unit-tests.yml | 1 - .../Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php | 7 +++++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index f342e252ec34..7fe5b25c3686 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -12,7 +12,6 @@ init: - SET SYMFONY_DEPRECATIONS_HELPER=strict - SET ANSICON=121x90 (121x90) - SET SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE=1 - - SET SYMFONY_DEPRECATIONS_HELPER=max[direct]=1 - REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v DelayedExpansion /t REG_DWORD /d 1 /f install: diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 09acdcd9dbba..9832c8a9d09a 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -99,7 +99,6 @@ jobs: - name: Run tests run: ./phpunit --group integration -v env: - SYMFONY_DEPRECATIONS_HELPER: max[direct]=1 # to be removed once DbalLogger is compatible with dbal 3.2+ REDIS_HOST: localhost REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005' REDIS_SENTINEL_HOSTS: 'localhost:26379' diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index edd59d3f188f..157f6462b4e6 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -63,7 +63,6 @@ jobs: echo COLUMNS=120 >> $GITHUB_ENV echo PHPUNIT="$(readlink -f ./phpunit) --exclude-group tty,benchmark,intl-data" >> $GITHUB_ENV echo COMPOSER_UP='composer update --no-progress --ansi' >> $GITHUB_ENV - echo SYMFONY_DEPRECATIONS_HELPER=max[direct]=1 >> $GITHUB_ENV # to be removed once DbalLogger is compatible with dbal 3.2+ SYMFONY_VERSIONS=$(git ls-remote -q --heads | cut -f2 | grep -o '/[1-9][0-9]*\.[0-9].*' | sort -V) SYMFONY_VERSION=$(grep ' VERSION = ' src/Symfony/Component/HttpKernel/Kernel.php | grep -P -o '[0-9]+\.[0-9]+') diff --git a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php index d79b7d499813..710e87a15e0b 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php @@ -15,6 +15,9 @@ use Psr\Log\LoggerInterface; use Symfony\Bridge\Doctrine\Logger\DbalLogger; +/** + * @group legacy + */ class DbalLoggerTest extends TestCase { /** @@ -46,8 +49,8 @@ public function getLogFixtures() ['SQL', null, []], ['SQL', [], []], ['SQL', ['foo' => 'bar'], ['foo' => 'bar']], - ['SQL', ['foo' => "\x7F\xFF"], ['foo' => DbalLogger::BINARY_DATA_VALUE]], - ['SQL', ['foo' => "bar\x7F\xFF"], ['foo' => DbalLogger::BINARY_DATA_VALUE]], + ['SQL', ['foo' => "\x7F\xFF"], ['foo' => '(binary value)']], + ['SQL', ['foo' => "bar\x7F\xFF"], ['foo' => '(binary value)']], ['SQL', ['foo' => ''], ['foo' => '']], ]; } From 97160ddffa52258b3fbbfcbb0a27ddd1215a84e4 Mon Sep 17 00:00:00 2001 From: Khoo Yong Jun Date: Sun, 24 Oct 2021 09:06:50 +0800 Subject: [PATCH 26/37] Complete event name & dispatcher in EventDispatcherDebugCommand --- .../Command/EventDispatcherDebugCommand.php | 28 ++++++++ .../EventDispatcherDebugCommandTest.php | 70 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php index 523c481a4ba0..cfc9ae2fbee4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php @@ -14,12 +14,15 @@ use Psr\Container\ContainerInterface; use Symfony\Bundle\FrameworkBundle\Console\Helper\DescriptorHelper; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Completion\CompletionInput; +use Symfony\Component\Console\Completion\CompletionSuggestions; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Contracts\Service\ServiceProviderInterface; /** * A console command for retrieving information about event dispatcher. @@ -120,6 +123,31 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } + public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void + { + if ($input->mustSuggestArgumentValuesFor('event')) { + $dispatcherServiceName = $input->getOption('dispatcher'); + if ($this->dispatchers->has($dispatcherServiceName)) { + $dispatcher = $this->dispatchers->get($dispatcherServiceName); + $suggestions->suggestValues(array_keys($dispatcher->getListeners())); + } + + return; + } + + if ($input->mustSuggestOptionValuesFor('dispatcher')) { + if ($this->dispatchers instanceof ServiceProviderInterface) { + $suggestions->suggestValues(array_keys($this->dispatchers->getProvidedServices())); + } + + return; + } + + if ($input->mustSuggestOptionValuesFor('format')) { + $suggestions->suggestValues((new DescriptorHelper())->getFormats()); + } + } + private function searchForEvent(EventDispatcherInterface $dispatcher, string $needle): array { $output = []; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php new file mode 100644 index 000000000000..57e2487dd6b9 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php @@ -0,0 +1,70 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Tests\Command; + +use PHPUnit\Framework\TestCase; +use Symfony\Bundle\FrameworkBundle\Command\EventDispatcherDebugCommand; +use Symfony\Component\Console\Tester\CommandCompletionTester; +use Symfony\Component\DependencyInjection\ServiceLocator; +use Symfony\Component\EventDispatcher\EventDispatcher; + +class EventDispatcherDebugCommandTest extends TestCase +{ + /** + * @dataProvider provideCompletionSuggestions + */ + public function testComplete(array $input, array $expectedSuggestions) + { + $tester = $this->createCommandCompletionTester(); + + $suggestions = $tester->complete($input); + + $this->assertSame($expectedSuggestions, $suggestions); + } + + public function provideCompletionSuggestions() + { + yield 'event' => [[''], ['Symfony\Component\Mailer\Event\MessageEvent', 'console.command']]; + yield 'event for other dispatcher' => [['--dispatcher', 'other_event_dispatcher', ''], ['other_event', 'App\OtherEvent']]; + yield 'dispatcher' => [['--dispatcher='], ['event_dispatcher', 'other_event_dispatcher']]; + yield 'format' => [['--format='], ['txt', 'xml', 'json', 'md']]; + } + + private function createCommandCompletionTester(): CommandCompletionTester + { + $dispatcher = new EventDispatcher(); + $otherDispatcher = new EventDispatcher(); + + $dispatcher->addListener('event', 'Listener'); + $otherDispatcher->addListener('other_event', 'OtherListener'); + + $dispatchers = new ServiceLocator([ + 'event_dispatcher' => function () { + $dispatcher = new EventDispatcher(); + $dispatcher->addListener('Symfony\Component\Mailer\Event\MessageEvent', 'var_dump'); + $dispatcher->addListener('console.command', 'var_dump'); + + return $dispatcher; + }, + 'other_event_dispatcher' => function () { + $dispatcher = new EventDispatcher(); + $dispatcher->addListener('other_event', 'var_dump'); + $dispatcher->addListener('App\OtherEvent', 'var_dump'); + + return $dispatcher; + }, + ]); + $command = new EventDispatcherDebugCommand($dispatchers); + + return new CommandCompletionTester($command); + } +} From cbac3133c5875b28addebf2741593ec1e4048670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20S=CC=8Cakalys?= Date: Mon, 29 Nov 2021 10:40:48 +0200 Subject: [PATCH 27/37] Increased the reserved memory from 10k to 32k The ErrorHandler's job includes handling out of memory (OOM) exceptions, therefore it is imoprtant that that feature works. In the current state, when handling OOM exceptions, the error handler produces an OOM error itself, because the old 10k reserve is apparently not enough anymore. To mitigate that, the reserved memory gets bumped to 32k (which is enouogh). --- src/Symfony/Component/Debug/ErrorHandler.php | 2 +- src/Symfony/Component/ErrorHandler/ErrorHandler.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index fd22f201adef..99791f9aad9f 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -119,7 +119,7 @@ class ErrorHandler public static function register(self $handler = null, $replace = true) { if (null === self::$reservedMemory) { - self::$reservedMemory = str_repeat('x', 10240); + self::$reservedMemory = str_repeat('x', 32768); register_shutdown_function(__CLASS__.'::handleFatalError'); } diff --git a/src/Symfony/Component/ErrorHandler/ErrorHandler.php b/src/Symfony/Component/ErrorHandler/ErrorHandler.php index 4c4d7dc361cb..9e523fd4c11f 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/ErrorHandler.php @@ -111,7 +111,7 @@ class ErrorHandler public static function register(self $handler = null, bool $replace = true): self { if (null === self::$reservedMemory) { - self::$reservedMemory = str_repeat('x', 10240); + self::$reservedMemory = str_repeat('x', 32768); register_shutdown_function(__CLASS__.'::handleFatalError'); } From 4243335012c0f3f16ee3707d367e2b25f3efef24 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Mon, 29 Nov 2021 13:29:37 +0100 Subject: [PATCH 28/37] Fix redundant type casts --- .../Bridge/Doctrine/Form/Type/DoctrineType.php | 2 +- .../DeprecationErrorHandler/Configuration.php | 2 +- ...ExtensionBootstrap5HorizontalLayoutTest.php | 18 +++++++++--------- .../FormExtensionBootstrap5LayoutTest.php | 18 +++++++++--------- .../Component/Console/Question/Question.php | 11 ++++------- .../DependencyInjection/Definition.php | 2 +- .../ParameterBag/ParameterBag.php | 2 +- .../Component/Form/AbstractRendererEngine.php | 2 +- src/Symfony/Component/Form/FormFactory.php | 2 +- .../Component/Ldap/Adapter/ExtLdap/Adapter.php | 2 +- .../Component/Translation/Translator.php | 2 +- .../Mapping/Loader/AbstractLoader.php | 2 +- .../Component/VarDumper/Cloner/Data.php | 4 ++-- 13 files changed, 33 insertions(+), 36 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php index 324d5d26d4b0..3dc87f5af0a3 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php @@ -75,7 +75,7 @@ public static function createChoiceLabel(object $choice): string */ public static function createChoiceName(object $choice, $key, string $value): string { - return str_replace('-', '_', (string) $value); + return str_replace('-', '_', $value); } /** diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php index 99248c508cca..4420ef3d0e46 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php @@ -107,7 +107,7 @@ private function __construct(array $thresholds = [], $regex = '', $verboseOutput if (!isset($this->verboseOutput[$group])) { throw new \InvalidArgumentException(sprintf('Unsupported verbosity group "%s", expected one of "%s".', $group, implode('", "', array_keys($this->verboseOutput)))); } - $this->verboseOutput[$group] = (bool) $status; + $this->verboseOutput[$group] = $status; } if ($generateBaseline && !$baselineFile) { diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php index 042cbf0e40a7..ef924884a475 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php @@ -59,7 +59,7 @@ protected function setUp(): void protected function renderForm(FormView $view, array $vars = []): string { - return (string) $this->renderer->renderBlock($view, 'form', $vars); + return $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = []): string @@ -68,42 +68,42 @@ protected function renderLabel(FormView $view, $label = null, array $vars = []): $vars += ['label' => $label]; } - return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); + return $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderHelp(FormView $view): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'help'); + return $this->renderer->searchAndRenderBlock($view, 'help'); } protected function renderErrors(FormView $view): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); + return $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = []): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); + return $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = []): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); + return $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = []): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); + return $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = []): string { - return (string) $this->renderer->renderBlock($view, 'form_start', $vars); + return $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = []): string { - return (string) $this->renderer->renderBlock($view, 'form_end', $vars); + return $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true): void diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php index 1bf4a315fab0..8c0e54744f96 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap5LayoutTest.php @@ -111,7 +111,7 @@ public function testMoneyWidgetInIso() protected function renderForm(FormView $view, array $vars = []): string { - return (string) $this->renderer->renderBlock($view, 'form', $vars); + return $this->renderer->renderBlock($view, 'form', $vars); } protected function renderLabel(FormView $view, $label = null, array $vars = []): string @@ -120,42 +120,42 @@ protected function renderLabel(FormView $view, $label = null, array $vars = []): $vars += ['label' => $label]; } - return (string) $this->renderer->searchAndRenderBlock($view, 'label', $vars); + return $this->renderer->searchAndRenderBlock($view, 'label', $vars); } protected function renderHelp(FormView $view): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'help'); + return $this->renderer->searchAndRenderBlock($view, 'help'); } protected function renderErrors(FormView $view): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'errors'); + return $this->renderer->searchAndRenderBlock($view, 'errors'); } protected function renderWidget(FormView $view, array $vars = []): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'widget', $vars); + return $this->renderer->searchAndRenderBlock($view, 'widget', $vars); } protected function renderRow(FormView $view, array $vars = []): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'row', $vars); + return $this->renderer->searchAndRenderBlock($view, 'row', $vars); } protected function renderRest(FormView $view, array $vars = []): string { - return (string) $this->renderer->searchAndRenderBlock($view, 'rest', $vars); + return $this->renderer->searchAndRenderBlock($view, 'rest', $vars); } protected function renderStart(FormView $view, array $vars = []): string { - return (string) $this->renderer->renderBlock($view, 'form_start', $vars); + return $this->renderer->renderBlock($view, 'form_start', $vars); } protected function renderEnd(FormView $view, array $vars = []): string { - return (string) $this->renderer->renderBlock($view, 'form_end', $vars); + return $this->renderer->renderBlock($view, 'form_end', $vars); } protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true): void diff --git a/src/Symfony/Component/Console/Question/Question.php b/src/Symfony/Component/Console/Question/Question.php index 04d2d411d6e5..553be3404e03 100644 --- a/src/Symfony/Component/Console/Question/Question.php +++ b/src/Symfony/Component/Console/Question/Question.php @@ -105,7 +105,7 @@ public function setHidden(bool $hidden) throw new LogicException('A hidden question cannot use the autocompleter.'); } - $this->hidden = (bool) $hidden; + $this->hidden = $hidden; return $this; } @@ -127,7 +127,7 @@ public function isHiddenFallback() */ public function setHiddenFallback(bool $fallback) { - $this->hiddenFallback = (bool) $fallback; + $this->hiddenFallback = $fallback; return $this; } @@ -230,11 +230,8 @@ public function getValidator() */ public function setMaxAttempts(?int $attempts) { - if (null !== $attempts) { - $attempts = (int) $attempts; - if ($attempts < 1) { - throw new InvalidArgumentException('Maximum number of attempts must be a positive value.'); - } + if (null !== $attempts && $attempts < 1) { + throw new InvalidArgumentException('Maximum number of attempts must be a positive value.'); } $this->attempts = $attempts; diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 90f8f886cd94..9d711f8982f4 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -146,7 +146,7 @@ public function setDecoratedService(?string $id, string $renamedId = null, int $ if (null === $id) { $this->decoratedService = null; } else { - $this->decoratedService = [$id, $renamedId, (int) $priority]; + $this->decoratedService = [$id, $renamedId, $priority]; if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) { $this->decoratedService[] = $invalidBehavior; diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index fad04fc6df08..41da2c7267a4 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php @@ -109,7 +109,7 @@ public function set(string $name, $value) */ public function has(string $name) { - return \array_key_exists((string) $name, $this->parameters); + return \array_key_exists($name, $this->parameters); } /** diff --git a/src/Symfony/Component/Form/AbstractRendererEngine.php b/src/Symfony/Component/Form/AbstractRendererEngine.php index b4437471234a..33e66f84fc62 100644 --- a/src/Symfony/Component/Form/AbstractRendererEngine.php +++ b/src/Symfony/Component/Form/AbstractRendererEngine.php @@ -68,7 +68,7 @@ public function setTheme(FormView $view, $themes, bool $useDefaultThemes = true) // Do not cast, as casting turns objects into arrays of properties $this->themes[$cacheKey] = \is_array($themes) ? $themes : [$themes]; - $this->useDefaultThemes[$cacheKey] = (bool) $useDefaultThemes; + $this->useDefaultThemes[$cacheKey] = $useDefaultThemes; // Unset instead of resetting to an empty array, in order to allow // implementations (like TwigRendererEngine) to check whether $cacheKey diff --git a/src/Symfony/Component/Form/FormFactory.php b/src/Symfony/Component/Form/FormFactory.php index 959f6bcf782a..b3185d1a376c 100644 --- a/src/Symfony/Component/Form/FormFactory.php +++ b/src/Symfony/Component/Form/FormFactory.php @@ -66,7 +66,7 @@ public function createNamedBuilder(string $name, string $type = FormType::class, $type = $this->registry->getType($type); - $builder = $type->createBuilder($this, (string) $name, $options); + $builder = $type->createBuilder($this, $name, $options); // Explicitly call buildForm() in order to be able to override either // createBuilder() or buildForm() in the resolved form type diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php index 3106ba3ce4aa..ff6d4d9f6a02 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Adapter.php @@ -72,7 +72,7 @@ public function escape(string $subject, string $ignore = '', int $flags = 0) $value = ldap_escape($subject, $ignore, $flags); // Per RFC 4514, leading/trailing spaces should be encoded in DNs, as well as carriage returns. - if ((int) $flags & \LDAP_ESCAPE_DN) { + if ($flags & \LDAP_ESCAPE_DN) { if (!empty($value) && ' ' === $value[0]) { $value = '\\20'.substr($value, 1); } diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index c432b8867fd0..ccdf88f11d11 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -455,7 +455,7 @@ protected function computeFallbackLocales(string $locale) */ protected function assertValidLocale(string $locale) { - if (!preg_match('/^[a-z0-9@_\\.\\-]*$/i', (string) $locale)) { + if (!preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) { throw new InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale)); } } diff --git a/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php index 74f445085e47..9f6667f836f9 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php @@ -67,7 +67,7 @@ protected function addNamespaceAlias(string $alias, string $namespace) protected function newConstraint(string $name, $options = null) { if (str_contains($name, '\\') && class_exists($name)) { - $className = (string) $name; + $className = $name; } elseif (str_contains($name, ':')) { [$prefix, $className] = explode(':', $name, 2); diff --git a/src/Symfony/Component/VarDumper/Cloner/Data.php b/src/Symfony/Component/VarDumper/Cloner/Data.php index b17dc55e27db..b8238c6e071e 100644 --- a/src/Symfony/Component/VarDumper/Cloner/Data.php +++ b/src/Symfony/Component/VarDumper/Cloner/Data.php @@ -207,7 +207,7 @@ public function __toString() public function withMaxDepth(int $maxDepth) { $data = clone $this; - $data->maxDepth = (int) $maxDepth; + $data->maxDepth = $maxDepth; return $data; } @@ -220,7 +220,7 @@ public function withMaxDepth(int $maxDepth) public function withMaxItemsPerDepth(int $maxItemsPerDepth) { $data = clone $this; - $data->maxItemsPerDepth = (int) $maxItemsPerDepth; + $data->maxItemsPerDepth = $maxItemsPerDepth; return $data; } From a3802e2547a59433efc0a92a1e323640230c162a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 25 Nov 2021 12:14:54 +0100 Subject: [PATCH 29/37] [Notifier] add Vonage bridge to replace the Nexmo one --- .../FrameworkExtension.php | 2 + .../Resources/config/notifier_transports.php | 6 ++ .../Notifier/Bridge/Nexmo/NexmoTransport.php | 4 + .../Bridge/Nexmo/NexmoTransportFactory.php | 2 + .../Component/Notifier/Bridge/Nexmo/README.md | 14 +-- .../Nexmo/Tests/NexmoTransportFactoryTest.php | 3 + .../Bridge/Nexmo/Tests/NexmoTransportTest.php | 3 + .../Notifier/Bridge/Nexmo/composer.json | 1 + .../Notifier/Bridge/Vonage/.gitattributes | 4 + .../Notifier/Bridge/Vonage/.gitignore | 3 + .../Notifier/Bridge/Vonage/CHANGELOG.md | 7 ++ .../Component/Notifier/Bridge/Vonage/LICENSE | 19 ++++ .../Notifier/Bridge/Vonage/README.md | 24 +++++ .../Tests/VonageTransportFactoryTest.php | 52 +++++++++++ .../Vonage/Tests/VonageTransportTest.php | 47 ++++++++++ .../Bridge/Vonage/VonageTransport.php | 90 +++++++++++++++++++ .../Bridge/Vonage/VonageTransportFactory.php | 48 ++++++++++ .../Notifier/Bridge/Vonage/composer.json | 30 +++++++ .../Notifier/Bridge/Vonage/phpunit.xml.dist | 31 +++++++ .../Exception/UnsupportedSchemeException.php | 4 + .../UnsupportedSchemeExceptionTest.php | 2 + src/Symfony/Component/Notifier/Transport.php | 2 + 22 files changed, 385 insertions(+), 13 deletions(-) create mode 100644 src/Symfony/Component/Notifier/Bridge/Vonage/.gitattributes create mode 100644 src/Symfony/Component/Notifier/Bridge/Vonage/.gitignore create mode 100644 src/Symfony/Component/Notifier/Bridge/Vonage/CHANGELOG.md create mode 100644 src/Symfony/Component/Notifier/Bridge/Vonage/LICENSE create mode 100644 src/Symfony/Component/Notifier/Bridge/Vonage/README.md create mode 100644 src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportFactoryTest.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportTest.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransport.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransportFactory.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Vonage/composer.json create mode 100644 src/Symfony/Component/Notifier/Bridge/Vonage/phpunit.xml.dist diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 22517ad5c7d3..b58d398f1ba6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -157,6 +157,7 @@ use Symfony\Component\Notifier\Bridge\Telnyx\TelnyxTransportFactory; use Symfony\Component\Notifier\Bridge\TurboSms\TurboSmsTransport; use Symfony\Component\Notifier\Bridge\Twilio\TwilioTransportFactory; +use Symfony\Component\Notifier\Bridge\Vonage\VonageTransportFactory; use Symfony\Component\Notifier\Bridge\Yunpian\YunpianTransportFactory; use Symfony\Component\Notifier\Bridge\Zulip\ZulipTransportFactory; use Symfony\Component\Notifier\Notifier; @@ -2540,6 +2541,7 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $ TelnyxTransportFactory::class => 'notifier.transport_factory.telnyx', TurboSmsTransport::class => 'notifier.transport_factory.turbo-sms', TwilioTransportFactory::class => 'notifier.transport_factory.twilio', + VonageTransportFactory::class => 'notifier.transport_factory.vonage', YunpianTransportFactory::class => 'notifier.transport_factory.yunpian', ZulipTransportFactory::class => 'notifier.transport_factory.zulip', ]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php index 18620b30832c..8e3bb4ce2abe 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php @@ -52,6 +52,7 @@ use Symfony\Component\Notifier\Bridge\Telnyx\TelnyxTransportFactory; use Symfony\Component\Notifier\Bridge\TurboSms\TurboSmsTransportFactory; use Symfony\Component\Notifier\Bridge\Twilio\TwilioTransportFactory; +use Symfony\Component\Notifier\Bridge\Vonage\VonageTransportFactory; use Symfony\Component\Notifier\Bridge\Yunpian\YunpianTransportFactory; use Symfony\Component\Notifier\Bridge\Zulip\ZulipTransportFactory; use Symfony\Component\Notifier\Transport\AbstractTransportFactory; @@ -109,6 +110,11 @@ ->set('notifier.transport_factory.nexmo', NexmoTransportFactory::class) ->parent('notifier.transport_factory.abstract') ->tag('texter.transport_factory') + ->deprecate('symfony/framework-bundle', '5.4', 'The "%service_id% service is deprecated, use "notifier.transport_factory.vonage" instead.') + + ->set('notifier.transport_factory.vonage', VonageTransportFactory::class) + ->parent('notifier.transport_factory.abstract') + ->tag('texter.transport_factory') ->set('notifier.transport_factory.rocket-chat', RocketChatTransportFactory::class) ->parent('notifier.transport_factory.abstract') diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php b/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php index 70313fb9f50f..c69aeb6b4c0f 100644 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Notifier\Bridge\Nexmo; +trigger_deprecation('symfony/nexmo-notifier', '5.4', 'The "symfony/nexmo-notifier" package is deprecated, use "symfony/vonage-notifier" instead.'); + use Symfony\Component\Notifier\Exception\TransportException; use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; @@ -23,6 +25,8 @@ /** * @author Fabien Potencier + * + * @deprecated since Symfony 5.4, use the Vonage bridge instead. */ final class NexmoTransport extends AbstractTransport { diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransportFactory.php index 6c7287b39865..f00b9232860b 100644 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransportFactory.php @@ -18,6 +18,8 @@ /** * @author Fabien Potencier + * + * @deprecated since Symfony 5.4, use the Vonage bridge instead. */ final class NexmoTransportFactory extends AbstractTransportFactory { diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/README.md b/src/Symfony/Component/Notifier/Bridge/Nexmo/README.md index 71b63069f5c0..24006aabb35c 100644 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/README.md +++ b/src/Symfony/Component/Notifier/Bridge/Nexmo/README.md @@ -1,19 +1,7 @@ Nexmo Notifier ============== -Provides [Nexmo](https://nexmo.com) integration for Symfony Notifier. - -DSN example ------------ - -``` -NEXMO_DSN=nexmo://KEY:SECRET@default?from=FROM -``` - -where: - - `KEY` is your Nexmo key - - `SECRET` is your Nexmo secret - - `FROM` is your sender +The Nexmo bridge is deprecated, use the Vonage bridge instead. Resources --------- diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportFactoryTest.php index a44545b069e5..907b98e1ccf7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportFactoryTest.php @@ -15,6 +15,9 @@ use Symfony\Component\Notifier\Test\TransportFactoryTestCase; use Symfony\Component\Notifier\Transport\TransportFactoryInterface; +/** + * @group legacy + */ final class NexmoTransportFactoryTest extends TransportFactoryTestCase { /** diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportTest.php index 8473b3a8888a..d52014957b1c 100644 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportTest.php @@ -19,6 +19,9 @@ use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; +/** + * @group legacy + */ final class NexmoTransportTest extends TransportTestCase { /** diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json b/src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json index 8f2051c4c5ac..8550289e8542 100644 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json @@ -17,6 +17,7 @@ ], "require": { "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", "symfony/http-client": "^4.3|^5.0|^6.0", "symfony/notifier": "^5.3|^6.0" }, diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/.gitattributes b/src/Symfony/Component/Notifier/Bridge/Vonage/.gitattributes new file mode 100644 index 000000000000..84c7add058fb --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/.gitattributes @@ -0,0 +1,4 @@ +/Tests export-ignore +/phpunit.xml.dist export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/.gitignore b/src/Symfony/Component/Notifier/Bridge/Vonage/.gitignore new file mode 100644 index 000000000000..c49a5d8df5c6 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +phpunit.xml diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Vonage/CHANGELOG.md new file mode 100644 index 000000000000..3a08c7ededfc --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/CHANGELOG.md @@ -0,0 +1,7 @@ +CHANGELOG +========= + +5.4 +--- + + * Add the bridge diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/LICENSE b/src/Symfony/Component/Notifier/Bridge/Vonage/LICENSE new file mode 100644 index 000000000000..efb17f98e7dd --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2021 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/README.md b/src/Symfony/Component/Notifier/Bridge/Vonage/README.md new file mode 100644 index 000000000000..5f43d5e0ec6c --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/README.md @@ -0,0 +1,24 @@ +Vonage Notifier +=============== + +Provides [Vonage](https://vonage.com) integration for Symfony Notifier. + +DSN example +----------- + +``` +VONAGE_DSN=vonage://KEY:SECRET@default?from=FROM +``` + +where: + - `KEY` is your Vonage key + - `SECRET` is your Vonage secret + - `FROM` is your sender + +Resources +--------- + + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportFactoryTest.php new file mode 100644 index 000000000000..b25b54982884 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportFactoryTest.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Bridge\Vonage\Tests; + +use Symfony\Component\Notifier\Bridge\Vonage\VonageTransportFactory; +use Symfony\Component\Notifier\Test\TransportFactoryTestCase; +use Symfony\Component\Notifier\Transport\TransportFactoryInterface; + +final class VonageTransportFactoryTest extends TransportFactoryTestCase +{ + /** + * @return VonageTransportFactory + */ + public function createFactory(): TransportFactoryInterface + { + return new VonageTransportFactory(); + } + + public function createProvider(): iterable + { + yield [ + 'vonage://host.test?from=0611223344', + 'vonage://apiKey:apiSecret@host.test?from=0611223344', + ]; + } + + public function supportsProvider(): iterable + { + yield [true, 'vonage://apiKey:apiSecret@default?from=0611223344']; + yield [false, 'somethingElse://apiKey:apiSecret@default?from=0611223344']; + } + + public function missingRequiredOptionProvider(): iterable + { + yield 'missing option: from' => ['vonage://apiKey:apiSecret@default']; + } + + public function unsupportedSchemeProvider(): iterable + { + yield ['somethingElse://apiKey:apiSecret@default?from=0611223344']; + yield ['somethingElse://apiKey:apiSecret@default']; // missing "from" option + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportTest.php new file mode 100644 index 000000000000..dc545a02a9d7 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportTest.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Bridge\Vonage\Tests; + +use Symfony\Component\Notifier\Bridge\Vonage\VonageTransport; +use Symfony\Component\Notifier\Message\ChatMessage; +use Symfony\Component\Notifier\Message\MessageInterface; +use Symfony\Component\Notifier\Message\SmsMessage; +use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Transport\TransportInterface; +use Symfony\Contracts\HttpClient\HttpClientInterface; + +final class VonageTransportTest extends TransportTestCase +{ + /** + * @return VonageTransport + */ + public function createTransport(HttpClientInterface $client = null): TransportInterface + { + return new VonageTransport('apiKey', 'apiSecret', 'sender', $client ?? $this->createMock(HttpClientInterface::class)); + } + + public function toStringProvider(): iterable + { + yield ['vonage://rest.nexmo.com?from=sender', $this->createTransport()]; + } + + public function supportedMessagesProvider(): iterable + { + yield [new SmsMessage('0611223344', 'Hello!')]; + } + + public function unsupportedMessagesProvider(): iterable + { + yield [new ChatMessage('Hello!')]; + yield [$this->createMock(MessageInterface::class)]; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransport.php b/src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransport.php new file mode 100644 index 000000000000..f47f41a70fef --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransport.php @@ -0,0 +1,90 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Bridge\Vonage; + +use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; +use Symfony\Component\Notifier\Message\MessageInterface; +use Symfony\Component\Notifier\Message\SentMessage; +use Symfony\Component\Notifier\Message\SmsMessage; +use Symfony\Component\Notifier\Transport\AbstractTransport; +use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; +use Symfony\Contracts\HttpClient\HttpClientInterface; + +/** + * @author Fabien Potencier + */ +final class VonageTransport extends AbstractTransport +{ + // see https://developer.vonage.com/messaging/sms/overview + protected const HOST = 'rest.nexmo.com'; + + private $apiKey; + private $apiSecret; + private $from; + + public function __construct(string $apiKey, string $apiSecret, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) + { + $this->apiKey = $apiKey; + $this->apiSecret = $apiSecret; + $this->from = $from; + + parent::__construct($client, $dispatcher); + } + + public function __toString(): string + { + return sprintf('vonage://%s?from=%s', $this->getEndpoint(), $this->from); + } + + public function supports(MessageInterface $message): bool + { + return $message instanceof SmsMessage; + } + + protected function doSend(MessageInterface $message): SentMessage + { + if (!$message instanceof SmsMessage) { + throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message); + } + + $response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/sms/json', [ + 'body' => [ + 'from' => $this->from, + 'to' => $message->getPhone(), + 'text' => $message->getSubject(), + 'api_key' => $this->apiKey, + 'api_secret' => $this->apiSecret, + ], + ]); + + try { + $result = $response->toArray(false); + } catch (TransportExceptionInterface $e) { + throw new TransportException('Could not reach the remote Vonage server.', $response, 0, $e); + } + + foreach ($result['messages'] as $msg) { + if ($msg['status'] ?? false) { + throw new TransportException('Unable to send the SMS: '.$msg['error-text'].sprintf(' (code %s).', $msg['status']), $response); + } + } + + $success = $response->toArray(false); + + $sentMessage = new SentMessage($message, (string) $this); + $sentMessage->setMessageId($success['messages'][0]['message-id']); + + return $sentMessage; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransportFactory.php new file mode 100644 index 000000000000..c0f23b242548 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransportFactory.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Bridge\Vonage; + +use Symfony\Component\Notifier\Exception\UnsupportedSchemeException; +use Symfony\Component\Notifier\Transport\AbstractTransportFactory; +use Symfony\Component\Notifier\Transport\Dsn; +use Symfony\Component\Notifier\Transport\TransportInterface; + +/** + * @author Fabien Potencier + */ +final class VonageTransportFactory extends AbstractTransportFactory +{ + /** + * @return VonageTransport + */ + public function create(Dsn $dsn): TransportInterface + { + $scheme = $dsn->getScheme(); + + if ('vonage' !== $scheme) { + throw new UnsupportedSchemeException($dsn, 'vonage', $this->getSupportedSchemes()); + } + + $apiKey = $this->getUser($dsn); + $apiSecret = $this->getPassword($dsn); + $from = $dsn->getRequiredOption('from'); + $host = 'default' === $dsn->getHost() ? null : $dsn->getHost(); + $port = $dsn->getPort(); + + return (new VonageTransport($apiKey, $apiSecret, $from, $this->client, $this->dispatcher))->setHost($host)->setPort($port); + } + + protected function getSupportedSchemes(): array + { + return ['vonage']; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/composer.json b/src/Symfony/Component/Notifier/Bridge/Vonage/composer.json new file mode 100644 index 000000000000..c80b016feaaa --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/composer.json @@ -0,0 +1,30 @@ +{ + "name": "symfony/vonage-notifier", + "type": "symfony-notifier-bridge", + "description": "Symfony Vonage Notifier Bridge", + "keywords": ["sms", "vonage", "notifier"], + "homepage": "https://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "require": { + "php": ">=7.2.5", + "symfony/http-client": "^4.3|^5.0|^6.0", + "symfony/notifier": "^5.3|^6.0" + }, + "autoload": { + "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Vonage\\": "" }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "minimum-stability": "dev" +} diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/phpunit.xml.dist b/src/Symfony/Component/Notifier/Bridge/Vonage/phpunit.xml.dist new file mode 100644 index 000000000000..84bc254ccab0 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + + + + + + ./Tests/ + + + + + + ./ + + ./Resources + ./Tests + ./vendor + + + + diff --git a/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php b/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php index 0e7628f2f155..ebe0cef610df 100644 --- a/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php +++ b/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php @@ -184,6 +184,10 @@ class UnsupportedSchemeException extends LogicException 'class' => Bridge\Twilio\TwilioTransportFactory::class, 'package' => 'symfony/twilio-notifier', ], + 'vonage' => [ + 'class' => Bridge\Vonage\VonageTransportFactory::class, + 'package' => 'symfony/vonage-notifier', + ], 'yunpian' => [ 'class' => Bridge\Yunpian\YunpianTransportFactory::class, 'package' => 'symfony/yunpian-notifier', diff --git a/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php b/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php index 05ef2ed96417..1cd8d4033eb4 100644 --- a/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php +++ b/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php @@ -53,6 +53,7 @@ use Symfony\Component\Notifier\Bridge\Telnyx\TelnyxTransportFactory; use Symfony\Component\Notifier\Bridge\TurboSms\TurboSmsTransportFactory; use Symfony\Component\Notifier\Bridge\Twilio\TwilioTransportFactory; +use Symfony\Component\Notifier\Bridge\Vonage\VonageTransportFactory; use Symfony\Component\Notifier\Bridge\Yunpian\YunpianTransportFactory; use Symfony\Component\Notifier\Bridge\Zulip\ZulipTransportFactory; use Symfony\Component\Notifier\Exception\UnsupportedSchemeException; @@ -107,6 +108,7 @@ public static function setUpBeforeClass(): void TelnyxTransportFactory::class => false, TurboSmsTransportFactory::class => false, TwilioTransportFactory::class => false, + VonageTransportFactory::class => false, YunpianTransportFactory::class => false, ZulipTransportFactory::class => false, ]); diff --git a/src/Symfony/Component/Notifier/Transport.php b/src/Symfony/Component/Notifier/Transport.php index a8ca4c91e6fa..9944573630e6 100644 --- a/src/Symfony/Component/Notifier/Transport.php +++ b/src/Symfony/Component/Notifier/Transport.php @@ -45,6 +45,7 @@ use Symfony\Component\Notifier\Bridge\Telnyx\TelnyxTransportFactory; use Symfony\Component\Notifier\Bridge\TurboSms\TurboSmsTransportFactory; use Symfony\Component\Notifier\Bridge\Twilio\TwilioTransportFactory; +use Symfony\Component\Notifier\Bridge\Vonage\VonageTransportFactory; use Symfony\Component\Notifier\Bridge\Yunpian\YunpianTransportFactory; use Symfony\Component\Notifier\Bridge\Zulip\ZulipTransportFactory; use Symfony\Component\Notifier\Exception\UnsupportedSchemeException; @@ -100,6 +101,7 @@ class Transport TelnyxTransportFactory::class, TurboSmsTransportFactory::class, TwilioTransportFactory::class, + VonageTransportFactory::class, YunpianTransportFactory::class, ZulipTransportFactory::class, ]; From 653a21d9756196c59417dcc4c3c860487b742ed3 Mon Sep 17 00:00:00 2001 From: HypeMC Date: Mon, 29 Nov 2021 08:33:54 +0100 Subject: [PATCH 30/37] [Validator] Fix validation for single level domains --- .../Validator/Constraints/UrlValidator.php | 8 +++++++- .../Tests/Constraints/UrlValidatorTest.php | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Validator/Constraints/UrlValidator.php b/src/Symfony/Component/Validator/Constraints/UrlValidator.php index 5bac10c8fe60..1150a8ab8e03 100644 --- a/src/Symfony/Component/Validator/Constraints/UrlValidator.php +++ b/src/Symfony/Component/Validator/Constraints/UrlValidator.php @@ -26,7 +26,13 @@ class UrlValidator extends ConstraintValidator (%s):// # protocol (((?:[\_\.\pL\pN-]|%%[0-9A-Fa-f]{2})+:)?((?:[\_\.\pL\pN-]|%%[0-9A-Fa-f]{2})+)@)? # basic auth ( - ([\pL\pN\pS\-\_]+\.)*(([\pL\pN]|xn\-\-[\pL\pN-]+)+\.?) # a domain name + (?: + (?:xn--[a-z0-9-]++\.)*+xn--[a-z0-9-]++ # a domain name using punycode + | + (?:[\pL\pN\pS\pM\-\_]++\.)+[\pL\pN\pM]++ # a multi-level domain name + | + [a-z0-9\-\_]++ # a single-level domain name + )\.? | # or \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} # an IP address | # or diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php index b224671c5340..26d0f34cc812 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php @@ -128,6 +128,10 @@ public function getValidUrls() ['http://very.long.domain.name.com/'], ['http://localhost/'], ['http://myhost123/'], + ['http://internal-api'], + ['http://internal-api.'], + ['http://internal-api/'], + ['http://internal-api/path'], ['http://127.0.0.1/'], ['http://127.0.0.1:80/'], ['http://[::1]/'], @@ -174,6 +178,7 @@ public function getValidUrls() ['http://symfony.com/#fragment'], ['http://symfony.com/#one_more%20test'], ['http://example.com/exploit.html?hello[0]=test'], + ['http://বিডিআইএ.বাংলা'], ]; } @@ -259,7 +264,14 @@ public function getInvalidUrls() ['http://127.0.0.1:aa/'], ['ftp://[::1]/'], ['http://[::1'], + ['http://☎'], + ['http://☎.'], + ['http://☎/'], + ['http://☎/path'], + ['http://hello.☎'], + ['http://hello.☎.'], ['http://hello.☎/'], + ['http://hello.☎/path'], ['http://:password@symfony.com'], ['http://:password@@symfony.com'], ['http://username:passwordsymfony.com'], @@ -276,6 +288,9 @@ public function getInvalidUrls() ['http://.m.example.com'], ['http://wwww.example..com'], ['http://.www.example.com'], + ['http://example.co-'], + ['http://example.co-/path'], + ['http:///path'], ]; } From ce1ee7459e5a2213e39ab8f209eb0364deea8da1 Mon Sep 17 00:00:00 2001 From: stlrnz Date: Wed, 10 Nov 2021 11:44:45 +0100 Subject: [PATCH 31/37] [Security] Do not overwrite already stored tokens for REMOTE_USER authentication --- .../AbstractPreAuthenticatedAuthenticator.php | 11 +++++++++++ .../Authenticator/RemoteUserAuthenticatorTest.php | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/Symfony/Component/Security/Http/Authenticator/AbstractPreAuthenticatedAuthenticator.php b/src/Symfony/Component/Security/Http/Authenticator/AbstractPreAuthenticatedAuthenticator.php index a5736aecd800..7317967125e1 100644 --- a/src/Symfony/Component/Security/Http/Authenticator/AbstractPreAuthenticatedAuthenticator.php +++ b/src/Symfony/Component/Security/Http/Authenticator/AbstractPreAuthenticatedAuthenticator.php @@ -79,6 +79,17 @@ public function supports(Request $request): ?bool return false; } + // do not overwrite already stored tokens from the same user (i.e. from the session) + $token = $this->tokenStorage->getToken(); + + if ($token instanceof PreAuthenticatedToken && $this->firewallName === $token->getFirewallName() && $token->getUserIdentifier() === $username) { + if (null !== $this->logger) { + $this->logger->debug('Skipping pre-authenticated authenticator as the user already has an existing session.', ['authenticator' => static::class]); + } + + return false; + } + $request->attributes->set('_pre_authenticated_username', $username); return true; diff --git a/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php b/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php index 46454e6aaf86..d1322ec4a316 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; use Symfony\Component\Security\Core\User\InMemoryUser; use Symfony\Component\Security\Core\User\InMemoryUserProvider; @@ -37,6 +38,17 @@ public function testSupportNoUser() $this->assertFalse($authenticator->supports($this->createRequest([]))); } + public function testSupportTokenStorageWithToken() + { + $tokenStorage = new TokenStorage(); + $tokenStorage->setToken(new PreAuthenticatedToken('username', 'credentials', 'main')); + + $authenticator = new RemoteUserAuthenticator(new InMemoryUserProvider(), $tokenStorage, 'main'); + + $this->assertFalse($authenticator->supports($this->createRequest(['REMOTE_USER' => 'username']))); + $this->assertTrue($authenticator->supports($this->createRequest(['REMOTE_USER' => 'another_username']))); + } + /** * @dataProvider provideAuthenticators */ From 00bbe9e681dcc3fdc241b960969c8f1f05e48d3a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 29 Nov 2021 16:34:21 +0100 Subject: [PATCH 32/37] [Notifier] remove deprecated Nexmo bridge --- .../FrameworkExtension.php | 2 - .../Resources/config/notifier_transports.php | 6 -- .../Notifier/Bridge/Nexmo/.gitattributes | 4 - .../Notifier/Bridge/Nexmo/.gitignore | 3 - .../Notifier/Bridge/Nexmo/CHANGELOG.md | 12 --- .../Component/Notifier/Bridge/Nexmo/LICENSE | 19 ---- .../Notifier/Bridge/Nexmo/NexmoTransport.php | 93 ------------------- .../Bridge/Nexmo/NexmoTransportFactory.php | 46 --------- .../Component/Notifier/Bridge/Nexmo/README.md | 12 --- .../Nexmo/Tests/NexmoTransportFactoryTest.php | 51 ---------- .../Bridge/Nexmo/Tests/NexmoTransportTest.php | 46 --------- .../Notifier/Bridge/Nexmo/composer.json | 30 ------ .../Notifier/Bridge/Nexmo/phpunit.xml.dist | 31 ------- .../Exception/UnsupportedSchemeException.php | 4 - .../UnsupportedSchemeExceptionTest.php | 3 - src/Symfony/Component/Notifier/Transport.php | 2 - 16 files changed, 364 deletions(-) delete mode 100644 src/Symfony/Component/Notifier/Bridge/Nexmo/.gitattributes delete mode 100644 src/Symfony/Component/Notifier/Bridge/Nexmo/.gitignore delete mode 100644 src/Symfony/Component/Notifier/Bridge/Nexmo/CHANGELOG.md delete mode 100644 src/Symfony/Component/Notifier/Bridge/Nexmo/LICENSE delete mode 100644 src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php delete mode 100644 src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransportFactory.php delete mode 100644 src/Symfony/Component/Notifier/Bridge/Nexmo/README.md delete mode 100644 src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportFactoryTest.php delete mode 100644 src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportTest.php delete mode 100644 src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json delete mode 100644 src/Symfony/Component/Notifier/Bridge/Nexmo/phpunit.xml.dist diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index bfc42efa67da..a22c0593881b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -135,7 +135,6 @@ use Symfony\Component\Notifier\Bridge\MessageMedia\MessageMediaTransportFactory; use Symfony\Component\Notifier\Bridge\MicrosoftTeams\MicrosoftTeamsTransportFactory; use Symfony\Component\Notifier\Bridge\Mobyt\MobytTransportFactory; -use Symfony\Component\Notifier\Bridge\Nexmo\NexmoTransportFactory; use Symfony\Component\Notifier\Bridge\Octopush\OctopushTransportFactory; use Symfony\Component\Notifier\Bridge\OneSignal\OneSignalTransportFactory; use Symfony\Component\Notifier\Bridge\OvhCloud\OvhCloudTransportFactory; @@ -2419,7 +2418,6 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $ MessageMediaTransportFactory::class => 'notifier.transport_factory.message-media', MicrosoftTeamsTransportFactory::class => 'notifier.transport_factory.microsoft-teams', MobytTransportFactory::class => 'notifier.transport_factory.mobyt', - NexmoTransportFactory::class => 'notifier.transport_factory.nexmo', OctopushTransportFactory::class => 'notifier.transport_factory.octopush', OneSignalTransportFactory::class => 'notifier.transport_factory.one-signal', OvhCloudTransportFactory::class => 'notifier.transport_factory.ovh-cloud', diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php index 5f48650e887e..36353c7019ee 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php @@ -35,7 +35,6 @@ use Symfony\Component\Notifier\Bridge\MessageMedia\MessageMediaTransportFactory; use Symfony\Component\Notifier\Bridge\MicrosoftTeams\MicrosoftTeamsTransportFactory; use Symfony\Component\Notifier\Bridge\Mobyt\MobytTransportFactory; -use Symfony\Component\Notifier\Bridge\Nexmo\NexmoTransportFactory; use Symfony\Component\Notifier\Bridge\Octopush\OctopushTransportFactory; use Symfony\Component\Notifier\Bridge\OneSignal\OneSignalTransportFactory; use Symfony\Component\Notifier\Bridge\OvhCloud\OvhCloudTransportFactory; @@ -81,11 +80,6 @@ ->parent('notifier.transport_factory.abstract') ->tag('chatter.transport_factory') - ->set('notifier.transport_factory.nexmo', NexmoTransportFactory::class) - ->parent('notifier.transport_factory.abstract') - ->tag('texter.transport_factory') - ->deprecate('symfony/framework-bundle', '5.4', 'The "%service_id% service is deprecated, use "notifier.transport_factory.vonage" instead.') - ->set('notifier.transport_factory.vonage', VonageTransportFactory::class) ->parent('notifier.transport_factory.abstract') ->tag('texter.transport_factory') diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/.gitattributes b/src/Symfony/Component/Notifier/Bridge/Nexmo/.gitattributes deleted file mode 100644 index 84c7add058fb..000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/.gitattributes +++ /dev/null @@ -1,4 +0,0 @@ -/Tests export-ignore -/phpunit.xml.dist export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/.gitignore b/src/Symfony/Component/Notifier/Bridge/Nexmo/.gitignore deleted file mode 100644 index c49a5d8df5c6..000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Nexmo/CHANGELOG.md deleted file mode 100644 index d0d472393474..000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/CHANGELOG.md +++ /dev/null @@ -1,12 +0,0 @@ -CHANGELOG -========= - -5.3 ---- - - * The bridge is not marked as `@experimental` anymore - -5.0.0 ------ - - * Added the bridge diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/LICENSE b/src/Symfony/Component/Notifier/Bridge/Nexmo/LICENSE deleted file mode 100644 index 383e7a54586e..000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2019-2021 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php b/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php deleted file mode 100644 index 1ae81d1c58e4..000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransport.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Notifier\Bridge\Nexmo; - -trigger_deprecation('symfony/nexmo-notifier', '5.4', 'The "symfony/nexmo-notifier" package is deprecated, use "symfony/vonage-notifier" instead.'); - -use Symfony\Component\Notifier\Exception\TransportException; -use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; -use Symfony\Component\Notifier\Message\MessageInterface; -use Symfony\Component\Notifier\Message\SentMessage; -use Symfony\Component\Notifier\Message\SmsMessage; -use Symfony\Component\Notifier\Transport\AbstractTransport; -use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; -use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; -use Symfony\Contracts\HttpClient\HttpClientInterface; - -/** - * @author Fabien Potencier - * - * @deprecated since Symfony 5.4, use the Vonage bridge instead. - */ -final class NexmoTransport extends AbstractTransport -{ - protected const HOST = 'rest.nexmo.com'; - - private string $apiKey; - private string $apiSecret; - private string $from; - - public function __construct(string $apiKey, string $apiSecret, string $from, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) - { - $this->apiKey = $apiKey; - $this->apiSecret = $apiSecret; - $this->from = $from; - - parent::__construct($client, $dispatcher); - } - - public function __toString(): string - { - return sprintf('nexmo://%s?from=%s', $this->getEndpoint(), $this->from); - } - - public function supports(MessageInterface $message): bool - { - return $message instanceof SmsMessage; - } - - protected function doSend(MessageInterface $message): SentMessage - { - if (!$message instanceof SmsMessage) { - throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message); - } - - $response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/sms/json', [ - 'body' => [ - 'from' => $this->from, - 'to' => $message->getPhone(), - 'text' => $message->getSubject(), - 'api_key' => $this->apiKey, - 'api_secret' => $this->apiSecret, - ], - ]); - - try { - $result = $response->toArray(false); - } catch (TransportExceptionInterface $e) { - throw new TransportException('Could not reach the remote Nexmo server.', $response, 0, $e); - } - - foreach ($result['messages'] as $msg) { - if ($msg['status'] ?? false) { - throw new TransportException('Unable to send the SMS: '.$msg['error-text'].sprintf(' (code %s).', $msg['status']), $response); - } - } - - $success = $response->toArray(false); - - $sentMessage = new SentMessage($message, (string) $this); - $sentMessage->setMessageId($success['messages'][0]['message-id']); - - return $sentMessage; - } -} diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransportFactory.php deleted file mode 100644 index 9e3e2c5b7e04..000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/NexmoTransportFactory.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Notifier\Bridge\Nexmo; - -use Symfony\Component\Notifier\Exception\UnsupportedSchemeException; -use Symfony\Component\Notifier\Transport\AbstractTransportFactory; -use Symfony\Component\Notifier\Transport\Dsn; - -/** - * @author Fabien Potencier - * - * @deprecated since Symfony 5.4, use the Vonage bridge instead. - */ -final class NexmoTransportFactory extends AbstractTransportFactory -{ - public function create(Dsn $dsn): NexmoTransport - { - $scheme = $dsn->getScheme(); - - if ('nexmo' !== $scheme) { - throw new UnsupportedSchemeException($dsn, 'nexmo', $this->getSupportedSchemes()); - } - - $apiKey = $this->getUser($dsn); - $apiSecret = $this->getPassword($dsn); - $from = $dsn->getRequiredOption('from'); - $host = 'default' === $dsn->getHost() ? null : $dsn->getHost(); - $port = $dsn->getPort(); - - return (new NexmoTransport($apiKey, $apiSecret, $from, $this->client, $this->dispatcher))->setHost($host)->setPort($port); - } - - protected function getSupportedSchemes(): array - { - return ['nexmo']; - } -} diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/README.md b/src/Symfony/Component/Notifier/Bridge/Nexmo/README.md deleted file mode 100644 index 24006aabb35c..000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/README.md +++ /dev/null @@ -1,12 +0,0 @@ -Nexmo Notifier -============== - -The Nexmo bridge is deprecated, use the Vonage bridge instead. - -Resources ---------- - - * [Contributing](https://symfony.com/doc/current/contributing/index.html) - * [Report issues](https://github.com/symfony/symfony/issues) and - [send Pull Requests](https://github.com/symfony/symfony/pulls) - in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportFactoryTest.php deleted file mode 100644 index 85c413e4e662..000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportFactoryTest.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Notifier\Bridge\Nexmo\Tests; - -use Symfony\Component\Notifier\Bridge\Nexmo\NexmoTransportFactory; -use Symfony\Component\Notifier\Test\TransportFactoryTestCase; - -/** - * @group legacy - */ -final class NexmoTransportFactoryTest extends TransportFactoryTestCase -{ - public function createFactory(): NexmoTransportFactory - { - return new NexmoTransportFactory(); - } - - public function createProvider(): iterable - { - yield [ - 'nexmo://host.test?from=0611223344', - 'nexmo://apiKey:apiSecret@host.test?from=0611223344', - ]; - } - - public function supportsProvider(): iterable - { - yield [true, 'nexmo://apiKey:apiSecret@default?from=0611223344']; - yield [false, 'somethingElse://apiKey:apiSecret@default?from=0611223344']; - } - - public function missingRequiredOptionProvider(): iterable - { - yield 'missing option: from' => ['nexmo://apiKey:apiSecret@default']; - } - - public function unsupportedSchemeProvider(): iterable - { - yield ['somethingElse://apiKey:apiSecret@default?from=0611223344']; - yield ['somethingElse://apiKey:apiSecret@default']; // missing "from" option - } -} diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportTest.php deleted file mode 100644 index a66d180f673d..000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportTest.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Notifier\Bridge\Nexmo\Tests; - -use Symfony\Component\Notifier\Bridge\Nexmo\NexmoTransport; -use Symfony\Component\Notifier\Message\ChatMessage; -use Symfony\Component\Notifier\Message\MessageInterface; -use Symfony\Component\Notifier\Message\SmsMessage; -use Symfony\Component\Notifier\Test\TransportTestCase; -use Symfony\Contracts\HttpClient\HttpClientInterface; - -/** - * @group legacy - */ -final class NexmoTransportTest extends TransportTestCase -{ - public function createTransport(HttpClientInterface $client = null): NexmoTransport - { - return new NexmoTransport('apiKey', 'apiSecret', 'sender', $client ?? $this->createMock(HttpClientInterface::class)); - } - - public function toStringProvider(): iterable - { - yield ['nexmo://rest.nexmo.com?from=sender', $this->createTransport()]; - } - - public function supportedMessagesProvider(): iterable - { - yield [new SmsMessage('0611223344', 'Hello!')]; - } - - public function unsupportedMessagesProvider(): iterable - { - yield [new ChatMessage('Hello!')]; - yield [$this->createMock(MessageInterface::class)]; - } -} diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json b/src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json deleted file mode 100644 index 46f0d4c12c68..000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/composer.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "symfony/nexmo-notifier", - "type": "symfony-notifier-bridge", - "description": "Symfony Nexmo Notifier Bridge", - "keywords": ["sms", "nexmo", "notifier"], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": ">=8.0.2", - "symfony/http-client": "^5.4|^6.0", - "symfony/notifier": "^5.4|^6.0" - }, - "autoload": { - "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Nexmo\\": "" }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "minimum-stability": "dev" -} diff --git a/src/Symfony/Component/Notifier/Bridge/Nexmo/phpunit.xml.dist b/src/Symfony/Component/Notifier/Bridge/Nexmo/phpunit.xml.dist deleted file mode 100644 index 02a715bf0a9c..000000000000 --- a/src/Symfony/Component/Notifier/Bridge/Nexmo/phpunit.xml.dist +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - ./Tests/ - - - - - - ./ - - - ./Resources - ./Tests - ./vendor - - - diff --git a/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php b/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php index ebe0cef610df..be1637719b39 100644 --- a/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php +++ b/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php @@ -112,10 +112,6 @@ class UnsupportedSchemeException extends LogicException 'class' => Bridge\Mobyt\MobytTransportFactory::class, 'package' => 'symfony/mobyt-notifier', ], - 'nexmo' => [ - 'class' => Bridge\Nexmo\NexmoTransportFactory::class, - 'package' => 'symfony/nexmo-notifier', - ], 'octopush' => [ 'class' => Bridge\Octopush\OctopushTransportFactory::class, 'package' => 'symfony/octopush-notifier', diff --git a/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php b/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php index 1cd8d4033eb4..66c04cc68d73 100644 --- a/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php +++ b/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php @@ -36,7 +36,6 @@ use Symfony\Component\Notifier\Bridge\MessageMedia\MessageMediaTransportFactory; use Symfony\Component\Notifier\Bridge\MicrosoftTeams\MicrosoftTeamsTransportFactory; use Symfony\Component\Notifier\Bridge\Mobyt\MobytTransportFactory; -use Symfony\Component\Notifier\Bridge\Nexmo\NexmoTransportFactory; use Symfony\Component\Notifier\Bridge\Octopush\OctopushTransportFactory; use Symfony\Component\Notifier\Bridge\OneSignal\OneSignalTransportFactory; use Symfony\Component\Notifier\Bridge\OvhCloud\OvhCloudTransportFactory; @@ -91,7 +90,6 @@ public static function setUpBeforeClass(): void MessageMediaTransportFactory::class => false, MicrosoftTeamsTransportFactory::class => false, MobytTransportFactory::class => false, - NexmoTransportFactory::class => false, OctopushTransportFactory::class => false, OneSignalTransportFactory::class => false, OvhCloudTransportFactory::class => false, @@ -152,7 +150,6 @@ public function messageWhereSchemeIsPartOfSchemeToPackageMapProvider(): \Generat yield ['messagemedia', 'symfony/message-media-notifier']; yield ['microsoftteams', 'symfony/microsoft-teams-notifier']; yield ['mobyt', 'symfony/mobyt-notifier']; - yield ['nexmo', 'symfony/nexmo-notifier']; yield ['octopush', 'symfony/octopush-notifier']; yield ['onesignal', 'symfony/one-signal-notifier']; yield ['ovhcloud', 'symfony/ovh-cloud-notifier']; diff --git a/src/Symfony/Component/Notifier/Transport.php b/src/Symfony/Component/Notifier/Transport.php index 064e1bbde3b4..7e57bc26d214 100644 --- a/src/Symfony/Component/Notifier/Transport.php +++ b/src/Symfony/Component/Notifier/Transport.php @@ -30,7 +30,6 @@ use Symfony\Component\Notifier\Bridge\MessageMedia\MessageMediaTransportFactory; use Symfony\Component\Notifier\Bridge\MicrosoftTeams\MicrosoftTeamsTransport; use Symfony\Component\Notifier\Bridge\Mobyt\MobytTransportFactory; -use Symfony\Component\Notifier\Bridge\Nexmo\NexmoTransportFactory; use Symfony\Component\Notifier\Bridge\Octopush\OctopushTransportFactory; use Symfony\Component\Notifier\Bridge\OvhCloud\OvhCloudTransportFactory; use Symfony\Component\Notifier\Bridge\RocketChat\RocketChatTransportFactory; @@ -84,7 +83,6 @@ final class Transport MessageMediaTransportFactory::class, MicrosoftTeamsTransport::class, MobytTransportFactory::class, - NexmoTransportFactory::class, OctopushTransportFactory::class, OvhCloudTransportFactory::class, RocketChatTransportFactory::class, From abc4c93da75dbf2ce49ab70a9d23cc6880bb972b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 29 Nov 2021 16:46:23 +0100 Subject: [PATCH 33/37] [Notifer] fix merge --- .../Bridge/Vonage/Tests/VonageTransportFactoryTest.php | 5 +---- .../Notifier/Bridge/Vonage/Tests/VonageTransportTest.php | 5 +---- .../Notifier/Bridge/Vonage/VonageTransportFactory.php | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportFactoryTest.php index b25b54982884..254978bd2647 100644 --- a/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportFactoryTest.php @@ -17,10 +17,7 @@ final class VonageTransportFactoryTest extends TransportFactoryTestCase { - /** - * @return VonageTransportFactory - */ - public function createFactory(): TransportFactoryInterface + public function createFactory(): VonageTransportFactory { return new VonageTransportFactory(); } diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportTest.php index dc545a02a9d7..34c7f7e3b4f3 100644 --- a/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/Tests/VonageTransportTest.php @@ -21,10 +21,7 @@ final class VonageTransportTest extends TransportTestCase { - /** - * @return VonageTransport - */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public function createTransport(HttpClientInterface $client = null): VonageTransport { return new VonageTransport('apiKey', 'apiSecret', 'sender', $client ?? $this->createMock(HttpClientInterface::class)); } diff --git a/src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransportFactory.php index c0f23b242548..a54a519687a7 100644 --- a/src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Vonage/VonageTransportFactory.php @@ -21,10 +21,7 @@ */ final class VonageTransportFactory extends AbstractTransportFactory { - /** - * @return VonageTransport - */ - public function create(Dsn $dsn): TransportInterface + public function create(Dsn $dsn): VonageTransport { $scheme = $dsn->getScheme(); From 8dbff3312ef68aafdc8c2beae50bb2d06c14b61b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 29 Nov 2021 16:50:27 +0100 Subject: [PATCH 34/37] [Security] fix merge --- .../Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php b/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php index d1322ec4a316..89a5776decd2 100644 --- a/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Authenticator/RemoteUserAuthenticatorTest.php @@ -41,7 +41,7 @@ public function testSupportNoUser() public function testSupportTokenStorageWithToken() { $tokenStorage = new TokenStorage(); - $tokenStorage->setToken(new PreAuthenticatedToken('username', 'credentials', 'main')); + $tokenStorage->setToken(new PreAuthenticatedToken(new InMemoryUser('username', null), 'main')); $authenticator = new RemoteUserAuthenticator(new InMemoryUserProvider(), $tokenStorage, 'main'); From 3a96e4cde6aa0c9e138bdfcce60564a2f396c070 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 29 Nov 2021 17:01:17 +0100 Subject: [PATCH 35/37] [FrameworkBundle] fix tests --- .../Tests/Command/EventDispatcherDebugCommandTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php index 57e2487dd6b9..ce653c6bfaaa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/EventDispatcherDebugCommandTest.php @@ -44,8 +44,8 @@ private function createCommandCompletionTester(): CommandCompletionTester $dispatcher = new EventDispatcher(); $otherDispatcher = new EventDispatcher(); - $dispatcher->addListener('event', 'Listener'); - $otherDispatcher->addListener('other_event', 'OtherListener'); + $dispatcher->addListener('event', ['Listener']); + $otherDispatcher->addListener('other_event', ['OtherListener']); $dispatchers = new ServiceLocator([ 'event_dispatcher' => function () { From 464c4196ed6c4ef640f7f40fd10a7cdf652f8dcc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 29 Nov 2021 18:04:03 +0100 Subject: [PATCH 36/37] Update CHANGELOG for 6.0.0 --- CHANGELOG-6.0.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG-6.0.md b/CHANGELOG-6.0.md index 969f4134161f..05e84492bfeb 100644 --- a/CHANGELOG-6.0.md +++ b/CHANGELOG-6.0.md @@ -7,6 +7,20 @@ in 6.0 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v6.0.0...v6.0.1 +* 6.0.0 (2021-11-29) + + * bug #44309 [Messenger] Leverage DBAL's getNativeConnection() method (derrabus) + * bug #44300 [FrameworkBundle] Fix property-info phpstan extractor discovery (1ed) + * feature #44271 [Notifier] add Vonage bridge to replace the Nexmo one (nicolas-grekas) + * bug #44187 [Translation] [Loco] Fix idempotency of LocoProvider write method (welcoMattic) + * bug #43992 [Security] Do not overwrite already stored tokens for REMOTE_USER authentication (stlrnz) + * bug #43876 [Validator] Fix validation for single level domains (HypeMC) + * bug #44327 [Debug][ErrorHandler] Increased the reserved memory from 10k to 32k (sakalys) + * bug #44261 [Process] intersect with getenv() in case-insensitive manner to get default envs (stable-staple) + * bug #44295 [Serializer] fix support for lazy/unset properties (nicolas-grekas) + * bug #44277 [Notifier] Fix AllMySms bridge body content (afiocre) + * bug #44269 [DoctrineBridge] Revert " add support for the JSON type" (dunglas) + * 6.0.0-RC1 (2021-11-24) * security #cve-2021-41268 [SecurityBundle] Default signature_properties to the previous behavior (wouterj) From 0a23c6aa647581fb40238e8ecba8dbec4906b7cc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 29 Nov 2021 18:04:08 +0100 Subject: [PATCH 37/37] Update VERSION for 6.0.0 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 28c499510d98..6c2d9b33e0d7 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static array $freshCache = []; - public const VERSION = '6.0.0-DEV'; + public const VERSION = '6.0.0'; public const VERSION_ID = 60000; public const MAJOR_VERSION = 6; public const MINOR_VERSION = 0; public const RELEASE_VERSION = 0; - public const EXTRA_VERSION = 'DEV'; + public const EXTRA_VERSION = ''; public const END_OF_MAINTENANCE = '07/2022'; public const END_OF_LIFE = '07/2022';