From 8869eb35218974f2ad64bf9e6cc5cfcfeadd76e2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 28 May 2019 14:18:42 +0200 Subject: [PATCH 001/588] updated version to 5.0 --- composer.json | 2 +- src/Symfony/Bridge/Doctrine/composer.json | 2 +- src/Symfony/Bridge/Monolog/composer.json | 2 +- src/Symfony/Bridge/PhpUnit/composer.json | 2 +- src/Symfony/Bridge/ProxyManager/composer.json | 2 +- src/Symfony/Bridge/Twig/composer.json | 2 +- src/Symfony/Bundle/DebugBundle/composer.json | 2 +- src/Symfony/Bundle/FrameworkBundle/composer.json | 2 +- src/Symfony/Bundle/SecurityBundle/composer.json | 2 +- src/Symfony/Bundle/TwigBundle/composer.json | 2 +- src/Symfony/Bundle/WebProfilerBundle/composer.json | 2 +- src/Symfony/Bundle/WebServerBundle/composer.json | 2 +- src/Symfony/Component/Asset/composer.json | 2 +- src/Symfony/Component/BrowserKit/composer.json | 2 +- src/Symfony/Component/Cache/composer.json | 2 +- src/Symfony/Component/Config/composer.json | 2 +- src/Symfony/Component/Console/composer.json | 2 +- src/Symfony/Component/CssSelector/composer.json | 2 +- src/Symfony/Component/Debug/composer.json | 2 +- .../Component/DependencyInjection/composer.json | 2 +- src/Symfony/Component/DomCrawler/composer.json | 2 +- src/Symfony/Component/Dotenv/composer.json | 2 +- src/Symfony/Component/EventDispatcher/composer.json | 2 +- .../Component/ExpressionLanguage/composer.json | 2 +- src/Symfony/Component/Filesystem/composer.json | 2 +- src/Symfony/Component/Finder/composer.json | 2 +- src/Symfony/Component/Form/composer.json | 2 +- src/Symfony/Component/HttpClient/composer.json | 2 +- src/Symfony/Component/HttpFoundation/composer.json | 2 +- src/Symfony/Component/HttpKernel/Kernel.php | 12 ++++++------ src/Symfony/Component/HttpKernel/composer.json | 2 +- src/Symfony/Component/Inflector/composer.json | 2 +- src/Symfony/Component/Intl/composer.json | 2 +- src/Symfony/Component/Ldap/composer.json | 2 +- src/Symfony/Component/Lock/composer.json | 2 +- .../Component/Mailer/Bridge/Amazon/composer.json | 2 +- .../Component/Mailer/Bridge/Google/composer.json | 2 +- .../Component/Mailer/Bridge/Mailchimp/composer.json | 2 +- .../Component/Mailer/Bridge/Mailgun/composer.json | 2 +- .../Component/Mailer/Bridge/Postmark/composer.json | 2 +- .../Component/Mailer/Bridge/Sendgrid/composer.json | 2 +- src/Symfony/Component/Mailer/composer.json | 2 +- src/Symfony/Component/Messenger/composer.json | 2 +- src/Symfony/Component/Mime/composer.json | 2 +- src/Symfony/Component/OptionsResolver/composer.json | 2 +- src/Symfony/Component/Process/composer.json | 2 +- src/Symfony/Component/PropertyAccess/composer.json | 2 +- src/Symfony/Component/PropertyInfo/composer.json | 2 +- src/Symfony/Component/Routing/composer.json | 2 +- src/Symfony/Component/Security/Core/composer.json | 2 +- src/Symfony/Component/Security/Csrf/composer.json | 2 +- src/Symfony/Component/Security/Guard/composer.json | 2 +- src/Symfony/Component/Security/Http/composer.json | 2 +- src/Symfony/Component/Security/composer.json | 2 +- src/Symfony/Component/Serializer/composer.json | 2 +- src/Symfony/Component/Stopwatch/composer.json | 2 +- src/Symfony/Component/Templating/composer.json | 2 +- src/Symfony/Component/Translation/composer.json | 2 +- src/Symfony/Component/Validator/composer.json | 2 +- src/Symfony/Component/VarDumper/composer.json | 2 +- src/Symfony/Component/VarExporter/composer.json | 2 +- src/Symfony/Component/WebLink/composer.json | 2 +- src/Symfony/Component/Workflow/composer.json | 2 +- src/Symfony/Component/Yaml/composer.json | 2 +- 64 files changed, 69 insertions(+), 69 deletions(-) diff --git a/composer.json b/composer.json index 9d43a419d0f30..5d94a6aa93770 100644 --- a/composer.json +++ b/composer.json @@ -153,7 +153,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index cd9891fe7222f..554a196407035 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -68,7 +68,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Bridge/Monolog/composer.json b/src/Symfony/Bridge/Monolog/composer.json index b3de2e85f4c14..0286ebef3a6ab 100644 --- a/src/Symfony/Bridge/Monolog/composer.json +++ b/src/Symfony/Bridge/Monolog/composer.json @@ -44,7 +44,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Bridge/PhpUnit/composer.json b/src/Symfony/Bridge/PhpUnit/composer.json index 1518be6503b55..8d7fe1259852b 100644 --- a/src/Symfony/Bridge/PhpUnit/composer.json +++ b/src/Symfony/Bridge/PhpUnit/composer.json @@ -39,7 +39,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" }, "thanks": { "name": "phpunit/phpunit", diff --git a/src/Symfony/Bridge/ProxyManager/composer.json b/src/Symfony/Bridge/ProxyManager/composer.json index 3626580ad7e1a..ae67917030884 100644 --- a/src/Symfony/Bridge/ProxyManager/composer.json +++ b/src/Symfony/Bridge/ProxyManager/composer.json @@ -35,7 +35,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index e11f54581968a..581bed942bad0 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -76,7 +76,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Bundle/DebugBundle/composer.json b/src/Symfony/Bundle/DebugBundle/composer.json index bc7d2bde9afd2..28088ed921551 100644 --- a/src/Symfony/Bundle/DebugBundle/composer.json +++ b/src/Symfony/Bundle/DebugBundle/composer.json @@ -44,7 +44,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index b617d80789487..de0d9e42034d3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -100,7 +100,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index 2f51b452215ff..ed97d48450331 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -62,7 +62,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index 3fe61d6e15806..6b3d478a7af6f 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -54,7 +54,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json index 16d6cac4baa51..bab9b01b01a86 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/composer.json +++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json @@ -44,7 +44,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Bundle/WebServerBundle/composer.json b/src/Symfony/Bundle/WebServerBundle/composer.json index 91cdcc62e756d..23df935101231 100644 --- a/src/Symfony/Bundle/WebServerBundle/composer.json +++ b/src/Symfony/Bundle/WebServerBundle/composer.json @@ -37,7 +37,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Asset/composer.json b/src/Symfony/Component/Asset/composer.json index 8ec094a7a20e1..5563a68af52de 100644 --- a/src/Symfony/Component/Asset/composer.json +++ b/src/Symfony/Component/Asset/composer.json @@ -34,7 +34,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/BrowserKit/composer.json b/src/Symfony/Component/BrowserKit/composer.json index b4be743973303..e12db957dbb36 100644 --- a/src/Symfony/Component/BrowserKit/composer.json +++ b/src/Symfony/Component/BrowserKit/composer.json @@ -37,7 +37,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Cache/composer.json b/src/Symfony/Component/Cache/composer.json index 512a6bd93efe0..021b88c0ad50b 100644 --- a/src/Symfony/Component/Cache/composer.json +++ b/src/Symfony/Component/Cache/composer.json @@ -52,7 +52,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Config/composer.json b/src/Symfony/Component/Config/composer.json index 2f68dfc21b8f1..3574e6d486dfd 100644 --- a/src/Symfony/Component/Config/composer.json +++ b/src/Symfony/Component/Config/composer.json @@ -42,7 +42,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index d8e9b163e74b9..510805e24729b 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -53,7 +53,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/CssSelector/composer.json b/src/Symfony/Component/CssSelector/composer.json index 65642dc9bc584..cb4c253617e4b 100644 --- a/src/Symfony/Component/CssSelector/composer.json +++ b/src/Symfony/Component/CssSelector/composer.json @@ -31,7 +31,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Debug/composer.json b/src/Symfony/Component/Debug/composer.json index 2b54c6c281c94..036a6b7386daa 100644 --- a/src/Symfony/Component/Debug/composer.json +++ b/src/Symfony/Component/Debug/composer.json @@ -34,7 +34,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/DependencyInjection/composer.json b/src/Symfony/Component/DependencyInjection/composer.json index 289bfae0d4393..6ac0ef45d0bf4 100644 --- a/src/Symfony/Component/DependencyInjection/composer.json +++ b/src/Symfony/Component/DependencyInjection/composer.json @@ -51,7 +51,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/DomCrawler/composer.json b/src/Symfony/Component/DomCrawler/composer.json index ad2c149897c53..55847a24788b8 100644 --- a/src/Symfony/Component/DomCrawler/composer.json +++ b/src/Symfony/Component/DomCrawler/composer.json @@ -39,7 +39,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Dotenv/composer.json b/src/Symfony/Component/Dotenv/composer.json index e5e614fe66735..23cca581b876b 100644 --- a/src/Symfony/Component/Dotenv/composer.json +++ b/src/Symfony/Component/Dotenv/composer.json @@ -30,7 +30,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/EventDispatcher/composer.json b/src/Symfony/Component/EventDispatcher/composer.json index d8db1afb9b85f..ff73e95bc4c80 100644 --- a/src/Symfony/Component/EventDispatcher/composer.json +++ b/src/Symfony/Component/EventDispatcher/composer.json @@ -48,7 +48,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/ExpressionLanguage/composer.json b/src/Symfony/Component/ExpressionLanguage/composer.json index 99624fbc5cb09..aea4d0c513109 100644 --- a/src/Symfony/Component/ExpressionLanguage/composer.json +++ b/src/Symfony/Component/ExpressionLanguage/composer.json @@ -29,7 +29,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Filesystem/composer.json b/src/Symfony/Component/Filesystem/composer.json index 9e0373d2f6662..9250cfc36a703 100644 --- a/src/Symfony/Component/Filesystem/composer.json +++ b/src/Symfony/Component/Filesystem/composer.json @@ -28,7 +28,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Finder/composer.json b/src/Symfony/Component/Finder/composer.json index 0b1408c0dfd41..52ae6b3be2e6c 100644 --- a/src/Symfony/Component/Finder/composer.json +++ b/src/Symfony/Component/Finder/composer.json @@ -27,7 +27,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index 7b0ab78dbbb23..e5a5916019a65 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -61,7 +61,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/HttpClient/composer.json b/src/Symfony/Component/HttpClient/composer.json index 79d60f6e01dcf..afbc5628bc692 100644 --- a/src/Symfony/Component/HttpClient/composer.json +++ b/src/Symfony/Component/HttpClient/composer.json @@ -39,7 +39,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/HttpFoundation/composer.json b/src/Symfony/Component/HttpFoundation/composer.json index bf73d393cd286..4d76683d56cb7 100644 --- a/src/Symfony/Component/HttpFoundation/composer.json +++ b/src/Symfony/Component/HttpFoundation/composer.json @@ -33,7 +33,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 5b3a9cbf2e33f..5f10c4bcacfec 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -73,15 +73,15 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '4.4.0-DEV'; - const VERSION_ID = 40400; - const MAJOR_VERSION = 4; - const MINOR_VERSION = 4; + const VERSION = '5.0.0-DEV'; + const VERSION_ID = 50000; + const MAJOR_VERSION = 5; + const MINOR_VERSION = 0; const RELEASE_VERSION = 0; const EXTRA_VERSION = 'DEV'; - const END_OF_MAINTENANCE = '11/2022'; - const END_OF_LIFE = '11/2023'; + const END_OF_MAINTENANCE = '07/2020'; + const END_OF_LIFE = '01/2021'; public function __construct(string $environment, bool $debug) { diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index 4742ab6636b0f..1d6b9cfc06623 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -70,7 +70,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Inflector/composer.json b/src/Symfony/Component/Inflector/composer.json index afd56dfd6bd32..13f830de0191a 100644 --- a/src/Symfony/Component/Inflector/composer.json +++ b/src/Symfony/Component/Inflector/composer.json @@ -35,7 +35,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Intl/composer.json b/src/Symfony/Component/Intl/composer.json index a357fdf1392db..a6b1ddd1db3bb 100644 --- a/src/Symfony/Component/Intl/composer.json +++ b/src/Symfony/Component/Intl/composer.json @@ -43,7 +43,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Ldap/composer.json b/src/Symfony/Component/Ldap/composer.json index 7677b1d19b505..caf690f559865 100644 --- a/src/Symfony/Component/Ldap/composer.json +++ b/src/Symfony/Component/Ldap/composer.json @@ -32,7 +32,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Lock/composer.json b/src/Symfony/Component/Lock/composer.json index 5909a421eacfc..07e751c7e7ed0 100644 --- a/src/Symfony/Component/Lock/composer.json +++ b/src/Symfony/Component/Lock/composer.json @@ -33,7 +33,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json b/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json index dfb950a86085c..7c9bfc60c3f62 100644 --- a/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json @@ -31,7 +31,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Mailer/Bridge/Google/composer.json b/src/Symfony/Component/Mailer/Bridge/Google/composer.json index 9007d7d87d427..6d409adfee66e 100644 --- a/src/Symfony/Component/Mailer/Bridge/Google/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Google/composer.json @@ -31,7 +31,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json b/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json index 0d1560faa99e5..75c45a95e441e 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json @@ -31,7 +31,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json b/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json index a65bbfe49600d..36816700cff90 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json @@ -31,7 +31,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json b/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json index 45170470bfa91..ad5343358054b 100644 --- a/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json @@ -31,7 +31,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json b/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json index 5ac20c76648a6..ae73025ee3c1f 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json @@ -31,7 +31,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Mailer/composer.json b/src/Symfony/Component/Mailer/composer.json index 7a3070291192d..998ccfdbd1dc1 100644 --- a/src/Symfony/Component/Mailer/composer.json +++ b/src/Symfony/Component/Mailer/composer.json @@ -40,7 +40,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Messenger/composer.json b/src/Symfony/Component/Messenger/composer.json index ae9f424885773..8dd40c024c34d 100644 --- a/src/Symfony/Component/Messenger/composer.json +++ b/src/Symfony/Component/Messenger/composer.json @@ -52,7 +52,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Mime/composer.json b/src/Symfony/Component/Mime/composer.json index 78f03921b22b3..2ba226afc3fd9 100644 --- a/src/Symfony/Component/Mime/composer.json +++ b/src/Symfony/Component/Mime/composer.json @@ -33,7 +33,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/OptionsResolver/composer.json b/src/Symfony/Component/OptionsResolver/composer.json index d9a237e8ac75a..c37b78f04edee 100644 --- a/src/Symfony/Component/OptionsResolver/composer.json +++ b/src/Symfony/Component/OptionsResolver/composer.json @@ -27,7 +27,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Process/composer.json b/src/Symfony/Component/Process/composer.json index e0174de75533c..9dcdd6de85440 100644 --- a/src/Symfony/Component/Process/composer.json +++ b/src/Symfony/Component/Process/composer.json @@ -27,7 +27,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/PropertyAccess/composer.json b/src/Symfony/Component/PropertyAccess/composer.json index b40225b57d301..6210c8ef942e4 100644 --- a/src/Symfony/Component/PropertyAccess/composer.json +++ b/src/Symfony/Component/PropertyAccess/composer.json @@ -34,7 +34,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/PropertyInfo/composer.json b/src/Symfony/Component/PropertyInfo/composer.json index 6f7c556b8658d..1f1ad6e8c5c7b 100644 --- a/src/Symfony/Component/PropertyInfo/composer.json +++ b/src/Symfony/Component/PropertyInfo/composer.json @@ -53,7 +53,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Routing/composer.json b/src/Symfony/Component/Routing/composer.json index 0eefbd552cac7..420fdaa3a942e 100644 --- a/src/Symfony/Component/Routing/composer.json +++ b/src/Symfony/Component/Routing/composer.json @@ -48,7 +48,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Security/Core/composer.json b/src/Symfony/Component/Security/Core/composer.json index 27318d5930219..fbc98363d08fa 100644 --- a/src/Symfony/Component/Security/Core/composer.json +++ b/src/Symfony/Component/Security/Core/composer.json @@ -50,7 +50,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Security/Csrf/composer.json b/src/Symfony/Component/Security/Csrf/composer.json index 6bc61e690aef3..149c34c9c62df 100644 --- a/src/Symfony/Component/Security/Csrf/composer.json +++ b/src/Symfony/Component/Security/Csrf/composer.json @@ -37,7 +37,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Security/Guard/composer.json b/src/Symfony/Component/Security/Guard/composer.json index f17dacfdf6092..be54b9e008a69 100644 --- a/src/Symfony/Component/Security/Guard/composer.json +++ b/src/Symfony/Component/Security/Guard/composer.json @@ -32,7 +32,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Security/Http/composer.json b/src/Symfony/Component/Security/Http/composer.json index b040839e42bb7..8b601f0ea0c07 100644 --- a/src/Symfony/Component/Security/Http/composer.json +++ b/src/Symfony/Component/Security/Http/composer.json @@ -43,7 +43,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Security/composer.json b/src/Symfony/Component/Security/composer.json index fe1bf73754c2c..2788714feffd0 100644 --- a/src/Symfony/Component/Security/composer.json +++ b/src/Symfony/Component/Security/composer.json @@ -60,7 +60,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Serializer/composer.json b/src/Symfony/Component/Serializer/composer.json index 1ac23722f1990..a7ef11a3e4317 100644 --- a/src/Symfony/Component/Serializer/composer.json +++ b/src/Symfony/Component/Serializer/composer.json @@ -58,7 +58,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Stopwatch/composer.json b/src/Symfony/Component/Stopwatch/composer.json index 68cc9dab75901..84a3f4ea26d0d 100644 --- a/src/Symfony/Component/Stopwatch/composer.json +++ b/src/Symfony/Component/Stopwatch/composer.json @@ -28,7 +28,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Templating/composer.json b/src/Symfony/Component/Templating/composer.json index f785cf1cca666..50b9082281729 100644 --- a/src/Symfony/Component/Templating/composer.json +++ b/src/Symfony/Component/Templating/composer.json @@ -34,7 +34,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Translation/composer.json b/src/Symfony/Component/Translation/composer.json index 04b7d39fd4ab2..d374a1991e40f 100644 --- a/src/Symfony/Component/Translation/composer.json +++ b/src/Symfony/Component/Translation/composer.json @@ -54,7 +54,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index 1fc22e1dc0e96..ddcfc7ac2d37e 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -70,7 +70,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/VarDumper/composer.json b/src/Symfony/Component/VarDumper/composer.json index e5b1cc3efb525..18cfbd6305a12 100644 --- a/src/Symfony/Component/VarDumper/composer.json +++ b/src/Symfony/Component/VarDumper/composer.json @@ -48,7 +48,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/VarExporter/composer.json b/src/Symfony/Component/VarExporter/composer.json index 5929fecb5e08f..af6f3c2eff1af 100644 --- a/src/Symfony/Component/VarExporter/composer.json +++ b/src/Symfony/Component/VarExporter/composer.json @@ -30,7 +30,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/WebLink/composer.json b/src/Symfony/Component/WebLink/composer.json index b2f784d89ad3a..c023a27444ed2 100644 --- a/src/Symfony/Component/WebLink/composer.json +++ b/src/Symfony/Component/WebLink/composer.json @@ -39,7 +39,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Workflow/composer.json b/src/Symfony/Component/Workflow/composer.json index 5c87b8826321f..f5e9faa1b0dbe 100644 --- a/src/Symfony/Component/Workflow/composer.json +++ b/src/Symfony/Component/Workflow/composer.json @@ -40,7 +40,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } diff --git a/src/Symfony/Component/Yaml/composer.json b/src/Symfony/Component/Yaml/composer.json index 8bce945a6f57f..c435cce0e4ebe 100644 --- a/src/Symfony/Component/Yaml/composer.json +++ b/src/Symfony/Component/Yaml/composer.json @@ -37,7 +37,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.0-dev" } } } From d94d9d792c445240cbaf80c7b413795b71aff718 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 28 May 2019 15:10:17 +0200 Subject: [PATCH 002/588] Bump Symfony 5.0 to PHP 7.2 --- .appveyor.yml | 10 ++-- .travis.yml | 6 +-- composer.json | 3 +- src/Symfony/Bridge/Doctrine/composer.json | 2 +- src/Symfony/Bridge/Monolog/composer.json | 2 +- src/Symfony/Bridge/ProxyManager/composer.json | 2 +- src/Symfony/Bridge/Twig/composer.json | 2 +- src/Symfony/Bundle/DebugBundle/composer.json | 2 +- .../Bundle/FrameworkBundle/composer.json | 2 +- .../Bundle/SecurityBundle/composer.json | 2 +- src/Symfony/Bundle/TwigBundle/composer.json | 2 +- .../Bundle/WebProfilerBundle/composer.json | 2 +- .../Bundle/WebServerBundle/composer.json | 2 +- src/Symfony/Component/Asset/composer.json | 2 +- .../Component/BrowserKit/composer.json | 2 +- src/Symfony/Component/Cache/composer.json | 2 +- src/Symfony/Component/Config/composer.json | 2 +- src/Symfony/Component/Console/composer.json | 2 +- .../Component/CssSelector/composer.json | 2 +- src/Symfony/Component/Debug/composer.json | 2 +- .../DependencyInjection/composer.json | 2 +- .../Component/DomCrawler/composer.json | 2 +- src/Symfony/Component/Dotenv/composer.json | 2 +- .../Component/EventDispatcher/composer.json | 2 +- .../ExpressionLanguage/composer.json | 2 +- .../Component/Filesystem/composer.json | 2 +- src/Symfony/Component/Finder/composer.json | 2 +- src/Symfony/Component/Form/composer.json | 2 +- .../Component/HttpClient/composer.json | 2 +- .../Tests/ResponseFunctionalTest.php | 3 -- .../Component/HttpFoundation/composer.json | 2 +- .../Component/HttpKernel/composer.json | 2 +- src/Symfony/Component/Inflector/composer.json | 2 +- src/Symfony/Component/Intl/composer.json | 2 +- src/Symfony/Component/Ldap/composer.json | 2 +- src/Symfony/Component/Lock/composer.json | 2 +- .../Mailer/Bridge/Amazon/composer.json | 2 +- .../Mailer/Bridge/Google/composer.json | 2 +- .../Mailer/Bridge/Mailchimp/composer.json | 2 +- .../Mailer/Bridge/Mailgun/composer.json | 2 +- .../Mailer/Bridge/Postmark/composer.json | 2 +- .../Mailer/Bridge/Sendgrid/composer.json | 2 +- src/Symfony/Component/Mailer/composer.json | 2 +- src/Symfony/Component/Messenger/composer.json | 2 +- src/Symfony/Component/Mime/composer.json | 2 +- .../Component/OptionsResolver/composer.json | 2 +- .../Process/Tests/ExecutableFinderTest.php | 3 -- src/Symfony/Component/Process/composer.json | 2 +- .../Component/PropertyAccess/composer.json | 2 +- .../Component/PropertyInfo/composer.json | 2 +- .../Tests/Loader/AnnotationFileLoaderTest.php | 3 -- src/Symfony/Component/Routing/composer.json | 2 +- .../Core/Encoder/Argon2iPasswordEncoder.php | 4 +- .../Component/Security/Core/composer.json | 2 +- .../Component/Security/Csrf/composer.json | 2 +- .../Component/Security/Guard/composer.json | 2 +- .../Component/Security/Http/composer.json | 2 +- src/Symfony/Component/Security/composer.json | 2 +- .../Component/Serializer/composer.json | 2 +- src/Symfony/Component/Stopwatch/composer.json | 2 +- .../Component/Templating/composer.json | 2 +- .../Component/Translation/composer.json | 2 +- src/Symfony/Component/Validator/composer.json | 2 +- .../Component/VarDumper/Caster/Caster.php | 2 +- .../Component/VarDumper/Caster/DateCaster.php | 20 ++++---- .../Component/VarDumper/Cloner/VarCloner.php | 17 ------- .../Component/VarDumper/Dumper/CliDumper.php | 2 +- .../VarDumper/Tests/Caster/DateCasterTest.php | 16 ------- .../VarDumper/Tests/Cloner/VarClonerTest.php | 2 +- .../VarDumper/Tests/Dumper/CliDumperTest.php | 48 ++++--------------- src/Symfony/Component/VarDumper/composer.json | 5 +- .../Component/VarExporter/composer.json | 2 +- src/Symfony/Component/WebLink/composer.json | 2 +- src/Symfony/Component/Workflow/composer.json | 2 +- src/Symfony/Component/Yaml/composer.json | 2 +- src/Symfony/Contracts/Cache/composer.json | 4 +- .../Contracts/EventDispatcher/composer.json | 4 +- .../Contracts/HttpClient/composer.json | 4 +- src/Symfony/Contracts/Service/composer.json | 4 +- .../Contracts/Translation/composer.json | 4 +- src/Symfony/Contracts/composer.json | 4 +- 81 files changed, 107 insertions(+), 181 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 4b417c5dfc122..d7c02bb2ba9b3 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -10,17 +10,17 @@ init: - SET PATH=c:\php;%PATH% - SET COMPOSER_NO_INTERACTION=1 - SET SYMFONY_DEPRECATIONS_HELPER=strict - - SET "SYMFONY_REQUIRE=>=4.2" + - SET "SYMFONY_REQUIRE=>=4.4" - SET ANSICON=121x90 (121x90) - REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v DelayedExpansion /t REG_DWORD /d 1 /f install: - mkdir c:\php && cd c:\php - - 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 + - appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php-7.2.9-Win32-VC15-x86.zip + - 7z x php-7.2.9-Win32-VC15-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.17-7.2-ts-vc15-x86.zip + - 7z x php_apcu-5.1.17-7.2-ts-vc15-x86.zip -y >nul - cd .. - copy /Y php.ini-development php.ini-min - echo memory_limit=-1 >> php.ini-min diff --git a/.travis.yml b/.travis.yml index 3949845f897a8..8034fb316a141 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,14 +17,14 @@ addons: env: global: - - MIN_PHP=7.1.3 + - MIN_PHP=7.2.9 - SYMFONY_PROCESS_PHP_TEST_BINARY=~/.phpenv/shims/php - MESSENGER_AMQP_DSN=amqp://localhost/%2f/messages - MESSENGER_REDIS_DSN=redis://127.0.0.1:7001/messages matrix: include: - - php: 7.1 + - php: 7.2 - php: 7.2 env: deps=high - php: 7.3 @@ -215,7 +215,7 @@ install: - | # Install symfony/flex if [[ $deps = low ]]; then - export SYMFONY_REQUIRE='>=2.3' + export SYMFONY_REQUIRE='>=3.4' else export SYMFONY_REQUIRE=">=$SYMFONY_VERSION" fi diff --git a/composer.json b/composer.json index 5d94a6aa93770..a69a22596b714 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "ext-xml": "*", "doctrine/event-manager": "~1.0", "doctrine/persistence": "~1.0", @@ -31,7 +31,6 @@ "symfony/polyfill-intl-icu": "~1.0", "symfony/polyfill-intl-idn": "^1.10", "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php72": "~1.5", "symfony/polyfill-php73": "^1.11" }, "replace": { diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 2c7b009d81d7a..0fb1b8a305fb5 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "doctrine/event-manager": "~1.0", "doctrine/persistence": "~1.0", "symfony/polyfill-ctype": "~1.8", diff --git a/src/Symfony/Bridge/Monolog/composer.json b/src/Symfony/Bridge/Monolog/composer.json index 9d9b793d538dc..7c08b8b97e871 100644 --- a/src/Symfony/Bridge/Monolog/composer.json +++ b/src/Symfony/Bridge/Monolog/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "monolog/monolog": "~1.19", "symfony/service-contracts": "^1.1", "symfony/http-kernel": "^4.3|^5.0" diff --git a/src/Symfony/Bridge/ProxyManager/composer.json b/src/Symfony/Bridge/ProxyManager/composer.json index 9eee98e17bb10..3af8ab6cbe088 100644 --- a/src/Symfony/Bridge/ProxyManager/composer.json +++ b/src/Symfony/Bridge/ProxyManager/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/dependency-injection": "^4.0|^5.0", "ocramius/proxy-manager": "~2.1" }, diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index 84cd5d31ce874..7b289952e279c 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "twig/twig": "^1.41|^2.10" }, "require-dev": { diff --git a/src/Symfony/Bundle/DebugBundle/composer.json b/src/Symfony/Bundle/DebugBundle/composer.json index 2c7432c115aee..2185e4e4adb3c 100644 --- a/src/Symfony/Bundle/DebugBundle/composer.json +++ b/src/Symfony/Bundle/DebugBundle/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "ext-xml": "*", "symfony/http-kernel": "^3.4|^4.0|^5.0", "symfony/twig-bridge": "^3.4|^4.0|^5.0", diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 37ac172e01077..bff01ac768ee0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "ext-xml": "*", "symfony/cache": "^4.3|^5.0", "symfony/config": "^4.2|^5.0", diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index 834a7015a5fac..328de335530a5 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "ext-xml": "*", "symfony/config": "^4.2|^5.0", "symfony/dependency-injection": "^4.2|^5.0", diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index 558d1cc158bfe..643d0e09c6f48 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/config": "^4.2|^5.0", "symfony/twig-bridge": "^4.3|^5.0", "symfony/http-foundation": "^4.3|^5.0", diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json index 3e55fe76c532f..c05e0f4fc610c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/composer.json +++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/config": "^4.2|^5.0", "symfony/http-kernel": "^4.3|^5.0", "symfony/routing": "^3.4|^4.0|^5.0", diff --git a/src/Symfony/Bundle/WebServerBundle/composer.json b/src/Symfony/Bundle/WebServerBundle/composer.json index fa32ca3172780..eef4a429e8180 100644 --- a/src/Symfony/Bundle/WebServerBundle/composer.json +++ b/src/Symfony/Bundle/WebServerBundle/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/config": "^3.4|^4.0|^5.0", "symfony/console": "^3.4|^4.0|^5.0", "symfony/dependency-injection": "^3.4|^4.0|^5.0", diff --git a/src/Symfony/Component/Asset/composer.json b/src/Symfony/Component/Asset/composer.json index e74c256219886..5485b234dd510 100644 --- a/src/Symfony/Component/Asset/composer.json +++ b/src/Symfony/Component/Asset/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.2.9" }, "suggest": { "symfony/http-foundation": "" diff --git a/src/Symfony/Component/BrowserKit/composer.json b/src/Symfony/Component/BrowserKit/composer.json index eee3257ad33d0..aaf320d9d3217 100644 --- a/src/Symfony/Component/BrowserKit/composer.json +++ b/src/Symfony/Component/BrowserKit/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/dom-crawler": "^3.4|^4.0|^5.0" }, "require-dev": { diff --git a/src/Symfony/Component/Cache/composer.json b/src/Symfony/Component/Cache/composer.json index ee4082879262d..d5c30394ff838 100644 --- a/src/Symfony/Component/Cache/composer.json +++ b/src/Symfony/Component/Cache/composer.json @@ -21,7 +21,7 @@ "symfony/cache-implementation": "1.0" }, "require": { - "php": "^7.1.3", + "php": "^7.2.9", "psr/cache": "~1.0", "psr/log": "~1.0", "symfony/cache-contracts": "^1.1", diff --git a/src/Symfony/Component/Config/composer.json b/src/Symfony/Component/Config/composer.json index 1df862fdd1f67..272de71a30412 100644 --- a/src/Symfony/Component/Config/composer.json +++ b/src/Symfony/Component/Config/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/filesystem": "^3.4|^4.0|^5.0", "symfony/polyfill-ctype": "~1.8" }, diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index ad1bb17a66034..de3967df95760 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php73": "^1.8", "symfony/service-contracts": "^1.1" diff --git a/src/Symfony/Component/CssSelector/composer.json b/src/Symfony/Component/CssSelector/composer.json index cb4c253617e4b..869769000388c 100644 --- a/src/Symfony/Component/CssSelector/composer.json +++ b/src/Symfony/Component/CssSelector/composer.json @@ -20,7 +20,7 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.2.9" }, "autoload": { "psr-4": { "Symfony\\Component\\CssSelector\\": "" }, diff --git a/src/Symfony/Component/Debug/composer.json b/src/Symfony/Component/Debug/composer.json index 93a873fdca58b..cccd26bc290b0 100644 --- a/src/Symfony/Component/Debug/composer.json +++ b/src/Symfony/Component/Debug/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "psr/log": "~1.0" }, "conflict": { diff --git a/src/Symfony/Component/DependencyInjection/composer.json b/src/Symfony/Component/DependencyInjection/composer.json index cea8fd32d1499..412ab98af41a9 100644 --- a/src/Symfony/Component/DependencyInjection/composer.json +++ b/src/Symfony/Component/DependencyInjection/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "psr/container": "^1.0", "symfony/service-contracts": "^1.1.2" }, diff --git a/src/Symfony/Component/DomCrawler/composer.json b/src/Symfony/Component/DomCrawler/composer.json index 99a8569b7aba8..e7866347a9742 100644 --- a/src/Symfony/Component/DomCrawler/composer.json +++ b/src/Symfony/Component/DomCrawler/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.0" }, diff --git a/src/Symfony/Component/Dotenv/composer.json b/src/Symfony/Component/Dotenv/composer.json index 0e480bc5374a9..2f673fbcd1188 100644 --- a/src/Symfony/Component/Dotenv/composer.json +++ b/src/Symfony/Component/Dotenv/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.2.9" }, "require-dev": { "symfony/process": "^3.4|^4.0|^5.0" diff --git a/src/Symfony/Component/EventDispatcher/composer.json b/src/Symfony/Component/EventDispatcher/composer.json index 8a3b980e51d89..9d32b42310948 100644 --- a/src/Symfony/Component/EventDispatcher/composer.json +++ b/src/Symfony/Component/EventDispatcher/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/event-dispatcher-contracts": "^1.1" }, "require-dev": { diff --git a/src/Symfony/Component/ExpressionLanguage/composer.json b/src/Symfony/Component/ExpressionLanguage/composer.json index 26fdb27c8938a..c90a29c4bda1a 100644 --- a/src/Symfony/Component/ExpressionLanguage/composer.json +++ b/src/Symfony/Component/ExpressionLanguage/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/cache": "^3.4|^4.0|^5.0", "symfony/service-contracts": "^1.1" }, diff --git a/src/Symfony/Component/Filesystem/composer.json b/src/Symfony/Component/Filesystem/composer.json index 9250cfc36a703..0f0117f3f8561 100644 --- a/src/Symfony/Component/Filesystem/composer.json +++ b/src/Symfony/Component/Filesystem/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/polyfill-ctype": "~1.8" }, "autoload": { diff --git a/src/Symfony/Component/Finder/composer.json b/src/Symfony/Component/Finder/composer.json index 52ae6b3be2e6c..0ffe3f4aef245 100644 --- a/src/Symfony/Component/Finder/composer.json +++ b/src/Symfony/Component/Finder/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.2.9" }, "autoload": { "psr-4": { "Symfony\\Component\\Finder\\": "" }, diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index d92714bd68011..9d76349a9ba0d 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/event-dispatcher": "^4.3|^5.0", "symfony/intl": "^4.3|^5.0", "symfony/options-resolver": "~4.3|^5.0", diff --git a/src/Symfony/Component/HttpClient/composer.json b/src/Symfony/Component/HttpClient/composer.json index 7f2f0f39812e9..acd57a3f8b0b0 100644 --- a/src/Symfony/Component/HttpClient/composer.json +++ b/src/Symfony/Component/HttpClient/composer.json @@ -19,7 +19,7 @@ "symfony/http-client-implementation": "1.1" }, "require": { - "php": "^7.1.3", + "php": "^7.2.9", "psr/log": "^1.0", "symfony/http-client-contracts": "^1.1", "symfony/polyfill-php73": "^1.11" diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php index 3d3e696c75c3b..b2483385044e5 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseFunctionalTest.php @@ -13,9 +13,6 @@ use PHPUnit\Framework\TestCase; -/** - * @requires PHP 7.0 - */ class ResponseFunctionalTest extends TestCase { private static $server; diff --git a/src/Symfony/Component/HttpFoundation/composer.json b/src/Symfony/Component/HttpFoundation/composer.json index 0102b83f2c4cc..aef0e58eb4c32 100644 --- a/src/Symfony/Component/HttpFoundation/composer.json +++ b/src/Symfony/Component/HttpFoundation/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/mime": "^4.3|^5.0", "symfony/polyfill-mbstring": "~1.1" }, diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index f3bdeb62a9163..1f8448a5c1655 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/event-dispatcher": "^4.3|^5.0", "symfony/http-foundation": "^4.1.1|^5.0", "symfony/debug": "^3.4|^4.0|^5.0", diff --git a/src/Symfony/Component/Inflector/composer.json b/src/Symfony/Component/Inflector/composer.json index 13f830de0191a..726500d1b6b83 100644 --- a/src/Symfony/Component/Inflector/composer.json +++ b/src/Symfony/Component/Inflector/composer.json @@ -23,7 +23,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/polyfill-ctype": "~1.8" }, "autoload": { diff --git a/src/Symfony/Component/Intl/composer.json b/src/Symfony/Component/Intl/composer.json index bb8c14ef03871..966a4b5120463 100644 --- a/src/Symfony/Component/Intl/composer.json +++ b/src/Symfony/Component/Intl/composer.json @@ -24,7 +24,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/polyfill-intl-icu": "~1.0" }, "require-dev": { diff --git a/src/Symfony/Component/Ldap/composer.json b/src/Symfony/Component/Ldap/composer.json index d0224e729c860..0a1a7b10409ec 100644 --- a/src/Symfony/Component/Ldap/composer.json +++ b/src/Symfony/Component/Ldap/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/options-resolver": "^4.2|^5.0", "ext-ldap": "*" }, diff --git a/src/Symfony/Component/Lock/composer.json b/src/Symfony/Component/Lock/composer.json index 07e751c7e7ed0..17e4c1a994d5c 100644 --- a/src/Symfony/Component/Lock/composer.json +++ b/src/Symfony/Component/Lock/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "psr/log": "~1.0" }, "require-dev": { diff --git a/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json b/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json index 60d740c532975..cbd98527d5e8f 100644 --- a/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/mailer": "^4.3|^5.0" }, "require-dev": { diff --git a/src/Symfony/Component/Mailer/Bridge/Google/composer.json b/src/Symfony/Component/Mailer/Bridge/Google/composer.json index 752d19a779a87..7618aefdc741b 100644 --- a/src/Symfony/Component/Mailer/Bridge/Google/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Google/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/mailer": "^4.3|^5.0" }, "require-dev": { diff --git a/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json b/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json index c3771a67d6348..fa065233f48ec 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/mailer": "^4.3|^5.0" }, "require-dev": { diff --git a/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json b/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json index 5d33ebdd72ff0..bb8f08c889af3 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/mailer": "^4.3|^5.0" }, "require-dev": { diff --git a/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json b/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json index fdf31c6ac4461..0f7e3d2983741 100644 --- a/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/mailer": "^4.3|^5.0" }, "require-dev": { diff --git a/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json b/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json index 9af34fe33a305..5792618533e97 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/mailer": "^4.3|^5.0" }, "require-dev": { diff --git a/src/Symfony/Component/Mailer/composer.json b/src/Symfony/Component/Mailer/composer.json index bf148d1023876..52fe86404ddbe 100644 --- a/src/Symfony/Component/Mailer/composer.json +++ b/src/Symfony/Component/Mailer/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "egulias/email-validator": "^2.0", "psr/log": "~1.0", "symfony/event-dispatcher": "^4.3|^5.0", diff --git a/src/Symfony/Component/Messenger/composer.json b/src/Symfony/Component/Messenger/composer.json index be3c9d850af30..4f6c425af0f59 100644 --- a/src/Symfony/Component/Messenger/composer.json +++ b/src/Symfony/Component/Messenger/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "psr/log": "~1.0" }, "require-dev": { diff --git a/src/Symfony/Component/Mime/composer.json b/src/Symfony/Component/Mime/composer.json index f6c7839aea1a5..1a3e73e0220c8 100644 --- a/src/Symfony/Component/Mime/composer.json +++ b/src/Symfony/Component/Mime/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/polyfill-intl-idn": "^1.10", "symfony/polyfill-mbstring": "^1.0" }, diff --git a/src/Symfony/Component/OptionsResolver/composer.json b/src/Symfony/Component/OptionsResolver/composer.json index c37b78f04edee..ce5df16eb164d 100644 --- a/src/Symfony/Component/OptionsResolver/composer.json +++ b/src/Symfony/Component/OptionsResolver/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.2.9" }, "autoload": { "psr-4": { "Symfony\\Component\\OptionsResolver\\": "" }, diff --git a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php index 6d69a77e08627..65d5451a0abad 100644 --- a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php @@ -132,9 +132,6 @@ public function testFindProcessInOpenBasedir() $this->assertSamePath(PHP_BINARY, $result); } - /** - * @requires PHP 5.4 - */ public function testFindBatchExecutableOnWindows() { if (ini_get('open_basedir')) { diff --git a/src/Symfony/Component/Process/composer.json b/src/Symfony/Component/Process/composer.json index 9dcdd6de85440..cfccd2832d60d 100644 --- a/src/Symfony/Component/Process/composer.json +++ b/src/Symfony/Component/Process/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.2.9" }, "autoload": { "psr-4": { "Symfony\\Component\\Process\\": "" }, diff --git a/src/Symfony/Component/PropertyAccess/composer.json b/src/Symfony/Component/PropertyAccess/composer.json index c39480c49b29c..47722d1084278 100644 --- a/src/Symfony/Component/PropertyAccess/composer.json +++ b/src/Symfony/Component/PropertyAccess/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/inflector": "^3.4|^4.0|^5.0" }, "require-dev": { diff --git a/src/Symfony/Component/PropertyInfo/composer.json b/src/Symfony/Component/PropertyInfo/composer.json index 0a2930b93f368..fdc05cd45349a 100644 --- a/src/Symfony/Component/PropertyInfo/composer.json +++ b/src/Symfony/Component/PropertyInfo/composer.json @@ -23,7 +23,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/inflector": "^3.4|^4.0|^5.0" }, "require-dev": { diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php index e3c1a3318bb76..dfe153e80f400 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php @@ -61,9 +61,6 @@ public function testLoadVariadic() $this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php'); } - /** - * @requires PHP 7.0 - */ public function testLoadAnonymousClass() { $this->reader->expects($this->never())->method('getClassAnnotation'); diff --git a/src/Symfony/Component/Routing/composer.json b/src/Symfony/Component/Routing/composer.json index 1c2e8b551348e..fadd5873db327 100644 --- a/src/Symfony/Component/Routing/composer.json +++ b/src/Symfony/Component/Routing/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.2.9" }, "require-dev": { "symfony/config": "^4.2|^5.0", diff --git a/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php index d7b53d34b0854..d63722c1ec0ae 100644 --- a/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php +++ b/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php @@ -67,7 +67,7 @@ public function encodePassword($raw, $salt) throw new BadCredentialsException('Invalid password.'); } - if (\PHP_VERSION_ID >= 70200 && \defined('PASSWORD_ARGON2I')) { + if (\defined('PASSWORD_ARGON2I')) { return $this->encodePasswordNative($raw); } if (\function_exists('sodium_crypto_pwhash_str')) { @@ -87,7 +87,7 @@ public function isPasswordValid($encoded, $raw, $salt) { // If $encoded was created via "sodium_crypto_pwhash_str()", the hashing algorithm may be "argon2id" instead of "argon2i". // In this case, "password_verify()" cannot be used. - if (\PHP_VERSION_ID >= 70200 && \defined('PASSWORD_ARGON2I') && (false === strpos($encoded, '$argon2id$'))) { + if (\defined('PASSWORD_ARGON2I') && (false === strpos($encoded, '$argon2id$'))) { return !$this->isPasswordTooLong($raw) && password_verify($raw, $encoded); } if (\function_exists('sodium_crypto_pwhash_str_verify')) { diff --git a/src/Symfony/Component/Security/Core/composer.json b/src/Symfony/Component/Security/Core/composer.json index 73d3a65079b0e..3e999f28f62f7 100644 --- a/src/Symfony/Component/Security/Core/composer.json +++ b/src/Symfony/Component/Security/Core/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/event-dispatcher-contracts": "^1.1", "symfony/service-contracts": "^1.1" }, diff --git a/src/Symfony/Component/Security/Csrf/composer.json b/src/Symfony/Component/Security/Csrf/composer.json index 4224b31b44ec1..1e63ef64a1008 100644 --- a/src/Symfony/Component/Security/Csrf/composer.json +++ b/src/Symfony/Component/Security/Csrf/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/security-core": "^3.4|^4.0|^5.0" }, "require-dev": { diff --git a/src/Symfony/Component/Security/Guard/composer.json b/src/Symfony/Component/Security/Guard/composer.json index 2286d81d405d1..2b01456cc7f2f 100644 --- a/src/Symfony/Component/Security/Guard/composer.json +++ b/src/Symfony/Component/Security/Guard/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/security-core": "^3.4.22|^4.2.3|^5.0", "symfony/security-http": "^4.3|^5.0" }, diff --git a/src/Symfony/Component/Security/Http/composer.json b/src/Symfony/Component/Security/Http/composer.json index 9b0edc6d60a70..1a9dd2cbac96a 100644 --- a/src/Symfony/Component/Security/Http/composer.json +++ b/src/Symfony/Component/Security/Http/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/security-core": "^4.3|^5.0", "symfony/http-foundation": "^3.4|^4.0|^5.0", "symfony/http-kernel": "^4.3|^5.0", diff --git a/src/Symfony/Component/Security/composer.json b/src/Symfony/Component/Security/composer.json index 700514350f74a..a955482ca460a 100644 --- a/src/Symfony/Component/Security/composer.json +++ b/src/Symfony/Component/Security/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/event-dispatcher-contracts": "^1.1", "symfony/http-foundation": "^3.4|^4.0|^5.0", "symfony/http-kernel": "^4.3|^5.0", diff --git a/src/Symfony/Component/Serializer/composer.json b/src/Symfony/Component/Serializer/composer.json index 575a3f5fe09ff..4ab4ea2a7ce2c 100644 --- a/src/Symfony/Component/Serializer/composer.json +++ b/src/Symfony/Component/Serializer/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/polyfill-ctype": "~1.8" }, "require-dev": { diff --git a/src/Symfony/Component/Stopwatch/composer.json b/src/Symfony/Component/Stopwatch/composer.json index 84a3f4ea26d0d..fdf5a7d3235c5 100644 --- a/src/Symfony/Component/Stopwatch/composer.json +++ b/src/Symfony/Component/Stopwatch/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/service-contracts": "^1.0" }, "autoload": { diff --git a/src/Symfony/Component/Templating/composer.json b/src/Symfony/Component/Templating/composer.json index 50b9082281729..3847be666baef 100644 --- a/src/Symfony/Component/Templating/composer.json +++ b/src/Symfony/Component/Templating/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/polyfill-ctype": "~1.8" }, "require-dev": { diff --git a/src/Symfony/Component/Translation/composer.json b/src/Symfony/Component/Translation/composer.json index 9aeaf1c96b179..455dbe498d65b 100644 --- a/src/Symfony/Component/Translation/composer.json +++ b/src/Symfony/Component/Translation/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/polyfill-mbstring": "~1.0", "symfony/translation-contracts": "^1.1.2" }, diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index c9ac106c1419b..48846b1d64bb8 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.0", "symfony/translation-contracts": "^1.1" diff --git a/src/Symfony/Component/VarDumper/Caster/Caster.php b/src/Symfony/Component/VarDumper/Caster/Caster.php index 292bd67eb4bd4..a8a7e212475ae 100644 --- a/src/Symfony/Component/VarDumper/Caster/Caster.php +++ b/src/Symfony/Component/VarDumper/Caster/Caster.php @@ -65,7 +65,7 @@ public static function castObject($obj, $class, $hasDebugInfo = false) $i = 0; $prefixedKeys = []; foreach ($a as $k => $v) { - if (isset($k[0]) ? "\0" !== $k[0] : \PHP_VERSION_ID >= 70200) { + if ("\0" !== ($k[0] ?? '')) { if (!isset($publicProperties[$class])) { foreach (get_class_vars($class) as $prop => $v) { $publicProperties[$class][$prop] = true; diff --git a/src/Symfony/Component/VarDumper/Caster/DateCaster.php b/src/Symfony/Component/VarDumper/Caster/DateCaster.php index 29c123d6ee5e3..175a6df39385c 100644 --- a/src/Symfony/Component/VarDumper/Caster/DateCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/DateCaster.php @@ -83,18 +83,16 @@ public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stu public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, $isNested, $filter) { $dates = []; - if (\PHP_VERSION_ID >= 70107) { // see https://bugs.php.net/bug.php?id=74639 - foreach (clone $p as $i => $d) { - if (self::PERIOD_LIMIT === $i) { - $now = new \DateTimeImmutable(); - $dates[] = sprintf('%s more', ($end = $p->getEndDate()) - ? ceil(($end->format('U.u') - $d->format('U.u')) / ($now->add($p->getDateInterval())->format('U.u') - $now->format('U.u'))) - : $p->recurrences - $i - ); - break; - } - $dates[] = sprintf('%s) %s', $i + 1, self::formatDateTime($d)); + foreach (clone $p as $i => $d) { + if (self::PERIOD_LIMIT === $i) { + $now = new \DateTimeImmutable(); + $dates[] = sprintf('%s more', ($end = $p->getEndDate()) + ? ceil(($end->format('U.u') - $d->format('U.u')) / ($now->add($p->getDateInterval())->format('U.u') - $now->format('U.u'))) + : $p->recurrences - $i + ); + break; } + $dates[] = sprintf('%s) %s', $i + 1, self::formatDateTime($d)); } $period = sprintf( diff --git a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php index b8318c514ffbf..4739088f14e1b 100644 --- a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php @@ -63,21 +63,6 @@ protected function doClone($var) } $refs = $vals = $queue[$i]; - if (\PHP_VERSION_ID < 70200 && empty($indexedArrays[$i])) { - // see https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts - foreach ($vals as $k => $v) { - if (\is_int($k)) { - continue; - } - foreach ([$k => true] as $gk => $gv) { - } - if ($gk !== $k) { - $fromObjCast = true; - $refs = $vals = \array_values($queue[$i]); - break; - } - } - } foreach ($vals as $k => $v) { // $v is the original value or a stub object in case of hard references $refs[$k] = $cookie; @@ -166,8 +151,6 @@ protected function doClone($var) } else { $a = $v; } - } elseif (\PHP_VERSION_ID < 70200) { - $indexedArrays[$len] = true; } break; diff --git a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php index 3ca3e33587c41..6f50b41fe9797 100644 --- a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php @@ -619,7 +619,7 @@ private function isWindowsTrueColor() || 'xterm' === getenv('TERM') || 'Hyper' === getenv('TERM_PROGRAM'); - if (!$result && \PHP_VERSION_ID >= 70200) { + if (!$result) { $version = sprintf( '%s.%s.%s', PHP_WINDOWS_VERSION_MAJOR, diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php index dae13efe5671f..dbfd3fd8cb1e3 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php @@ -94,10 +94,6 @@ public function provideDateTimes() */ public function testDumpInterval($intervalSpec, $ms, $invert, $expected) { - if ($ms && \PHP_VERSION_ID >= 70200 && version_compare(PHP_VERSION, '7.2.0rc3', '<=')) { - $this->markTestSkipped('Skipped on 7.2 before rc4 because of php bug #75354.'); - } - $interval = $this->createInterval($intervalSpec, $ms, $invert); $xDump = <<= 70200 && version_compare(PHP_VERSION, '7.2.0rc3', '<=')) { - $this->markTestSkipped('Skipped on 7.2 before rc4 because of php bug #75354.'); - } - $interval = $this->createInterval($intervalSpec, $ms, $invert); $xDump = <<= 70200 && version_compare(PHP_VERSION, '7.2.0rc3', '<=')) { - $this->markTestSkipped('Skipped on 7.2 before rc4 because of php bug #75354.'); - } - $interval = $this->createInterval($intervalSpec, $ms, $invert); $stub = new Stub(); @@ -372,10 +360,6 @@ public function providePeriods() ['2017-01-01', 'P1D', 2, \DatePeriod::EXCLUDE_START_DATE, 'every + 1d, from 2017-01-01 00:00:00.0 (excluded) recurring 2 time/s', '1) 2017-01-02%a2) 2017-01-03'], ]; - if (\PHP_VERSION_ID < 70107) { - array_walk($periods, function (&$i) { $i[5] = ''; }); - } - return $periods; } diff --git a/src/Symfony/Component/VarDumper/Tests/Cloner/VarClonerTest.php b/src/Symfony/Component/VarDumper/Tests/Cloner/VarClonerTest.php index d3141c6eaf285..e9720565ad848 100644 --- a/src/Symfony/Component/VarDumper/Tests/Cloner/VarClonerTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Cloner/VarClonerTest.php @@ -376,7 +376,7 @@ public function testJsonCast() EOTXT; ob_start(); var_dump($clone); - $this->assertStringMatchesFormat(\PHP_VERSION_ID >= 70200 ? str_replace('"1"', '1', $expected) : $expected, ob_get_clean()); + $this->assertStringMatchesFormat(str_replace('"1"', '1', $expected), ob_get_clean()); } public function testCaster() diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php b/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php index fc623808ce1d6..7dea0b59f7499 100644 --- a/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Dumper/CliDumperTest.php @@ -225,9 +225,8 @@ public function testJsonCast() $var[] = &$v; $var[''] = 2; - if (\PHP_VERSION_ID >= 70200) { - $this->assertDumpMatchesFormat( - <<<'EOTXT' + $this->assertDumpMatchesFormat( + <<<'EOTXT' array:4 [ 0 => {} 1 => &1 null @@ -235,23 +234,9 @@ public function testJsonCast() "" => 2 ] EOTXT - , - $var - ); - } else { - $this->assertDumpMatchesFormat( - <<<'EOTXT' -array:4 [ - "0" => {} - "1" => &1 null - 0 => &1 null - "" => 2 -] -EOTXT - , - $var - ); - } + , + $var + ); } public function testObjectCast() @@ -259,28 +244,15 @@ public function testObjectCast() $var = (object) [1 => 1]; $var->{1} = 2; - if (\PHP_VERSION_ID >= 70200) { - $this->assertDumpMatchesFormat( - <<<'EOTXT' -{ - +"1": 2 -} -EOTXT - , - $var - ); - } else { - $this->assertDumpMatchesFormat( - <<<'EOTXT' + $this->assertDumpMatchesFormat( + <<<'EOTXT' { - +1: 1 +"1": 2 } EOTXT - , - $var - ); - } + , + $var + ); } public function testClosedResource() diff --git a/src/Symfony/Component/VarDumper/composer.json b/src/Symfony/Component/VarDumper/composer.json index 2d244b7747847..5a46220109451 100644 --- a/src/Symfony/Component/VarDumper/composer.json +++ b/src/Symfony/Component/VarDumper/composer.json @@ -16,9 +16,8 @@ } ], "require": { - "php": "^7.1.3", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php72": "~1.5" + "php": "^7.2.9", + "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { "ext-iconv": "*", diff --git a/src/Symfony/Component/VarExporter/composer.json b/src/Symfony/Component/VarExporter/composer.json index 533cd3ef56d4a..a37226d12cc3b 100644 --- a/src/Symfony/Component/VarExporter/composer.json +++ b/src/Symfony/Component/VarExporter/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.2.9" }, "require-dev": { "symfony/var-dumper": "^4.1.1|^5.0" diff --git a/src/Symfony/Component/WebLink/composer.json b/src/Symfony/Component/WebLink/composer.json index 48706097f155e..9ca0bbec56c5e 100644 --- a/src/Symfony/Component/WebLink/composer.json +++ b/src/Symfony/Component/WebLink/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "fig/link-util": "^1.0", "psr/link": "^1.0" }, diff --git a/src/Symfony/Component/Workflow/composer.json b/src/Symfony/Component/Workflow/composer.json index 45fe11b082cdb..f8285800ea13e 100644 --- a/src/Symfony/Component/Workflow/composer.json +++ b/src/Symfony/Component/Workflow/composer.json @@ -20,7 +20,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/property-access": "^3.4|^4.0|^5.0" }, "require-dev": { diff --git a/src/Symfony/Component/Yaml/composer.json b/src/Symfony/Component/Yaml/composer.json index ed1c7b54d95d9..cd6fe054351bb 100644 --- a/src/Symfony/Component/Yaml/composer.json +++ b/src/Symfony/Component/Yaml/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3", + "php": "^7.2.9", "symfony/polyfill-ctype": "~1.8" }, "require-dev": { diff --git a/src/Symfony/Contracts/Cache/composer.json b/src/Symfony/Contracts/Cache/composer.json index 719146ace195f..3c86b9cab45a2 100644 --- a/src/Symfony/Contracts/Cache/composer.json +++ b/src/Symfony/Contracts/Cache/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.2.9" }, "suggest": { "psr/cache": "", @@ -28,7 +28,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } } } diff --git a/src/Symfony/Contracts/EventDispatcher/composer.json b/src/Symfony/Contracts/EventDispatcher/composer.json index 8251d90a0cb45..ae617313cd831 100644 --- a/src/Symfony/Contracts/EventDispatcher/composer.json +++ b/src/Symfony/Contracts/EventDispatcher/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.2.9" }, "suggest": { "psr/event-dispatcher": "", @@ -28,7 +28,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } } } diff --git a/src/Symfony/Contracts/HttpClient/composer.json b/src/Symfony/Contracts/HttpClient/composer.json index 718852d5c0a18..9a064141485e9 100644 --- a/src/Symfony/Contracts/HttpClient/composer.json +++ b/src/Symfony/Contracts/HttpClient/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.2.9" }, "suggest": { "symfony/http-client-implementation": "" @@ -27,7 +27,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } } } diff --git a/src/Symfony/Contracts/Service/composer.json b/src/Symfony/Contracts/Service/composer.json index 11f98854f1c52..ab16f54ddd936 100644 --- a/src/Symfony/Contracts/Service/composer.json +++ b/src/Symfony/Contracts/Service/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.2.9" }, "suggest": { "psr/container": "", @@ -28,7 +28,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } } } diff --git a/src/Symfony/Contracts/Translation/composer.json b/src/Symfony/Contracts/Translation/composer.json index 22ef38363eb38..3f64ef801e9e8 100644 --- a/src/Symfony/Contracts/Translation/composer.json +++ b/src/Symfony/Contracts/Translation/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.2.9" }, "suggest": { "symfony/translation-implementation": "" @@ -27,7 +27,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } } } diff --git a/src/Symfony/Contracts/composer.json b/src/Symfony/Contracts/composer.json index 850d66eb5404f..f1da7d46a586f 100644 --- a/src/Symfony/Contracts/composer.json +++ b/src/Symfony/Contracts/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1.3" + "php": "^7.2.9" }, "require-dev": { "psr/cache": "^1.0", @@ -49,7 +49,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } } } From 2dffc58aacdc2bd03b605a2fc2c221e6a144cc28 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 28 May 2019 19:17:01 +0200 Subject: [PATCH 003/588] Bump deps to ^4.4|^5.0 for Symfony 5.0 --- src/Symfony/Bridge/Doctrine/composer.json | 31 ++++--- src/Symfony/Bridge/Monolog/composer.json | 12 +-- src/Symfony/Bridge/PhpUnit/composer.json | 2 +- src/Symfony/Bridge/ProxyManager/composer.json | 4 +- src/Symfony/Bridge/Twig/composer.json | 45 +++++----- src/Symfony/Bundle/DebugBundle/composer.json | 16 ++-- .../Bundle/FrameworkBundle/composer.json | 84 ++++++++----------- .../Bundle/SecurityBundle/composer.json | 53 +++++------- src/Symfony/Bundle/TwigBundle/composer.json | 37 ++++---- .../Bundle/WebProfilerBundle/composer.json | 22 ++--- .../Bundle/WebServerBundle/composer.json | 10 +-- src/Symfony/Component/Asset/composer.json | 4 +- .../Component/BrowserKit/composer.json | 10 +-- src/Symfony/Component/Cache/composer.json | 12 ++- src/Symfony/Component/Config/composer.json | 15 ++-- src/Symfony/Component/Console/composer.json | 17 ++-- src/Symfony/Component/Debug/composer.json | 5 +- .../DependencyInjection/composer.json | 12 +-- .../Component/DomCrawler/composer.json | 2 +- src/Symfony/Component/Dotenv/composer.json | 2 +- .../Component/EventDispatcher/composer.json | 13 ++- .../ExpressionLanguage/composer.json | 2 +- src/Symfony/Component/Form/composer.json | 36 ++++---- .../Component/HttpClient/composer.json | 4 +- .../Component/HttpFoundation/composer.json | 4 +- .../Component/HttpKernel/composer.json | 39 ++++----- src/Symfony/Component/Intl/composer.json | 2 +- src/Symfony/Component/Ldap/composer.json | 5 +- .../Mailer/Bridge/Amazon/composer.json | 4 +- .../Mailer/Bridge/Google/composer.json | 4 +- .../Mailer/Bridge/Mailchimp/composer.json | 4 +- .../Mailer/Bridge/Mailgun/composer.json | 4 +- .../Mailer/Bridge/Postmark/composer.json | 4 +- .../Mailer/Bridge/Sendgrid/composer.json | 4 +- src/Symfony/Component/Mailer/composer.json | 16 ++-- src/Symfony/Component/Messenger/composer.json | 28 +++---- src/Symfony/Component/Mime/composer.json | 2 +- .../Component/PropertyAccess/composer.json | 4 +- .../Component/PropertyInfo/composer.json | 12 ++- src/Symfony/Component/Routing/composer.json | 15 ++-- .../Component/Security/Core/composer.json | 14 ++-- .../Component/Security/Csrf/composer.json | 7 +- .../Component/Security/Guard/composer.json | 4 +- .../Component/Security/Http/composer.json | 15 ++-- src/Symfony/Component/Security/composer.json | 16 ++-- .../Component/Serializer/composer.json | 22 ++--- .../Component/Translation/composer.json | 23 ++--- src/Symfony/Component/Validator/composer.json | 33 ++++---- src/Symfony/Component/VarDumper/composer.json | 7 +- .../Component/VarExporter/composer.json | 2 +- src/Symfony/Component/WebLink/composer.json | 7 +- src/Symfony/Component/Workflow/composer.json | 15 ++-- src/Symfony/Component/Yaml/composer.json | 5 +- 53 files changed, 319 insertions(+), 452 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 0fb1b8a305fb5..b22442cf6d2da 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -24,19 +24,19 @@ "symfony/service-contracts": "^1.1" }, "require-dev": { - "symfony/stopwatch": "^3.4|^4.0|^5.0", - "symfony/config": "^4.2|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/form": "^4.3|^5.0", - "symfony/http-kernel": "^3.4|^4.0|^5.0", - "symfony/messenger": "^4.3|^5.0", - "symfony/property-access": "^3.4|^4.0|^5.0", - "symfony/property-info": "^3.4|^4.0|^5.0", - "symfony/proxy-manager-bridge": "^3.4|^4.0|^5.0", - "symfony/security-core": "^3.4|^4.0|^5.0", - "symfony/expression-language": "^3.4|^4.0|^5.0", - "symfony/validator": "^3.4|^4.0|^5.0", - "symfony/translation": "^3.4|^4.0|^5.0", + "symfony/stopwatch": "^4.4|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/form": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", + "symfony/messenger": "^4.4|^5.0", + "symfony/property-access": "^4.4|^5.0", + "symfony/property-info": "^4.4|^5.0", + "symfony/proxy-manager-bridge": "^4.4|^5.0", + "symfony/security-core": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/validator": "^4.4|^5.0", + "symfony/translation": "^4.4|^5.0", "doctrine/annotations": "~1.0", "doctrine/cache": "~1.6", "doctrine/collections": "~1.0", @@ -46,10 +46,7 @@ "doctrine/reflection": "~1.0" }, "conflict": { - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", - "symfony/dependency-injection": "<3.4", - "symfony/form": "<4.3", - "symfony/messenger": "<4.3" + "phpunit/phpunit": "<5.4.3" }, "suggest": { "symfony/form": "", diff --git a/src/Symfony/Bridge/Monolog/composer.json b/src/Symfony/Bridge/Monolog/composer.json index 7c08b8b97e871..f80ac3b6ed725 100644 --- a/src/Symfony/Bridge/Monolog/composer.json +++ b/src/Symfony/Bridge/Monolog/composer.json @@ -19,16 +19,12 @@ "php": "^7.2.9", "monolog/monolog": "~1.19", "symfony/service-contracts": "^1.1", - "symfony/http-kernel": "^4.3|^5.0" + "symfony/http-kernel": "^4.4|^5.0" }, "require-dev": { - "symfony/console": "^3.4|^4.0|^5.0", - "symfony/security-core": "^3.4|^4.0|^5.0", - "symfony/var-dumper": "^3.4|^4.0|^5.0" - }, - "conflict": { - "symfony/console": "<3.4", - "symfony/http-foundation": "<3.4" + "symfony/console": "^4.4|^5.0", + "symfony/security-core": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0" }, "suggest": { "symfony/http-kernel": "For using the debugging handlers together with the response life cycle of the HTTP kernel.", diff --git a/src/Symfony/Bridge/PhpUnit/composer.json b/src/Symfony/Bridge/PhpUnit/composer.json index 8d7fe1259852b..570e9fae86704 100644 --- a/src/Symfony/Bridge/PhpUnit/composer.json +++ b/src/Symfony/Bridge/PhpUnit/composer.json @@ -24,7 +24,7 @@ "symfony/debug": "For tracking deprecated interfaces usages at runtime with DebugClassLoader" }, "conflict": { - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0" + "phpunit/phpunit": "<5.4.3" }, "autoload": { "files": [ "bootstrap.php" ], diff --git a/src/Symfony/Bridge/ProxyManager/composer.json b/src/Symfony/Bridge/ProxyManager/composer.json index 3af8ab6cbe088..6c9bee243f264 100644 --- a/src/Symfony/Bridge/ProxyManager/composer.json +++ b/src/Symfony/Bridge/ProxyManager/composer.json @@ -17,11 +17,11 @@ ], "require": { "php": "^7.2.9", - "symfony/dependency-injection": "^4.0|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", "ocramius/proxy-manager": "~2.1" }, "require-dev": { - "symfony/config": "^3.4|^4.0|^5.0" + "symfony/config": "^4.4|^5.0" }, "conflict": { "zendframework/zend-eventmanager": "2.6.0" diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index 7b289952e279c..9baea3fb3ce21 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -21,34 +21,27 @@ }, "require-dev": { "egulias/email-validator": "^2.0", - "symfony/asset": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/finder": "^3.4|^4.0|^5.0", - "symfony/form": "^4.3|^5.0", - "symfony/http-foundation": "^4.3|^5.0", - "symfony/http-kernel": "^3.4|^4.0|^5.0", - "symfony/mime": "~4.3|^5.0", + "symfony/asset": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/finder": "^4.4|^5.0", + "symfony/form": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", + "symfony/mime": "^4.4|^5.0", "symfony/polyfill-intl-icu": "~1.0", - "symfony/routing": "^3.4|^4.0|^5.0", - "symfony/templating": "^3.4|^4.0|^5.0", - "symfony/translation": "^4.2.1|^5.0", - "symfony/yaml": "^3.4|^4.0|^5.0", + "symfony/routing": "^4.4|^5.0", + "symfony/templating": "^4.4|^5.0", + "symfony/translation": "^4.4|^5.0", + "symfony/yaml": "^4.4|^5.0", "symfony/security-acl": "^2.8|^3.0", - "symfony/security-csrf": "^3.4|^4.0|^5.0", - "symfony/security-http": "^3.4|^4.0|^5.0", - "symfony/stopwatch": "^3.4|^4.0|^5.0", - "symfony/console": "^3.4|^4.0|^5.0", - "symfony/var-dumper": "^3.4|^4.0|^5.0", - "symfony/expression-language": "^3.4|^4.0|^5.0", - "symfony/web-link": "^3.4|^4.0|^5.0", - "symfony/workflow": "^4.3|^5.0" - }, - "conflict": { - "symfony/console": "<3.4", - "symfony/form": "<4.3", - "symfony/http-foundation": "<4.3", - "symfony/translation": "<4.2", - "symfony/workflow": "<4.3" + "symfony/security-csrf": "^4.4|^5.0", + "symfony/security-http": "^4.4|^5.0", + "symfony/stopwatch": "^4.4|^5.0", + "symfony/console": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/web-link": "^4.4|^5.0", + "symfony/workflow": "^4.4|^5.0" }, "suggest": { "symfony/finder": "", diff --git a/src/Symfony/Bundle/DebugBundle/composer.json b/src/Symfony/Bundle/DebugBundle/composer.json index 2185e4e4adb3c..7e1b9236ab70e 100644 --- a/src/Symfony/Bundle/DebugBundle/composer.json +++ b/src/Symfony/Bundle/DebugBundle/composer.json @@ -18,18 +18,14 @@ "require": { "php": "^7.2.9", "ext-xml": "*", - "symfony/http-kernel": "^3.4|^4.0|^5.0", - "symfony/twig-bridge": "^3.4|^4.0|^5.0", - "symfony/var-dumper": "^4.1.1|^5.0" + "symfony/http-kernel": "^4.4|^5.0", + "symfony/twig-bridge": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0" }, "require-dev": { - "symfony/config": "^4.2|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/web-profiler-bundle": "^3.4|^4.0|^5.0" - }, - "conflict": { - "symfony/config": "<4.2", - "symfony/dependency-injection": "<3.4" + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/web-profiler-bundle": "^4.4|^5.0" }, "suggest": { "symfony/config": "For service container configuration", diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index bff01ac768ee0..c7dfdcb277e00 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -18,46 +18,46 @@ "require": { "php": "^7.2.9", "ext-xml": "*", - "symfony/cache": "^4.3|^5.0", - "symfony/config": "^4.2|^5.0", - "symfony/dependency-injection": "^4.3|^5.0", - "symfony/http-foundation": "^4.3|^5.0", - "symfony/http-kernel": "^4.3|^5.0", + "symfony/cache": "^4.4|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", "symfony/polyfill-mbstring": "~1.0", - "symfony/filesystem": "^3.4|^4.0|^5.0", - "symfony/finder": "^3.4|^4.0|^5.0", - "symfony/routing": "^4.3|^5.0" + "symfony/filesystem": "^4.4|^5.0", + "symfony/finder": "^4.4|^5.0", + "symfony/routing": "^4.4|^5.0" }, "require-dev": { "doctrine/cache": "~1.0", "fig/link-util": "^1.0", - "symfony/asset": "^3.4|^4.0|^5.0", - "symfony/browser-kit": "^4.3|^5.0", - "symfony/console": "^4.3|^5.0", - "symfony/css-selector": "^3.4|^4.0|^5.0", - "symfony/dom-crawler": "^4.3|^5.0", + "symfony/asset": "^4.4|^5.0", + "symfony/browser-kit": "^4.4|^5.0", + "symfony/console": "^4.4|^5.0", + "symfony/css-selector": "^4.4|^5.0", + "symfony/dom-crawler": "^4.4|^5.0", "symfony/polyfill-intl-icu": "~1.0", - "symfony/form": "^4.3|^5.0", - "symfony/expression-language": "^3.4|^4.0|^5.0", - "symfony/http-client": "^4.3|^5.0", - "symfony/mailer": "^4.3|^5.0", - "symfony/messenger": "^4.3|^5.0", - "symfony/mime": "^4.3|^5.0", - "symfony/process": "^3.4|^4.0|^5.0", - "symfony/security-csrf": "^3.4|^4.0|^5.0", - "symfony/security-http": "^3.4|^4.0|^5.0", - "symfony/serializer": "^4.3|^5.0", - "symfony/stopwatch": "^3.4|^4.0|^5.0", - "symfony/translation": "^4.2|^5.0", - "symfony/templating": "^3.4|^4.0|^5.0", - "symfony/twig-bundle": "^3.4|^4.0|^5.0", - "symfony/validator": "^4.1|^5.0", - "symfony/var-dumper": "^4.3|^5.0", - "symfony/workflow": "^4.3|^5.0", - "symfony/yaml": "^3.4|^4.0|^5.0", - "symfony/property-info": "^3.4|^4.0|^5.0", - "symfony/lock": "^3.4|^4.0|^5.0", - "symfony/web-link": "^3.4|^4.0|^5.0", + "symfony/form": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/http-client": "^4.4|^5.0", + "symfony/mailer": "^4.4|^5.0", + "symfony/messenger": "^4.4|^5.0", + "symfony/mime": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0", + "symfony/security-csrf": "^4.4|^5.0", + "symfony/security-http": "^4.4|^5.0", + "symfony/serializer": "^4.4|^5.0", + "symfony/stopwatch": "^4.4|^5.0", + "symfony/translation": "^4.4|^5.0", + "symfony/templating": "^4.4|^5.0", + "symfony/twig-bundle": "^4.4|^5.0", + "symfony/validator": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0", + "symfony/workflow": "^4.4|^5.0", + "symfony/yaml": "^4.4|^5.0", + "symfony/property-info": "^4.4|^5.0", + "symfony/lock": "^4.4|^5.0", + "symfony/web-link": "^4.4|^5.0", "doctrine/annotations": "~1.0", "phpdocumentor/reflection-docblock": "^3.0|^4.0", "twig/twig": "~1.34|~2.4" @@ -65,21 +65,7 @@ "conflict": { "phpdocumentor/reflection-docblock": "<3.0", "phpdocumentor/type-resolver": "<0.2.1", - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", - "symfony/asset": "<3.4", - "symfony/browser-kit": "<4.3", - "symfony/console": "<4.3", - "symfony/dotenv": "<4.2", - "symfony/dom-crawler": "<4.3", - "symfony/form": "<4.3", - "symfony/messenger": "<4.3", - "symfony/property-info": "<3.4", - "symfony/serializer": "<4.2", - "symfony/stopwatch": "<3.4", - "symfony/translation": "<4.3", - "symfony/twig-bridge": "<4.1.1", - "symfony/validator": "<4.1", - "symfony/workflow": "<4.3" + "phpunit/phpunit": "<5.4.3" }, "suggest": { "ext-apcu": "For best performance of the system caches", diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index 328de335530a5..77065a0006827 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -18,41 +18,34 @@ "require": { "php": "^7.2.9", "ext-xml": "*", - "symfony/config": "^4.2|^5.0", - "symfony/dependency-injection": "^4.2|^5.0", - "symfony/http-kernel": "^4.3|^5.0", - "symfony/security-core": "^4.3|^5.0", - "symfony/security-csrf": "^4.2|^5.0", - "symfony/security-guard": "^4.2|^5.0", - "symfony/security-http": "^4.3|^5.0" + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", + "symfony/security-core": "^4.4|^5.0", + "symfony/security-csrf": "^4.4|^5.0", + "symfony/security-guard": "^4.4|^5.0", + "symfony/security-http": "^4.4|^5.0" }, "require-dev": { - "symfony/asset": "^3.4|^4.0|^5.0", - "symfony/browser-kit": "^4.2|^5.0", - "symfony/console": "^3.4|^4.0|^5.0", - "symfony/css-selector": "^3.4|^4.0|^5.0", - "symfony/dom-crawler": "^3.4|^4.0|^5.0", - "symfony/form": "^3.4|^4.0|^5.0", - "symfony/framework-bundle": "^4.2|^5.0", - "symfony/http-foundation": "^3.4|^4.0|^5.0", - "symfony/translation": "^3.4|^4.0|^5.0", - "symfony/twig-bundle": "^4.2|^5.0", - "symfony/twig-bridge": "^3.4|^4.0|^5.0", - "symfony/process": "^3.4|^4.0|^5.0", - "symfony/validator": "^3.4|^4.0|^5.0", - "symfony/var-dumper": "^3.4|^4.0|^5.0", - "symfony/yaml": "^3.4|^4.0|^5.0", - "symfony/expression-language": "^3.4|^4.0|^5.0", + "symfony/asset": "^4.4|^5.0", + "symfony/browser-kit": "^4.4|^5.0", + "symfony/console": "^4.4|^5.0", + "symfony/css-selector": "^4.4|^5.0", + "symfony/dom-crawler": "^4.4|^5.0", + "symfony/form": "^4.4|^5.0", + "symfony/framework-bundle": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/translation": "^4.4|^5.0", + "symfony/twig-bundle": "^4.4|^5.0", + "symfony/twig-bridge": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0", + "symfony/validator": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0", + "symfony/yaml": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", "doctrine/doctrine-bundle": "~1.5", "twig/twig": "~1.34|~2.4" }, - "conflict": { - "symfony/browser-kit": "<4.2", - "symfony/twig-bundle": "<4.2", - "symfony/var-dumper": "<3.4", - "symfony/framework-bundle": "<4.2", - "symfony/console": "<3.4" - }, "autoload": { "psr-4": { "Symfony\\Bundle\\SecurityBundle\\": "" }, "exclude-from-classmap": [ diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index 643d0e09c6f48..b71cf96ae5706 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -17,34 +17,29 @@ ], "require": { "php": "^7.2.9", - "symfony/config": "^4.2|^5.0", - "symfony/twig-bridge": "^4.3|^5.0", - "symfony/http-foundation": "^4.3|^5.0", - "symfony/http-kernel": "^4.1|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/twig-bridge": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", "symfony/polyfill-ctype": "~1.8", "twig/twig": "~1.41|~2.10" }, "require-dev": { - "symfony/asset": "^3.4|^4.0|^5.0", - "symfony/stopwatch": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^4.2.5|^5.0", - "symfony/expression-language": "^3.4|^4.0|^5.0", - "symfony/finder": "^3.4|^4.0|^5.0", - "symfony/form": "^3.4|^4.0|^5.0", - "symfony/routing": "^3.4|^4.0|^5.0", - "symfony/templating": "^3.4|^4.0|^5.0", - "symfony/translation": "^4.2|^5.0", - "symfony/yaml": "^3.4|^4.0|^5.0", - "symfony/framework-bundle": "^4.3|^5.0", - "symfony/web-link": "^3.4|^4.0|^5.0", + "symfony/asset": "^4.4|^5.0", + "symfony/stopwatch": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/finder": "^4.4|^5.0", + "symfony/form": "^4.4|^5.0", + "symfony/routing": "^4.4|^5.0", + "symfony/templating": "^4.4|^5.0", + "symfony/translation": "^4.4|^5.0", + "symfony/yaml": "^4.4|^5.0", + "symfony/framework-bundle": "^4.4|^5.0", + "symfony/web-link": "^4.4|^5.0", "doctrine/annotations": "~1.0", "doctrine/cache": "~1.0" }, - "conflict": { - "symfony/dependency-injection": "<4.1", - "symfony/framework-bundle": "<4.3", - "symfony/translation": "<4.2" - }, "autoload": { "psr-4": { "Symfony\\Bundle\\TwigBundle\\": "" }, "exclude-from-classmap": [ diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json index c05e0f4fc610c..c5ac76836c1e4 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/composer.json +++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json @@ -17,23 +17,17 @@ ], "require": { "php": "^7.2.9", - "symfony/config": "^4.2|^5.0", - "symfony/http-kernel": "^4.3|^5.0", - "symfony/routing": "^3.4|^4.0|^5.0", - "symfony/twig-bundle": "^4.2|^5.0", - "symfony/var-dumper": "^3.4|^4.0|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", + "symfony/routing": "^4.4|^5.0", + "symfony/twig-bundle": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0", "twig/twig": "^1.41|^2.10" }, "require-dev": { - "symfony/console": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/stopwatch": "^3.4|^4.0|^5.0" - }, - "conflict": { - "symfony/dependency-injection": "<3.4", - "symfony/messenger": "<4.2", - "symfony/var-dumper": "<3.4", - "symfony/form": "<4.3" + "symfony/console": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/stopwatch": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Bundle\\WebProfilerBundle\\": "" }, diff --git a/src/Symfony/Bundle/WebServerBundle/composer.json b/src/Symfony/Bundle/WebServerBundle/composer.json index eef4a429e8180..d1d9db29c8e3f 100644 --- a/src/Symfony/Bundle/WebServerBundle/composer.json +++ b/src/Symfony/Bundle/WebServerBundle/composer.json @@ -17,12 +17,12 @@ ], "require": { "php": "^7.2.9", - "symfony/config": "^3.4|^4.0|^5.0", - "symfony/console": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/http-kernel": "^3.4|^4.0|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/console": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", "symfony/polyfill-ctype": "~1.8", - "symfony/process": "^3.4.2|^4.0.2|^5.0" + "symfony/process": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Bundle\\WebServerBundle\\": "" }, diff --git a/src/Symfony/Component/Asset/composer.json b/src/Symfony/Component/Asset/composer.json index 5485b234dd510..3d1c89fcc23ba 100644 --- a/src/Symfony/Component/Asset/composer.json +++ b/src/Symfony/Component/Asset/composer.json @@ -22,8 +22,8 @@ "symfony/http-foundation": "" }, "require-dev": { - "symfony/http-foundation": "^3.4|^4.0|^5.0", - "symfony/http-kernel": "^3.4|^4.0|^5.0" + "symfony/http-foundation": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Asset\\": "" }, diff --git a/src/Symfony/Component/BrowserKit/composer.json b/src/Symfony/Component/BrowserKit/composer.json index aaf320d9d3217..9326efd19c1c3 100644 --- a/src/Symfony/Component/BrowserKit/composer.json +++ b/src/Symfony/Component/BrowserKit/composer.json @@ -17,13 +17,13 @@ ], "require": { "php": "^7.2.9", - "symfony/dom-crawler": "^3.4|^4.0|^5.0" + "symfony/dom-crawler": "^4.4|^5.0" }, "require-dev": { - "symfony/css-selector": "^3.4|^4.0|^5.0", - "symfony/http-client": "^4.3|^5.0", - "symfony/mime": "^4.3|^5.0", - "symfony/process": "^3.4|^4.0|^5.0" + "symfony/css-selector": "^4.4|^5.0", + "symfony/http-client": "^4.4|^5.0", + "symfony/mime": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0" }, "suggest": { "symfony/process": "" diff --git a/src/Symfony/Component/Cache/composer.json b/src/Symfony/Component/Cache/composer.json index d5c30394ff838..ff9e99ca13ad6 100644 --- a/src/Symfony/Component/Cache/composer.json +++ b/src/Symfony/Component/Cache/composer.json @@ -26,7 +26,7 @@ "psr/log": "~1.0", "symfony/cache-contracts": "^1.1", "symfony/service-contracts": "^1.1", - "symfony/var-exporter": "^4.2|^5.0" + "symfony/var-exporter": "^4.4|^5.0" }, "require-dev": { "cache/integration-tests": "dev-master", @@ -34,14 +34,12 @@ "doctrine/dbal": "~2.5", "predis/predis": "~1.1", "psr/simple-cache": "^1.0", - "symfony/config": "^4.2|^5.0", - "symfony/dependency-injection": "^3.4|^4.1|^5.0", - "symfony/var-dumper": "^4.1.1|^5.0" + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0" }, "conflict": { - "doctrine/dbal": "<2.5", - "symfony/dependency-injection": "<3.4", - "symfony/var-dumper": "<3.4" + "doctrine/dbal": "<2.5" }, "autoload": { "psr-4": { "Symfony\\Component\\Cache\\": "" }, diff --git a/src/Symfony/Component/Config/composer.json b/src/Symfony/Component/Config/composer.json index 272de71a30412..bc7cf84d15a53 100644 --- a/src/Symfony/Component/Config/composer.json +++ b/src/Symfony/Component/Config/composer.json @@ -17,18 +17,15 @@ ], "require": { "php": "^7.2.9", - "symfony/filesystem": "^3.4|^4.0|^5.0", + "symfony/filesystem": "^4.4|^5.0", "symfony/polyfill-ctype": "~1.8" }, "require-dev": { - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/event-dispatcher": "^3.4|^4.0|^5.0", - "symfony/finder": "^3.4|^4.0|^5.0", - "symfony/messenger": "^4.1|^5.0", - "symfony/yaml": "^3.4|^4.0|^5.0" - }, - "conflict": { - "symfony/finder": "<3.4" + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/event-dispatcher": "^4.4|^5.0", + "symfony/finder": "^4.4|^5.0", + "symfony/messenger": "^4.4|^5.0", + "symfony/yaml": "^4.4|^5.0" }, "suggest": { "symfony/yaml": "To use the yaml reference dumper" diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index de3967df95760..74374e6a805f7 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -22,12 +22,12 @@ "symfony/service-contracts": "^1.1" }, "require-dev": { - "symfony/config": "^3.4|^4.0|^5.0", - "symfony/event-dispatcher": "^4.3|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/lock": "^3.4|^4.0|^5.0", - "symfony/process": "^3.4|^4.0|^5.0", - "symfony/var-dumper": "^4.3|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/event-dispatcher": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/lock": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0", "psr/log": "~1.0" }, "provide": { @@ -39,11 +39,6 @@ "symfony/process": "", "psr/log": "For using the console logger" }, - "conflict": { - "symfony/dependency-injection": "<3.4", - "symfony/event-dispatcher": "<4.3", - "symfony/process": "<3.3" - }, "autoload": { "psr-4": { "Symfony\\Component\\Console\\": "" }, "exclude-from-classmap": [ diff --git a/src/Symfony/Component/Debug/composer.json b/src/Symfony/Component/Debug/composer.json index cccd26bc290b0..a5e82c4a74353 100644 --- a/src/Symfony/Component/Debug/composer.json +++ b/src/Symfony/Component/Debug/composer.json @@ -19,11 +19,8 @@ "php": "^7.2.9", "psr/log": "~1.0" }, - "conflict": { - "symfony/http-kernel": "<3.4" - }, "require-dev": { - "symfony/http-kernel": "^3.4|^4.0|^5.0" + "symfony/http-kernel": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Debug\\": "" }, diff --git a/src/Symfony/Component/DependencyInjection/composer.json b/src/Symfony/Component/DependencyInjection/composer.json index 412ab98af41a9..f81ce8d02c655 100644 --- a/src/Symfony/Component/DependencyInjection/composer.json +++ b/src/Symfony/Component/DependencyInjection/composer.json @@ -21,9 +21,9 @@ "symfony/service-contracts": "^1.1.2" }, "require-dev": { - "symfony/yaml": "^3.4|^4.0|^5.0", - "symfony/config": "^4.3|^5.0", - "symfony/expression-language": "^3.4|^4.0|^5.0" + "symfony/yaml": "^4.4|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0" }, "suggest": { "symfony/yaml": "", @@ -32,12 +32,6 @@ "symfony/expression-language": "For using expressions in service container configuration", "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them" }, - "conflict": { - "symfony/config": "<4.3", - "symfony/finder": "<3.4", - "symfony/proxy-manager-bridge": "<3.4", - "symfony/yaml": "<3.4" - }, "provide": { "psr/container-implementation": "1.0", "symfony/service-implementation": "1.0" diff --git a/src/Symfony/Component/DomCrawler/composer.json b/src/Symfony/Component/DomCrawler/composer.json index e7866347a9742..866fa1f3da257 100644 --- a/src/Symfony/Component/DomCrawler/composer.json +++ b/src/Symfony/Component/DomCrawler/composer.json @@ -21,7 +21,7 @@ "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { - "symfony/css-selector": "^3.4|^4.0|^5.0", + "symfony/css-selector": "^4.4|^5.0", "masterminds/html5": "^2.6" }, "conflict": { diff --git a/src/Symfony/Component/Dotenv/composer.json b/src/Symfony/Component/Dotenv/composer.json index 2f673fbcd1188..6ca62b8d39d59 100644 --- a/src/Symfony/Component/Dotenv/composer.json +++ b/src/Symfony/Component/Dotenv/composer.json @@ -19,7 +19,7 @@ "php": "^7.2.9" }, "require-dev": { - "symfony/process": "^3.4|^4.0|^5.0" + "symfony/process": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Dotenv\\": "" }, diff --git a/src/Symfony/Component/EventDispatcher/composer.json b/src/Symfony/Component/EventDispatcher/composer.json index 9d32b42310948..34536b37ee26f 100644 --- a/src/Symfony/Component/EventDispatcher/composer.json +++ b/src/Symfony/Component/EventDispatcher/composer.json @@ -20,17 +20,14 @@ "symfony/event-dispatcher-contracts": "^1.1" }, "require-dev": { - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/expression-language": "^3.4|^4.0|^5.0", - "symfony/config": "^3.4|^4.0|^5.0", - "symfony/http-foundation": "^3.4|^4.0|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", "symfony/service-contracts": "^1.1", - "symfony/stopwatch": "^3.4|^4.0|^5.0", + "symfony/stopwatch": "^4.4|^5.0", "psr/log": "~1.0" }, - "conflict": { - "symfony/dependency-injection": "<3.4" - }, "provide": { "psr/event-dispatcher-implementation": "1.0", "symfony/event-dispatcher-implementation": "1.1" diff --git a/src/Symfony/Component/ExpressionLanguage/composer.json b/src/Symfony/Component/ExpressionLanguage/composer.json index c90a29c4bda1a..8dab712d708ff 100644 --- a/src/Symfony/Component/ExpressionLanguage/composer.json +++ b/src/Symfony/Component/ExpressionLanguage/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": "^7.2.9", - "symfony/cache": "^3.4|^4.0|^5.0", + "symfony/cache": "^4.4|^5.0", "symfony/service-contracts": "^1.1" }, "autoload": { diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index 9d76349a9ba0d..f621b80383f57 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -17,35 +17,27 @@ ], "require": { "php": "^7.2.9", - "symfony/event-dispatcher": "^4.3|^5.0", - "symfony/intl": "^4.3|^5.0", - "symfony/options-resolver": "~4.3|^5.0", + "symfony/event-dispatcher": "^4.4|^5.0", + "symfony/intl": "^4.4|^5.0", + "symfony/options-resolver": "^4.4|^5.0", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.0", - "symfony/property-access": "^3.4|^4.0|^5.0" + "symfony/property-access": "^4.4|^5.0" }, "require-dev": { "doctrine/collections": "~1.0", - "symfony/validator": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/config": "^3.4|^4.0|^5.0", - "symfony/console": "^4.3|^5.0", - "symfony/http-foundation": "^3.4|^4.0|^5.0", - "symfony/http-kernel": "^4.3|^5.0", - "symfony/security-csrf": "^3.4|^4.0|^5.0", - "symfony/translation": "^4.2|^5.0", - "symfony/var-dumper": "^4.3|^5.0" + "symfony/validator": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/console": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", + "symfony/security-csrf": "^4.4|^5.0", + "symfony/translation": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0" }, "conflict": { - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", - "symfony/console": "<4.3", - "symfony/dependency-injection": "<3.4", - "symfony/doctrine-bridge": "<3.4", - "symfony/framework-bundle": "<3.4", - "symfony/http-kernel": "<4.3", - "symfony/intl": "<4.3", - "symfony/translation": "<4.2", - "symfony/twig-bridge": "<3.4.5|<4.0.5,>=4.0" + "phpunit/phpunit": "<5.4.3" }, "suggest": { "symfony/validator": "For form validation.", diff --git a/src/Symfony/Component/HttpClient/composer.json b/src/Symfony/Component/HttpClient/composer.json index acd57a3f8b0b0..d4eb6af732429 100644 --- a/src/Symfony/Component/HttpClient/composer.json +++ b/src/Symfony/Component/HttpClient/composer.json @@ -27,8 +27,8 @@ "require-dev": { "nyholm/psr7": "^1.0", "psr/http-client": "^1.0", - "symfony/http-kernel": "^4.3|^5.0", - "symfony/process": "^4.2|^5.0" + "symfony/http-kernel": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\HttpClient\\": "" }, diff --git a/src/Symfony/Component/HttpFoundation/composer.json b/src/Symfony/Component/HttpFoundation/composer.json index aef0e58eb4c32..5311c77bfbf62 100644 --- a/src/Symfony/Component/HttpFoundation/composer.json +++ b/src/Symfony/Component/HttpFoundation/composer.json @@ -17,12 +17,12 @@ ], "require": { "php": "^7.2.9", - "symfony/mime": "^4.3|^5.0", + "symfony/mime": "^4.4|^5.0", "symfony/polyfill-mbstring": "~1.1" }, "require-dev": { "predis/predis": "~1.0", - "symfony/expression-language": "^3.4|^4.0|^5.0" + "symfony/expression-language": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\HttpFoundation\\": "" }, diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index 1f8448a5c1655..cf4d20446124d 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -17,29 +17,29 @@ ], "require": { "php": "^7.2.9", - "symfony/event-dispatcher": "^4.3|^5.0", - "symfony/http-foundation": "^4.1.1|^5.0", - "symfony/debug": "^3.4|^4.0|^5.0", + "symfony/event-dispatcher": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/debug": "^4.4|^5.0", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-php73": "^1.9", "psr/log": "~1.0" }, "require-dev": { - "symfony/browser-kit": "^4.3|^5.0", - "symfony/config": "^3.4|^4.0|^5.0", - "symfony/console": "^3.4|^4.0|^5.0", - "symfony/css-selector": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^4.3|^5.0", - "symfony/dom-crawler": "^3.4|^4.0|^5.0", - "symfony/expression-language": "^3.4|^4.0|^5.0", - "symfony/finder": "^3.4|^4.0|^5.0", - "symfony/process": "^3.4|^4.0|^5.0", - "symfony/routing": "^3.4|^4.0|^5.0", - "symfony/stopwatch": "^3.4|^4.0|^5.0", - "symfony/templating": "^3.4|^4.0|^5.0", - "symfony/translation": "^4.2|^5.0", + "symfony/browser-kit": "^4.4|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/console": "^4.4|^5.0", + "symfony/css-selector": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/dom-crawler": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/finder": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0", + "symfony/routing": "^4.4|^5.0", + "symfony/stopwatch": "^4.4|^5.0", + "symfony/templating": "^4.4|^5.0", + "symfony/translation": "^4.4|^5.0", "symfony/translation-contracts": "^1.1", - "symfony/var-dumper": "^4.1.1|^5.0", + "symfony/var-dumper": "^4.4|^5.0", "psr/cache": "~1.0", "twig/twig": "^1.34|^2.4" }, @@ -47,11 +47,6 @@ "psr/log-implementation": "1.0" }, "conflict": { - "symfony/browser-kit": "<4.3", - "symfony/config": "<3.4", - "symfony/dependency-injection": "<4.3", - "symfony/translation": "<4.2", - "symfony/var-dumper": "<4.1.1", "twig/twig": "<1.34|<2.4,>=2" }, "suggest": { diff --git a/src/Symfony/Component/Intl/composer.json b/src/Symfony/Component/Intl/composer.json index 966a4b5120463..daf9b2783c243 100644 --- a/src/Symfony/Component/Intl/composer.json +++ b/src/Symfony/Component/Intl/composer.json @@ -28,7 +28,7 @@ "symfony/polyfill-intl-icu": "~1.0" }, "require-dev": { - "symfony/filesystem": "^3.4|^4.0|^5.0" + "symfony/filesystem": "^4.4|^5.0" }, "suggest": { "ext-intl": "to use the component with locales other than \"en\"" diff --git a/src/Symfony/Component/Ldap/composer.json b/src/Symfony/Component/Ldap/composer.json index 0a1a7b10409ec..bd18d35b922a5 100644 --- a/src/Symfony/Component/Ldap/composer.json +++ b/src/Symfony/Component/Ldap/composer.json @@ -17,12 +17,9 @@ ], "require": { "php": "^7.2.9", - "symfony/options-resolver": "^4.2|^5.0", + "symfony/options-resolver": "^4.4|^5.0", "ext-ldap": "*" }, - "conflict": { - "symfony/options-resolver": "<4.2" - }, "autoload": { "psr-4": { "Symfony\\Component\\Ldap\\": "" }, "exclude-from-classmap": [ diff --git a/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json b/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json index cbd98527d5e8f..66d246c5931ac 100644 --- a/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Amazon/composer.json @@ -17,10 +17,10 @@ ], "require": { "php": "^7.2.9", - "symfony/mailer": "^4.3|^5.0" + "symfony/mailer": "^4.4|^5.0" }, "require-dev": { - "symfony/http-client": "^4.3|^5.0" + "symfony/http-client": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Mailer\\Bridge\\Amazon\\": "" }, diff --git a/src/Symfony/Component/Mailer/Bridge/Google/composer.json b/src/Symfony/Component/Mailer/Bridge/Google/composer.json index 7618aefdc741b..42629567d9151 100644 --- a/src/Symfony/Component/Mailer/Bridge/Google/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Google/composer.json @@ -17,10 +17,10 @@ ], "require": { "php": "^7.2.9", - "symfony/mailer": "^4.3|^5.0" + "symfony/mailer": "^4.4|^5.0" }, "require-dev": { - "symfony/http-client": "^4.3|^5.0" + "symfony/http-client": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Mailer\\Bridge\\Google\\": "" }, diff --git a/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json b/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json index fa065233f48ec..bf985cf259e03 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Mailchimp/composer.json @@ -17,10 +17,10 @@ ], "require": { "php": "^7.2.9", - "symfony/mailer": "^4.3|^5.0" + "symfony/mailer": "^4.4|^5.0" }, "require-dev": { - "symfony/http-client": "^4.3|^5.0" + "symfony/http-client": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Mailer\\Bridge\\Mailchimp\\": "" }, diff --git a/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json b/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json index bb8f08c889af3..3bc2a609d375d 100644 --- a/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Mailgun/composer.json @@ -17,10 +17,10 @@ ], "require": { "php": "^7.2.9", - "symfony/mailer": "^4.3|^5.0" + "symfony/mailer": "^4.4|^5.0" }, "require-dev": { - "symfony/http-client": "^4.3|^5.0" + "symfony/http-client": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Mailer\\Bridge\\Mailgun\\": "" }, diff --git a/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json b/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json index 0f7e3d2983741..c9ff019dc41c5 100644 --- a/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Postmark/composer.json @@ -17,10 +17,10 @@ ], "require": { "php": "^7.2.9", - "symfony/mailer": "^4.3|^5.0" + "symfony/mailer": "^4.4|^5.0" }, "require-dev": { - "symfony/http-client": "^4.3|^5.0" + "symfony/http-client": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Mailer\\Bridge\\Postmark\\": "" }, diff --git a/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json b/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json index 5792618533e97..bc0ee5d100d34 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json +++ b/src/Symfony/Component/Mailer/Bridge/Sendgrid/composer.json @@ -17,10 +17,10 @@ ], "require": { "php": "^7.2.9", - "symfony/mailer": "^4.3|^5.0" + "symfony/mailer": "^4.4|^5.0" }, "require-dev": { - "symfony/http-client": "^4.3|^5.0" + "symfony/http-client": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Mailer\\Bridge\\Sendgrid\\": "" }, diff --git a/src/Symfony/Component/Mailer/composer.json b/src/Symfony/Component/Mailer/composer.json index 52fe86404ddbe..f9790c2f8a282 100644 --- a/src/Symfony/Component/Mailer/composer.json +++ b/src/Symfony/Component/Mailer/composer.json @@ -19,17 +19,17 @@ "php": "^7.2.9", "egulias/email-validator": "^2.0", "psr/log": "~1.0", - "symfony/event-dispatcher": "^4.3|^5.0", - "symfony/mime": "^4.3|^5.0" + "symfony/event-dispatcher": "^4.4|^5.0", + "symfony/mime": "^4.4|^5.0" }, "require-dev": { - "symfony/amazon-mailer": "^4.3|^5.0", - "symfony/google-mailer": "^4.3|^5.0", + "symfony/amazon-mailer": "^4.4|^5.0", + "symfony/google-mailer": "^4.4|^5.0", "symfony/http-client-contracts": "^1.1", - "symfony/mailgun-mailer": "^4.3|^5.0", - "symfony/mailchimp-mailer": "^4.3|^5.0", - "symfony/postmark-mailer": "^4.3|^5.0", - "symfony/sendgrid-mailer": "^4.3|^5.0" + "symfony/mailgun-mailer": "^4.4|^5.0", + "symfony/mailchimp-mailer": "^4.4|^5.0", + "symfony/postmark-mailer": "^4.4|^5.0", + "symfony/sendgrid-mailer": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Mailer\\": "" }, diff --git a/src/Symfony/Component/Messenger/composer.json b/src/Symfony/Component/Messenger/composer.json index 4f6c425af0f59..7bbca44b41021 100644 --- a/src/Symfony/Component/Messenger/composer.json +++ b/src/Symfony/Component/Messenger/composer.json @@ -22,23 +22,19 @@ "require-dev": { "doctrine/dbal": "^2.5", "psr/cache": "~1.0", - "symfony/console": "^3.4|^4.0|^5.0", - "symfony/debug": "^4.1|^5.0", - "symfony/dependency-injection": "^3.4.19|^4.1.8|^5.0", - "symfony/doctrine-bridge": "^3.4|^4.0|^5.0", - "symfony/event-dispatcher": "^4.3|^5.0", - "symfony/http-kernel": "^3.4|^4.0|^5.0", - "symfony/process": "^3.4|^4.0|^5.0", - "symfony/property-access": "^3.4|^4.0|^5.0", - "symfony/serializer": "^3.4|^4.0|^5.0", + "symfony/console": "^4.4|^5.0", + "symfony/debug": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/doctrine-bridge": "^4.4|^5.0", + "symfony/event-dispatcher": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0", + "symfony/property-access": "^4.4|^5.0", + "symfony/serializer": "^4.4|^5.0", "symfony/service-contracts": "^1.1", - "symfony/stopwatch": "^3.4|^4.0|^5.0", - "symfony/validator": "^3.4|^4.0|^5.0", - "symfony/var-dumper": "^3.4|^4.0|^5.0" - }, - "conflict": { - "symfony/event-dispatcher": "<4.3", - "symfony/debug": "<4.1" + "symfony/stopwatch": "^4.4|^5.0", + "symfony/validator": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0" }, "suggest": { "enqueue/messenger-adapter": "For using the php-enqueue library as a transport." diff --git a/src/Symfony/Component/Mime/composer.json b/src/Symfony/Component/Mime/composer.json index 1a3e73e0220c8..f5ae1dc3a78ef 100644 --- a/src/Symfony/Component/Mime/composer.json +++ b/src/Symfony/Component/Mime/composer.json @@ -22,7 +22,7 @@ }, "require-dev": { "egulias/email-validator": "^2.0", - "symfony/dependency-injection": "^3.4|^4.1|^5.0" + "symfony/dependency-injection": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Mime\\": "" }, diff --git a/src/Symfony/Component/PropertyAccess/composer.json b/src/Symfony/Component/PropertyAccess/composer.json index 47722d1084278..e6ee34f5b9c29 100644 --- a/src/Symfony/Component/PropertyAccess/composer.json +++ b/src/Symfony/Component/PropertyAccess/composer.json @@ -17,10 +17,10 @@ ], "require": { "php": "^7.2.9", - "symfony/inflector": "^3.4|^4.0|^5.0" + "symfony/inflector": "^4.4|^5.0" }, "require-dev": { - "symfony/cache": "^3.4|^4.0|^5.0" + "symfony/cache": "^4.4|^5.0" }, "suggest": { "psr/cache-implementation": "To cache access methods." diff --git a/src/Symfony/Component/PropertyInfo/composer.json b/src/Symfony/Component/PropertyInfo/composer.json index fdc05cd45349a..5b956b0138bb7 100644 --- a/src/Symfony/Component/PropertyInfo/composer.json +++ b/src/Symfony/Component/PropertyInfo/composer.json @@ -24,19 +24,17 @@ ], "require": { "php": "^7.2.9", - "symfony/inflector": "^3.4|^4.0|^5.0" + "symfony/inflector": "^4.4|^5.0" }, "require-dev": { - "symfony/serializer": "^3.4|^4.0|^5.0", - "symfony/cache": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", + "symfony/serializer": "^4.4|^5.0", + "symfony/cache": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", "phpdocumentor/reflection-docblock": "^3.0|^4.0", "doctrine/annotations": "~1.0" }, "conflict": { - "phpdocumentor/reflection-docblock": "<3.0||>=3.2.0,<3.2.2", - "phpdocumentor/type-resolver": "<0.3.0", - "symfony/dependency-injection": "<3.4" + "phpdocumentor/reflection-docblock": "<3.2.2" }, "suggest": { "psr/cache-implementation": "To cache results", diff --git a/src/Symfony/Component/Routing/composer.json b/src/Symfony/Component/Routing/composer.json index fadd5873db327..f20a4e2a6c730 100644 --- a/src/Symfony/Component/Routing/composer.json +++ b/src/Symfony/Component/Routing/composer.json @@ -19,19 +19,14 @@ "php": "^7.2.9" }, "require-dev": { - "symfony/config": "^4.2|^5.0", - "symfony/http-foundation": "^3.4|^4.0|^5.0", - "symfony/yaml": "^3.4|^4.0|^5.0", - "symfony/expression-language": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/yaml": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", "doctrine/annotations": "~1.2", "psr/log": "~1.0" }, - "conflict": { - "symfony/config": "<4.2", - "symfony/dependency-injection": "<3.4", - "symfony/yaml": "<3.4" - }, "suggest": { "symfony/http-foundation": "For using a Symfony Request object", "symfony/config": "For using the all-in-one router or any loader", diff --git a/src/Symfony/Component/Security/Core/composer.json b/src/Symfony/Component/Security/Core/composer.json index 3e999f28f62f7..37b25ee59c78e 100644 --- a/src/Symfony/Component/Security/Core/composer.json +++ b/src/Symfony/Component/Security/Core/composer.json @@ -22,17 +22,13 @@ }, "require-dev": { "psr/container": "^1.0", - "symfony/event-dispatcher": "^4.3|^5.0", - "symfony/expression-language": "^3.4|^4.0|^5.0", - "symfony/http-foundation": "^3.4|^4.0|^5.0", - "symfony/ldap": "^3.4|^4.0|^5.0", - "symfony/validator": "^3.4|^4.0|^5.0", + "symfony/event-dispatcher": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/ldap": "^4.4|^5.0", + "symfony/validator": "^4.4|^5.0", "psr/log": "~1.0" }, - "conflict": { - "symfony/event-dispatcher": "<4.3", - "symfony/security-guard": "<4.3" - }, "suggest": { "psr/container-implementation": "To instantiate the Security class", "symfony/event-dispatcher": "", diff --git a/src/Symfony/Component/Security/Csrf/composer.json b/src/Symfony/Component/Security/Csrf/composer.json index 1e63ef64a1008..ba25905ff88cc 100644 --- a/src/Symfony/Component/Security/Csrf/composer.json +++ b/src/Symfony/Component/Security/Csrf/composer.json @@ -17,13 +17,10 @@ ], "require": { "php": "^7.2.9", - "symfony/security-core": "^3.4|^4.0|^5.0" + "symfony/security-core": "^4.4|^5.0" }, "require-dev": { - "symfony/http-foundation": "^3.4|^4.0|^5.0" - }, - "conflict": { - "symfony/http-foundation": "<3.4" + "symfony/http-foundation": "^4.4|^5.0" }, "suggest": { "symfony/http-foundation": "For using the class SessionTokenStorage." diff --git a/src/Symfony/Component/Security/Guard/composer.json b/src/Symfony/Component/Security/Guard/composer.json index 2b01456cc7f2f..3c0c7ba41a7cb 100644 --- a/src/Symfony/Component/Security/Guard/composer.json +++ b/src/Symfony/Component/Security/Guard/composer.json @@ -17,8 +17,8 @@ ], "require": { "php": "^7.2.9", - "symfony/security-core": "^3.4.22|^4.2.3|^5.0", - "symfony/security-http": "^4.3|^5.0" + "symfony/security-core": "^4.4|^5.0", + "symfony/security-http": "^4.4|^5.0" }, "require-dev": { "psr/log": "~1.0" diff --git a/src/Symfony/Component/Security/Http/composer.json b/src/Symfony/Component/Security/Http/composer.json index 1a9dd2cbac96a..439f85d4e2c74 100644 --- a/src/Symfony/Component/Security/Http/composer.json +++ b/src/Symfony/Component/Security/Http/composer.json @@ -17,19 +17,16 @@ ], "require": { "php": "^7.2.9", - "symfony/security-core": "^4.3|^5.0", - "symfony/http-foundation": "^3.4|^4.0|^5.0", - "symfony/http-kernel": "^4.3|^5.0", - "symfony/property-access": "^3.4|^4.0|^5.0" + "symfony/security-core": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", + "symfony/property-access": "^4.4|^5.0" }, "require-dev": { - "symfony/routing": "^3.4|^4.0|^5.0", - "symfony/security-csrf": "^3.4.11|^4.0.11|^5.0", + "symfony/routing": "^4.4|^5.0", + "symfony/security-csrf": "^4.4|^5.0", "psr/log": "~1.0" }, - "conflict": { - "symfony/security-csrf": "<3.4.11|~4.0,<4.0.11" - }, "suggest": { "symfony/security-csrf": "For using tokens to protect authentication/logout attempts", "symfony/routing": "For using the HttpUtils class to create sub-requests, redirect the user, and match URLs" diff --git a/src/Symfony/Component/Security/composer.json b/src/Symfony/Component/Security/composer.json index a955482ca460a..1f0563ffdd581 100644 --- a/src/Symfony/Component/Security/composer.json +++ b/src/Symfony/Component/Security/composer.json @@ -18,9 +18,9 @@ "require": { "php": "^7.2.9", "symfony/event-dispatcher-contracts": "^1.1", - "symfony/http-foundation": "^3.4|^4.0|^5.0", - "symfony/http-kernel": "^4.3|^5.0", - "symfony/property-access": "^3.4|^4.0|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", + "symfony/property-access": "^4.4|^5.0", "symfony/service-contracts": "^1.1" }, "replace": { @@ -31,13 +31,13 @@ }, "require-dev": { "psr/container": "^1.0", - "symfony/finder": "^3.4|^4.0|^5.0", + "symfony/finder": "^4.4|^5.0", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-icu": "~1.0", - "symfony/routing": "^3.4|^4.0|^5.0", - "symfony/validator": "^3.4|^4.0|^5.0", - "symfony/expression-language": "^3.4|^4.0|^5.0", - "symfony/ldap": "^3.4|^4.0|^5.0", + "symfony/routing": "^4.4|^5.0", + "symfony/validator": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/ldap": "^4.4|^5.0", "psr/log": "~1.0" }, "suggest": { diff --git a/src/Symfony/Component/Serializer/composer.json b/src/Symfony/Component/Serializer/composer.json index 4ab4ea2a7ce2c..695fac4db2021 100644 --- a/src/Symfony/Component/Serializer/composer.json +++ b/src/Symfony/Component/Serializer/composer.json @@ -20,24 +20,20 @@ "symfony/polyfill-ctype": "~1.8" }, "require-dev": { - "symfony/yaml": "^3.4|^4.0|^5.0", - "symfony/config": "^3.4|^4.0|^5.0", - "symfony/property-access": "^3.4|^4.0|^5.0", - "symfony/http-foundation": "^3.4|^4.0|^5.0", - "symfony/cache": "^3.4|^4.0|^5.0", - "symfony/property-info": "^3.4.13|~4.0|^5.0", - "symfony/validator": "^3.4|^4.0|^5.0", + "symfony/yaml": "^4.4|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/property-access": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/cache": "^4.4|^5.0", + "symfony/property-info": "^4.4|^5.0", + "symfony/validator": "^4.4|^5.0", "doctrine/annotations": "~1.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", "doctrine/cache": "~1.0", "phpdocumentor/reflection-docblock": "^3.0|^4.0" }, "conflict": { - "phpdocumentor/type-resolver": "<0.2.1", - "symfony/dependency-injection": "<3.4", - "symfony/property-access": "<3.4", - "symfony/property-info": "<3.4", - "symfony/yaml": "<3.4" + "phpdocumentor/type-resolver": "<0.2.1" }, "suggest": { "psr/cache-implementation": "For using the metadata cache.", diff --git a/src/Symfony/Component/Translation/composer.json b/src/Symfony/Component/Translation/composer.json index 455dbe498d65b..2e51206837480 100644 --- a/src/Symfony/Component/Translation/composer.json +++ b/src/Symfony/Component/Translation/composer.json @@ -21,22 +21,17 @@ "symfony/translation-contracts": "^1.1.2" }, "require-dev": { - "symfony/config": "^3.4|^4.0|^5.0", - "symfony/console": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/http-kernel": "^3.4|^4.0|^5.0", - "symfony/intl": "^3.4|^4.0|^5.0", - "symfony/service-contracts": "^1.1.2|^5.0", - "symfony/var-dumper": "^3.4|^4.0|^5.0", - "symfony/yaml": "^3.4|^4.0|^5.0", - "symfony/finder": "~2.8|~3.0|~4.0|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/console": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", + "symfony/intl": "^4.4|^5.0", + "symfony/service-contracts": "^1.1.2", + "symfony/var-dumper": "^4.4|^5.0", + "symfony/yaml": "^4.4|^5.0", + "symfony/finder": "^4.4|^5.0", "psr/log": "~1.0" }, - "conflict": { - "symfony/config": "<3.4", - "symfony/dependency-injection": "<3.4", - "symfony/yaml": "<3.4" - }, "provide": { "symfony/translation-implementation": "1.0" }, diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index 48846b1d64bb8..9aa04f8593b98 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -22,30 +22,25 @@ "symfony/translation-contracts": "^1.1" }, "require-dev": { - "symfony/http-client": "^4.3|^5.0", - "symfony/http-foundation": "^4.1|^5.0", - "symfony/http-kernel": "^3.4|^4.0|^5.0", - "symfony/var-dumper": "^3.4|^4.0|^5.0", - "symfony/intl": "^4.3|^5.0", - "symfony/yaml": "^3.4|^4.0|^5.0", - "symfony/config": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/expression-language": "^3.4|^4.0|^5.0", - "symfony/cache": "^3.4|^4.0|^5.0", - "symfony/property-access": "^3.4|^4.0|^5.0", - "symfony/property-info": "^3.4|^4.0|^5.0", - "symfony/translation": "^4.2|^5.0", + "symfony/http-client": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0", + "symfony/intl": "^4.4|^5.0", + "symfony/yaml": "^4.4|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/cache": "^4.4|^5.0", + "symfony/property-access": "^4.4|^5.0", + "symfony/property-info": "^4.4|^5.0", + "symfony/translation": "^4.4|^5.0", "doctrine/annotations": "~1.0", "doctrine/cache": "~1.0", "egulias/email-validator": "^1.2.8|~2.0" }, "conflict": { - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", - "symfony/dependency-injection": "<3.4", - "symfony/http-kernel": "<3.4", - "symfony/intl": "<4.3", - "symfony/translation": "<4.2", - "symfony/yaml": "<3.4" + "phpunit/phpunit": "<5.4.3" }, "suggest": { "psr/cache-implementation": "For using the metadata cache.", diff --git a/src/Symfony/Component/VarDumper/composer.json b/src/Symfony/Component/VarDumper/composer.json index 5a46220109451..5d4a23e356dcc 100644 --- a/src/Symfony/Component/VarDumper/composer.json +++ b/src/Symfony/Component/VarDumper/composer.json @@ -21,13 +21,12 @@ }, "require-dev": { "ext-iconv": "*", - "symfony/console": "^3.4|^4.0|^5.0", - "symfony/process": "^3.4|^4.0|^5.0", + "symfony/console": "^4.4|^5.0", + "symfony/process": "^4.4|^5.0", "twig/twig": "~1.34|~2.4" }, "conflict": { - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", - "symfony/console": "<3.4" + "phpunit/phpunit": "<5.4.3" }, "suggest": { "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).", diff --git a/src/Symfony/Component/VarExporter/composer.json b/src/Symfony/Component/VarExporter/composer.json index a37226d12cc3b..480a0155891b8 100644 --- a/src/Symfony/Component/VarExporter/composer.json +++ b/src/Symfony/Component/VarExporter/composer.json @@ -19,7 +19,7 @@ "php": "^7.2.9" }, "require-dev": { - "symfony/var-dumper": "^4.1.1|^5.0" + "symfony/var-dumper": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\VarExporter\\": "" }, diff --git a/src/Symfony/Component/WebLink/composer.json b/src/Symfony/Component/WebLink/composer.json index 9ca0bbec56c5e..baeb44db4bf93 100644 --- a/src/Symfony/Component/WebLink/composer.json +++ b/src/Symfony/Component/WebLink/composer.json @@ -24,11 +24,8 @@ "symfony/http-kernel": "" }, "require-dev": { - "symfony/http-foundation": "^3.4|^4.0|^5.0", - "symfony/http-kernel": "^4.3|^5.0" - }, - "conflict": { - "symfony/http-kernel": "<4.3" + "symfony/http-foundation": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\WebLink\\": "" }, diff --git a/src/Symfony/Component/Workflow/composer.json b/src/Symfony/Component/Workflow/composer.json index f8285800ea13e..f2da0ab76c118 100644 --- a/src/Symfony/Component/Workflow/composer.json +++ b/src/Symfony/Component/Workflow/composer.json @@ -21,18 +21,15 @@ ], "require": { "php": "^7.2.9", - "symfony/property-access": "^3.4|^4.0|^5.0" + "symfony/property-access": "^4.4|^5.0" }, "require-dev": { "psr/log": "~1.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/event-dispatcher": "^4.3|^5.0", - "symfony/expression-language": "^3.4|^4.0|^5.0", - "symfony/security-core": "^3.4|^4.0|^5.0", - "symfony/validator": "^3.4|^4.0|^5.0" - }, - "conflict": { - "symfony/event-dispatcher": "<4.3" + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/event-dispatcher": "^4.4|^5.0", + "symfony/expression-language": "^4.4|^5.0", + "symfony/security-core": "^4.4|^5.0", + "symfony/validator": "^4.4|^5.0" }, "autoload": { "psr-4": { "Symfony\\Component\\Workflow\\": "" } diff --git a/src/Symfony/Component/Yaml/composer.json b/src/Symfony/Component/Yaml/composer.json index cd6fe054351bb..196696ceecd0c 100644 --- a/src/Symfony/Component/Yaml/composer.json +++ b/src/Symfony/Component/Yaml/composer.json @@ -20,10 +20,7 @@ "symfony/polyfill-ctype": "~1.8" }, "require-dev": { - "symfony/console": "^3.4|^4.0|^5.0" - }, - "conflict": { - "symfony/console": "<3.4" + "symfony/console": "^4.4|^5.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" From 83207370cbc4d4ab9c49b8ee2eae8d8ab934231c Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Tue, 28 May 2019 15:39:08 -0400 Subject: [PATCH 004/588] Remove default value deprecation for twig.strict_variables --- .../DependencyInjection/Configuration.php | 8 +------- .../DependencyInjection/ConfigurationTest.php | 15 --------------- .../php/customTemplateEscapingGuesser.php | 1 - .../DependencyInjection/Fixtures/php/empty.php | 4 +--- .../DependencyInjection/Fixtures/php/extra.php | 1 - .../DependencyInjection/Fixtures/php/formats.php | 1 - .../xml/customTemplateEscapingGuesser.xml | 2 +- .../DependencyInjection/Fixtures/xml/empty.xml | 2 +- .../DependencyInjection/Fixtures/xml/formats.xml | 2 +- .../yml/customTemplateEscapingGuesser.yml | 1 - .../DependencyInjection/Fixtures/yml/empty.yml | 1 - .../DependencyInjection/Fixtures/yml/extra.yml | 1 - .../DependencyInjection/Fixtures/yml/formats.yml | 1 - .../DependencyInjection/TwigExtensionTest.php | 13 +++---------- .../Tests/Functional/CacheWarmingTest.php | 3 --- .../TwigBundle/Tests/Functional/EmptyAppTest.php | 7 ------- .../Tests/Functional/NoTemplatingEntryTest.php | 1 - 17 files changed, 8 insertions(+), 56 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index b635a752aba8d..7cb0225989d19 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -128,13 +128,7 @@ private function addTwigOptions(ArrayNodeDefinition $rootNode) ->scalarNode('cache')->defaultValue('%kernel.cache_dir%/twig')->end() ->scalarNode('charset')->defaultValue('%kernel.charset%')->end() ->booleanNode('debug')->defaultValue('%kernel.debug%')->end() - ->booleanNode('strict_variables') - ->defaultValue(function () { - @trigger_error('Relying on the default value ("false") of the "twig.strict_variables" configuration option is deprecated since Symfony 4.1. You should use "%kernel.debug%" explicitly instead, which will be the new default in 5.0.', E_USER_DEPRECATED); - - return false; - }) - ->end() + ->booleanNode('strict_variables')->defaultValue('%kernel.debug%')->end() ->scalarNode('auto_reload')->end() ->integerNode('optimizations')->min(-1)->end() ->scalarNode('default_path') diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php index e479804b987e1..41627c48041e3 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -20,7 +20,6 @@ class ConfigurationTest extends TestCase public function testDoNoDuplicateDefaultFormResources() { $input = [ - 'strict_variables' => false, // to be removed in 5.0 relying on default 'form_themes' => ['form_div_layout.html.twig'], ]; @@ -30,22 +29,9 @@ public function testDoNoDuplicateDefaultFormResources() $this->assertEquals(['form_div_layout.html.twig'], $config['form_themes']); } - /** - * @group legacy - * @expectedDeprecation Relying on the default value ("false") of the "twig.strict_variables" configuration option is deprecated since Symfony 4.1. You should use "%kernel.debug%" explicitly instead, which will be the new default in 5.0. - */ - public function testGetStrictVariablesDefaultFalse() - { - $processor = new Processor(); - $config = $processor->processConfiguration(new Configuration(), [[]]); - - $this->assertFalse($config['strict_variables']); - } - public function testGlobalsAreNotNormalized() { $input = [ - 'strict_variables' => false, // to be removed in 5.0 relying on default 'globals' => ['some-global' => true], ]; @@ -58,7 +44,6 @@ public function testGlobalsAreNotNormalized() public function testArrayKeysInGlobalsAreNotNormalized() { $input = [ - 'strict_variables' => false, // to be removed in 5.0 relying on default 'globals' => ['global' => ['some-key' => 'some-value']], ]; diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php index de55467d2285e..c9acb3c253967 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php @@ -3,5 +3,4 @@ $container->loadFromExtension('twig', [ 'autoescape_service' => 'my_project.some_bundle.template_escaping_guesser', 'autoescape_service_method' => 'guess', - 'strict_variables' => false, // to be removed in 5.0 relying on default ]); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/empty.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/empty.php index 76e66160f50d6..0236f4ff556f0 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/empty.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/empty.php @@ -1,5 +1,3 @@ loadFromExtension('twig', [ - 'strict_variables' => false, // to be removed in 5.0 relying on default -]); +$container->loadFromExtension('twig'); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php index 30c3428ef1b31..0143514f693fa 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/extra.php @@ -4,5 +4,4 @@ 'paths' => [ 'namespaced_path3' => 'namespace3', ], - 'strict_variables' => false, // to be removed in 5.0 relying on default ]); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/formats.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/formats.php index 69fbf7c012e88..7e85738809fb0 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/formats.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/php/formats.php @@ -11,5 +11,4 @@ 'decimal_point' => ',', 'thousands_separator' => '.', ], - 'strict_variables' => false, // to be removed in 5.0 relying on default ]); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml index 63c851720cc28..f72bed9d14884 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml @@ -6,5 +6,5 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/twig https://symfony.com/schema/dic/twig/twig-1.0.xsd"> - + diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/empty.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/empty.xml index ffe2f5257733c..f3b51fa24201c 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/empty.xml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/empty.xml @@ -6,5 +6,5 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/twig https://symfony.com/schema/dic/twig/twig-1.0.xsd"> - + diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/formats.xml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/formats.xml index 7f8fb84357da0..fa888b30acf61 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/formats.xml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/xml/formats.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/twig https://symfony.com/schema/dic/twig/twig-1.0.xsd"> - + diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml index 34e301c0957e5..eb26e7165bb09 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml @@ -1,4 +1,3 @@ twig: autoescape_service: my_project.some_bundle.template_escaping_guesser autoescape_service_method: guess - strict_variables: false # to be removed in 5.0 relying on default diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/empty.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/empty.yml index 9b5dbcf35b67b..a472b2698e5cd 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/empty.yml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/empty.yml @@ -1,2 +1 @@ twig: - strict_variables: false # to be removed in 5.0 relying on default diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml index 41a281cc8198c..3c5e6a3b5937a 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/extra.yml @@ -1,4 +1,3 @@ twig: - strict_variables: false # to be removed in 5.0 relying on default paths: namespaced_path3: namespace3 diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/formats.yml b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/formats.yml index a5c57f383edfe..290921630f9e6 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/formats.yml +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/yml/formats.yml @@ -1,5 +1,4 @@ twig: - strict_variables: false # to be removed in 5.0 relying on default date: format: Y-m-d interval_format: '%d' diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index 1057540dccaac..7b3595e93c0cd 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -29,9 +29,7 @@ public function testLoadEmptyConfiguration() { $container = $this->createContainer(); $container->registerExtension(new TwigExtension()); - $container->loadFromExtension('twig', [ - 'strict_variables' => false, // to be removed in 5.0 relying on default - ]); + $container->loadFromExtension('twig'); $this->compileContainer($container); $this->assertEquals('Twig\Environment', $container->getDefinition('twig')->getClass(), '->load() loads the twig.xml file'); @@ -155,7 +153,6 @@ public function testGlobalsWithDifferentTypesAndValues() $container->registerExtension(new TwigExtension()); $container->loadFromExtension('twig', [ 'globals' => $globals, - 'strict_variables' => false, // // to be removed in 5.0 relying on default ]); $this->compileContainer($container); @@ -257,9 +254,7 @@ public function testStopwatchExtensionAvailability($debug, $stopwatchEnabled, $e $container->register('debug.stopwatch', 'Symfony\Component\Stopwatch\Stopwatch'); } $container->registerExtension(new TwigExtension()); - $container->loadFromExtension('twig', [ - 'strict_variables' => false, // to be removed in 5.0 relying on default - ]); + $container->loadFromExtension('twig'); $container->setAlias('test.twig.extension.debug.stopwatch', 'twig.extension.debug.stopwatch')->setPublic(true); $this->compileContainer($container); @@ -287,9 +282,7 @@ public function testRuntimeLoader() { $container = $this->createContainer(); $container->registerExtension(new TwigExtension()); - $container->loadFromExtension('twig', [ - 'strict_variables' => false, // to be removed in 5.0 relying on default - ]); + $container->loadFromExtension('twig'); $container->setParameter('kernel.environment', 'test'); $container->setParameter('debug.file_link_format', 'test'); $container->setParameter('foo', 'FooClass'); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php index ca21df09029b9..66b31a1a09446 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php @@ -97,9 +97,6 @@ public function registerContainerConfiguration(LoaderInterface $loader) 'secret' => '$ecret', 'form' => ['enabled' => false], ]) - ->loadFromExtension('twig', [ // to be removed in 5.0 relying on default - 'strict_variables' => false, - ]) ; }); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Functional/EmptyAppTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Functional/EmptyAppTest.php index df90b237526e6..86d933b558220 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Functional/EmptyAppTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Functional/EmptyAppTest.php @@ -37,13 +37,6 @@ public function registerBundles() public function registerContainerConfiguration(LoaderInterface $loader) { - $loader->load(function ($container) { - $container - ->loadFromExtension('twig', [ // to be removed in 5.0 relying on default - 'strict_variables' => false, - ]) - ; - }); } public function getCacheDir() diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php index f1e77090721b9..9a45c25ba39e7 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php @@ -67,7 +67,6 @@ public function registerContainerConfiguration(LoaderInterface $loader) 'form' => ['enabled' => false], ]) ->loadFromExtension('twig', [ - 'strict_variables' => false, // to be removed in 5.0 relying on default 'default_path' => __DIR__.'/templates', ]) ; From ceb83e68981f1b9b4f60d3c8a30023fc4b453b93 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Tue, 28 May 2019 18:51:21 -0400 Subject: [PATCH 005/588] Remove dead code --- .../Tests/Command/TranslationDebugCommandTest.php | 7 ------- .../Tests/Command/TranslationUpdateCommandTest.php | 6 ------ .../Tests/Controller/ControllerNameParserTest.php | 6 ------ .../DependencyInjection/WebProfilerExtension.php | 7 ++----- 4 files changed, 2 insertions(+), 24 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php index 7253215c55963..3bbb92dbd24e4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php @@ -17,7 +17,6 @@ use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\HttpKernel; class TranslationDebugCommandTest extends TestCase { @@ -181,12 +180,6 @@ private function createCommandTester($extractedMessages = [], $loadedMessages = ['foo', $this->getBundle($this->translationDir)], ['test', $this->getBundle('test')], ]; - if (HttpKernel\Kernel::VERSION_ID < 40000) { - $returnValues = [ - ['foo', true, $this->getBundle($this->translationDir)], - ['test', true, $this->getBundle('test')], - ]; - } $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel ->expects($this->any()) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php index 1ec04fd970787..7592be99b790e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php @@ -167,12 +167,6 @@ private function createCommandTester($extractedMessages = [], $loadedMessages = ['foo', $this->getBundle($this->translationDir)], ['test', $this->getBundle('test')], ]; - if (HttpKernel\Kernel::VERSION_ID < 40000) { - $returnValues = [ - ['foo', true, $this->getBundle($this->translationDir)], - ['test', true, $this->getBundle('test')], - ]; - } $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); $kernel ->expects($this->any()) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php index 5e65ae5f13ac0..1e5cf48d26890 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php @@ -14,7 +14,6 @@ use Composer\Autoload\ClassLoader; use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; -use Symfony\Component\HttpKernel\Kernel; /** * @group legacy @@ -106,11 +105,6 @@ public function getMissingControllersTest() ['FooBundle:Fake:index'], ]; - // a bundle with children - if (Kernel::VERSION_ID < 40000) { - $bundles[] = ['SensioFooBundle:Fake:index']; - } - return $bundles; } diff --git a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php index 594e7fa3a7b47..97489c402081f 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php +++ b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\HttpKernel\Kernel; /** * WebProfilerExtension. @@ -55,10 +54,8 @@ public function load(array $configs, ContainerBuilder $container) $container->setParameter('web_profiler.debug_toolbar.mode', $config['toolbar'] ? WebDebugToolbarListener::ENABLED : WebDebugToolbarListener::DISABLED); } - if (Kernel::VERSION_ID >= 40008 || (Kernel::VERSION_ID >= 30408 && Kernel::VERSION_ID < 40000)) { - $container->getDefinition('debug.file_link_formatter') - ->replaceArgument(3, new ServiceClosureArgument(new Reference('debug.file_link_formatter.url_format'))); - } + $container->getDefinition('debug.file_link_formatter') + ->replaceArgument(3, new ServiceClosureArgument(new Reference('debug.file_link_formatter.url_format'))); } /** From b6eb1f4979db346ffe9fe7f6a5f335323f0c7175 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Tue, 28 May 2019 17:53:22 -0400 Subject: [PATCH 006/588] Removed capability to load/debug/update legacy translation directories --- .../Command/TranslationDebugCommand.php | 48 ------------------- .../Command/TranslationUpdateCommand.php | 38 --------------- .../FrameworkExtension.php | 17 ------- .../Command/TranslationDebugCommandTest.php | 17 ------- .../Command/TranslationUpdateCommandTest.php | 17 ------- .../translations/test_default.en.xlf | 0 .../FrameworkExtensionTest.php | 15 ------ .../TranslationDebugPass.php | 21 -------- .../Bundle/TestBundle/TestBundle.php | 2 - 9 files changed, 175 deletions(-) delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/Resources/translations/test_default.en.xlf delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TranslationDebugPass.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php index 86280c1cc875a..7fdd1dbca241d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php @@ -132,28 +132,13 @@ protected function execute(InputInterface $input, OutputInterface $output) $domain = $input->getOption('domain'); /** @var KernelInterface $kernel */ $kernel = $this->getApplication()->getKernel(); - $rootDir = $kernel->getContainer()->getParameter('kernel.root_dir'); // Define Root Paths $transPaths = $this->transPaths; - if (is_dir($dir = $rootDir.'/Resources/translations')) { - if ($dir !== $this->defaultTransPath) { - $notice = sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, ', $dir); - @trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); - } - $transPaths[] = $dir; - } if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } $viewsPaths = $this->viewsPaths; - if (is_dir($dir = $rootDir.'/Resources/views')) { - if ($dir !== $this->defaultViewsPath) { - $notice = sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, ', $dir); - @trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); - } - $viewsPaths[] = $dir; - } if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath; } @@ -166,39 +151,16 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } - if (is_dir($dir = sprintf('%s/Resources/%s/translations', $rootDir, $bundle->getName()))) { - $transPaths[] = $dir; - $notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $dir, $bundle->getName()); - @trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); - } $viewsPaths = [$bundle->getPath().'/Resources/views']; if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath; } - if (is_dir($dir = sprintf('%s/Resources/%s/views', $rootDir, $bundle->getName()))) { - $viewsPaths[] = $dir; - $notice = sprintf('Loading Twig templates for "%s" from the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $dir); - @trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); - } } catch (\InvalidArgumentException $e) { // such a bundle does not exist, so treat the argument as path $path = $input->getArgument('bundle'); $transPaths = [$path.'/translations']; - if (is_dir($dir = $path.'/Resources/translations')) { - if ($dir !== $this->defaultTransPath) { - @trigger_error(sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/translations'), E_USER_DEPRECATED); - } - $transPaths[] = $dir; - } - $viewsPaths = [$path.'/templates']; - if (is_dir($dir = $path.'/Resources/views')) { - if ($dir !== $this->defaultViewsPath) { - @trigger_error(sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/templates'), E_USER_DEPRECATED); - } - $viewsPaths[] = $dir; - } if (!is_dir($transPaths[0]) && !isset($transPaths[1])) { throw new InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0])); @@ -207,17 +169,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } elseif ($input->getOption('all')) { foreach ($kernel->getBundles() as $bundle) { $transPaths[] = $bundle->getPath().'/Resources/translations'; - if (is_dir($deprecatedPath = sprintf('%s/Resources/%s/translations', $rootDir, $bundle->getName()))) { - $transPaths[] = $deprecatedPath; - $notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $deprecatedPath); - @trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); - } $viewsPaths[] = $bundle->getPath().'/Resources/views'; - if (is_dir($deprecatedPath = sprintf('%s/Resources/%s/views', $rootDir, $bundle->getName()))) { - $viewsPaths[] = $deprecatedPath; - $notice = sprintf('Loading Twig templates for "%s" from the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $deprecatedPath); - @trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); - } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index ded71fd60e4bb..6e6b991f64f68 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -123,28 +123,13 @@ protected function execute(InputInterface $input, OutputInterface $output) } /** @var KernelInterface $kernel */ $kernel = $this->getApplication()->getKernel(); - $rootDir = $kernel->getContainer()->getParameter('kernel.root_dir'); // Define Root Paths $transPaths = $this->transPaths; - if (is_dir($dir = $rootDir.'/Resources/translations')) { - if ($dir !== $this->defaultTransPath) { - $notice = sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, ', $dir); - @trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); - } - $transPaths[] = $dir; - } if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } $viewsPaths = $this->viewsPaths; - if (is_dir($dir = $rootDir.'/Resources/views')) { - if ($dir !== $this->defaultViewsPath) { - $notice = sprintf('Storing templates in the "%s" directory is deprecated since Symfony 4.2, ', $dir); - @trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); - } - $viewsPaths[] = $dir; - } if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath; } @@ -158,40 +143,17 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($this->defaultTransPath) { $transPaths[] = $this->defaultTransPath; } - if (is_dir($dir = sprintf('%s/Resources/%s/translations', $rootDir, $foundBundle->getName()))) { - $transPaths[] = $dir; - $notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $foundBundle->getName(), $dir); - @trigger_error($notice.($this->defaultTransPath ? sprintf('use the "%s" directory instead.', $this->defaultTransPath) : 'configure and use "framework.translator.default_path" instead.'), E_USER_DEPRECATED); - } $viewsPaths = [$foundBundle->getPath().'/Resources/views']; if ($this->defaultViewsPath) { $viewsPaths[] = $this->defaultViewsPath; } - if (is_dir($dir = sprintf('%s/Resources/%s/views', $rootDir, $foundBundle->getName()))) { - $viewsPaths[] = $dir; - $notice = sprintf('Storing templates for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $foundBundle->getName(), $dir); - @trigger_error($notice.($this->defaultViewsPath ? sprintf('use the "%s" directory instead.', $this->defaultViewsPath) : 'configure and use "twig.default_path" instead.'), E_USER_DEPRECATED); - } $currentName = $foundBundle->getName(); } catch (\InvalidArgumentException $e) { // such a bundle does not exist, so treat the argument as path $path = $input->getArgument('bundle'); $transPaths = [$path.'/translations']; - if (is_dir($dir = $path.'/Resources/translations')) { - if ($dir !== $this->defaultTransPath) { - @trigger_error(sprintf('Storing translations in the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/translations'), E_USER_DEPRECATED); - } - $transPaths[] = $dir; - } - $viewsPaths = [$path.'/templates']; - if (is_dir($dir = $path.'/Resources/views')) { - if ($dir !== $this->defaultViewsPath) { - @trigger_error(sprintf('Storing templates in the "%s" directory is deprecated since Symfony 4.2, use the "%s" directory instead.', $dir, $path.'/templates'), E_USER_DEPRECATED); - } - $viewsPaths[] = $dir; - } if (!is_dir($transPaths[0]) && !isset($transPaths[1])) { throw new InvalidArgumentException(sprintf('"%s" is neither an enabled bundle nor a directory.', $transPaths[0])); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index a1d03e7280f97..4598ed9532fef 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -1116,19 +1116,12 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder $dirs[] = $transPaths[] = \dirname(\dirname($r->getFileName())).'/Resources/translations'; } $defaultDir = $container->getParameterBag()->resolveValue($config['default_path']); - $rootDir = $container->getParameter('kernel.root_dir'); foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) { if (\is_dir($dir = $bundle['path'].'/Resources/translations')) { $dirs[] = $dir; } else { $nonExistingDirs[] = $dir; } - if (\is_dir($dir = $rootDir.sprintf('/Resources/%s/translations', $name))) { - @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED); - $dirs[] = $dir; - } else { - $nonExistingDirs[] = $dir; - } } foreach ($config['paths'] as $dir) { @@ -1153,16 +1146,6 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder $nonExistingDirs[] = $defaultDir; } - if (\is_dir($dir = $rootDir.'/Resources/translations')) { - if ($dir !== $defaultDir) { - @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED); - } - - $dirs[] = $dir; - } else { - $nonExistingDirs[] = $dir; - } - // Register translation resources if ($dirs) { $files = []; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php index 7253215c55963..22158daf0fb99 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationDebugCommandTest.php @@ -65,23 +65,6 @@ public function testDebugDefaultDirectory() $this->assertRegExp('/unused/', $tester->getDisplay()); } - /** - * @group legacy - * @expectedDeprecation Storing translations in the "%ssf_translation%s/Resources/translations" directory is deprecated since Symfony 4.2, use the "%ssf_translation%s/translations" directory instead. - * @expectedDeprecation Loading Twig templates from the "%ssf_translation%s/Resources/views" directory is deprecated since Symfony 4.2, use the "%ssf_translation%s/templates" directory instead. - */ - public function testDebugLegacyDefaultDirectory() - { - $this->fs->mkdir($this->translationDir.'/Resources/translations'); - $this->fs->mkdir($this->translationDir.'/Resources/views'); - - $tester = $this->createCommandTester(['foo' => 'foo'], ['bar' => 'bar']); - $tester->execute(['locale' => 'en']); - - $this->assertRegExp('/missing/', $tester->getDisplay()); - $this->assertRegExp('/unused/', $tester->getDisplay()); - } - public function testDebugDefaultRootDirectory() { $this->fs->remove($this->translationDir); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php index 1ec04fd970787..65a4d801c5db2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php @@ -81,23 +81,6 @@ public function testWriteMessagesInRootDirectory() $this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay()); } - /** - * @group legacy - * @expectedDeprecation Storing translations in the "%ssf_translation%s/Resources/translations" directory is deprecated since Symfony 4.2, use the "%ssf_translation%s/translations" directory instead. - * @expectedDeprecation Storing templates in the "%ssf_translation%s/Resources/views" directory is deprecated since Symfony 4.2, use the "%ssf_translation%s/templates" directory instead. - */ - public function testWriteMessagesInLegacyRootDirectory() - { - $this->fs->remove($this->translationDir); - $this->translationDir = sys_get_temp_dir().'/'.uniqid('sf_translation', true); - $this->fs->mkdir($this->translationDir.'/Resources/translations'); - $this->fs->mkdir($this->translationDir.'/Resources/views'); - - $tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]); - $tester->execute(['command' => 'translation:update', 'locale' => 'en', '--force' => true]); - $this->assertRegExp('/Translation files were successfully updated./', $tester->getDisplay()); - } - public function testWriteMessagesForSpecificDomain() { $tester = $this->createCommandTester(['messages' => ['foo' => 'foo'], 'mydomain' => ['bar' => 'bar']]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/Resources/translations/test_default.en.xlf b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/Resources/translations/test_default.en.xlf deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 25b7353523906..322bcd1305c6c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -56,7 +56,6 @@ use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass; use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader; use Symfony\Component\Validator\Util\LegacyTranslatorProxy; -use Symfony\Component\Validator\Validation; use Symfony\Component\Workflow; abstract class FrameworkExtensionTest extends TestCase @@ -842,20 +841,6 @@ function ($directory) { } } - /** - * @group legacy - * @expectedDeprecation Translations directory "%s/Resources/translations" is deprecated since Symfony 4.2, use "%s/translations" instead. - */ - public function testLegacyTranslationsDirectory() - { - $container = $this->createContainerFromFile('full', ['kernel.root_dir' => __DIR__.'/Fixtures']); - $options = $container->getDefinition('translator.default')->getArgument(4); - $files = array_map('realpath', $options['resource_files']['en']); - - $dir = str_replace('/', \DIRECTORY_SEPARATOR, __DIR__.'/Fixtures/Resources/translations/test_default.en.xlf'); - $this->assertContains($dir, $files, '->registerTranslatorConfiguration() finds translation resources in legacy directory'); - } - public function testTranslatorMultipleFallbacks() { $container = $this->createContainerFromFile('translator_fallbacks'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TranslationDebugPass.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TranslationDebugPass.php deleted file mode 100644 index b8b53c25044cd..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/DependencyInjection/TranslationDebugPass.php +++ /dev/null @@ -1,21 +0,0 @@ -hasDefinition('console.command.translation_debug')) { - // skipping the /Resources/views path deprecation - $container->getDefinition('console.command.translation_debug') - ->setArgument(4, '%kernel.project_dir%/Resources/views'); - } - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TestBundle.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TestBundle.php index d90041213ce31..83dd4dc781910 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TestBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/TestBundle.php @@ -13,7 +13,6 @@ use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\AnnotationReaderPass; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\Config\CustomConfig; -use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection\TranslationDebugPass; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -30,6 +29,5 @@ public function build(ContainerBuilder $container) $extension->setCustomConfig(new CustomConfig()); $container->addCompilerPass(new AnnotationReaderPass(), PassConfig::TYPE_AFTER_REMOVING); - $container->addCompilerPass(new TranslationDebugPass()); } } From 2e6fbd52108e3b397d165842887156742154dad8 Mon Sep 17 00:00:00 2001 From: Amrouche Hamza Date: Wed, 29 May 2019 07:28:49 +0200 Subject: [PATCH 007/588] [Messenger] minor: Remove logging middleware --- .../Middleware/LoggingMiddleware.php | 58 ------------------ .../Middleware/LoggingMiddlewareTest.php | 61 ------------------- 2 files changed, 119 deletions(-) delete mode 100644 src/Symfony/Component/Messenger/Middleware/LoggingMiddleware.php delete mode 100644 src/Symfony/Component/Messenger/Tests/Middleware/LoggingMiddlewareTest.php diff --git a/src/Symfony/Component/Messenger/Middleware/LoggingMiddleware.php b/src/Symfony/Component/Messenger/Middleware/LoggingMiddleware.php deleted file mode 100644 index f68b6d802d8ad..0000000000000 --- a/src/Symfony/Component/Messenger/Middleware/LoggingMiddleware.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Messenger\Middleware; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, pass a logger to SendMessageMiddleware instead.', LoggingMiddleware::class), E_USER_DEPRECATED); - -use Psr\Log\LoggerInterface; -use Symfony\Component\Messenger\Envelope; - -/** - * @author Samuel Roze - * - * @deprecated since 4.3, pass a logger to SendMessageMiddleware instead - */ -class LoggingMiddleware implements MiddlewareInterface -{ - private $logger; - - public function __construct(LoggerInterface $logger) - { - $this->logger = $logger; - } - - /** - * {@inheritdoc} - */ - public function handle(Envelope $envelope, StackInterface $stack): Envelope - { - $message = $envelope->getMessage(); - $context = [ - 'message' => $message, - 'class' => \get_class($envelope->getMessage()), - ]; - $this->logger->debug('Starting handling message "{class}"', $context); - - try { - $envelope = $stack->next()->handle($envelope, $stack); - } catch (\Throwable $e) { - $context['exception'] = $e; - $this->logger->warning('An exception occurred while handling message "{class}": '.$e->getMessage(), $context); - - throw $e; - } - - $this->logger->debug('Finished handling message "{class}"', $context); - - return $envelope; - } -} diff --git a/src/Symfony/Component/Messenger/Tests/Middleware/LoggingMiddlewareTest.php b/src/Symfony/Component/Messenger/Tests/Middleware/LoggingMiddlewareTest.php deleted file mode 100644 index 675ff76730471..0000000000000 --- a/src/Symfony/Component/Messenger/Tests/Middleware/LoggingMiddlewareTest.php +++ /dev/null @@ -1,61 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Messenger\Tests\Middleware; - -use Psr\Log\LoggerInterface; -use Symfony\Component\Messenger\Envelope; -use Symfony\Component\Messenger\Middleware\LoggingMiddleware; -use Symfony\Component\Messenger\Test\Middleware\MiddlewareTestCase; -use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage; - -/** - * @group legacy - */ -class LoggingMiddlewareTest extends MiddlewareTestCase -{ - public function testDebugLogAndNextMiddleware() - { - $message = new DummyMessage('Hey'); - $envelope = new Envelope($message); - - $logger = $this->createMock(LoggerInterface::class); - $logger - ->expects($this->exactly(2)) - ->method('debug') - ; - - (new LoggingMiddleware($logger))->handle($envelope, $this->getStackMock()); - } - - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Thrown from next middleware. - */ - public function testWarningLogOnException() - { - $message = new DummyMessage('Hey'); - $envelope = new Envelope($message); - - $logger = $this->createMock(LoggerInterface::class); - $logger - ->expects($this->once()) - ->method('debug') - ; - $logger - ->expects($this->once()) - ->method('warning') - ; - $stack = $this->getThrowingStackMock(); - - (new LoggingMiddleware($logger))->handle($envelope, $stack); - } -} From bc7783c4bebdba761bc85748722a99b7873f645a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 29 May 2019 09:31:53 +0200 Subject: [PATCH 008/588] Add back some conflict rules --- src/Symfony/Bridge/Doctrine/composer.json | 4 +++- src/Symfony/Bridge/Twig/composer.json | 4 ++++ src/Symfony/Bundle/FrameworkBundle/composer.json | 9 ++++++++- src/Symfony/Bundle/TwigBundle/composer.json | 3 +++ src/Symfony/Bundle/WebProfilerBundle/composer.json | 3 +++ src/Symfony/Component/Console/composer.json | 3 +++ src/Symfony/Component/DependencyInjection/composer.json | 3 +++ src/Symfony/Component/Form/composer.json | 5 ++++- src/Symfony/Component/HttpKernel/composer.json | 2 ++ src/Symfony/Component/Messenger/composer.json | 3 +++ src/Symfony/Component/PropertyInfo/composer.json | 3 ++- src/Symfony/Component/Security/Core/composer.json | 4 ++++ src/Symfony/Component/Validator/composer.json | 3 ++- src/Symfony/Component/WebLink/composer.json | 3 +++ src/Symfony/Component/Workflow/composer.json | 3 +++ 15 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index b22442cf6d2da..3e981443085d0 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -46,7 +46,9 @@ "doctrine/reflection": "~1.0" }, "conflict": { - "phpunit/phpunit": "<5.4.3" + "phpunit/phpunit": "<5.4.3", + "symfony/form": "<4.4", + "symfony/messenger": "<4.4" }, "suggest": { "symfony/form": "", diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index 9baea3fb3ce21..8854d3deb56ed 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -43,6 +43,10 @@ "symfony/web-link": "^4.4|^5.0", "symfony/workflow": "^4.4|^5.0" }, + "conflict": { + "symfony/form": "<4.4", + "symfony/http-foundation": "<4.4" + }, "suggest": { "symfony/finder": "", "symfony/asset": "For using the AssetExtension", diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index c7dfdcb277e00..b0a063cd4591e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -65,7 +65,14 @@ "conflict": { "phpdocumentor/reflection-docblock": "<3.0", "phpdocumentor/type-resolver": "<0.2.1", - "phpunit/phpunit": "<5.4.3" + "phpunit/phpunit": "<5.4.3", + "symfony/browser-kit": "<4.4", + "symfony/console": "<4.4", + "symfony/dom-crawler": "<4.4", + "symfony/form": "<4.4", + "symfony/messenger": "<4.4", + "symfony/translation": "<4.4", + "symfony/workflow": "<4.4" }, "suggest": { "ext-apcu": "For best performance of the system caches", diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index b71cf96ae5706..2e32f5652399e 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -40,6 +40,9 @@ "doctrine/annotations": "~1.0", "doctrine/cache": "~1.0" }, + "conflict": { + "symfony/framework-bundle": "<4.4" + }, "autoload": { "psr-4": { "Symfony\\Bundle\\TwigBundle\\": "" }, "exclude-from-classmap": [ diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json index c5ac76836c1e4..c52d74be4d974 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/composer.json +++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json @@ -29,6 +29,9 @@ "symfony/dependency-injection": "^4.4|^5.0", "symfony/stopwatch": "^4.4|^5.0" }, + "conflict": { + "symfony/form": "<4.4" + }, "autoload": { "psr-4": { "Symfony\\Bundle\\WebProfilerBundle\\": "" }, "exclude-from-classmap": [ diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index 74374e6a805f7..d0eb5cc3b8590 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -39,6 +39,9 @@ "symfony/process": "", "psr/log": "For using the console logger" }, + "conflict": { + "symfony/event-dispatcher": "<4.4" + }, "autoload": { "psr-4": { "Symfony\\Component\\Console\\": "" }, "exclude-from-classmap": [ diff --git a/src/Symfony/Component/DependencyInjection/composer.json b/src/Symfony/Component/DependencyInjection/composer.json index f81ce8d02c655..6d1f254617b7a 100644 --- a/src/Symfony/Component/DependencyInjection/composer.json +++ b/src/Symfony/Component/DependencyInjection/composer.json @@ -32,6 +32,9 @@ "symfony/expression-language": "For using expressions in service container configuration", "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them" }, + "conflict": { + "symfony/config": "<4.4" + }, "provide": { "psr/container-implementation": "1.0", "symfony/service-implementation": "1.0" diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index f621b80383f57..e6cc24864a743 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -37,7 +37,10 @@ "symfony/var-dumper": "^4.4|^5.0" }, "conflict": { - "phpunit/phpunit": "<5.4.3" + "phpunit/phpunit": "<5.4.3", + "symfony/console": "<4.4", + "symfony/http-kernel": "<4.4", + "symfony/intl": "<4.4" }, "suggest": { "symfony/validator": "For form validation.", diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index cf4d20446124d..6fc50ddfe918f 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -47,6 +47,8 @@ "psr/log-implementation": "1.0" }, "conflict": { + "symfony/browser-kit": "<4.4", + "symfony/dependency-injection": "<4.4", "twig/twig": "<1.34|<2.4,>=2" }, "suggest": { diff --git a/src/Symfony/Component/Messenger/composer.json b/src/Symfony/Component/Messenger/composer.json index 7bbca44b41021..08c82fac766f0 100644 --- a/src/Symfony/Component/Messenger/composer.json +++ b/src/Symfony/Component/Messenger/composer.json @@ -36,6 +36,9 @@ "symfony/validator": "^4.4|^5.0", "symfony/var-dumper": "^4.4|^5.0" }, + "conflict": { + "symfony/event-dispatcher": "<4.4" + }, "suggest": { "enqueue/messenger-adapter": "For using the php-enqueue library as a transport." }, diff --git a/src/Symfony/Component/PropertyInfo/composer.json b/src/Symfony/Component/PropertyInfo/composer.json index 5b956b0138bb7..c1ce0b7e0cb77 100644 --- a/src/Symfony/Component/PropertyInfo/composer.json +++ b/src/Symfony/Component/PropertyInfo/composer.json @@ -34,7 +34,8 @@ "doctrine/annotations": "~1.0" }, "conflict": { - "phpdocumentor/reflection-docblock": "<3.2.2" + "phpdocumentor/reflection-docblock": "<3.2.2", + "phpdocumentor/type-resolver": "<0.3.0" }, "suggest": { "psr/cache-implementation": "To cache results", diff --git a/src/Symfony/Component/Security/Core/composer.json b/src/Symfony/Component/Security/Core/composer.json index 37b25ee59c78e..d2eb938cfa08d 100644 --- a/src/Symfony/Component/Security/Core/composer.json +++ b/src/Symfony/Component/Security/Core/composer.json @@ -29,6 +29,10 @@ "symfony/validator": "^4.4|^5.0", "psr/log": "~1.0" }, + "conflict": { + "symfony/event-dispatcher": "<4.4", + "symfony/security-guard": "<4.4" + }, "suggest": { "psr/container-implementation": "To instantiate the Security class", "symfony/event-dispatcher": "", diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index 9aa04f8593b98..1f0c10fbe4637 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -40,7 +40,8 @@ "egulias/email-validator": "^1.2.8|~2.0" }, "conflict": { - "phpunit/phpunit": "<5.4.3" + "phpunit/phpunit": "<5.4.3", + "symfony/intl": "<4.4" }, "suggest": { "psr/cache-implementation": "For using the metadata cache.", diff --git a/src/Symfony/Component/WebLink/composer.json b/src/Symfony/Component/WebLink/composer.json index baeb44db4bf93..81a742f3b3908 100644 --- a/src/Symfony/Component/WebLink/composer.json +++ b/src/Symfony/Component/WebLink/composer.json @@ -27,6 +27,9 @@ "symfony/http-foundation": "^4.4|^5.0", "symfony/http-kernel": "^4.4|^5.0" }, + "conflict": { + "symfony/http-kernel": "<4.4" + }, "autoload": { "psr-4": { "Symfony\\Component\\WebLink\\": "" }, "exclude-from-classmap": [ diff --git a/src/Symfony/Component/Workflow/composer.json b/src/Symfony/Component/Workflow/composer.json index f2da0ab76c118..b8432a5c11b68 100644 --- a/src/Symfony/Component/Workflow/composer.json +++ b/src/Symfony/Component/Workflow/composer.json @@ -31,6 +31,9 @@ "symfony/security-core": "^4.4|^5.0", "symfony/validator": "^4.4|^5.0" }, + "conflict": { + "symfony/event-dispatcher": "<4.4" + }, "autoload": { "psr-4": { "Symfony\\Component\\Workflow\\": "" } }, From 09ca33cde4bc5cb2e4909ddddf7057534108df75 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Wed, 29 May 2019 09:40:21 +0200 Subject: [PATCH 009/588] [HttpKernel] Cleanup legacy in ConfigDataCollector --- .../DataCollector/ConfigDataCollector.php | 35 +------------------ .../DataCollector/ConfigDataCollectorTest.php | 16 --------- 2 files changed, 1 insertion(+), 50 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index ddc331af62175..2280888951cfc 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -26,21 +26,10 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte * @var KernelInterface */ private $kernel; - private $name; - private $version; private $hasVarDumper; - public function __construct(string $name = null, string $version = null) + public function __construct() { - if (1 <= \func_num_args()) { - @trigger_error(sprintf('The "$name" argument in method "%s()" is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); - } - if (2 <= \func_num_args()) { - @trigger_error(sprintf('The "$version" argument in method "%s()" is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); - } - - $this->name = $name; - $this->version = $version; $this->hasVarDumper = class_exists(LinkStub::class); } @@ -58,8 +47,6 @@ public function setKernel(KernelInterface $kernel = null) public function collect(Request $request, Response $response, \Exception $exception = null) { $this->data = [ - 'app_name' => $this->name, - 'app_version' => $this->version, 'token' => $response->headers->get('X-Debug-Token'), 'symfony_version' => Kernel::VERSION, 'symfony_state' => 'unknown', @@ -109,26 +96,6 @@ public function lateCollect() $this->data = $this->cloneVar($this->data); } - /** - * @deprecated since Symfony 4.2 - */ - public function getApplicationName() - { - @trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); - - return $this->data['app_name']; - } - - /** - * @deprecated since Symfony 4.2 - */ - public function getApplicationVersion() - { - @trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); - - return $this->data['app_version']; - } - /** * Gets the token. * diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index 18269d28e7339..1c073ce181ba3 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -42,22 +42,6 @@ public function testCollect() $this->assertSame(\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN), $c->hasZendOpcache()); $this->assertSame(\extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN), $c->hasApcu()); } - - /** - * @group legacy - * @expectedDeprecation The "$name" argument in method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::__construct()" is deprecated since Symfony 4.2. - * @expectedDeprecation The "$version" argument in method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::__construct()" is deprecated since Symfony 4.2. - * @expectedDeprecation The method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::getApplicationName()" is deprecated since Symfony 4.2. - * @expectedDeprecation The method "Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector::getApplicationVersion()" is deprecated since Symfony 4.2. - */ - public function testLegacy() - { - $c = new ConfigDataCollector('name', null); - $c->collect(new Request(), new Response()); - - $this->assertSame('name', $c->getApplicationName()); - $this->assertNull($c->getApplicationVersion()); - } } class KernelForTest extends Kernel From 37c1cbbed3f74f2340a1997a9f905556b825bc1b Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Wed, 29 May 2019 10:06:33 +0200 Subject: [PATCH 010/588] [Validator] Remove DateTime support in date/time validators --- .../Constraints/DateTimeValidator.php | 6 ----- .../Validator/Constraints/DateValidator.php | 6 ----- .../Validator/Constraints/TimeValidator.php | 6 ----- .../Constraints/DateTimeValidatorTest.php | 22 ------------------- .../Tests/Constraints/DateValidatorTest.php | 22 ------------------- .../Tests/Constraints/TimeValidatorTest.php | 22 ------------------- 6 files changed, 84 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php b/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php index 16abf6f671ce4..73ff99c9dcb63 100644 --- a/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/DateTimeValidator.php @@ -34,12 +34,6 @@ public function validate($value, Constraint $constraint) return; } - if ($value instanceof \DateTimeInterface) { - @trigger_error(sprintf('Validating a \\DateTimeInterface with "%s" is deprecated since version 4.2. Use "%s" instead or remove the constraint if the underlying model is already type hinted to \\DateTimeInterface.', DateTime::class, Type::class), E_USER_DEPRECATED); - - return; - } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/DateValidator.php b/src/Symfony/Component/Validator/Constraints/DateValidator.php index 93b1f7d074e18..b3bbb5da20228 100644 --- a/src/Symfony/Component/Validator/Constraints/DateValidator.php +++ b/src/Symfony/Component/Validator/Constraints/DateValidator.php @@ -52,12 +52,6 @@ public function validate($value, Constraint $constraint) return; } - if ($value instanceof \DateTimeInterface) { - @trigger_error(sprintf('Validating a \\DateTimeInterface with "%s" is deprecated since version 4.2. Use "%s" instead or remove the constraint if the underlying model is already type hinted to \\DateTimeInterface.', Date::class, Type::class), E_USER_DEPRECATED); - - return; - } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Constraints/TimeValidator.php b/src/Symfony/Component/Validator/Constraints/TimeValidator.php index 799dbc3108e0c..2613ac5280354 100644 --- a/src/Symfony/Component/Validator/Constraints/TimeValidator.php +++ b/src/Symfony/Component/Validator/Constraints/TimeValidator.php @@ -52,12 +52,6 @@ public function validate($value, Constraint $constraint) return; } - if ($value instanceof \DateTimeInterface) { - @trigger_error(sprintf('Validating a \\DateTimeInterface with "%s" is deprecated since version 4.2. Use "%s" instead or remove the constraint if the underlying model is already type hinted to \\DateTimeInterface.', Time::class, Type::class), E_USER_DEPRECATED); - - return; - } - if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { throw new UnexpectedValueException($value, 'string'); } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php index 06f3894cfc962..968ce10178062 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php @@ -36,28 +36,6 @@ public function testEmptyStringIsValid() $this->assertNoViolation(); } - /** - * @group legacy - * @expectedDeprecation Validating a \DateTimeInterface with "Symfony\Component\Validator\Constraints\DateTime" is deprecated since version 4.2. Use "Symfony\Component\Validator\Constraints\Type" instead or remove the constraint if the underlying model is already type hinted to \DateTimeInterface. - */ - public function testDateTimeClassIsValid() - { - $this->validator->validate(new \DateTime(), new DateTime()); - - $this->assertNoViolation(); - } - - /** - * @group legacy - * @expectedDeprecation Validating a \DateTimeInterface with "Symfony\Component\Validator\Constraints\DateTime" is deprecated since version 4.2. Use "Symfony\Component\Validator\Constraints\Type" instead or remove the constraint if the underlying model is already type hinted to \DateTimeInterface. - */ - public function testDateTimeImmutableClassIsValid() - { - $this->validator->validate(new \DateTimeImmutable(), new DateTime()); - - $this->assertNoViolation(); - } - /** * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException */ diff --git a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php index 4dc8a966b4ccf..fa3bdd49ee442 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/DateValidatorTest.php @@ -36,28 +36,6 @@ public function testEmptyStringIsValid() $this->assertNoViolation(); } - /** - * @group legacy - * @expectedDeprecation Validating a \DateTimeInterface with "Symfony\Component\Validator\Constraints\Date" is deprecated since version 4.2. Use "Symfony\Component\Validator\Constraints\Type" instead or remove the constraint if the underlying model is already type hinted to \DateTimeInterface. - */ - public function testDateTimeClassIsValid() - { - $this->validator->validate(new \DateTime(), new Date()); - - $this->assertNoViolation(); - } - - /** - * @group legacy - * @expectedDeprecation Validating a \DateTimeInterface with "Symfony\Component\Validator\Constraints\Date" is deprecated since version 4.2. Use "Symfony\Component\Validator\Constraints\Type" instead or remove the constraint if the underlying model is already type hinted to \DateTimeInterface. - */ - public function testDateTimeImmutableClassIsValid() - { - $this->validator->validate(new \DateTimeImmutable(), new Date()); - - $this->assertNoViolation(); - } - /** * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException */ diff --git a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php index e2045628456e5..da5b4eb9df7bb 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/TimeValidatorTest.php @@ -36,17 +36,6 @@ public function testEmptyStringIsValid() $this->assertNoViolation(); } - /** - * @group legacy - * @expectedDeprecation Validating a \DateTimeInterface with "Symfony\Component\Validator\Constraints\Time" is deprecated since version 4.2. Use "Symfony\Component\Validator\Constraints\Type" instead or remove the constraint if the underlying model is already type hinted to \DateTimeInterface. - */ - public function testDateTimeClassIsValid() - { - $this->validator->validate(new \DateTime(), new Time()); - - $this->assertNoViolation(); - } - /** * @expectedException \Symfony\Component\Validator\Exception\UnexpectedValueException */ @@ -103,15 +92,4 @@ public function getInvalidTimes() ['00:00:60', Time::INVALID_TIME_ERROR], ]; } - - /** - * @group legacy - * @expectedDeprecation Validating a \DateTimeInterface with "Symfony\Component\Validator\Constraints\Time" is deprecated since version 4.2. Use "Symfony\Component\Validator\Constraints\Type" instead or remove the constraint if the underlying model is already type hinted to \DateTimeInterface. - */ - public function testDateTimeImmutableIsValid() - { - $this->validator->validate(new \DateTimeImmutable(), new Time()); - - $this->assertNoViolation(); - } } From aa84cfdb7b1f6634a199ee482c002f7b4ed7d55a Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Wed, 29 May 2019 10:14:45 +0200 Subject: [PATCH 011/588] [Validator] Remove fallback dependency checks --- src/Symfony/Component/Validator/Constraints/Bic.php | 3 +-- .../Component/Validator/Constraints/BicValidator.php | 10 +--------- .../Component/Validator/Constraints/Country.php | 3 +-- .../Validator/Constraints/CountryValidator.php | 5 ----- .../Component/Validator/Constraints/Currency.php | 3 +-- .../Validator/Constraints/CurrencyValidator.php | 5 ----- src/Symfony/Component/Validator/Constraints/Email.php | 3 +-- .../Component/Validator/Constraints/EmailValidator.php | 5 ----- .../Component/Validator/Constraints/Expression.php | 3 +-- .../Validator/Constraints/ExpressionValidator.php | 4 ---- .../Component/Validator/Constraints/Language.php | 3 +-- .../Validator/Constraints/LanguageValidator.php | 5 ----- src/Symfony/Component/Validator/Constraints/Locale.php | 3 +-- .../Validator/Constraints/LocaleValidator.php | 5 ----- 14 files changed, 8 insertions(+), 52 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/Bic.php b/src/Symfony/Component/Validator/Constraints/Bic.php index 8164bf6c2d961..0813728b4a96a 100644 --- a/src/Symfony/Component/Validator/Constraints/Bic.php +++ b/src/Symfony/Component/Validator/Constraints/Bic.php @@ -48,8 +48,7 @@ class Bic extends Constraint public function __construct($options = null) { if (!class_exists(Countries::class)) { - // throw new LogicException('The Intl component is required to use the Bic constraint. Try running "composer require symfony/intl".'); - @trigger_error(sprintf('Using the "%s" constraint without the "symfony/intl" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + throw new LogicException('The Intl component is required to use the Bic constraint. Try running "composer require symfony/intl".'); } if (isset($options['iban']) && isset($options['ibanPropertyPath'])) { diff --git a/src/Symfony/Component/Validator/Constraints/BicValidator.php b/src/Symfony/Component/Validator/Constraints/BicValidator.php index bc306d35e805e..3fd84e69f649d 100644 --- a/src/Symfony/Component/Validator/Constraints/BicValidator.php +++ b/src/Symfony/Component/Validator/Constraints/BicValidator.php @@ -104,15 +104,7 @@ public function validate($value, Constraint $constraint) return; } - // @deprecated since Symfony 4.2, will throw in 5.0 - if (class_exists(Countries::class)) { - $validCountryCode = Countries::exists(substr($canonicalize, 4, 2)); - } else { - $validCountryCode = ctype_alpha(substr($canonicalize, 4, 2)); - // throw new LogicException('The Intl component is required to use the Bic constraint. Try running "composer require symfony/intl".'); - } - - if (!$validCountryCode) { + if (!Countries::exists(substr($canonicalize, 4, 2))) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) ->setCode(Bic::INVALID_COUNTRY_CODE_ERROR) diff --git a/src/Symfony/Component/Validator/Constraints/Country.php b/src/Symfony/Component/Validator/Constraints/Country.php index 9c8cd4ada2849..1eaaa985fc144 100644 --- a/src/Symfony/Component/Validator/Constraints/Country.php +++ b/src/Symfony/Component/Validator/Constraints/Country.php @@ -34,8 +34,7 @@ class Country extends Constraint public function __construct($options = null) { if (!class_exists(Countries::class)) { - // throw new LogicException('The Intl component is required to use the Country constraint. Try running "composer require symfony/intl".'); - @trigger_error(sprintf('Using the "%s" constraint without the "symfony/intl" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + throw new LogicException('The Intl component is required to use the Country constraint. Try running "composer require symfony/intl".'); } parent::__construct($options); diff --git a/src/Symfony/Component/Validator/Constraints/CountryValidator.php b/src/Symfony/Component/Validator/Constraints/CountryValidator.php index 21dd62b034e19..ca2867f09495e 100644 --- a/src/Symfony/Component/Validator/Constraints/CountryValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CountryValidator.php @@ -14,7 +14,6 @@ use Symfony\Component\Intl\Countries; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\LogicException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\UnexpectedValueException; @@ -42,10 +41,6 @@ public function validate($value, Constraint $constraint) throw new UnexpectedValueException($value, 'string'); } - if (!class_exists(Countries::class)) { - throw new LogicException('The Intl component is required to use the Country constraint. Try running "composer require symfony/intl".'); - } - $value = (string) $value; if (!Countries::exists($value)) { diff --git a/src/Symfony/Component/Validator/Constraints/Currency.php b/src/Symfony/Component/Validator/Constraints/Currency.php index 580a5cb6161d8..2ee5ae37890fa 100644 --- a/src/Symfony/Component/Validator/Constraints/Currency.php +++ b/src/Symfony/Component/Validator/Constraints/Currency.php @@ -35,8 +35,7 @@ class Currency extends Constraint public function __construct($options = null) { if (!class_exists(Currencies::class)) { - // throw new LogicException('The Intl component is required to use the Currency constraint. Try running "composer require symfony/intl".'); - @trigger_error(sprintf('Using the "%s" constraint without the "symfony/intl" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + throw new LogicException('The Intl component is required to use the Currency constraint. Try running "composer require symfony/intl".'); } parent::__construct($options); diff --git a/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php b/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php index a6352c3263498..3108f51443430 100644 --- a/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php +++ b/src/Symfony/Component/Validator/Constraints/CurrencyValidator.php @@ -14,7 +14,6 @@ use Symfony\Component\Intl\Currencies; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\LogicException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\UnexpectedValueException; @@ -43,10 +42,6 @@ public function validate($value, Constraint $constraint) throw new UnexpectedValueException($value, 'string'); } - if (!class_exists(Currencies::class)) { - throw new LogicException('The Intl component is required to use the Currency constraint. Try running "composer require symfony/intl".'); - } - $value = (string) $value; if (!Currencies::exists($value)) { diff --git a/src/Symfony/Component/Validator/Constraints/Email.php b/src/Symfony/Component/Validator/Constraints/Email.php index bb3ea5ce020ca..e780d36c7528d 100644 --- a/src/Symfony/Component/Validator/Constraints/Email.php +++ b/src/Symfony/Component/Validator/Constraints/Email.php @@ -97,8 +97,7 @@ public function __construct($options = null) parent::__construct($options); if ((self::VALIDATION_MODE_STRICT === $this->mode || true === $this->strict) && !class_exists(StrictEmailValidator::class)) { - // throw new LogicException(sprintf('The "egulias/email-validator" component is required to use the "%s" constraint in strict mode.', __CLASS__)); - @trigger_error(sprintf('Using the "%s" constraint in strict mode without the "egulias/email-validator" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + throw new LogicException(sprintf('The "egulias/email-validator" component is required to use the "%s" constraint in strict mode.', __CLASS__)); } if (null !== $this->normalizer && !\is_callable($this->normalizer)) { diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php index b7306d2b0e174..c3a15a2354ae7 100644 --- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php +++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php @@ -15,7 +15,6 @@ use Egulias\EmailValidator\Validation\NoRFCWarningsValidation; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\LogicException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\UnexpectedValueException; @@ -104,10 +103,6 @@ public function validate($value, Constraint $constraint) } if (Email::VALIDATION_MODE_STRICT === $constraint->mode) { - if (!class_exists('\Egulias\EmailValidator\EmailValidator')) { - throw new LogicException('Strict email validation requires egulias/email-validator ~1.2|~2.0'); - } - $strictValidator = new \Egulias\EmailValidator\EmailValidator(); if (interface_exists(EmailValidation::class) && !$strictValidator->isValid($value, new NoRFCWarningsValidation())) { diff --git a/src/Symfony/Component/Validator/Constraints/Expression.php b/src/Symfony/Component/Validator/Constraints/Expression.php index 42e7248819f31..4c79ea0f22f99 100644 --- a/src/Symfony/Component/Validator/Constraints/Expression.php +++ b/src/Symfony/Component/Validator/Constraints/Expression.php @@ -37,8 +37,7 @@ class Expression extends Constraint public function __construct($options = null) { if (!class_exists(ExpressionLanguage::class)) { - // throw new LogicException(sprintf('The "symfony/expression-language" component is required to use the "%s" constraint.', __CLASS__)); - @trigger_error(sprintf('Using the "%s" constraint without the "symfony/expression-language" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + throw new LogicException(sprintf('The "symfony/expression-language" component is required to use the "%s" constraint.', __CLASS__)); } parent::__construct($options); diff --git a/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php b/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php index b72a83365b7b7..b5476910e1592 100644 --- a/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php +++ b/src/Symfony/Component/Validator/Constraints/ExpressionValidator.php @@ -14,7 +14,6 @@ use Symfony\Component\ExpressionLanguage\ExpressionLanguage; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\LogicException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** @@ -54,9 +53,6 @@ public function validate($value, Constraint $constraint) private function getExpressionLanguage() { if (null === $this->expressionLanguage) { - if (!class_exists('Symfony\Component\ExpressionLanguage\ExpressionLanguage')) { - throw new LogicException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed.'); - } $this->expressionLanguage = new ExpressionLanguage(); } diff --git a/src/Symfony/Component/Validator/Constraints/Language.php b/src/Symfony/Component/Validator/Constraints/Language.php index c8e242d187111..6b3ac769f9723 100644 --- a/src/Symfony/Component/Validator/Constraints/Language.php +++ b/src/Symfony/Component/Validator/Constraints/Language.php @@ -34,8 +34,7 @@ class Language extends Constraint public function __construct($options = null) { if (!class_exists(Languages::class)) { - // throw new LogicException('The Intl component is required to use the Language constraint. Try running "composer require symfony/intl".'); - @trigger_error(sprintf('Using the "%s" constraint without the "symfony/intl" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + throw new LogicException('The Intl component is required to use the Language constraint. Try running "composer require symfony/intl".'); } parent::__construct($options); diff --git a/src/Symfony/Component/Validator/Constraints/LanguageValidator.php b/src/Symfony/Component/Validator/Constraints/LanguageValidator.php index 4f9b118d8416c..96c36985a8953 100644 --- a/src/Symfony/Component/Validator/Constraints/LanguageValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LanguageValidator.php @@ -14,7 +14,6 @@ use Symfony\Component\Intl\Languages; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\LogicException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\UnexpectedValueException; @@ -42,10 +41,6 @@ public function validate($value, Constraint $constraint) throw new UnexpectedValueException($value, 'string'); } - if (!class_exists(Languages::class)) { - throw new LogicException('The Intl component is required to use the Language constraint. Try running "composer require symfony/intl".'); - } - $value = (string) $value; if (!Languages::exists($value)) { diff --git a/src/Symfony/Component/Validator/Constraints/Locale.php b/src/Symfony/Component/Validator/Constraints/Locale.php index faff564d31746..b5b31986334aa 100644 --- a/src/Symfony/Component/Validator/Constraints/Locale.php +++ b/src/Symfony/Component/Validator/Constraints/Locale.php @@ -39,8 +39,7 @@ public function __construct($options = null) } if (!class_exists(Locales::class)) { - // throw new LogicException('The Intl component is required to use the Locale constraint. Try running "composer require symfony/intl".'); - @trigger_error(sprintf('Using the "%s" constraint without the "symfony/intl" component installed is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + throw new LogicException('The Intl component is required to use the Locale constraint. Try running "composer require symfony/intl".'); } parent::__construct($options); diff --git a/src/Symfony/Component/Validator/Constraints/LocaleValidator.php b/src/Symfony/Component/Validator/Constraints/LocaleValidator.php index f965a0fcf21e8..760131279a4ff 100644 --- a/src/Symfony/Component/Validator/Constraints/LocaleValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LocaleValidator.php @@ -14,7 +14,6 @@ use Symfony\Component\Intl\Locales; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\LogicException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\UnexpectedValueException; @@ -42,10 +41,6 @@ public function validate($value, Constraint $constraint) throw new UnexpectedValueException($value, 'string'); } - if (!class_exists(Locales::class)) { - throw new LogicException('The Intl component is required to use the Locale constraint. Try running "composer require symfony/intl".'); - } - $inputValue = (string) $value; $value = $inputValue; if ($constraint->canonicalize) { From 885703f18957f2c575f9cebc8ee37eb9e8b6599c Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Wed, 29 May 2019 10:27:26 +0200 Subject: [PATCH 012/588] [Validator] Remove checkDNS option in Url --- .../Component/Validator/Constraints/Url.php | 84 -------------- .../Validator/Constraints/UrlValidator.php | 29 ----- .../Tests/Constraints/UrlValidatorTest.php | 106 ------------------ 3 files changed, 219 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/Url.php b/src/Symfony/Component/Validator/Constraints/Url.php index 45d21c8ae281b..31d3395f109a6 100644 --- a/src/Symfony/Component/Validator/Constraints/Url.php +++ b/src/Symfony/Component/Validator/Constraints/Url.php @@ -22,71 +22,6 @@ */ class Url extends Constraint { - /** - * @deprecated since Symfony 4.1 - */ - const CHECK_DNS_TYPE_ANY = 'ANY'; - - /** - * @deprecated since Symfony 4.1 - */ - const CHECK_DNS_TYPE_NONE = false; - - /** - * @deprecated since Symfony 4.1 - */ - const CHECK_DNS_TYPE_A = 'A'; - - /** - * @deprecated since Symfony 4.1 - */ - const CHECK_DNS_TYPE_A6 = 'A6'; - - /** - * @deprecated since Symfony 4.1 - */ - const CHECK_DNS_TYPE_AAAA = 'AAAA'; - - /** - * @deprecated since Symfony 4.1 - */ - const CHECK_DNS_TYPE_CNAME = 'CNAME'; - - /** - * @deprecated since Symfony 4.1 - */ - const CHECK_DNS_TYPE_MX = 'MX'; - - /** - * @deprecated since Symfony 4.1 - */ - const CHECK_DNS_TYPE_NAPTR = 'NAPTR'; - - /** - * @deprecated since Symfony 4.1 - */ - const CHECK_DNS_TYPE_NS = 'NS'; - - /** - * @deprecated since Symfony 4.1 - */ - const CHECK_DNS_TYPE_PTR = 'PTR'; - - /** - * @deprecated since Symfony 4.1 - */ - const CHECK_DNS_TYPE_SOA = 'SOA'; - - /** - * @deprecated since Symfony 4.1 - */ - const CHECK_DNS_TYPE_SRV = 'SRV'; - - /** - * @deprecated since Symfony 4.1 - */ - const CHECK_DNS_TYPE_TXT = 'TXT'; - const INVALID_URL_ERROR = '57c2f299-1154-4870-89bb-ef3b1f5ad229'; protected static $errorNames = [ @@ -94,31 +29,12 @@ class Url extends Constraint ]; public $message = 'This value is not a valid URL.'; - - /** - * @deprecated since Symfony 4.1 - */ - public $dnsMessage = 'The host could not be resolved.'; public $protocols = ['http', 'https']; - - /** - * @deprecated since Symfony 4.1 - */ - public $checkDNS = self::CHECK_DNS_TYPE_NONE; public $relativeProtocol = false; public $normalizer; public function __construct($options = null) { - if (\is_array($options)) { - if (\array_key_exists('checkDNS', $options)) { - @trigger_error(sprintf('The "checkDNS" option in "%s" is deprecated since Symfony 4.1. Its false-positive rate is too high to be relied upon.', self::class), E_USER_DEPRECATED); - } - if (\array_key_exists('dnsMessage', $options)) { - @trigger_error(sprintf('The "dnsMessage" option in "%s" is deprecated since Symfony 4.1.', self::class), E_USER_DEPRECATED); - } - } - parent::__construct($options); if (null !== $this->normalizer && !\is_callable($this->normalizer)) { diff --git a/src/Symfony/Component/Validator/Constraints/UrlValidator.php b/src/Symfony/Component/Validator/Constraints/UrlValidator.php index cc0522a62a786..babd29adbecef 100644 --- a/src/Symfony/Component/Validator/Constraints/UrlValidator.php +++ b/src/Symfony/Component/Validator/Constraints/UrlValidator.php @@ -13,7 +13,6 @@ use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\InvalidOptionsException; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Exception\UnexpectedValueException; @@ -77,33 +76,5 @@ public function validate($value, Constraint $constraint) return; } - - if ($constraint->checkDNS) { - if (!\in_array($constraint->checkDNS, [ - Url::CHECK_DNS_TYPE_ANY, - Url::CHECK_DNS_TYPE_A, - Url::CHECK_DNS_TYPE_A6, - Url::CHECK_DNS_TYPE_AAAA, - Url::CHECK_DNS_TYPE_CNAME, - Url::CHECK_DNS_TYPE_MX, - Url::CHECK_DNS_TYPE_NAPTR, - Url::CHECK_DNS_TYPE_NS, - Url::CHECK_DNS_TYPE_PTR, - Url::CHECK_DNS_TYPE_SOA, - Url::CHECK_DNS_TYPE_SRV, - Url::CHECK_DNS_TYPE_TXT, - ], true)) { - throw new InvalidOptionsException(sprintf('Invalid value for option "checkDNS" in constraint %s', \get_class($constraint)), ['checkDNS']); - } - - $host = parse_url($value, PHP_URL_HOST); - - if (!\is_string($host) || !checkdnsrr($host, $constraint->checkDNS)) { - $this->context->buildViolation($constraint->dnsMessage) - ->setParameter('{{ value }}', $this->formatValue($host)) - ->setCode(Url::INVALID_URL_ERROR) - ->addViolation(); - } - } } } diff --git a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php index 792316460f498..4f9daeba5c9b6 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/UrlValidatorTest.php @@ -11,14 +11,10 @@ namespace Symfony\Component\Validator\Tests\Constraints; -use Symfony\Bridge\PhpUnit\DnsMock; use Symfony\Component\Validator\Constraints\Url; use Symfony\Component\Validator\Constraints\UrlValidator; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; -/** - * @group dns-sensitive - */ class UrlValidatorTest extends ConstraintValidatorTestCase { protected function createValidator() @@ -283,108 +279,6 @@ public function getValidCustomUrls() ['git://[::1]/'], ]; } - - /** - * @dataProvider getCheckDns - * @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts - * @group legacy - * @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1. Its false-positive rate is too high to be relied upon. - */ - public function testCheckDns($violation) - { - DnsMock::withMockedHosts(['example.com' => [['type' => $violation ? '' : 'A']]]); - - $constraint = new Url([ - 'checkDNS' => 'ANY', - 'dnsMessage' => 'myMessage', - ]); - - $this->validator->validate('http://example.com', $constraint); - - if (!$violation) { - $this->assertNoViolation(); - } else { - $this->buildViolation('myMessage') - ->setParameter('{{ value }}', '"example.com"') - ->setCode(Url::INVALID_URL_ERROR) - ->assertRaised(); - } - } - - public function getCheckDns() - { - return [[true], [false]]; - } - - /** - * @dataProvider getCheckDnsTypes - * @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts - * @group legacy - * @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1. Its false-positive rate is too high to be relied upon. - */ - public function testCheckDnsByType($type) - { - DnsMock::withMockedHosts(['example.com' => [['type' => $type]]]); - - $constraint = new Url([ - 'checkDNS' => $type, - 'dnsMessage' => 'myMessage', - ]); - - $this->validator->validate('http://example.com', $constraint); - - $this->assertNoViolation(); - } - - public function getCheckDnsTypes() - { - return [ - ['ANY'], - ['A'], - ['A6'], - ['AAAA'], - ['CNAME'], - ['MX'], - ['NAPTR'], - ['NS'], - ['PTR'], - ['SOA'], - ['SRV'], - ['TXT'], - ]; - } - - /** - * @expectedException \Symfony\Component\Validator\Exception\InvalidOptionsException - * @requires function Symfony\Bridge\PhpUnit\DnsMock::withMockedHosts - * @group legacy - * @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1. Its false-positive rate is too high to be relied upon. - * @expectedDeprecation The "dnsMessage" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1. - */ - public function testCheckDnsWithInvalidType() - { - DnsMock::withMockedHosts(['example.com' => [['type' => 'A']]]); - - $constraint = new Url([ - 'checkDNS' => 'BOGUS', - 'dnsMessage' => 'myMessage', - ]); - - $this->validator->validate('http://example.com', $constraint); - } - - /** - * @group legacy - * @expectedDeprecation The "checkDNS" option in "Symfony\Component\Validator\Constraints\Url" is deprecated since Symfony 4.1. Its false-positive rate is too high to be relied upon. - */ - public function testCheckDnsOptionIsDeprecated() - { - $constraint = new Url([ - 'checkDNS' => Url::CHECK_DNS_TYPE_NONE, - ]); - - $this->validator->validate('http://example.com', $constraint); - } } class EmailProvider From ddbe11dbcdfdefcefbe4d22ef8fb882c938feb09 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 29 May 2019 10:53:30 +0200 Subject: [PATCH 013/588] Add back all conflict rules --- src/Symfony/Bridge/Doctrine/composer.json | 1 + src/Symfony/Bridge/Monolog/composer.json | 4 ++++ src/Symfony/Bridge/Twig/composer.json | 5 ++++- src/Symfony/Bundle/DebugBundle/composer.json | 4 ++++ src/Symfony/Bundle/FrameworkBundle/composer.json | 7 +++++++ src/Symfony/Bundle/SecurityBundle/composer.json | 7 +++++++ src/Symfony/Bundle/TwigBundle/composer.json | 4 +++- src/Symfony/Bundle/WebProfilerBundle/composer.json | 3 +++ src/Symfony/Component/Cache/composer.json | 4 +++- src/Symfony/Component/Config/composer.json | 3 +++ src/Symfony/Component/Console/composer.json | 4 +++- src/Symfony/Component/Debug/composer.json | 3 +++ src/Symfony/Component/DependencyInjection/composer.json | 5 ++++- src/Symfony/Component/EventDispatcher/composer.json | 3 +++ src/Symfony/Component/Form/composer.json | 7 ++++++- src/Symfony/Component/HttpKernel/composer.json | 3 +++ src/Symfony/Component/Ldap/composer.json | 3 +++ src/Symfony/Component/Messenger/composer.json | 3 ++- src/Symfony/Component/PropertyInfo/composer.json | 3 ++- src/Symfony/Component/Routing/composer.json | 5 +++++ src/Symfony/Component/Security/Csrf/composer.json | 3 +++ src/Symfony/Component/Security/Http/composer.json | 3 +++ src/Symfony/Component/Serializer/composer.json | 6 +++++- src/Symfony/Component/Translation/composer.json | 5 +++++ src/Symfony/Component/Validator/composer.json | 6 +++++- src/Symfony/Component/VarDumper/composer.json | 3 ++- src/Symfony/Component/Yaml/composer.json | 3 +++ 27 files changed, 99 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index 3e981443085d0..648a5190cb7ed 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -47,6 +47,7 @@ }, "conflict": { "phpunit/phpunit": "<5.4.3", + "symfony/dependency-injection": "<4.4", "symfony/form": "<4.4", "symfony/messenger": "<4.4" }, diff --git a/src/Symfony/Bridge/Monolog/composer.json b/src/Symfony/Bridge/Monolog/composer.json index f80ac3b6ed725..009e9b243bba2 100644 --- a/src/Symfony/Bridge/Monolog/composer.json +++ b/src/Symfony/Bridge/Monolog/composer.json @@ -26,6 +26,10 @@ "symfony/security-core": "^4.4|^5.0", "symfony/var-dumper": "^4.4|^5.0" }, + "conflict": { + "symfony/console": "<4.4", + "symfony/http-foundation": "<4.4" + }, "suggest": { "symfony/http-kernel": "For using the debugging handlers together with the response life cycle of the HTTP kernel.", "symfony/console": "For the possibility to show log messages in console commands depending on verbosity settings.", diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index 8854d3deb56ed..e0532d88ffc84 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -44,8 +44,11 @@ "symfony/workflow": "^4.4|^5.0" }, "conflict": { + "symfony/console": "<4.4", "symfony/form": "<4.4", - "symfony/http-foundation": "<4.4" + "symfony/http-foundation": "<4.4", + "symfony/translation": "<4.4", + "symfony/workflow": "<4.4" }, "suggest": { "symfony/finder": "", diff --git a/src/Symfony/Bundle/DebugBundle/composer.json b/src/Symfony/Bundle/DebugBundle/composer.json index 7e1b9236ab70e..1805712b855f4 100644 --- a/src/Symfony/Bundle/DebugBundle/composer.json +++ b/src/Symfony/Bundle/DebugBundle/composer.json @@ -27,6 +27,10 @@ "symfony/dependency-injection": "^4.4|^5.0", "symfony/web-profiler-bundle": "^4.4|^5.0" }, + "conflict": { + "symfony/config": "<4.4", + "symfony/dependency-injection": "<4.4" + }, "suggest": { "symfony/config": "For service container configuration", "symfony/dependency-injection": "For using as a service from the container" diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index b0a063cd4591e..f3fc1262a9c5b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -66,12 +66,19 @@ "phpdocumentor/reflection-docblock": "<3.0", "phpdocumentor/type-resolver": "<0.2.1", "phpunit/phpunit": "<5.4.3", + "symfony/asset": "<4.4", "symfony/browser-kit": "<4.4", "symfony/console": "<4.4", + "symfony/dotenv": "<4.4", "symfony/dom-crawler": "<4.4", "symfony/form": "<4.4", "symfony/messenger": "<4.4", + "symfony/property-info": "<4.4", + "symfony/serializer": "<4.4", + "symfony/stopwatch": "<4.4", "symfony/translation": "<4.4", + "symfony/twig-bridge": "<4.4", + "symfony/validator": "<4.4", "symfony/workflow": "<4.4" }, "suggest": { diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index 77065a0006827..1c2ed949f9bf8 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -46,6 +46,13 @@ "doctrine/doctrine-bundle": "~1.5", "twig/twig": "~1.34|~2.4" }, + "conflict": { + "symfony/browser-kit": "<4.4", + "symfony/twig-bundle": "<4.4", + "symfony/var-dumper": "<4.4", + "symfony/framework-bundle": "<4.4", + "symfony/console": "<4.4" + }, "autoload": { "psr-4": { "Symfony\\Bundle\\SecurityBundle\\": "" }, "exclude-from-classmap": [ diff --git a/src/Symfony/Bundle/TwigBundle/composer.json b/src/Symfony/Bundle/TwigBundle/composer.json index 2e32f5652399e..6c34f7149b28d 100644 --- a/src/Symfony/Bundle/TwigBundle/composer.json +++ b/src/Symfony/Bundle/TwigBundle/composer.json @@ -41,7 +41,9 @@ "doctrine/cache": "~1.0" }, "conflict": { - "symfony/framework-bundle": "<4.4" + "symfony/dependency-injection": "<4.4", + "symfony/framework-bundle": "<4.4", + "symfony/translation": "<4.4" }, "autoload": { "psr-4": { "Symfony\\Bundle\\TwigBundle\\": "" }, diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json index c52d74be4d974..817f455ef68ed 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/composer.json +++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json @@ -30,6 +30,9 @@ "symfony/stopwatch": "^4.4|^5.0" }, "conflict": { + "symfony/dependency-injection": "<4.4", + "symfony/messenger": "<4.4", + "symfony/var-dumper": "<4.4", "symfony/form": "<4.4" }, "autoload": { diff --git a/src/Symfony/Component/Cache/composer.json b/src/Symfony/Component/Cache/composer.json index ff9e99ca13ad6..18ae4ad0fe8a6 100644 --- a/src/Symfony/Component/Cache/composer.json +++ b/src/Symfony/Component/Cache/composer.json @@ -39,7 +39,9 @@ "symfony/var-dumper": "^4.4|^5.0" }, "conflict": { - "doctrine/dbal": "<2.5" + "doctrine/dbal": "<2.5", + "symfony/dependency-injection": "<4.4", + "symfony/var-dumper": "<4.4" }, "autoload": { "psr-4": { "Symfony\\Component\\Cache\\": "" }, diff --git a/src/Symfony/Component/Config/composer.json b/src/Symfony/Component/Config/composer.json index bc7cf84d15a53..fb06a8ec9a76b 100644 --- a/src/Symfony/Component/Config/composer.json +++ b/src/Symfony/Component/Config/composer.json @@ -27,6 +27,9 @@ "symfony/messenger": "^4.4|^5.0", "symfony/yaml": "^4.4|^5.0" }, + "conflict": { + "symfony/finder": "<4.4" + }, "suggest": { "symfony/yaml": "To use the yaml reference dumper" }, diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index d0eb5cc3b8590..ca5713f3cab81 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -40,7 +40,9 @@ "psr/log": "For using the console logger" }, "conflict": { - "symfony/event-dispatcher": "<4.4" + "symfony/dependency-injection": "<4.4", + "symfony/event-dispatcher": "<4.4", + "symfony/process": "<4.4" }, "autoload": { "psr-4": { "Symfony\\Component\\Console\\": "" }, diff --git a/src/Symfony/Component/Debug/composer.json b/src/Symfony/Component/Debug/composer.json index a5e82c4a74353..1f977bad7d373 100644 --- a/src/Symfony/Component/Debug/composer.json +++ b/src/Symfony/Component/Debug/composer.json @@ -19,6 +19,9 @@ "php": "^7.2.9", "psr/log": "~1.0" }, + "conflict": { + "symfony/http-kernel": "<4.4" + }, "require-dev": { "symfony/http-kernel": "^4.4|^5.0" }, diff --git a/src/Symfony/Component/DependencyInjection/composer.json b/src/Symfony/Component/DependencyInjection/composer.json index 6d1f254617b7a..351471e26a3c2 100644 --- a/src/Symfony/Component/DependencyInjection/composer.json +++ b/src/Symfony/Component/DependencyInjection/composer.json @@ -33,7 +33,10 @@ "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them" }, "conflict": { - "symfony/config": "<4.4" + "symfony/config": "<4.4", + "symfony/finder": "<4.4", + "symfony/proxy-manager-bridge": "<4.4", + "symfony/yaml": "<4.4" }, "provide": { "psr/container-implementation": "1.0", diff --git a/src/Symfony/Component/EventDispatcher/composer.json b/src/Symfony/Component/EventDispatcher/composer.json index 34536b37ee26f..eed6b05a988a5 100644 --- a/src/Symfony/Component/EventDispatcher/composer.json +++ b/src/Symfony/Component/EventDispatcher/composer.json @@ -28,6 +28,9 @@ "symfony/stopwatch": "^4.4|^5.0", "psr/log": "~1.0" }, + "conflict": { + "symfony/dependency-injection": "<4.4" + }, "provide": { "psr/event-dispatcher-implementation": "1.0", "symfony/event-dispatcher-implementation": "1.1" diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index e6cc24864a743..4c510eb564da3 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -39,8 +39,13 @@ "conflict": { "phpunit/phpunit": "<5.4.3", "symfony/console": "<4.4", + "symfony/dependency-injection": "<4.4", + "symfony/doctrine-bridge": "<4.4", + "symfony/framework-bundle": "<4.4", "symfony/http-kernel": "<4.4", - "symfony/intl": "<4.4" + "symfony/intl": "<4.4", + "symfony/translation": "<4.4", + "symfony/twig-bridge": "<4.4" }, "suggest": { "symfony/validator": "For form validation.", diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index 6fc50ddfe918f..0384f48c15c07 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -48,7 +48,10 @@ }, "conflict": { "symfony/browser-kit": "<4.4", + "symfony/config": "<4.4", "symfony/dependency-injection": "<4.4", + "symfony/translation": "<4.4", + "symfony/var-dumper": "<4.4", "twig/twig": "<1.34|<2.4,>=2" }, "suggest": { diff --git a/src/Symfony/Component/Ldap/composer.json b/src/Symfony/Component/Ldap/composer.json index bd18d35b922a5..fb30acec02dd9 100644 --- a/src/Symfony/Component/Ldap/composer.json +++ b/src/Symfony/Component/Ldap/composer.json @@ -20,6 +20,9 @@ "symfony/options-resolver": "^4.4|^5.0", "ext-ldap": "*" }, + "conflict": { + "symfony/options-resolver": "<4.4" + }, "autoload": { "psr-4": { "Symfony\\Component\\Ldap\\": "" }, "exclude-from-classmap": [ diff --git a/src/Symfony/Component/Messenger/composer.json b/src/Symfony/Component/Messenger/composer.json index 08c82fac766f0..054d8b222c432 100644 --- a/src/Symfony/Component/Messenger/composer.json +++ b/src/Symfony/Component/Messenger/composer.json @@ -37,7 +37,8 @@ "symfony/var-dumper": "^4.4|^5.0" }, "conflict": { - "symfony/event-dispatcher": "<4.4" + "symfony/event-dispatcher": "<4.4", + "symfony/debug": "<4.4" }, "suggest": { "enqueue/messenger-adapter": "For using the php-enqueue library as a transport." diff --git a/src/Symfony/Component/PropertyInfo/composer.json b/src/Symfony/Component/PropertyInfo/composer.json index c1ce0b7e0cb77..ec6d718157c49 100644 --- a/src/Symfony/Component/PropertyInfo/composer.json +++ b/src/Symfony/Component/PropertyInfo/composer.json @@ -35,7 +35,8 @@ }, "conflict": { "phpdocumentor/reflection-docblock": "<3.2.2", - "phpdocumentor/type-resolver": "<0.3.0" + "phpdocumentor/type-resolver": "<0.3.0", + "symfony/dependency-injection": "<4.4" }, "suggest": { "psr/cache-implementation": "To cache results", diff --git a/src/Symfony/Component/Routing/composer.json b/src/Symfony/Component/Routing/composer.json index f20a4e2a6c730..eb39683d43b70 100644 --- a/src/Symfony/Component/Routing/composer.json +++ b/src/Symfony/Component/Routing/composer.json @@ -27,6 +27,11 @@ "doctrine/annotations": "~1.2", "psr/log": "~1.0" }, + "conflict": { + "symfony/config": "<4.4", + "symfony/dependency-injection": "<4.4", + "symfony/yaml": "<4.4" + }, "suggest": { "symfony/http-foundation": "For using a Symfony Request object", "symfony/config": "For using the all-in-one router or any loader", diff --git a/src/Symfony/Component/Security/Csrf/composer.json b/src/Symfony/Component/Security/Csrf/composer.json index ba25905ff88cc..807c65a87ee0b 100644 --- a/src/Symfony/Component/Security/Csrf/composer.json +++ b/src/Symfony/Component/Security/Csrf/composer.json @@ -22,6 +22,9 @@ "require-dev": { "symfony/http-foundation": "^4.4|^5.0" }, + "conflict": { + "symfony/http-foundation": "<4.4" + }, "suggest": { "symfony/http-foundation": "For using the class SessionTokenStorage." }, diff --git a/src/Symfony/Component/Security/Http/composer.json b/src/Symfony/Component/Security/Http/composer.json index 439f85d4e2c74..9cb56e9d1821b 100644 --- a/src/Symfony/Component/Security/Http/composer.json +++ b/src/Symfony/Component/Security/Http/composer.json @@ -27,6 +27,9 @@ "symfony/security-csrf": "^4.4|^5.0", "psr/log": "~1.0" }, + "conflict": { + "symfony/security-csrf": "<4.4" + }, "suggest": { "symfony/security-csrf": "For using tokens to protect authentication/logout attempts", "symfony/routing": "For using the HttpUtils class to create sub-requests, redirect the user, and match URLs" diff --git a/src/Symfony/Component/Serializer/composer.json b/src/Symfony/Component/Serializer/composer.json index 695fac4db2021..626bf238d8b13 100644 --- a/src/Symfony/Component/Serializer/composer.json +++ b/src/Symfony/Component/Serializer/composer.json @@ -33,7 +33,11 @@ "phpdocumentor/reflection-docblock": "^3.0|^4.0" }, "conflict": { - "phpdocumentor/type-resolver": "<0.2.1" + "phpdocumentor/type-resolver": "<0.2.1", + "symfony/dependency-injection": "<4.4", + "symfony/property-access": "<4.4", + "symfony/property-info": "<4.4", + "symfony/yaml": "<4.4" }, "suggest": { "psr/cache-implementation": "For using the metadata cache.", diff --git a/src/Symfony/Component/Translation/composer.json b/src/Symfony/Component/Translation/composer.json index 2e51206837480..c654a1f0602d2 100644 --- a/src/Symfony/Component/Translation/composer.json +++ b/src/Symfony/Component/Translation/composer.json @@ -32,6 +32,11 @@ "symfony/finder": "^4.4|^5.0", "psr/log": "~1.0" }, + "conflict": { + "symfony/config": "<4.4", + "symfony/dependency-injection": "<4.4", + "symfony/yaml": "<4.4" + }, "provide": { "symfony/translation-implementation": "1.0" }, diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index 1f0c10fbe4637..fc76453d509d9 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -41,7 +41,11 @@ }, "conflict": { "phpunit/phpunit": "<5.4.3", - "symfony/intl": "<4.4" + "symfony/dependency-injection": "<4.4", + "symfony/http-kernel": "<4.4", + "symfony/intl": "<4.4", + "symfony/translation": "<4.4", + "symfony/yaml": "<4.4" }, "suggest": { "psr/cache-implementation": "For using the metadata cache.", diff --git a/src/Symfony/Component/VarDumper/composer.json b/src/Symfony/Component/VarDumper/composer.json index 5d4a23e356dcc..11c16b8129039 100644 --- a/src/Symfony/Component/VarDumper/composer.json +++ b/src/Symfony/Component/VarDumper/composer.json @@ -26,7 +26,8 @@ "twig/twig": "~1.34|~2.4" }, "conflict": { - "phpunit/phpunit": "<5.4.3" + "phpunit/phpunit": "<5.4.3", + "symfony/console": "<4.4" }, "suggest": { "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).", diff --git a/src/Symfony/Component/Yaml/composer.json b/src/Symfony/Component/Yaml/composer.json index 196696ceecd0c..6a32ba97a215e 100644 --- a/src/Symfony/Component/Yaml/composer.json +++ b/src/Symfony/Component/Yaml/composer.json @@ -22,6 +22,9 @@ "require-dev": { "symfony/console": "^4.4|^5.0" }, + "conflict": { + "symfony/console": "<4.4" + }, "suggest": { "symfony/console": "For validating YAML files using the lint command" }, From 67105d24e61c138b331793d35aa361868539f2e2 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Wed, 29 May 2019 08:14:42 +0200 Subject: [PATCH 014/588] [Intl] Cleanup legacy API --- .../Data/Provider/CurrencyDataProvider.php | 141 --- .../Data/Provider/LanguageDataProvider.php | 93 -- .../Intl/Data/Provider/LocaleDataProvider.php | 82 -- .../Intl/Data/Provider/RegionDataProvider.php | 77 -- .../Intl/Data/Provider/ScriptDataProvider.php | 77 -- src/Symfony/Component/Intl/Intl.php | 153 --- .../Intl/ResourceBundle/CurrencyBundle.php | 108 -- .../CurrencyBundleInterface.php | 76 -- .../Intl/ResourceBundle/LanguageBundle.php | 108 -- .../LanguageBundleInterface.php | 66 -- .../Intl/ResourceBundle/LocaleBundle.php | 61 -- .../ResourceBundle/LocaleBundleInterface.php | 43 - .../Intl/ResourceBundle/RegionBundle.php | 72 -- .../ResourceBundle/RegionBundleInterface.php | 43 - .../ResourceBundleInterface.php | 29 - .../AbstractCurrencyDataProviderTest.php | 814 --------------- .../Provider/AbstractDataProviderTest.php | 774 -------------- .../AbstractLanguageDataProviderTest.php | 943 ------------------ .../AbstractLocaleDataProviderTest.php | 112 --- .../AbstractRegionDataProviderTest.php | 347 ------- .../AbstractScriptDataProviderTest.php | 301 ------ .../Json/JsonCurrencyDataProviderTest.php | 38 - .../Json/JsonLanguageDataProviderTest.php | 38 - .../Json/JsonLocaleDataProviderTest.php | 38 - .../Json/JsonRegionDataProviderTest.php | 38 - .../Json/JsonScriptDataProviderTest.php | 38 - src/Symfony/Component/Intl/Tests/IntlTest.php | 51 - 27 files changed, 4761 deletions(-) delete mode 100644 src/Symfony/Component/Intl/Data/Provider/CurrencyDataProvider.php delete mode 100644 src/Symfony/Component/Intl/Data/Provider/LanguageDataProvider.php delete mode 100644 src/Symfony/Component/Intl/Data/Provider/LocaleDataProvider.php delete mode 100644 src/Symfony/Component/Intl/Data/Provider/RegionDataProvider.php delete mode 100644 src/Symfony/Component/Intl/Data/Provider/ScriptDataProvider.php delete mode 100644 src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php delete mode 100644 src/Symfony/Component/Intl/ResourceBundle/CurrencyBundleInterface.php delete mode 100644 src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php delete mode 100644 src/Symfony/Component/Intl/ResourceBundle/LanguageBundleInterface.php delete mode 100644 src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php delete mode 100644 src/Symfony/Component/Intl/ResourceBundle/LocaleBundleInterface.php delete mode 100644 src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php delete mode 100644 src/Symfony/Component/Intl/ResourceBundle/RegionBundleInterface.php delete mode 100644 src/Symfony/Component/Intl/ResourceBundle/ResourceBundleInterface.php delete mode 100644 src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php delete mode 100644 src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php delete mode 100644 src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php delete mode 100644 src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLocaleDataProviderTest.php delete mode 100644 src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php delete mode 100644 src/Symfony/Component/Intl/Tests/Data/Provider/AbstractScriptDataProviderTest.php delete mode 100644 src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonCurrencyDataProviderTest.php delete mode 100644 src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLanguageDataProviderTest.php delete mode 100644 src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLocaleDataProviderTest.php delete mode 100644 src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonRegionDataProviderTest.php delete mode 100644 src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonScriptDataProviderTest.php diff --git a/src/Symfony/Component/Intl/Data/Provider/CurrencyDataProvider.php b/src/Symfony/Component/Intl/Data/Provider/CurrencyDataProvider.php deleted file mode 100644 index d09028938b15a..0000000000000 --- a/src/Symfony/Component/Intl/Data/Provider/CurrencyDataProvider.php +++ /dev/null @@ -1,141 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Provider; - -use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; -use Symfony\Component\Intl\Exception\MissingResourceException; - -/** - * Data provider for currency-related data. - * - * @author Bernhard Schussek - * - * @internal to be removed in 5.0. - */ -class CurrencyDataProvider -{ - const INDEX_SYMBOL = 0; - const INDEX_NAME = 1; - const INDEX_FRACTION_DIGITS = 0; - const INDEX_ROUNDING_INCREMENT = 1; - - private $path; - private $reader; - - /** - * Creates a data provider that reads currency-related data from a - * resource bundle. - * - * @param string $path The path to the resource bundle - * @param BundleEntryReaderInterface $reader The reader for reading the resource bundle - */ - public function __construct(string $path, BundleEntryReaderInterface $reader) - { - $this->path = $path; - $this->reader = $reader; - } - - public function getCurrencies() - { - return $this->reader->readEntry($this->path, 'meta', ['Currencies']); - } - - public function getSymbol($currency, $displayLocale = null) - { - if (null === $displayLocale) { - $displayLocale = \Locale::getDefault(); - } - - return $this->reader->readEntry($this->path, $displayLocale, ['Names', $currency, static::INDEX_SYMBOL]); - } - - public function getName($currency, $displayLocale = null) - { - if (null === $displayLocale) { - $displayLocale = \Locale::getDefault(); - } - - return $this->reader->readEntry($this->path, $displayLocale, ['Names', $currency, static::INDEX_NAME]); - } - - public function getNames($displayLocale = null) - { - if (null === $displayLocale) { - $displayLocale = \Locale::getDefault(); - } - - // ==================================================================== - // For reference: It is NOT possible to return names indexed by - // numeric code here, because some numeric codes map to multiple - // 3-letter codes (e.g. 32 => "ARA", "ARP", "ARS") - // ==================================================================== - - $names = $this->reader->readEntry($this->path, $displayLocale, ['Names']); - - if ($names instanceof \Traversable) { - $names = iterator_to_array($names); - } - - $index = static::INDEX_NAME; - - array_walk($names, function (&$value) use ($index) { - $value = $value[$index]; - }); - - // Sorting by value cannot be done during bundle generation, because - // binary bundles are always sorted by keys - $collator = new \Collator($displayLocale); - $collator->asort($names); - - return $names; - } - - /** - * Data provider for {@link \Symfony\Component\Intl\Currency::getFractionDigits()}. - */ - public function getFractionDigits($currency) - { - try { - return $this->reader->readEntry($this->path, 'meta', ['Meta', $currency, static::INDEX_FRACTION_DIGITS]); - } catch (MissingResourceException $e) { - return $this->reader->readEntry($this->path, 'meta', ['Meta', 'DEFAULT', static::INDEX_FRACTION_DIGITS]); - } - } - - /** - * Data provider for {@link \Symfony\Component\Intl\Currency::getRoundingIncrement()}. - */ - public function getRoundingIncrement($currency) - { - try { - return $this->reader->readEntry($this->path, 'meta', ['Meta', $currency, static::INDEX_ROUNDING_INCREMENT]); - } catch (MissingResourceException $e) { - return $this->reader->readEntry($this->path, 'meta', ['Meta', 'DEFAULT', static::INDEX_ROUNDING_INCREMENT]); - } - } - - /** - * Data provider for {@link \Symfony\Component\Intl\Currency::getNumericCode()}. - */ - public function getNumericCode($currency) - { - return $this->reader->readEntry($this->path, 'meta', ['Alpha3ToNumeric', $currency]); - } - - /** - * Data provider for {@link \Symfony\Component\Intl\Currency::forNumericCode()}. - */ - public function forNumericCode($numericCode) - { - return $this->reader->readEntry($this->path, 'meta', ['NumericToAlpha3', (string) $numericCode]); - } -} diff --git a/src/Symfony/Component/Intl/Data/Provider/LanguageDataProvider.php b/src/Symfony/Component/Intl/Data/Provider/LanguageDataProvider.php deleted file mode 100644 index fed764d6726e1..0000000000000 --- a/src/Symfony/Component/Intl/Data/Provider/LanguageDataProvider.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\Intl\Data\Provider; - -use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; - -/** - * Data provider for language-related ICU data. - * - * @author Bernhard Schussek - * - * @internal - */ -class LanguageDataProvider -{ - private $path; - private $reader; - - /** - * Creates a data provider that reads locale-related data from .res files. - * - * @param string $path The path to the directory containing the .res files - * @param BundleEntryReaderInterface $reader The reader for reading the .res files - */ - public function __construct(string $path, BundleEntryReaderInterface $reader) - { - $this->path = $path; - $this->reader = $reader; - } - - /** - * @internal to be removed in 5.0. - */ - public function getLanguages() - { - return $this->reader->readEntry($this->path, 'meta', ['Languages']); - } - - /** - * @internal to be removed in 5.0. - */ - public function getAliases() - { - return $this->reader->readEntry($this->path, 'root', ['Aliases']); - } - - public function getName($language, $displayLocale = null) - { - if (null === $displayLocale) { - $displayLocale = \Locale::getDefault(); - } - - return $this->reader->readEntry($this->path, $displayLocale, ['Names', $language]); - } - - /** - * @internal to be removed in 5.0. - */ - public function getNames($displayLocale = null) - { - if (null === $displayLocale) { - $displayLocale = \Locale::getDefault(); - } - - $languages = $this->reader->readEntry($this->path, $displayLocale, ['Names']); - - if ($languages instanceof \Traversable) { - $languages = iterator_to_array($languages); - } - - $collator = new \Collator($displayLocale); - $collator->asort($languages); - - return $languages; - } - - /** - * @internal to be removed in 5.0. - */ - public function getAlpha3Code($language) - { - return $this->reader->readEntry($this->path, 'meta', ['Alpha2ToAlpha3', $language]); - } -} diff --git a/src/Symfony/Component/Intl/Data/Provider/LocaleDataProvider.php b/src/Symfony/Component/Intl/Data/Provider/LocaleDataProvider.php deleted file mode 100644 index fdabb689fb632..0000000000000 --- a/src/Symfony/Component/Intl/Data/Provider/LocaleDataProvider.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Provider; - -use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; - -/** - * Data provider for locale-related ICU data. - * - * @author Bernhard Schussek - * - * @internal to be removed in 5.0. - */ -class LocaleDataProvider -{ - private $path; - private $reader; - - /** - * Creates a data provider that reads locale-related data from .res files. - * - * @param string $path The path to the directory containing the .res files - * @param BundleEntryReaderInterface $reader The reader for reading the .res files - */ - public function __construct(string $path, BundleEntryReaderInterface $reader) - { - $this->path = $path; - $this->reader = $reader; - } - - public function getLocales() - { - return $this->reader->readEntry($this->path, 'meta', ['Locales']); - } - - public function getAliases() - { - $aliases = $this->reader->readEntry($this->path, 'meta', ['Aliases']); - - if ($aliases instanceof \Traversable) { - $aliases = iterator_to_array($aliases); - } - - return $aliases; - } - - public function getName($locale, $displayLocale = null) - { - if (null === $displayLocale) { - $displayLocale = \Locale::getDefault(); - } - - return $this->reader->readEntry($this->path, $displayLocale, ['Names', $locale]); - } - - public function getNames($displayLocale = null) - { - if (null === $displayLocale) { - $displayLocale = \Locale::getDefault(); - } - - $names = $this->reader->readEntry($this->path, $displayLocale, ['Names']); - - if ($names instanceof \Traversable) { - $names = iterator_to_array($names); - } - - $collator = new \Collator($displayLocale); - $collator->asort($names); - - return $names; - } -} diff --git a/src/Symfony/Component/Intl/Data/Provider/RegionDataProvider.php b/src/Symfony/Component/Intl/Data/Provider/RegionDataProvider.php deleted file mode 100644 index ec16994f63a6f..0000000000000 --- a/src/Symfony/Component/Intl/Data/Provider/RegionDataProvider.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Provider; - -use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; - -/** - * Data provider for region-related ICU data. - * - * @author Bernhard Schussek - * - * @internal - */ -class RegionDataProvider -{ - private $path; - private $reader; - - /** - * Creates a data provider that reads locale-related data from .res files. - * - * @param string $path The path to the directory containing the .res files - * @param BundleEntryReaderInterface $reader The reader for reading the .res files - */ - public function __construct(string $path, BundleEntryReaderInterface $reader) - { - $this->path = $path; - $this->reader = $reader; - } - - /** - * @internal to be removed in 5.0. - */ - public function getRegions() - { - return $this->reader->readEntry($this->path, 'meta', ['Regions']); - } - - public function getName($region, $displayLocale = null) - { - if (null === $displayLocale) { - $displayLocale = \Locale::getDefault(); - } - - return $this->reader->readEntry($this->path, $displayLocale, ['Names', $region]); - } - - /** - * @internal to be removed in 5.0. - */ - public function getNames($displayLocale = null) - { - if (null === $displayLocale) { - $displayLocale = \Locale::getDefault(); - } - - $names = $this->reader->readEntry($this->path, $displayLocale, ['Names']); - - if ($names instanceof \Traversable) { - $names = iterator_to_array($names); - } - - $collator = new \Collator($displayLocale); - $collator->asort($names); - - return $names; - } -} diff --git a/src/Symfony/Component/Intl/Data/Provider/ScriptDataProvider.php b/src/Symfony/Component/Intl/Data/Provider/ScriptDataProvider.php deleted file mode 100644 index 3189da13e5aaa..0000000000000 --- a/src/Symfony/Component/Intl/Data/Provider/ScriptDataProvider.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Provider; - -use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; - -/** - * Data provider for script-related ICU data. - * - * @author Bernhard Schussek - * - * @internal - */ -class ScriptDataProvider -{ - private $path; - private $reader; - - /** - * Creates a data provider that reads locale-related data from .res files. - * - * @param string $path The path to the directory containing the .res files - * @param BundleEntryReaderInterface $reader The reader for reading the .res files - */ - public function __construct(string $path, BundleEntryReaderInterface $reader) - { - $this->path = $path; - $this->reader = $reader; - } - - /** - * @internal to be removed in 5.0. - */ - public function getScripts() - { - return $this->reader->readEntry($this->path, 'meta', ['Scripts']); - } - - public function getName($script, $displayLocale = null) - { - if (null === $displayLocale) { - $displayLocale = \Locale::getDefault(); - } - - return $this->reader->readEntry($this->path, $displayLocale, ['Names', $script]); - } - - /** - * @internal to be removed in 5.0. - */ - public function getNames($displayLocale = null) - { - if (null === $displayLocale) { - $displayLocale = \Locale::getDefault(); - } - - $names = $this->reader->readEntry($this->path, $displayLocale, ['Names']); - - if ($names instanceof \Traversable) { - $names = iterator_to_array($names); - } - - $collator = new \Collator($displayLocale); - $collator->asort($names); - - return $names; - } -} diff --git a/src/Symfony/Component/Intl/Intl.php b/src/Symfony/Component/Intl/Intl.php index 171fa671a29cd..e4c73273b37d7 100644 --- a/src/Symfony/Component/Intl/Intl.php +++ b/src/Symfony/Component/Intl/Intl.php @@ -11,21 +11,6 @@ namespace Symfony\Component\Intl; -use Symfony\Component\Intl\Data\Bundle\Reader\BufferedBundleReader; -use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReader; -use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; -use Symfony\Component\Intl\Data\Bundle\Reader\JsonBundleReader; -use Symfony\Component\Intl\Data\Provider\LocaleDataProvider; -use Symfony\Component\Intl\Data\Provider\ScriptDataProvider; -use Symfony\Component\Intl\ResourceBundle\CurrencyBundle; -use Symfony\Component\Intl\ResourceBundle\CurrencyBundleInterface; -use Symfony\Component\Intl\ResourceBundle\LanguageBundle; -use Symfony\Component\Intl\ResourceBundle\LanguageBundleInterface; -use Symfony\Component\Intl\ResourceBundle\LocaleBundle; -use Symfony\Component\Intl\ResourceBundle\LocaleBundleInterface; -use Symfony\Component\Intl\ResourceBundle\RegionBundle; -use Symfony\Component\Intl\ResourceBundle\RegionBundleInterface; - /** * Gives access to internationalization data. * @@ -69,26 +54,6 @@ final class Intl */ public const TIMEZONE_DIR = 'timezones'; - /** - * @var ResourceBundle\CurrencyBundleInterface - */ - private static $currencyBundle; - - /** - * @var ResourceBundle\LanguageBundleInterface - */ - private static $languageBundle; - - /** - * @var ResourceBundle\LocaleBundleInterface - */ - private static $localeBundle; - - /** - * @var ResourceBundle\RegionBundleInterface - */ - private static $regionBundle; - /** * @var string|bool|null */ @@ -99,11 +64,6 @@ final class Intl */ private static $icuDataVersion = false; - /** - * @var BundleEntryReaderInterface - */ - private static $entryReader; - /** * Returns whether the intl extension is installed. * @@ -114,97 +74,6 @@ public static function isExtensionLoaded() return class_exists('\ResourceBundle'); } - /** - * Returns the bundle containing currency information. - * - * @return CurrencyBundleInterface The currency resource bundle - * - * @deprecated since Symfony 4.3, to be removed in 5.0. Use {@see Currencies} instead. - */ - public static function getCurrencyBundle() - { - @trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.3, use "%s" instead.', __METHOD__, Currencies::class), E_USER_DEPRECATED); - - if (null === self::$currencyBundle) { - self::$currencyBundle = new CurrencyBundle( - self::getDataDirectory().'/'.self::CURRENCY_DIR, - self::getEntryReader(), - self::$localeBundle ?? self::$localeBundle = new LocaleBundle(self::getDataDirectory().'/'.self::LOCALE_DIR, self::getEntryReader()) - ); - } - - return self::$currencyBundle; - } - - /** - * Returns the bundle containing language information. - * - * @return LanguageBundleInterface The language resource bundle - * - * @deprecated since Symfony 4.3, to be removed in 5.0. Use {@see Languages} or {@see Scripts} instead. - */ - public static function getLanguageBundle() - { - @trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.3, use "%s" or "%s" instead.', __METHOD__, Languages::class, Scripts::class), E_USER_DEPRECATED); - - if (null === self::$languageBundle) { - self::$languageBundle = new LanguageBundle( - self::getDataDirectory().'/'.self::LANGUAGE_DIR, - self::getEntryReader(), - self::$localeBundle ?? self::$localeBundle = new LocaleBundle(self::getDataDirectory().'/'.self::LOCALE_DIR, self::getEntryReader()), - new ScriptDataProvider( - self::getDataDirectory().'/'.self::SCRIPT_DIR, - self::getEntryReader() - ) - ); - } - - return self::$languageBundle; - } - - /** - * Returns the bundle containing locale information. - * - * @return LocaleBundleInterface The locale resource bundle - * - * @deprecated since Symfony 4.3, to be removed in 5.0. Use {@see Locales} instead. - */ - public static function getLocaleBundle() - { - @trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.3, use "%s" instead.', __METHOD__, Locales::class), E_USER_DEPRECATED); - - if (null === self::$localeBundle) { - self::$localeBundle = new LocaleBundle( - self::getDataDirectory().'/'.self::LOCALE_DIR, - self::getEntryReader() - ); - } - - return self::$localeBundle; - } - - /** - * Returns the bundle containing region information. - * - * @return RegionBundleInterface The region resource bundle - * - * @deprecated since Symfony 4.3, to be removed in 5.0. Use {@see Countries} instead. - */ - public static function getRegionBundle() - { - @trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.3, use "%s" instead.', __METHOD__, Countries::class), E_USER_DEPRECATED); - - if (null === self::$regionBundle) { - self::$regionBundle = new RegionBundle( - self::getDataDirectory().'/'.self::REGION_DIR, - self::getEntryReader(), - self::$localeBundle ?? self::$localeBundle = new LocaleBundle(self::getDataDirectory().'/'.self::LOCALE_DIR, self::getEntryReader()) - ); - } - - return self::$regionBundle; - } - /** * Returns the version of the installed ICU library. * @@ -269,28 +138,6 @@ public static function getDataDirectory() return __DIR__.'/Resources/data'; } - /** - * Returns the cached bundle entry reader. - * - * @return BundleEntryReaderInterface The bundle entry reader - */ - private static function getEntryReader() - { - if (null === self::$entryReader) { - self::$entryReader = new BundleEntryReader(new BufferedBundleReader( - new JsonBundleReader(), - self::BUFFER_SIZE - )); - $localeDataProvider = new LocaleDataProvider( - self::getDataDirectory().'/'.self::LOCALE_DIR, - self::$entryReader - ); - self::$entryReader->setLocaleAliases($localeDataProvider->getAliases()); - } - - return self::$entryReader; - } - /** * This class must not be instantiated. */ diff --git a/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php b/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php deleted file mode 100644 index b7ea33ea58574..0000000000000 --- a/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundle.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\ResourceBundle; - -use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; -use Symfony\Component\Intl\Data\Provider\CurrencyDataProvider; -use Symfony\Component\Intl\Data\Provider\LocaleDataProvider; -use Symfony\Component\Intl\Exception\MissingResourceException; - -/** - * Default implementation of {@link CurrencyBundleInterface}. - * - * @author Bernhard Schussek - * - * @internal to be removed in 5.0. - */ -class CurrencyBundle extends CurrencyDataProvider implements CurrencyBundleInterface -{ - private $localeProvider; - - public function __construct(string $path, BundleEntryReaderInterface $reader, LocaleDataProvider $localeProvider) - { - parent::__construct($path, $reader); - - $this->localeProvider = $localeProvider; - } - - /** - * {@inheritdoc} - */ - public function getCurrencySymbol($currency, $displayLocale = null) - { - try { - return $this->getSymbol($currency, $displayLocale); - } catch (MissingResourceException $e) { - return; - } - } - - /** - * {@inheritdoc} - */ - public function getCurrencyName($currency, $displayLocale = null) - { - try { - return $this->getName($currency, $displayLocale); - } catch (MissingResourceException $e) { - return; - } - } - - /** - * {@inheritdoc} - */ - public function getCurrencyNames($displayLocale = null) - { - try { - return $this->getNames($displayLocale); - } catch (MissingResourceException $e) { - return []; - } - } - - /** - * {@inheritdoc} - */ - public function getFractionDigits($currency) - { - try { - return parent::getFractionDigits($currency); - } catch (MissingResourceException $e) { - return; - } - } - - /** - * {@inheritdoc} - */ - public function getRoundingIncrement($currency) - { - try { - return parent::getRoundingIncrement($currency); - } catch (MissingResourceException $e) { - return; - } - } - - /** - * {@inheritdoc} - */ - public function getLocales() - { - try { - return $this->localeProvider->getLocales(); - } catch (MissingResourceException $e) { - return []; - } - } -} diff --git a/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundleInterface.php b/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundleInterface.php deleted file mode 100644 index 421973b9fed31..0000000000000 --- a/src/Symfony/Component/Intl/ResourceBundle/CurrencyBundleInterface.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\ResourceBundle; - -/** - * Gives access to currency-related ICU data. - * - * @author Bernhard Schussek - * - * @deprecated since Symfony 4.3, to be removed in 5.0. - */ -interface CurrencyBundleInterface extends ResourceBundleInterface -{ - /** - * Returns the symbol used for a currency. - * - * @param string $currency A currency code (e.g. "EUR") - * @param string $displayLocale Optional. The locale to return the result in - * Defaults to {@link \Locale::getDefault()}. - * - * @return string|null The currency symbol or NULL if not found - */ - public function getCurrencySymbol($currency, $displayLocale = null); - - /** - * Returns the name of a currency. - * - * @param string $currency A currency code (e.g. "EUR") - * @param string $displayLocale Optional. The locale to return the name in - * Defaults to {@link \Locale::getDefault()}. - * - * @return string|null The name of the currency or NULL if not found - */ - public function getCurrencyName($currency, $displayLocale = null); - - /** - * Returns the names of all known currencies. - * - * @param string $displayLocale Optional. The locale to return the names in - * Defaults to {@link \Locale::getDefault()}. - * - * @return string[] A list of currency names indexed by currency codes - */ - public function getCurrencyNames($displayLocale = null); - - /** - * Returns the number of digits after the comma of a currency. - * - * @param string $currency A currency code (e.g. "EUR") - * - * @return int|null The number of digits after the comma or NULL if not found - */ - public function getFractionDigits($currency); - - /** - * Returns the rounding increment of a currency. - * - * The rounding increment indicates to which number a currency is rounded. - * For example, 1230 rounded to the nearest 50 is 1250. 1.234 rounded to the - * nearest 0.65 is 1.3. - * - * @param string $currency A currency code (e.g. "EUR") - * - * @return float|int|null The rounding increment or NULL if not found - */ - public function getRoundingIncrement($currency); -} diff --git a/src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php b/src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php deleted file mode 100644 index eabd94821db2c..0000000000000 --- a/src/Symfony/Component/Intl/ResourceBundle/LanguageBundle.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\ResourceBundle; - -use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; -use Symfony\Component\Intl\Data\Provider\LanguageDataProvider; -use Symfony\Component\Intl\Data\Provider\LocaleDataProvider; -use Symfony\Component\Intl\Data\Provider\ScriptDataProvider; -use Symfony\Component\Intl\Exception\MissingResourceException; - -/** - * Default implementation of {@link LanguageBundleInterface}. - * - * @author Bernhard Schussek - * - * @internal to be removed in 5.0. - */ -class LanguageBundle extends LanguageDataProvider implements LanguageBundleInterface -{ - private $localeProvider; - private $scriptProvider; - - public function __construct(string $path, BundleEntryReaderInterface $reader, LocaleDataProvider $localeProvider, ScriptDataProvider $scriptProvider) - { - parent::__construct($path, $reader); - - $this->localeProvider = $localeProvider; - $this->scriptProvider = $scriptProvider; - } - - /** - * {@inheritdoc} - */ - public function getLanguageName($language, $region = null, $displayLocale = null) - { - // Some languages are translated together with their region, - // i.e. "en_GB" is translated as "British English" - if (null !== $region) { - try { - return $this->getName($language.'_'.$region, $displayLocale); - } catch (MissingResourceException $e) { - } - } - - try { - return $this->getName($language, $displayLocale); - } catch (MissingResourceException $e) { - return; - } - } - - /** - * {@inheritdoc} - */ - public function getLanguageNames($displayLocale = null) - { - try { - return $this->getNames($displayLocale); - } catch (MissingResourceException $e) { - return []; - } - } - - /** - * {@inheritdoc} - */ - public function getScriptName($script, $language = null, $displayLocale = null) - { - try { - return $this->scriptProvider->getName($script, $displayLocale); - } catch (MissingResourceException $e) { - return; - } - } - - /** - * {@inheritdoc} - */ - public function getScriptNames($displayLocale = null) - { - try { - return $this->scriptProvider->getNames($displayLocale); - } catch (MissingResourceException $e) { - return []; - } - } - - /** - * {@inheritdoc} - */ - public function getLocales() - { - try { - return $this->localeProvider->getLocales(); - } catch (MissingResourceException $e) { - return []; - } - } -} diff --git a/src/Symfony/Component/Intl/ResourceBundle/LanguageBundleInterface.php b/src/Symfony/Component/Intl/ResourceBundle/LanguageBundleInterface.php deleted file mode 100644 index ab2c1805d145b..0000000000000 --- a/src/Symfony/Component/Intl/ResourceBundle/LanguageBundleInterface.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\ResourceBundle; - -/** - * Gives access to language-related ICU data. - * - * @author Bernhard Schussek - * - * @deprecated since Symfony 4.3, to be removed in 5.0. - */ -interface LanguageBundleInterface extends ResourceBundleInterface -{ - /** - * Returns the name of a language. - * - * @param string $language A language code (e.g. "en") - * @param string|null $region Optional. A region code (e.g. "US") - * @param string $displayLocale Optional. The locale to return the name in - * Defaults to {@link \Locale::getDefault()}. - * - * @return string|null The name of the language or NULL if not found - */ - public function getLanguageName($language, $region = null, $displayLocale = null); - - /** - * Returns the names of all known languages. - * - * @param string $displayLocale Optional. The locale to return the names in - * Defaults to {@link \Locale::getDefault()}. - * - * @return string[] A list of language names indexed by language codes - */ - public function getLanguageNames($displayLocale = null); - - /** - * Returns the name of a script. - * - * @param string $script A script code (e.g. "Hans") - * @param string $language Optional. A language code (e.g. "zh") - * @param string $displayLocale Optional. The locale to return the name in - * Defaults to {@link \Locale::getDefault()}. - * - * @return string|null The name of the script or NULL if not found - */ - public function getScriptName($script, $language = null, $displayLocale = null); - - /** - * Returns the names of all known scripts. - * - * @param string $displayLocale Optional. The locale to return the names in - * Defaults to {@link \Locale::getDefault()}. - * - * @return string[] A list of script names indexed by script codes - */ - public function getScriptNames($displayLocale = null); -} diff --git a/src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php b/src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php deleted file mode 100644 index 19acc41782cf2..0000000000000 --- a/src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php +++ /dev/null @@ -1,61 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\ResourceBundle; - -use Symfony\Component\Intl\Data\Provider\LocaleDataProvider; -use Symfony\Component\Intl\Exception\MissingResourceException; - -/** - * Default implementation of {@link LocaleBundleInterface}. - * - * @author Bernhard Schussek - * - * @internal to be removed in 5.0. - */ -class LocaleBundle extends LocaleDataProvider implements LocaleBundleInterface -{ - /** - * {@inheritdoc} - */ - public function getLocales() - { - try { - return parent::getLocales(); - } catch (MissingResourceException $e) { - return []; - } - } - - /** - * {@inheritdoc} - */ - public function getLocaleName($locale, $displayLocale = null) - { - try { - return $this->getName($locale, $displayLocale); - } catch (MissingResourceException $e) { - return; - } - } - - /** - * {@inheritdoc} - */ - public function getLocaleNames($displayLocale = null) - { - try { - return $this->getNames($displayLocale); - } catch (MissingResourceException $e) { - return []; - } - } -} diff --git a/src/Symfony/Component/Intl/ResourceBundle/LocaleBundleInterface.php b/src/Symfony/Component/Intl/ResourceBundle/LocaleBundleInterface.php deleted file mode 100644 index f7791adcbfec7..0000000000000 --- a/src/Symfony/Component/Intl/ResourceBundle/LocaleBundleInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\ResourceBundle; - -/** - * Gives access to locale-related ICU data. - * - * @author Bernhard Schussek - * - * @deprecated since Symfony 4.3, to be removed in 5.0. - */ -interface LocaleBundleInterface extends ResourceBundleInterface -{ - /** - * Returns the name of a locale. - * - * @param string $locale The locale to return the name of (e.g. "de_AT") - * @param string $displayLocale Optional. The locale to return the name in - * Defaults to {@link \Locale::getDefault()}. - * - * @return string|null The name of the locale or NULL if not found - */ - public function getLocaleName($locale, $displayLocale = null); - - /** - * Returns the names of all known locales. - * - * @param string $displayLocale Optional. The locale to return the names in - * Defaults to {@link \Locale::getDefault()}. - * - * @return string[] A list of locale names indexed by locale codes - */ - public function getLocaleNames($displayLocale = null); -} diff --git a/src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php b/src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php deleted file mode 100644 index 4cb34c2a09dda..0000000000000 --- a/src/Symfony/Component/Intl/ResourceBundle/RegionBundle.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\ResourceBundle; - -use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReaderInterface; -use Symfony\Component\Intl\Data\Provider\LocaleDataProvider; -use Symfony\Component\Intl\Data\Provider\RegionDataProvider; -use Symfony\Component\Intl\Exception\MissingResourceException; - -/** - * Default implementation of {@link RegionBundleInterface}. - * - * @author Bernhard Schussek - * - * @internal to be removed in 5.0. - */ -class RegionBundle extends RegionDataProvider implements RegionBundleInterface -{ - private $localeProvider; - - public function __construct(string $path, BundleEntryReaderInterface $reader, LocaleDataProvider $localeProvider) - { - parent::__construct($path, $reader); - - $this->localeProvider = $localeProvider; - } - - /** - * {@inheritdoc} - */ - public function getCountryName($country, $displayLocale = null) - { - try { - return $this->getName($country, $displayLocale); - } catch (MissingResourceException $e) { - return; - } - } - - /** - * {@inheritdoc} - */ - public function getCountryNames($displayLocale = null) - { - try { - return $this->getNames($displayLocale); - } catch (MissingResourceException $e) { - return []; - } - } - - /** - * {@inheritdoc} - */ - public function getLocales() - { - try { - return $this->localeProvider->getLocales(); - } catch (MissingResourceException $e) { - return []; - } - } -} diff --git a/src/Symfony/Component/Intl/ResourceBundle/RegionBundleInterface.php b/src/Symfony/Component/Intl/ResourceBundle/RegionBundleInterface.php deleted file mode 100644 index a417dbb3812da..0000000000000 --- a/src/Symfony/Component/Intl/ResourceBundle/RegionBundleInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\ResourceBundle; - -/** - * Gives access to region-related ICU data. - * - * @author Bernhard Schussek - * - * @deprecated since Symfony 4.3, to be removed in 5.0. - */ -interface RegionBundleInterface extends ResourceBundleInterface -{ - /** - * Returns the name of a country. - * - * @param string $country A country code (e.g. "US") - * @param string $displayLocale Optional. The locale to return the name in - * Defaults to {@link \Locale::getDefault()}. - * - * @return string|null The name of the country or NULL if not found - */ - public function getCountryName($country, $displayLocale = null); - - /** - * Returns the names of all known countries. - * - * @param string $displayLocale Optional. The locale to return the names in - * Defaults to {@link \Locale::getDefault()}. - * - * @return string[] A list of country names indexed by country codes - */ - public function getCountryNames($displayLocale = null); -} diff --git a/src/Symfony/Component/Intl/ResourceBundle/ResourceBundleInterface.php b/src/Symfony/Component/Intl/ResourceBundle/ResourceBundleInterface.php deleted file mode 100644 index 37ef2648bddc9..0000000000000 --- a/src/Symfony/Component/Intl/ResourceBundle/ResourceBundleInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\ResourceBundle; - -/** - * Gives access to ICU data. - * - * @author Bernhard Schussek - * - * @deprecated since Symfony 4.3, to be removed in 5.0. - */ -interface ResourceBundleInterface -{ - /** - * Returns the list of locales that this bundle supports. - * - * @return string[] A list of locale codes - */ - public function getLocales(); -} diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php deleted file mode 100644 index 6133af4990237..0000000000000 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractCurrencyDataProviderTest.php +++ /dev/null @@ -1,814 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Tests\Data\Provider; - -use Symfony\Component\Intl\Data\Provider\CurrencyDataProvider; -use Symfony\Component\Intl\Intl; - -/** - * @author Bernhard Schussek - * - * @group legacy - */ -abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest -{ - // The below arrays document the state of the ICU data bundled with this package. - - protected static $currencies = [ - 'ADP', - 'AED', - 'AFA', - 'AFN', - 'ALK', - 'ALL', - 'AMD', - 'ANG', - 'AOA', - 'AOK', - 'AON', - 'AOR', - 'ARA', - 'ARL', - 'ARM', - 'ARP', - 'ARS', - 'ATS', - 'AUD', - 'AWG', - 'AZM', - 'AZN', - 'BAD', - 'BAM', - 'BAN', - 'BBD', - 'BDT', - 'BEC', - 'BEF', - 'BEL', - 'BGL', - 'BGM', - 'BGN', - 'BGO', - 'BHD', - 'BIF', - 'BMD', - 'BND', - 'BOB', - 'BOL', - 'BOP', - 'BOV', - 'BRB', - 'BRC', - 'BRE', - 'BRL', - 'BRN', - 'BRR', - 'BRZ', - 'BSD', - 'BTN', - 'BUK', - 'BWP', - 'BYB', - 'BYN', - 'BYR', - 'BZD', - 'CAD', - 'CDF', - 'CHE', - 'CHF', - 'CHW', - 'CLE', - 'CLF', - 'CLP', - 'CNH', - 'CNX', - 'CNY', - 'COP', - 'COU', - 'CRC', - 'CSD', - 'CSK', - 'CUC', - 'CUP', - 'CVE', - 'CYP', - 'CZK', - 'DDM', - 'DEM', - 'DJF', - 'DKK', - 'DOP', - 'DZD', - 'ECS', - 'ECV', - 'EEK', - 'EGP', - 'ERN', - 'ESA', - 'ESB', - 'ESP', - 'ETB', - 'EUR', - 'FIM', - 'FJD', - 'FKP', - 'FRF', - 'GBP', - 'GEK', - 'GEL', - 'GHC', - 'GHS', - 'GIP', - 'GMD', - 'GNF', - 'GNS', - 'GQE', - 'GRD', - 'GTQ', - 'GWE', - 'GWP', - 'GYD', - 'HKD', - 'HNL', - 'HRD', - 'HRK', - 'HTG', - 'HUF', - 'IDR', - 'IEP', - 'ILP', - 'ILR', - 'ILS', - 'INR', - 'IQD', - 'IRR', - 'ISJ', - 'ISK', - 'ITL', - 'JMD', - 'JOD', - 'JPY', - 'KES', - 'KGS', - 'KHR', - 'KMF', - 'KPW', - 'KRH', - 'KRO', - 'KRW', - 'KWD', - 'KYD', - 'KZT', - 'LAK', - 'LBP', - 'LKR', - 'LRD', - 'LSL', - 'LTL', - 'LTT', - 'LUC', - 'LUF', - 'LUL', - 'LVL', - 'LVR', - 'LYD', - 'MAD', - 'MAF', - 'MCF', - 'MDC', - 'MDL', - 'MGA', - 'MGF', - 'MKD', - 'MKN', - 'MLF', - 'MMK', - 'MNT', - 'MOP', - 'MRO', - 'MRU', - 'MTL', - 'MTP', - 'MUR', - 'MVP', - 'MVR', - 'MWK', - 'MXN', - 'MXP', - 'MXV', - 'MYR', - 'MZE', - 'MZM', - 'MZN', - 'NAD', - 'NGN', - 'NIC', - 'NIO', - 'NLG', - 'NOK', - 'NPR', - 'NZD', - 'OMR', - 'PAB', - 'PEI', - 'PEN', - 'PES', - 'PGK', - 'PHP', - 'PKR', - 'PLN', - 'PLZ', - 'PTE', - 'PYG', - 'QAR', - 'RHD', - 'ROL', - 'RON', - 'RSD', - 'RUB', - 'RUR', - 'RWF', - 'SAR', - 'SBD', - 'SCR', - 'SDD', - 'SDG', - 'SDP', - 'SEK', - 'SGD', - 'SHP', - 'SIT', - 'SKK', - 'SLL', - 'SOS', - 'SRD', - 'SRG', - 'SSP', - 'STD', - 'STN', - 'SUR', - 'SVC', - 'SYP', - 'SZL', - 'THB', - 'TJR', - 'TJS', - 'TMM', - 'TMT', - 'TND', - 'TOP', - 'TPE', - 'TRL', - 'TRY', - 'TTD', - 'TWD', - 'TZS', - 'UAH', - 'UAK', - 'UGS', - 'UGX', - 'USD', - 'USN', - 'USS', - 'UYI', - 'UYP', - 'UYU', - 'UYW', - 'UZS', - 'VEB', - 'VEF', - 'VES', - 'VND', - 'VNN', - 'VUV', - 'WST', - 'XAF', - 'XCD', - 'XEU', - 'XFO', - 'XFU', - 'XOF', - 'XPF', - 'XRE', - 'YDD', - 'YER', - 'YUD', - 'YUM', - 'YUN', - 'YUR', - 'ZAL', - 'ZAR', - 'ZMK', - 'ZMW', - 'ZRN', - 'ZRZ', - 'ZWD', - 'ZWL', - 'ZWR', - ]; - - protected static $alpha3ToNumeric = [ - 'AFA' => 4, - 'ALK' => 8, - 'ALL' => 8, - 'DZD' => 12, - 'ADP' => 20, - 'AON' => 24, - 'AOK' => 24, - 'AZM' => 31, - 'ARA' => 32, - 'ARP' => 32, - 'ARS' => 32, - 'AUD' => 36, - 'ATS' => 40, - 'BSD' => 44, - 'BHD' => 48, - 'BDT' => 50, - 'AMD' => 51, - 'BBD' => 52, - 'BEF' => 56, - 'BMD' => 60, - 'BTN' => 64, - 'BOB' => 68, - 'BOP' => 68, - 'BAD' => 70, - 'BWP' => 72, - 'BRN' => 76, - 'BRE' => 76, - 'BRC' => 76, - 'BRB' => 76, - 'BZD' => 84, - 'SBD' => 90, - 'BND' => 96, - 'BGL' => 100, - 'MMK' => 104, - 'BUK' => 104, - 'BIF' => 108, - 'BYB' => 112, - 'KHR' => 116, - 'CAD' => 124, - 'CVE' => 132, - 'KYD' => 136, - 'LKR' => 144, - 'CLP' => 152, - 'CNY' => 156, - 'COP' => 170, - 'KMF' => 174, - 'ZRZ' => 180, - 'ZRN' => 180, - 'CRC' => 188, - 'HRK' => 191, - 'HRD' => 191, - 'CUP' => 192, - 'CYP' => 196, - 'CSK' => 200, - 'CZK' => 203, - 'DKK' => 208, - 'DOP' => 214, - 'ECS' => 218, - 'SVC' => 222, - 'GQE' => 226, - 'ETB' => 230, - 'ERN' => 232, - 'EEK' => 233, - 'FKP' => 238, - 'FJD' => 242, - 'FIM' => 246, - 'FRF' => 250, - 'DJF' => 262, - 'GEK' => 268, - 'GMD' => 270, - 'DEM' => 276, - 'DDM' => 278, - 'GHC' => 288, - 'GIP' => 292, - 'GRD' => 300, - 'GTQ' => 320, - 'GNS' => 324, - 'GNF' => 324, - 'GYD' => 328, - 'HTG' => 332, - 'HNL' => 340, - 'HKD' => 344, - 'HUF' => 348, - 'ISJ' => 352, - 'ISK' => 352, - 'INR' => 356, - 'IDR' => 360, - 'IRR' => 364, - 'IQD' => 368, - 'IEP' => 372, - 'ILP' => 376, - 'ILR' => 376, - 'ILS' => 376, - 'ITL' => 380, - 'JMD' => 388, - 'JPY' => 392, - 'KZT' => 398, - 'JOD' => 400, - 'KES' => 404, - 'KPW' => 408, - 'KRW' => 410, - 'KWD' => 414, - 'KGS' => 417, - 'LAK' => 418, - 'LBP' => 422, - 'LSL' => 426, - 'LVR' => 428, - 'LVL' => 428, - 'LRD' => 430, - 'LYD' => 434, - 'LTL' => 440, - 'LTT' => 440, - 'LUF' => 442, - 'MOP' => 446, - 'MGF' => 450, - 'MWK' => 454, - 'MYR' => 458, - 'MVR' => 462, - 'MLF' => 466, - 'MTL' => 470, - 'MTP' => 470, - 'MRO' => 478, - 'MUR' => 480, - 'MXP' => 484, - 'MXN' => 484, - 'MNT' => 496, - 'MDL' => 498, - 'MAD' => 504, - 'MZE' => 508, - 'MZM' => 508, - 'OMR' => 512, - 'NAD' => 516, - 'NPR' => 524, - 'NLG' => 528, - 'ANG' => 532, - 'AWG' => 533, - 'VUV' => 548, - 'NZD' => 554, - 'NIC' => 558, - 'NIO' => 558, - 'NGN' => 566, - 'NOK' => 578, - 'PKR' => 586, - 'PAB' => 590, - 'PGK' => 598, - 'PYG' => 600, - 'PEI' => 604, - 'PES' => 604, - 'PEN' => 604, - 'PHP' => 608, - 'PLZ' => 616, - 'PTE' => 620, - 'GWP' => 624, - 'GWE' => 624, - 'TPE' => 626, - 'QAR' => 634, - 'ROL' => 642, - 'RUB' => 643, - 'RWF' => 646, - 'SHP' => 654, - 'STD' => 678, - 'SAR' => 682, - 'SCR' => 690, - 'SLL' => 694, - 'SGD' => 702, - 'SKK' => 703, - 'VND' => 704, - 'SIT' => 705, - 'SOS' => 706, - 'ZAR' => 710, - 'ZWD' => 716, - 'RHD' => 716, - 'YDD' => 720, - 'ESP' => 724, - 'SSP' => 728, - 'SDD' => 736, - 'SDP' => 736, - 'SRG' => 740, - 'SZL' => 748, - 'SEK' => 752, - 'CHF' => 756, - 'SYP' => 760, - 'TJR' => 762, - 'THB' => 764, - 'TOP' => 776, - 'TTD' => 780, - 'AED' => 784, - 'TND' => 788, - 'TRL' => 792, - 'TMM' => 795, - 'UGX' => 800, - 'UGS' => 800, - 'UAK' => 804, - 'MKD' => 807, - 'RUR' => 810, - 'SUR' => 810, - 'EGP' => 818, - 'GBP' => 826, - 'TZS' => 834, - 'USD' => 840, - 'UYP' => 858, - 'UYU' => 858, - 'UZS' => 860, - 'VEB' => 862, - 'WST' => 882, - 'YER' => 886, - 'YUN' => 890, - 'YUD' => 890, - 'YUM' => 891, - 'CSD' => 891, - 'ZMK' => 894, - 'TWD' => 901, - 'UYW' => 927, - 'VES' => 928, - 'MRU' => 929, - 'STN' => 930, - 'CUC' => 931, - 'ZWL' => 932, - 'BYN' => 933, - 'TMT' => 934, - 'ZWR' => 935, - 'GHS' => 936, - 'VEF' => 937, - 'SDG' => 938, - 'UYI' => 940, - 'RSD' => 941, - 'MZN' => 943, - 'AZN' => 944, - 'RON' => 946, - 'CHE' => 947, - 'CHW' => 948, - 'TRY' => 949, - 'XAF' => 950, - 'XCD' => 951, - 'XOF' => 952, - 'XPF' => 953, - 'XEU' => 954, - 'ZMW' => 967, - 'SRD' => 968, - 'MGA' => 969, - 'COU' => 970, - 'AFN' => 971, - 'TJS' => 972, - 'AOA' => 973, - 'BYR' => 974, - 'BGN' => 975, - 'CDF' => 976, - 'BAM' => 977, - 'EUR' => 978, - 'MXV' => 979, - 'UAH' => 980, - 'GEL' => 981, - 'AOR' => 982, - 'ECV' => 983, - 'BOV' => 984, - 'PLN' => 985, - 'BRL' => 986, - 'BRR' => 987, - 'LUL' => 988, - 'LUC' => 989, - 'CLF' => 990, - 'ZAL' => 991, - 'BEL' => 992, - 'BEC' => 993, - 'ESB' => 995, - 'ESA' => 996, - 'USN' => 997, - 'USS' => 998, - ]; - - /** - * @var CurrencyDataProvider - */ - protected $dataProvider; - - protected function setUp() - { - parent::setUp(); - - $this->dataProvider = new CurrencyDataProvider( - $this->getDataDirectory().'/'.Intl::CURRENCY_DIR, - $this->createEntryReader() - ); - } - - abstract protected function getDataDirectory(); - - public function testGetCurrencies() - { - $this->assertSame(static::$currencies, $this->dataProvider->getCurrencies()); - } - - /** - * @dataProvider provideLocales - */ - public function testGetNames($displayLocale) - { - $names = $this->dataProvider->getNames($displayLocale); - - $keys = array_keys($names); - - sort($keys); - - $this->assertEquals(static::$currencies, $keys); - - // Names should be sorted - $sortedNames = $names; - $collator = new \Collator($displayLocale); - $collator->asort($names); - - $this->assertEquals($sortedNames, $names); - } - - public function testGetNamesDefaultLocale() - { - \Locale::setDefault('de_AT'); - - $this->assertSame( - $this->dataProvider->getNames('de_AT'), - $this->dataProvider->getNames() - ); - } - - /** - * @dataProvider provideLocaleAliases - */ - public function testGetNamesSupportsAliases($alias, $ofLocale) - { - // Can't use assertSame(), because some aliases contain scripts with - // different collation (=order of output) than their aliased locale - // e.g. sr_Latn_ME => sr_ME - $this->assertEquals( - $this->dataProvider->getNames($ofLocale), - $this->dataProvider->getNames($alias) - ); - } - - /** - * @dataProvider provideLocales - */ - public function testGetName($displayLocale) - { - $expected = $this->dataProvider->getNames($displayLocale); - $actual = []; - - foreach ($expected as $currency => $name) { - $actual[$currency] = $this->dataProvider->getName($currency, $displayLocale); - } - - $this->assertSame($expected, $actual); - } - - public function testGetNameDefaultLocale() - { - \Locale::setDefault('de_AT'); - - $expected = $this->dataProvider->getNames('de_AT'); - $actual = []; - - foreach ($expected as $currency => $name) { - $actual[$currency] = $this->dataProvider->getName($currency); - } - - $this->assertSame($expected, $actual); - } - - /** - * @dataProvider provideLocales - */ - public function testGetSymbol($displayLocale) - { - $currencies = $this->dataProvider->getCurrencies(); - - foreach ($currencies as $currency) { - $this->assertGreaterThan(0, mb_strlen($this->dataProvider->getSymbol($currency, $displayLocale))); - } - } - - public function provideCurrencies() - { - return array_map( - function ($currency) { return [$currency]; }, - static::$currencies - ); - } - - /** - * @dataProvider provideCurrencies - */ - public function testGetFractionDigits($currency) - { - $this->assertInternalType('numeric', $this->dataProvider->getFractionDigits($currency)); - } - - /** - * @dataProvider provideCurrencies - */ - public function testGetRoundingIncrement($currency) - { - $this->assertInternalType('numeric', $this->dataProvider->getRoundingIncrement($currency)); - } - - public function provideCurrenciesWithNumericEquivalent() - { - return array_map( - function ($value) { return [$value]; }, - array_keys(static::$alpha3ToNumeric) - ); - } - - /** - * @dataProvider provideCurrenciesWithNumericEquivalent - */ - public function testGetNumericCode($currency) - { - $this->assertSame(static::$alpha3ToNumeric[$currency], $this->dataProvider->getNumericCode($currency)); - } - - public function provideCurrenciesWithoutNumericEquivalent() - { - return array_map( - function ($value) { return [$value]; }, - array_diff(static::$currencies, array_keys(static::$alpha3ToNumeric)) - ); - } - - /** - * @dataProvider provideCurrenciesWithoutNumericEquivalent - * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException - */ - public function testGetNumericCodeFailsIfNoNumericEquivalent($currency) - { - $this->dataProvider->getNumericCode($currency); - } - - public function provideValidNumericCodes() - { - $numericToAlpha3 = $this->getNumericToAlpha3Mapping(); - - return array_map( - function ($numeric, $alpha3) { return [$numeric, $alpha3]; }, - array_keys($numericToAlpha3), - $numericToAlpha3 - ); - } - - /** - * @dataProvider provideValidNumericCodes - */ - public function testForNumericCode($numeric, $expected) - { - $actual = $this->dataProvider->forNumericCode($numeric); - - // Make sure that a different array order doesn't break the test - sort($actual); - sort($expected); - - $this->assertEquals($expected, $actual); - } - - public function provideInvalidNumericCodes() - { - $validNumericCodes = array_keys($this->getNumericToAlpha3Mapping()); - $invalidNumericCodes = array_diff(range(0, 1000), $validNumericCodes); - - return array_map( - function ($value) { return [$value]; }, - $invalidNumericCodes - ); - } - - /** - * @dataProvider provideInvalidNumericCodes - * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException - */ - public function testForNumericCodeFailsIfInvalidNumericCode($currency) - { - $this->dataProvider->forNumericCode($currency); - } - - private function getNumericToAlpha3Mapping() - { - $numericToAlpha3 = []; - - foreach (static::$alpha3ToNumeric as $alpha3 => $numeric) { - if (!isset($numericToAlpha3[$numeric])) { - $numericToAlpha3[$numeric] = []; - } - - $numericToAlpha3[$numeric][] = $alpha3; - } - - return $numericToAlpha3; - } -} diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php deleted file mode 100644 index cf3cca8cf2563..0000000000000 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php +++ /dev/null @@ -1,774 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Tests\Data\Provider; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReader; -use Symfony\Component\Intl\Data\Bundle\Reader\BundleReaderInterface; -use Symfony\Component\Intl\Locale; - -/** - * @author Bernhard Schussek - * - * @group legacy - */ -abstract class AbstractDataProviderTest extends TestCase -{ - // Include the locales statically so that the data providers are decoupled - // from the Intl class. Otherwise tests will fail if the intl extension is - // not loaded, because it is NOT possible to skip the execution of data - // providers. - - private static $locales = [ - 'af', - 'af_NA', - 'af_ZA', - 'ak', - 'ak_GH', - 'am', - 'am_ET', - 'ar', - 'ar_001', - 'ar_AE', - 'ar_BH', - 'ar_DJ', - 'ar_DZ', - 'ar_EG', - 'ar_EH', - 'ar_ER', - 'ar_IL', - 'ar_IQ', - 'ar_JO', - 'ar_KM', - 'ar_KW', - 'ar_LB', - 'ar_LY', - 'ar_MA', - 'ar_MR', - 'ar_OM', - 'ar_PS', - 'ar_QA', - 'ar_SA', - 'ar_SD', - 'ar_SO', - 'ar_SS', - 'ar_SY', - 'ar_TD', - 'ar_TN', - 'ar_YE', - 'as', - 'as_IN', - 'az', - 'az_AZ', - 'az_Cyrl', - 'az_Cyrl_AZ', - 'az_Latn', - 'az_Latn_AZ', - 'be', - 'be_BY', - 'bg', - 'bg_BG', - 'bm', - 'bm_ML', - 'bn', - 'bn_BD', - 'bn_IN', - 'bo', - 'bo_CN', - 'bo_IN', - 'br', - 'br_FR', - 'bs', - 'bs_BA', - 'bs_Cyrl', - 'bs_Cyrl_BA', - 'bs_Latn', - 'bs_Latn_BA', - 'ca', - 'ca_AD', - 'ca_ES', - 'ca_FR', - 'ca_IT', - 'ce', - 'ce_RU', - 'cs', - 'cs_CZ', - 'cy', - 'cy_GB', - 'da', - 'da_DK', - 'da_GL', - 'de', - 'de_AT', - 'de_BE', - 'de_CH', - 'de_DE', - 'de_IT', - 'de_LI', - 'de_LU', - 'dz', - 'dz_BT', - 'ee', - 'ee_GH', - 'ee_TG', - 'el', - 'el_CY', - 'el_GR', - 'en', - 'en_001', - 'en_150', - 'en_AE', - 'en_AG', - 'en_AI', - 'en_AS', - 'en_AT', - 'en_AU', - 'en_BB', - 'en_BE', - 'en_BI', - 'en_BM', - 'en_BS', - 'en_BW', - 'en_BZ', - 'en_CA', - 'en_CC', - 'en_CH', - 'en_CK', - 'en_CM', - 'en_CX', - 'en_CY', - 'en_DE', - 'en_DG', - 'en_DK', - 'en_DM', - 'en_ER', - 'en_FI', - 'en_FJ', - 'en_FK', - 'en_FM', - 'en_GB', - 'en_GD', - 'en_GG', - 'en_GH', - 'en_GI', - 'en_GM', - 'en_GU', - 'en_GY', - 'en_HK', - 'en_IE', - 'en_IL', - 'en_IM', - 'en_IN', - 'en_IO', - 'en_JE', - 'en_JM', - 'en_KE', - 'en_KI', - 'en_KN', - 'en_KY', - 'en_LC', - 'en_LR', - 'en_LS', - 'en_MG', - 'en_MH', - 'en_MO', - 'en_MP', - 'en_MS', - 'en_MT', - 'en_MU', - 'en_MW', - 'en_MY', - 'en_NA', - 'en_NF', - 'en_NG', - 'en_NH', - 'en_NL', - 'en_NR', - 'en_NU', - 'en_NZ', - 'en_PG', - 'en_PH', - 'en_PK', - 'en_PN', - 'en_PR', - 'en_PW', - 'en_RH', - 'en_RW', - 'en_SB', - 'en_SC', - 'en_SD', - 'en_SE', - 'en_SG', - 'en_SH', - 'en_SI', - 'en_SL', - 'en_SS', - 'en_SX', - 'en_SZ', - 'en_TC', - 'en_TK', - 'en_TO', - 'en_TT', - 'en_TV', - 'en_TZ', - 'en_UG', - 'en_UM', - 'en_US', - 'en_US_POSIX', - 'en_VC', - 'en_VG', - 'en_VI', - 'en_VU', - 'en_WS', - 'en_ZA', - 'en_ZM', - 'en_ZW', - 'eo', - 'eo_001', - 'es', - 'es_419', - 'es_AR', - 'es_BO', - 'es_BR', - 'es_BZ', - 'es_CL', - 'es_CO', - 'es_CR', - 'es_CU', - 'es_DO', - 'es_EA', - 'es_EC', - 'es_ES', - 'es_GQ', - 'es_GT', - 'es_HN', - 'es_IC', - 'es_MX', - 'es_NI', - 'es_PA', - 'es_PE', - 'es_PH', - 'es_PR', - 'es_PY', - 'es_SV', - 'es_US', - 'es_UY', - 'es_VE', - 'et', - 'et_EE', - 'eu', - 'eu_ES', - 'fa', - 'fa_AF', - 'fa_IR', - 'ff', - 'ff_CM', - 'ff_GN', - 'ff_Latn', - 'ff_Latn_BF', - 'ff_Latn_CM', - 'ff_Latn_GH', - 'ff_Latn_GM', - 'ff_Latn_GN', - 'ff_Latn_GW', - 'ff_Latn_LR', - 'ff_Latn_MR', - 'ff_Latn_NE', - 'ff_Latn_NG', - 'ff_Latn_SL', - 'ff_Latn_SN', - 'ff_MR', - 'ff_SN', - 'fi', - 'fi_FI', - 'fo', - 'fo_DK', - 'fo_FO', - 'fr', - 'fr_BE', - 'fr_BF', - 'fr_BI', - 'fr_BJ', - 'fr_BL', - 'fr_CA', - 'fr_CD', - 'fr_CF', - 'fr_CG', - 'fr_CH', - 'fr_CI', - 'fr_CM', - 'fr_DJ', - 'fr_DZ', - 'fr_FR', - 'fr_GA', - 'fr_GF', - 'fr_GN', - 'fr_GP', - 'fr_GQ', - 'fr_HT', - 'fr_KM', - 'fr_LU', - 'fr_MA', - 'fr_MC', - 'fr_MF', - 'fr_MG', - 'fr_ML', - 'fr_MQ', - 'fr_MR', - 'fr_MU', - 'fr_NC', - 'fr_NE', - 'fr_PF', - 'fr_PM', - 'fr_RE', - 'fr_RW', - 'fr_SC', - 'fr_SN', - 'fr_SY', - 'fr_TD', - 'fr_TG', - 'fr_TN', - 'fr_VU', - 'fr_WF', - 'fr_YT', - 'fy', - 'fy_NL', - 'ga', - 'ga_IE', - 'gd', - 'gd_GB', - 'gl', - 'gl_ES', - 'gu', - 'gu_IN', - 'gv', - 'gv_IM', - 'ha', - 'ha_GH', - 'ha_NE', - 'ha_NG', - 'he', - 'he_IL', - 'hi', - 'hi_IN', - 'hr', - 'hr_BA', - 'hr_HR', - 'hu', - 'hu_HU', - 'hy', - 'hy_AM', - 'ia', - 'ia_001', - 'id', - 'id_ID', - 'ig', - 'ig_NG', - 'ii', - 'ii_CN', - 'in', - 'in_ID', - 'is', - 'is_IS', - 'it', - 'it_CH', - 'it_IT', - 'it_SM', - 'it_VA', - 'iw', - 'iw_IL', - 'ja', - 'ja_JP', - 'ja_JP_TRADITIONAL', - 'jv', - 'jv_ID', - 'ka', - 'ka_GE', - 'ki', - 'ki_KE', - 'kk', - 'kk_KZ', - 'kl', - 'kl_GL', - 'km', - 'km_KH', - 'kn', - 'kn_IN', - 'ko', - 'ko_KP', - 'ko_KR', - 'ks', - 'ks_IN', - 'ku', - 'ku_TR', - 'kw', - 'kw_GB', - 'ky', - 'ky_KG', - 'lb', - 'lb_LU', - 'lg', - 'lg_UG', - 'ln', - 'ln_AO', - 'ln_CD', - 'ln_CF', - 'ln_CG', - 'lo', - 'lo_LA', - 'lt', - 'lt_LT', - 'lu', - 'lu_CD', - 'lv', - 'lv_LV', - 'mg', - 'mg_MG', - 'mi', - 'mi_NZ', - 'mk', - 'mk_MK', - 'ml', - 'ml_IN', - 'mn', - 'mn_MN', - 'mo', - 'mr', - 'mr_IN', - 'ms', - 'ms_BN', - 'ms_MY', - 'ms_SG', - 'mt', - 'mt_MT', - 'my', - 'my_MM', - 'nb', - 'nb_NO', - 'nb_SJ', - 'nd', - 'nd_ZW', - 'ne', - 'ne_IN', - 'ne_NP', - 'nl', - 'nl_AW', - 'nl_BE', - 'nl_BQ', - 'nl_CW', - 'nl_NL', - 'nl_SR', - 'nl_SX', - 'nn', - 'nn_NO', - 'no', - 'no_NO', - 'no_NO_NY', - 'om', - 'om_ET', - 'om_KE', - 'or', - 'or_IN', - 'os', - 'os_GE', - 'os_RU', - 'pa', - 'pa_Arab', - 'pa_Arab_PK', - 'pa_Guru', - 'pa_Guru_IN', - 'pa_IN', - 'pa_PK', - 'pl', - 'pl_PL', - 'ps', - 'ps_AF', - 'ps_PK', - 'pt', - 'pt_AO', - 'pt_BR', - 'pt_CH', - 'pt_CV', - 'pt_GQ', - 'pt_GW', - 'pt_LU', - 'pt_MO', - 'pt_MZ', - 'pt_PT', - 'pt_ST', - 'pt_TL', - 'qu', - 'qu_BO', - 'qu_EC', - 'qu_PE', - 'rm', - 'rm_CH', - 'rn', - 'rn_BI', - 'ro', - 'ro_MD', - 'ro_RO', - 'ru', - 'ru_BY', - 'ru_KG', - 'ru_KZ', - 'ru_MD', - 'ru_RU', - 'ru_UA', - 'rw', - 'rw_RW', - 'sd', - 'sd_PK', - 'se', - 'se_FI', - 'se_NO', - 'se_SE', - 'sg', - 'sg_CF', - 'sh', - 'sh_BA', - 'sh_CS', - 'sh_YU', - 'si', - 'si_LK', - 'sk', - 'sk_SK', - 'sl', - 'sl_SI', - 'sn', - 'sn_ZW', - 'so', - 'so_DJ', - 'so_ET', - 'so_KE', - 'so_SO', - 'sq', - 'sq_AL', - 'sq_MK', - 'sq_XK', - 'sr', - 'sr_BA', - 'sr_CS', - 'sr_Cyrl', - 'sr_Cyrl_BA', - 'sr_Cyrl_CS', - 'sr_Cyrl_ME', - 'sr_Cyrl_RS', - 'sr_Cyrl_XK', - 'sr_Cyrl_YU', - 'sr_Latn', - 'sr_Latn_BA', - 'sr_Latn_CS', - 'sr_Latn_ME', - 'sr_Latn_RS', - 'sr_Latn_XK', - 'sr_Latn_YU', - 'sr_ME', - 'sr_RS', - 'sr_XK', - 'sr_YU', - 'sv', - 'sv_AX', - 'sv_FI', - 'sv_SE', - 'sw', - 'sw_CD', - 'sw_KE', - 'sw_TZ', - 'sw_UG', - 'ta', - 'ta_IN', - 'ta_LK', - 'ta_MY', - 'ta_SG', - 'te', - 'te_IN', - 'tg', - 'tg_TJ', - 'th', - 'th_TH', - 'th_TH_TRADITIONAL', - 'ti', - 'ti_ER', - 'ti_ET', - 'tk', - 'tk_TM', - 'tl', - 'tl_PH', - 'to', - 'to_TO', - 'tr', - 'tr_CY', - 'tr_TR', - 'tt', - 'tt_RU', - 'ug', - 'ug_CN', - 'uk', - 'uk_UA', - 'ur', - 'ur_IN', - 'ur_PK', - 'uz', - 'uz_AF', - 'uz_Arab', - 'uz_Arab_AF', - 'uz_Cyrl', - 'uz_Cyrl_UZ', - 'uz_Latn', - 'uz_Latn_UZ', - 'uz_UZ', - 'vi', - 'vi_VN', - 'wo', - 'wo_SN', - 'xh', - 'xh_ZA', - 'yi', - 'yi_001', - 'yo', - 'yo_BJ', - 'yo_NG', - 'zh', - 'zh_CN', - 'zh_HK', - 'zh_Hans', - 'zh_Hans_CN', - 'zh_Hans_HK', - 'zh_Hans_MO', - 'zh_Hans_SG', - 'zh_Hant', - 'zh_Hant_HK', - 'zh_Hant_MO', - 'zh_Hant_TW', - 'zh_MO', - 'zh_SG', - 'zh_TW', - 'zu', - 'zu_ZA', - ]; - - private static $localeAliases = [ - 'az_AZ' => 'az_Latn_AZ', - 'bs_BA' => 'bs_Latn_BA', - 'en_NH' => 'en_VU', - 'en_RH' => 'en_ZW', - 'ff_CM' => 'ff_Latn_CM', - 'ff_GN' => 'ff_Latn_GN', - 'ff_MR' => 'ff_Latn_MR', - 'ff_SN' => 'ff_Latn_SN', - 'in' => 'id', - 'in_ID' => 'id_ID', - 'iw' => 'he', - 'iw_IL' => 'he_IL', - 'mo' => 'ro', - 'no' => 'nb', - 'no_NO' => 'nb_NO', - 'no_NO_NY' => 'nn_NO', - 'pa_IN' => 'pa_Guru_IN', - 'pa_PK' => 'pa_Arab_PK', - 'sh' => 'sr_Latn', - 'sh_BA' => 'sr_Latn_BA', - 'sh_CS' => 'sr_Latn_RS', - 'sh_YU' => 'sr_Latn_RS', - 'sr_BA' => 'sr_Cyrl_BA', - 'sr_CS' => 'sr_Cyrl_RS', - 'sr_Cyrl_CS' => 'sr_Cyrl_RS', - 'sr_Cyrl_YU' => 'sr_Cyrl_RS', - 'sr_Latn_CS' => 'sr_Latn_RS', - 'sr_Latn_YU' => 'sr_Latn_RS', - 'sr_ME' => 'sr_Latn_ME', - 'sr_RS' => 'sr_Cyrl_RS', - 'sr_XK' => 'sr_Cyrl_XK', - 'sr_YU' => 'sr_Cyrl_RS', - 'tl' => 'fil', - 'tl_PH' => 'fil_PH', - 'uz_AF' => 'uz_Arab_AF', - 'uz_UZ' => 'uz_Latn_UZ', - 'zh_CN' => 'zh_Hans_CN', - 'zh_HK' => 'zh_Hant_HK', - 'zh_MO' => 'zh_Hant_MO', - 'zh_SG' => 'zh_Hans_SG', - 'zh_TW' => 'zh_Hant_TW', - ]; - - private static $rootLocales; - - protected function setUp() - { - \Locale::setDefault('en'); - Locale::setDefaultFallback('en'); - } - - public function provideLocales() - { - return array_map( - function ($locale) { return [$locale]; }, - $this->getLocales() - ); - } - - public function provideLocaleAliases() - { - return array_map( - function ($alias, $ofLocale) { return [$alias, $ofLocale]; }, - array_keys($this->getLocaleAliases()), - $this->getLocaleAliases() - ); - } - - public function provideRootLocales() - { - return array_map( - function ($locale) { return [$locale]; }, - $this->getRootLocales() - ); - } - - protected function getLocales() - { - return self::$locales; - } - - protected function getLocaleAliases() - { - return self::$localeAliases; - } - - protected function getRootLocales() - { - if (null === self::$rootLocales) { - self::$rootLocales = array_filter(static::getLocales(), function ($locale) { - // no locales for which fallback is possible (e.g "en_GB") - return false === strpos($locale, '_'); - }); - } - - return self::$rootLocales; - } - - /** - * @return BundleEntryReader - */ - protected function createEntryReader() - { - $entryReader = new BundleEntryReader($this->createBundleReader()); - $entryReader->setLocaleAliases($this->getLocaleAliases()); - - return $entryReader; - } - - /** - * @return BundleReaderInterface - */ - abstract protected function createBundleReader(); -} diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php deleted file mode 100644 index 119e2c75ed205..0000000000000 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLanguageDataProviderTest.php +++ /dev/null @@ -1,943 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Tests\Data\Provider; - -use Symfony\Component\Intl\Data\Provider\LanguageDataProvider; -use Symfony\Component\Intl\Intl; - -/** - * @author Bernhard Schussek - * - * @group legacy - */ -abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest -{ - // The below arrays document the state of the ICU data bundled with this package. - - protected static $languages = [ - 'aa', - 'ab', - 'ace', - 'ach', - 'ada', - 'ady', - 'ae', - 'aeb', - 'af', - 'afh', - 'agq', - 'ain', - 'ak', - 'akk', - 'akz', - 'ale', - 'aln', - 'alt', - 'am', - 'an', - 'ang', - 'anp', - 'ar', - 'ar_001', - 'arc', - 'arn', - 'aro', - 'arp', - 'arq', - 'ars', - 'arw', - 'ary', - 'arz', - 'as', - 'asa', - 'ase', - 'ast', - 'av', - 'avk', - 'awa', - 'ay', - 'az', - 'az_Arab', - 'ba', - 'bal', - 'ban', - 'bar', - 'bas', - 'bax', - 'bbc', - 'bbj', - 'be', - 'bej', - 'bem', - 'bew', - 'bez', - 'bfd', - 'bfq', - 'bg', - 'bgn', - 'bho', - 'bi', - 'bik', - 'bin', - 'bjn', - 'bkm', - 'bla', - 'bm', - 'bn', - 'bo', - 'bpy', - 'bqi', - 'br', - 'bra', - 'brh', - 'brx', - 'bs', - 'bss', - 'bua', - 'bug', - 'bum', - 'byn', - 'byv', - 'ca', - 'cad', - 'car', - 'cay', - 'cch', - 'ccp', - 'ce', - 'ceb', - 'cgg', - 'ch', - 'chb', - 'chg', - 'chk', - 'chm', - 'chn', - 'cho', - 'chp', - 'chr', - 'chy', - 'ckb', - 'co', - 'cop', - 'cps', - 'cr', - 'crh', - 'crs', - 'cs', - 'csb', - 'cu', - 'cv', - 'cy', - 'da', - 'dak', - 'dar', - 'dav', - 'de', - 'de_AT', - 'de_CH', - 'del', - 'den', - 'dgr', - 'din', - 'dje', - 'doi', - 'dsb', - 'dtp', - 'dua', - 'dum', - 'dv', - 'dyo', - 'dyu', - 'dz', - 'dzg', - 'ebu', - 'ee', - 'efi', - 'egl', - 'egy', - 'eka', - 'el', - 'elx', - 'en', - 'en_AU', - 'en_CA', - 'en_GB', - 'en_US', - 'enm', - 'eo', - 'es', - 'es_419', - 'es_ES', - 'es_MX', - 'esu', - 'et', - 'eu', - 'ewo', - 'ext', - 'fa', - 'fa_AF', - 'fan', - 'fat', - 'ff', - 'fi', - 'fil', - 'fit', - 'fj', - 'fo', - 'fon', - 'fr', - 'fr_CA', - 'fr_CH', - 'frc', - 'frm', - 'fro', - 'frp', - 'frr', - 'frs', - 'fur', - 'fy', - 'ga', - 'gaa', - 'gag', - 'gan', - 'gay', - 'gba', - 'gbz', - 'gd', - 'gez', - 'gil', - 'gl', - 'glk', - 'gmh', - 'gn', - 'goh', - 'gom', - 'gon', - 'gor', - 'got', - 'grb', - 'grc', - 'gsw', - 'gu', - 'guc', - 'gur', - 'guz', - 'gv', - 'gwi', - 'ha', - 'hai', - 'hak', - 'haw', - 'he', - 'hi', - 'hif', - 'hil', - 'hit', - 'hmn', - 'ho', - 'hr', - 'hsb', - 'hsn', - 'ht', - 'hu', - 'hup', - 'hy', - 'hz', - 'ia', - 'iba', - 'ibb', - 'id', - 'ie', - 'ig', - 'ii', - 'ik', - 'ilo', - 'inh', - 'io', - 'is', - 'it', - 'iu', - 'izh', - 'ja', - 'jam', - 'jbo', - 'jgo', - 'jmc', - 'jpr', - 'jrb', - 'jut', - 'jv', - 'ka', - 'kaa', - 'kab', - 'kac', - 'kaj', - 'kam', - 'kaw', - 'kbd', - 'kbl', - 'kcg', - 'kde', - 'kea', - 'ken', - 'kfo', - 'kg', - 'kgp', - 'kha', - 'kho', - 'khq', - 'khw', - 'ki', - 'kiu', - 'kj', - 'kk', - 'kkj', - 'kl', - 'kln', - 'km', - 'kmb', - 'kn', - 'ko', - 'koi', - 'kok', - 'kos', - 'kpe', - 'kr', - 'krc', - 'kri', - 'krj', - 'krl', - 'kru', - 'ks', - 'ksb', - 'ksf', - 'ksh', - 'ku', - 'kum', - 'kut', - 'kv', - 'kw', - 'ky', - 'la', - 'lad', - 'lag', - 'lah', - 'lam', - 'lb', - 'lez', - 'lfn', - 'lg', - 'li', - 'lij', - 'liv', - 'lkt', - 'lmo', - 'ln', - 'lo', - 'lol', - 'lou', - 'loz', - 'lrc', - 'lt', - 'ltg', - 'lu', - 'lua', - 'lui', - 'lun', - 'luo', - 'lus', - 'luy', - 'lv', - 'lzh', - 'lzz', - 'mad', - 'maf', - 'mag', - 'mai', - 'mak', - 'man', - 'mas', - 'mde', - 'mdf', - 'mdr', - 'men', - 'mer', - 'mfe', - 'mg', - 'mga', - 'mgh', - 'mgo', - 'mh', - 'mi', - 'mic', - 'min', - 'mk', - 'ml', - 'mn', - 'mnc', - 'mni', - 'moh', - 'mos', - 'mr', - 'mrj', - 'ms', - 'mt', - 'mua', - 'mus', - 'mwl', - 'mwr', - 'mwv', - 'my', - 'mye', - 'myv', - 'mzn', - 'na', - 'nan', - 'nap', - 'naq', - 'nb', - 'nd', - 'nds', - 'nds_NL', - 'ne', - 'new', - 'ng', - 'nia', - 'niu', - 'njo', - 'nl', - 'nl_BE', - 'nmg', - 'nn', - 'nnh', - 'no', - 'nog', - 'non', - 'nov', - 'nqo', - 'nr', - 'nso', - 'nus', - 'nv', - 'nwc', - 'ny', - 'nym', - 'nyn', - 'nyo', - 'nzi', - 'oc', - 'oj', - 'om', - 'or', - 'os', - 'osa', - 'ota', - 'pa', - 'pag', - 'pal', - 'pam', - 'pap', - 'pau', - 'pcd', - 'pcm', - 'pdc', - 'pdt', - 'peo', - 'pfl', - 'phn', - 'pi', - 'pl', - 'pms', - 'pnt', - 'pon', - 'prg', - 'pro', - 'ps', - 'pt', - 'pt_BR', - 'pt_PT', - 'qu', - 'quc', - 'qug', - 'raj', - 'rap', - 'rar', - 'rgn', - 'rif', - 'rm', - 'rn', - 'ro', - 'ro_MD', - 'rof', - 'rom', - 'root', - 'rtm', - 'ru', - 'rue', - 'rug', - 'rup', - 'rw', - 'rwk', - 'sa', - 'sad', - 'sah', - 'sam', - 'saq', - 'sas', - 'sat', - 'saz', - 'sba', - 'sbp', - 'sc', - 'scn', - 'sco', - 'sd', - 'sdc', - 'sdh', - 'se', - 'see', - 'seh', - 'sei', - 'sel', - 'ses', - 'sg', - 'sga', - 'sgs', - 'sh', - 'shi', - 'shn', - 'shu', - 'si', - 'sid', - 'sk', - 'sl', - 'sli', - 'sly', - 'sm', - 'sma', - 'smj', - 'smn', - 'sms', - 'sn', - 'snk', - 'so', - 'sog', - 'sq', - 'sr', - 'sr_ME', - 'srn', - 'srr', - 'ss', - 'ssy', - 'st', - 'stq', - 'su', - 'suk', - 'sus', - 'sux', - 'sv', - 'sw', - 'sw_CD', - 'swb', - 'syc', - 'syr', - 'szl', - 'ta', - 'tcy', - 'te', - 'tem', - 'teo', - 'ter', - 'tet', - 'tg', - 'th', - 'ti', - 'tig', - 'tiv', - 'tk', - 'tkl', - 'tkr', - 'tl', - 'tlh', - 'tli', - 'tly', - 'tmh', - 'tn', - 'to', - 'tog', - 'tpi', - 'tr', - 'tru', - 'trv', - 'ts', - 'tsd', - 'tsi', - 'tt', - 'ttt', - 'tum', - 'tvl', - 'tw', - 'twq', - 'ty', - 'tyv', - 'tzm', - 'udm', - 'ug', - 'uga', - 'uk', - 'umb', - 'ur', - 'uz', - 'vai', - 've', - 'vec', - 'vep', - 'vi', - 'vls', - 'vmf', - 'vo', - 'vot', - 'vro', - 'vun', - 'wa', - 'wae', - 'wal', - 'war', - 'was', - 'wbp', - 'wo', - 'wuu', - 'xal', - 'xh', - 'xmf', - 'xog', - 'yao', - 'yap', - 'yav', - 'ybb', - 'yi', - 'yo', - 'yrl', - 'yue', - 'za', - 'zap', - 'zbl', - 'zea', - 'zen', - 'zgh', - 'zh', - 'zh_Hans', - 'zh_Hant', - 'zu', - 'zun', - 'zza', - ]; - - protected static $alpha2ToAlpha3 = [ - 'aa' => 'aar', - 'ab' => 'abk', - 'af' => 'afr', - 'ak' => 'aka', - 'sq' => 'sqi', - 'am' => 'amh', - 'ar' => 'ara', - 'an' => 'arg', - 'hy' => 'hye', - 'as' => 'asm', - 'av' => 'ava', - 'ae' => 'ave', - 'ay' => 'aym', - 'az' => 'aze', - 'ba' => 'bak', - 'bm' => 'bam', - 'eu' => 'eus', - 'be' => 'bel', - 'bn' => 'ben', - 'bi' => 'bis', - 'bo' => 'bod', - 'bs' => 'bos', - 'br' => 'bre', - 'bg' => 'bul', - 'my' => 'mya', - 'ca' => 'cat', - 'cs' => 'ces', - 'ch' => 'cha', - 'ce' => 'che', - 'zh' => 'zho', - 'cu' => 'chu', - 'cv' => 'chv', - 'kw' => 'cor', - 'co' => 'cos', - 'cr' => 'cre', - 'cy' => 'cym', - 'da' => 'dan', - 'de' => 'deu', - 'dv' => 'div', - 'nl' => 'nld', - 'dz' => 'dzo', - 'et' => 'est', - 'el' => 'ell', - 'en' => 'eng', - 'eo' => 'epo', - 'ik' => 'ipk', - 'ee' => 'ewe', - 'fo' => 'fao', - 'fa' => 'fas', - 'fj' => 'fij', - 'fi' => 'fin', - 'fr' => 'fra', - 'fy' => 'fry', - 'ff' => 'ful', - 'om' => 'orm', - 'ka' => 'kat', - 'gd' => 'gla', - 'ga' => 'gle', - 'gl' => 'glg', - 'gv' => 'glv', - 'gn' => 'grn', - 'gu' => 'guj', - 'ht' => 'hat', - 'ha' => 'hau', - 'he' => 'heb', - 'hz' => 'her', - 'hi' => 'hin', - 'ho' => 'hmo', - 'hr' => 'hrv', - 'hu' => 'hun', - 'ig' => 'ibo', - 'is' => 'isl', - 'io' => 'ido', - 'ii' => 'iii', - 'iu' => 'iku', - 'ie' => 'ile', - 'ia' => 'ina', - 'id' => 'ind', - 'it' => 'ita', - 'jv' => 'jav', - 'ja' => 'jpn', - 'kl' => 'kal', - 'kn' => 'kan', - 'ks' => 'kas', - 'kr' => 'kau', - 'kk' => 'kaz', - 'mn' => 'mon', - 'km' => 'khm', - 'ki' => 'kik', - 'rw' => 'kin', - 'ky' => 'kir', - 'ku' => 'kur', - 'kg' => 'kon', - 'kv' => 'kom', - 'ko' => 'kor', - 'kj' => 'kua', - 'lo' => 'lao', - 'la' => 'lat', - 'lv' => 'lav', - 'li' => 'lim', - 'ln' => 'lin', - 'lt' => 'lit', - 'lb' => 'ltz', - 'lu' => 'lub', - 'lg' => 'lug', - 'mk' => 'mkd', - 'mh' => 'mah', - 'ml' => 'mal', - 'mi' => 'mri', - 'mr' => 'mar', - 'ms' => 'msa', - 'mg' => 'mlg', - 'mt' => 'mlt', - 'na' => 'nau', - 'nv' => 'nav', - 'nr' => 'nbl', - 'nd' => 'nde', - 'ng' => 'ndo', - 'ne' => 'nep', - 'nn' => 'nno', - 'nb' => 'nob', - 'ny' => 'nya', - 'oc' => 'oci', - 'oj' => 'oji', - 'or' => 'ori', - 'os' => 'oss', - 'pa' => 'pan', - 'ps' => 'pus', - 'pi' => 'pli', - 'pl' => 'pol', - 'pt' => 'por', - 'qu' => 'que', - 'rm' => 'roh', - 'ro' => 'ron', - 'rn' => 'run', - 'ru' => 'rus', - 'sg' => 'sag', - 'sa' => 'san', - 'sr' => 'srp', - 'si' => 'sin', - 'sk' => 'slk', - 'sl' => 'slv', - 'se' => 'sme', - 'sm' => 'smo', - 'sn' => 'sna', - 'sd' => 'snd', - 'so' => 'som', - 'st' => 'sot', - 'es' => 'spa', - 'sc' => 'srd', - 'ss' => 'ssw', - 'su' => 'sun', - 'sw' => 'swa', - 'sv' => 'swe', - 'ty' => 'tah', - 'ta' => 'tam', - 'tt' => 'tat', - 'te' => 'tel', - 'tg' => 'tgk', - 'th' => 'tha', - 'ti' => 'tir', - 'to' => 'ton', - 'tn' => 'tsn', - 'ts' => 'tso', - 'tk' => 'tuk', - 'tr' => 'tur', - 'ug' => 'uig', - 'uk' => 'ukr', - 'ur' => 'urd', - 'uz' => 'uzb', - 've' => 'ven', - 'vi' => 'vie', - 'vo' => 'vol', - 'wa' => 'wln', - 'wo' => 'wol', - 'xh' => 'xho', - 'yi' => 'yid', - 'yo' => 'yor', - 'za' => 'zha', - 'zu' => 'zul', - ]; - - /** - * @var LanguageDataProvider - */ - protected $dataProvider; - - protected function setUp() - { - parent::setUp(); - - $this->dataProvider = new LanguageDataProvider( - $this->getDataDirectory().'/'.Intl::LANGUAGE_DIR, - $this->createEntryReader() - ); - } - - abstract protected function getDataDirectory(); - - public function testGetLanguages() - { - $this->assertEquals(static::$languages, $this->dataProvider->getLanguages()); - } - - /** - * @dataProvider provideLocales - */ - public function testGetNames($displayLocale) - { - $languages = array_keys($this->dataProvider->getNames($displayLocale)); - - sort($languages); - - $this->assertNotEmpty($languages); - $this->assertEmpty(array_diff($languages, static::$languages)); - } - - public function testGetNamesDefaultLocale() - { - \Locale::setDefault('de_AT'); - - $this->assertSame( - $this->dataProvider->getNames('de_AT'), - $this->dataProvider->getNames() - ); - } - - /** - * @dataProvider provideLocaleAliases - */ - public function testGetNamesSupportsAliases($alias, $ofLocale) - { - // Can't use assertSame(), because some aliases contain scripts with - // different collation (=order of output) than their aliased locale - // e.g. sr_Latn_ME => sr_ME - $this->assertEquals( - $this->dataProvider->getNames($ofLocale), - $this->dataProvider->getNames($alias) - ); - } - - /** - * @dataProvider provideLocales - */ - public function testGetName($displayLocale) - { - $names = $this->dataProvider->getNames($displayLocale); - - foreach ($names as $language => $name) { - $this->assertSame($name, $this->dataProvider->getName($language, $displayLocale)); - } - } - - public function testGetNameDefaultLocale() - { - \Locale::setDefault('de_AT'); - - $names = $this->dataProvider->getNames('de_AT'); - - foreach ($names as $language => $name) { - $this->assertSame($name, $this->dataProvider->getName($language)); - } - } - - public function provideLanguagesWithAlpha3Equivalent() - { - return array_map( - function ($value) { return [$value]; }, - array_keys(static::$alpha2ToAlpha3) - ); - } - - /** - * @dataProvider provideLanguagesWithAlpha3Equivalent - */ - public function testGetAlpha3Code($language) - { - $this->assertSame(static::$alpha2ToAlpha3[$language], $this->dataProvider->getAlpha3Code($language)); - } - - public function provideLanguagesWithoutAlpha3Equivalent() - { - return array_map( - function ($value) { return [$value]; }, - array_diff(static::$languages, array_keys(static::$alpha2ToAlpha3)) - ); - } - - /** - * @dataProvider provideLanguagesWithoutAlpha3Equivalent - * @expectedException \Symfony\Component\Intl\Exception\MissingResourceException - */ - public function testGetAlpha3CodeFailsIfNoAlpha3Equivalent($currency) - { - $this->dataProvider->getAlpha3Code($currency); - } -} diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLocaleDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLocaleDataProviderTest.php deleted file mode 100644 index 4f5bb903841c3..0000000000000 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractLocaleDataProviderTest.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Tests\Data\Provider; - -use Symfony\Component\Intl\Data\Provider\LocaleDataProvider; -use Symfony\Component\Intl\Intl; - -/** - * @author Bernhard Schussek - * - * @group legacy - */ -abstract class AbstractLocaleDataProviderTest extends AbstractDataProviderTest -{ - /** - * @var LocaleDataProvider - */ - protected $dataProvider; - - protected function setUp() - { - parent::setUp(); - - $this->dataProvider = new LocaleDataProvider( - $this->getDataDirectory().'/'.Intl::LOCALE_DIR, - $this->createEntryReader() - ); - } - - abstract protected function getDataDirectory(); - - public function testGetLocales() - { - $this->assertSame($this->getLocales(), $this->dataProvider->getLocales()); - } - - public function testGetLocaleAliases() - { - $this->assertSame($this->getLocaleAliases(), $this->dataProvider->getAliases()); - } - - /** - * @dataProvider provideLocales - */ - public function testGetNames($displayLocale) - { - $locales = array_keys($this->dataProvider->getNames($displayLocale)); - - sort($locales); - - // We can't assert on exact list of locale, as there's too many variations. - // The best we can do is to make sure getNames() returns a subset of what getLocales() returns. - $this->assertNotEmpty($locales); - $this->assertEmpty(array_diff($locales, $this->getLocales())); - } - - public function testGetNamesDefaultLocale() - { - \Locale::setDefault('de_AT'); - - $this->assertSame( - $this->dataProvider->getNames('de_AT'), - $this->dataProvider->getNames() - ); - } - - /** - * @dataProvider provideLocaleAliases - */ - public function testGetNamesSupportsAliases($alias, $ofLocale) - { - // Can't use assertSame(), because some aliases contain scripts with - // different collation (=order of output) than their aliased locale - // e.g. sr_Latn_ME => sr_ME - $this->assertEquals( - $this->dataProvider->getNames($ofLocale), - $this->dataProvider->getNames($alias) - ); - } - - /** - * @dataProvider provideLocales - */ - public function testGetName($displayLocale) - { - $names = $this->dataProvider->getNames($displayLocale); - - foreach ($names as $locale => $name) { - $this->assertSame($name, $this->dataProvider->getName($locale, $displayLocale)); - } - } - - public function testGetNameDefaultLocale() - { - \Locale::setDefault('de_AT'); - - $names = $this->dataProvider->getNames('de_AT'); - - foreach ($names as $locale => $name) { - $this->assertSame($name, $this->dataProvider->getName($locale)); - } - } -} diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php deleted file mode 100644 index 8fd136f418fe2..0000000000000 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractRegionDataProviderTest.php +++ /dev/null @@ -1,347 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Tests\Data\Provider; - -use Symfony\Component\Intl\Data\Provider\RegionDataProvider; -use Symfony\Component\Intl\Intl; - -/** - * @author Bernhard Schussek - * - * @group legacy - */ -abstract class AbstractRegionDataProviderTest extends AbstractDataProviderTest -{ - // The below arrays document the state of the ICU data bundled with this package. - - protected static $territories = [ - 'AD', - 'AE', - 'AF', - 'AG', - 'AI', - 'AL', - 'AM', - 'AO', - 'AQ', - 'AR', - 'AS', - 'AT', - 'AU', - 'AW', - 'AX', - 'AZ', - 'BA', - 'BB', - 'BD', - 'BE', - 'BF', - 'BG', - 'BH', - 'BI', - 'BJ', - 'BL', - 'BM', - 'BN', - 'BO', - 'BQ', - 'BR', - 'BS', - 'BT', - 'BV', - 'BW', - 'BY', - 'BZ', - 'CA', - 'CC', - 'CD', - 'CF', - 'CG', - 'CH', - 'CI', - 'CK', - 'CL', - 'CM', - 'CN', - 'CO', - 'CR', - 'CU', - 'CV', - 'CW', - 'CX', - 'CY', - 'CZ', - 'DE', - 'DJ', - 'DK', - 'DM', - 'DO', - 'DZ', - 'EC', - 'EE', - 'EG', - 'EH', - 'ER', - 'ES', - 'ET', - 'FI', - 'FJ', - 'FK', - 'FM', - 'FO', - 'FR', - 'GA', - 'GB', - 'GD', - 'GE', - 'GF', - 'GG', - 'GH', - 'GI', - 'GL', - 'GM', - 'GN', - 'GP', - 'GQ', - 'GR', - 'GS', - 'GT', - 'GU', - 'GW', - 'GY', - 'HK', - 'HM', - 'HN', - 'HR', - 'HT', - 'HU', - 'ID', - 'IE', - 'IL', - 'IM', - 'IN', - 'IO', - 'IQ', - 'IR', - 'IS', - 'IT', - 'JE', - 'JM', - 'JO', - 'JP', - 'KE', - 'KG', - 'KH', - 'KI', - 'KM', - 'KN', - 'KP', - 'KR', - 'KW', - 'KY', - 'KZ', - 'LA', - 'LB', - 'LC', - 'LI', - 'LK', - 'LR', - 'LS', - 'LT', - 'LU', - 'LV', - 'LY', - 'MA', - 'MC', - 'MD', - 'ME', - 'MF', - 'MG', - 'MH', - 'MK', - 'ML', - 'MM', - 'MN', - 'MO', - 'MP', - 'MQ', - 'MR', - 'MS', - 'MT', - 'MU', - 'MV', - 'MW', - 'MX', - 'MY', - 'MZ', - 'NA', - 'NC', - 'NE', - 'NF', - 'NG', - 'NI', - 'NL', - 'NO', - 'NP', - 'NR', - 'NU', - 'NZ', - 'OM', - 'PA', - 'PE', - 'PF', - 'PG', - 'PH', - 'PK', - 'PL', - 'PM', - 'PN', - 'PR', - 'PS', - 'PT', - 'PW', - 'PY', - 'QA', - 'RE', - 'RO', - 'RS', - 'RU', - 'RW', - 'SA', - 'SB', - 'SC', - 'SD', - 'SE', - 'SG', - 'SH', - 'SI', - 'SJ', - 'SK', - 'SL', - 'SM', - 'SN', - 'SO', - 'SR', - 'SS', - 'ST', - 'SV', - 'SX', - 'SY', - 'SZ', - 'TC', - 'TD', - 'TF', - 'TG', - 'TH', - 'TJ', - 'TK', - 'TL', - 'TM', - 'TN', - 'TO', - 'TR', - 'TT', - 'TV', - 'TW', - 'TZ', - 'UA', - 'UG', - 'UM', - 'US', - 'UY', - 'UZ', - 'VA', - 'VC', - 'VE', - 'VG', - 'VI', - 'VN', - 'VU', - 'WF', - 'WS', - 'YE', - 'YT', - 'ZA', - 'ZM', - 'ZW', - ]; - - /** - * @var RegionDataProvider - */ - protected $dataProvider; - - protected function setUp() - { - parent::setUp(); - - $this->dataProvider = new RegionDataProvider( - $this->getDataDirectory().'/'.Intl::REGION_DIR, - $this->createEntryReader() - ); - } - - abstract protected function getDataDirectory(); - - public function testGetRegions() - { - $this->assertSame(static::$territories, $this->dataProvider->getRegions()); - } - - /** - * @dataProvider provideLocales - */ - public function testGetNames($displayLocale) - { - $countries = array_keys($this->dataProvider->getNames($displayLocale)); - - sort($countries); - - $this->assertSame(static::$territories, $countries); - } - - public function testGetNamesDefaultLocale() - { - \Locale::setDefault('de_AT'); - - $this->assertSame( - $this->dataProvider->getNames('de_AT'), - $this->dataProvider->getNames() - ); - } - - /** - * @dataProvider provideLocaleAliases - */ - public function testGetNamesSupportsAliases($alias, $ofLocale) - { - // Can't use assertSame(), because some aliases contain scripts with - // different collation (=order of output) than their aliased locale - // e.g. sr_Latn_ME => sr_ME - $this->assertEquals( - $this->dataProvider->getNames($ofLocale), - $this->dataProvider->getNames($alias) - ); - } - - /** - * @dataProvider provideLocales - */ - public function testGetName($displayLocale) - { - $names = $this->dataProvider->getNames($displayLocale); - - foreach ($names as $country => $name) { - $this->assertSame($name, $this->dataProvider->getName($country, $displayLocale)); - } - } -} diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractScriptDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractScriptDataProviderTest.php deleted file mode 100644 index 3dde488905400..0000000000000 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractScriptDataProviderTest.php +++ /dev/null @@ -1,301 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Tests\Data\Provider; - -use Symfony\Component\Intl\Data\Provider\ScriptDataProvider; -use Symfony\Component\Intl\Intl; - -/** - * @author Bernhard Schussek - * @group intl-data - * @group legacy - */ -abstract class AbstractScriptDataProviderTest extends AbstractDataProviderTest -{ - // The below arrays document the state of the ICU data bundled with this package. - - protected static $scripts = [ - 'Adlm', - 'Afak', - 'Aghb', - 'Ahom', - 'Arab', - 'Armi', - 'Armn', - 'Avst', - 'Bali', - 'Bamu', - 'Bass', - 'Batk', - 'Beng', - 'Bhks', - 'Blis', - 'Bopo', - 'Brah', - 'Brai', - 'Bugi', - 'Buhd', - 'Cakm', - 'Cans', - 'Cari', - 'Cham', - 'Cher', - 'Cirt', - 'Copt', - 'Cprt', - 'Cyrl', - 'Cyrs', - 'Deva', - 'Dogr', - 'Dsrt', - 'Dupl', - 'Egyd', - 'Egyh', - 'Egyp', - 'Elba', - 'Elym', - 'Ethi', - 'Geok', - 'Geor', - 'Glag', - 'Gong', - 'Gonm', - 'Goth', - 'Gran', - 'Grek', - 'Gujr', - 'Guru', - 'Hanb', - 'Hang', - 'Hani', - 'Hano', - 'Hans', - 'Hant', - 'Hatr', - 'Hebr', - 'Hira', - 'Hluw', - 'Hmng', - 'Hmnp', - 'Hrkt', - 'Hung', - 'Inds', - 'Ital', - 'Jamo', - 'Java', - 'Jpan', - 'Jurc', - 'Kali', - 'Kana', - 'Khar', - 'Khmr', - 'Khoj', - 'Knda', - 'Kore', - 'Kpel', - 'Kthi', - 'Lana', - 'Laoo', - 'Latf', - 'Latg', - 'Latn', - 'Lepc', - 'Limb', - 'Lina', - 'Linb', - 'Lisu', - 'Loma', - 'Lyci', - 'Lydi', - 'Mahj', - 'Maka', - 'Mand', - 'Mani', - 'Marc', - 'Maya', - 'Medf', - 'Mend', - 'Merc', - 'Mero', - 'Mlym', - 'Modi', - 'Mong', - 'Moon', - 'Mroo', - 'Mtei', - 'Mult', - 'Mymr', - 'Nand', - 'Narb', - 'Nbat', - 'Newa', - 'Nkgb', - 'Nkoo', - 'Nshu', - 'Ogam', - 'Olck', - 'Orkh', - 'Orya', - 'Osge', - 'Osma', - 'Palm', - 'Pauc', - 'Perm', - 'Phag', - 'Phli', - 'Phlp', - 'Phlv', - 'Phnx', - 'Plrd', - 'Prti', - 'Qaag', - 'Rjng', - 'Rohg', - 'Roro', - 'Runr', - 'Samr', - 'Sara', - 'Sarb', - 'Saur', - 'Sgnw', - 'Shaw', - 'Shrd', - 'Sidd', - 'Sind', - 'Sinh', - 'Sogd', - 'Sogo', - 'Sora', - 'Soyo', - 'Sund', - 'Sylo', - 'Syrc', - 'Syre', - 'Syrj', - 'Syrn', - 'Tagb', - 'Takr', - 'Tale', - 'Talu', - 'Taml', - 'Tang', - 'Tavt', - 'Telu', - 'Teng', - 'Tfng', - 'Tglg', - 'Thaa', - 'Thai', - 'Tibt', - 'Tirh', - 'Ugar', - 'Vaii', - 'Visp', - 'Wara', - 'Wcho', - 'Wole', - 'Xpeo', - 'Xsux', - 'Yiii', - 'Zanb', - 'Zinh', - 'Zmth', - 'Zsye', - 'Zsym', - 'Zxxx', - 'Zyyy', - ]; - - /** - * @var ScriptDataProvider - */ - protected $dataProvider; - - protected function setUp() - { - parent::setUp(); - - $this->dataProvider = new ScriptDataProvider( - $this->getDataDirectory().'/'.Intl::SCRIPT_DIR, - $this->createEntryReader() - ); - } - - abstract protected function getDataDirectory(); - - public function testGetScripts() - { - $this->assertSame(static::$scripts, $this->dataProvider->getScripts()); - } - - /** - * @dataProvider provideLocales - */ - public function testGetNames($displayLocale) - { - $scripts = array_keys($this->dataProvider->getNames($displayLocale)); - - sort($scripts); - - // We can't assert on exact list of scripts, as there's too many variations between locales. - // The best we can do is to make sure getNames() returns a subset of what getScripts() returns. - $this->assertNotEmpty($scripts); - $this->assertEmpty(array_diff($scripts, self::$scripts)); - } - - public function testGetNamesDefaultLocale() - { - \Locale::setDefault('de_AT'); - - $this->assertSame( - $this->dataProvider->getNames('de_AT'), - $this->dataProvider->getNames() - ); - } - - /** - * @dataProvider provideLocaleAliases - */ - public function testGetNamesSupportsAliases($alias, $ofLocale) - { - // Can't use assertSame(), because some aliases contain scripts with - // different collation (=order of output) than their aliased locale - // e.g. sr_Latn_ME => sr_ME - $this->assertEquals( - $this->dataProvider->getNames($ofLocale), - $this->dataProvider->getNames($alias) - ); - } - - /** - * @dataProvider provideLocales - */ - public function testGetName($displayLocale) - { - $names = $this->dataProvider->getNames($displayLocale); - - foreach ($names as $script => $name) { - $this->assertSame($name, $this->dataProvider->getName($script, $displayLocale)); - } - } - - public function testGetNameDefaultLocale() - { - \Locale::setDefault('de_AT'); - - $names = $this->dataProvider->getNames('de_AT'); - - foreach ($names as $script => $name) { - $this->assertSame($name, $this->dataProvider->getName($script)); - } - } -} diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonCurrencyDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonCurrencyDataProviderTest.php deleted file mode 100644 index ff12edb44126b..0000000000000 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonCurrencyDataProviderTest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Tests\Data\Provider\Json; - -use Symfony\Component\Intl\Data\Bundle\Reader\BundleReaderInterface; -use Symfony\Component\Intl\Data\Bundle\Reader\JsonBundleReader; -use Symfony\Component\Intl\Intl; -use Symfony\Component\Intl\Tests\Data\Provider\AbstractCurrencyDataProviderTest; - -/** - * @author Bernhard Schussek - * @group intl-data - * @group legacy - */ -class JsonCurrencyDataProviderTest extends AbstractCurrencyDataProviderTest -{ - protected function getDataDirectory() - { - return Intl::getDataDirectory(); - } - - /** - * @return BundleReaderInterface - */ - protected function createBundleReader() - { - return new JsonBundleReader(); - } -} diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLanguageDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLanguageDataProviderTest.php deleted file mode 100644 index 74049ab53e13f..0000000000000 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLanguageDataProviderTest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Tests\Data\Provider\Json; - -use Symfony\Component\Intl\Data\Bundle\Reader\BundleReaderInterface; -use Symfony\Component\Intl\Data\Bundle\Reader\JsonBundleReader; -use Symfony\Component\Intl\Intl; -use Symfony\Component\Intl\Tests\Data\Provider\AbstractLanguageDataProviderTest; - -/** - * @author Bernhard Schussek - * @group intl-data - * @group legacy - */ -class JsonLanguageDataProviderTest extends AbstractLanguageDataProviderTest -{ - protected function getDataDirectory() - { - return Intl::getDataDirectory(); - } - - /** - * @return BundleReaderInterface - */ - protected function createBundleReader() - { - return new JsonBundleReader(); - } -} diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLocaleDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLocaleDataProviderTest.php deleted file mode 100644 index ba00439bdcea0..0000000000000 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonLocaleDataProviderTest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Tests\Data\Provider\Json; - -use Symfony\Component\Intl\Data\Bundle\Reader\BundleReaderInterface; -use Symfony\Component\Intl\Data\Bundle\Reader\JsonBundleReader; -use Symfony\Component\Intl\Intl; -use Symfony\Component\Intl\Tests\Data\Provider\AbstractLocaleDataProviderTest; - -/** - * @author Bernhard Schussek - * @group intl-data - * @group legacy - */ -class JsonLocaleDataProviderTest extends AbstractLocaleDataProviderTest -{ - protected function getDataDirectory() - { - return Intl::getDataDirectory(); - } - - /** - * @return BundleReaderInterface - */ - protected function createBundleReader() - { - return new JsonBundleReader(); - } -} diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonRegionDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonRegionDataProviderTest.php deleted file mode 100644 index 9bb3bba48917d..0000000000000 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonRegionDataProviderTest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Tests\Data\Provider\Json; - -use Symfony\Component\Intl\Data\Bundle\Reader\BundleReaderInterface; -use Symfony\Component\Intl\Data\Bundle\Reader\JsonBundleReader; -use Symfony\Component\Intl\Intl; -use Symfony\Component\Intl\Tests\Data\Provider\AbstractRegionDataProviderTest; - -/** - * @author Bernhard Schussek - * @group intl-data - * @group legacy - */ -class JsonRegionDataProviderTest extends AbstractRegionDataProviderTest -{ - protected function getDataDirectory() - { - return Intl::getDataDirectory(); - } - - /** - * @return BundleReaderInterface - */ - protected function createBundleReader() - { - return new JsonBundleReader(); - } -} diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonScriptDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonScriptDataProviderTest.php deleted file mode 100644 index 9648cbaca306f..0000000000000 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/Json/JsonScriptDataProviderTest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Tests\Data\Provider\Json; - -use Symfony\Component\Intl\Data\Bundle\Reader\BundleReaderInterface; -use Symfony\Component\Intl\Data\Bundle\Reader\JsonBundleReader; -use Symfony\Component\Intl\Intl; -use Symfony\Component\Intl\Tests\Data\Provider\AbstractScriptDataProviderTest; - -/** - * @author Bernhard Schussek - * @group intl-data - * @group legacy - */ -class JsonScriptDataProviderTest extends AbstractScriptDataProviderTest -{ - protected function getDataDirectory() - { - return Intl::getDataDirectory(); - } - - /** - * @return BundleReaderInterface - */ - protected function createBundleReader() - { - return new JsonBundleReader(); - } -} diff --git a/src/Symfony/Component/Intl/Tests/IntlTest.php b/src/Symfony/Component/Intl/Tests/IntlTest.php index fd8f294a3841e..b8d2c29e52117 100644 --- a/src/Symfony/Component/Intl/Tests/IntlTest.php +++ b/src/Symfony/Component/Intl/Tests/IntlTest.php @@ -24,38 +24,6 @@ public function testIsExtensionLoadedChecksIfIntlExtensionIsLoaded() $this->assertTrue(Intl::isExtensionLoaded()); } - /** - * @group legacy - */ - public function testGetCurrencyBundleCreatesTheCurrencyBundle() - { - $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\CurrencyBundleInterface', Intl::getCurrencyBundle()); - } - - /** - * @group legacy - */ - public function testGetLanguageBundleCreatesTheLanguageBundle() - { - $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\LanguageBundleInterface', Intl::getLanguageBundle()); - } - - /** - * @group legacy - */ - public function testGetLocaleBundleCreatesTheLocaleBundle() - { - $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\LocaleBundleInterface', Intl::getLocaleBundle()); - } - - /** - * @group legacy - */ - public function testGetRegionBundleCreatesTheRegionBundle() - { - $this->assertInstanceOf('Symfony\Component\Intl\ResourceBundle\RegionBundleInterface', Intl::getRegionBundle()); - } - public function testGetIcuVersionReadsTheVersionOfInstalledIcuLibrary() { $this->assertStringMatchesFormat('%d.%d', Intl::getIcuVersion()); @@ -75,23 +43,4 @@ public function testGetDataDirectoryReturnsThePathToIcuData() { $this->assertTrue(is_dir(Intl::getDataDirectory())); } - - /** - * @group legacy - * @requires extension intl - */ - public function testLocaleAliasesAreLoaded() - { - \Locale::setDefault('zh_TW'); - $countryNameZhTw = Intl::getRegionBundle()->getCountryName('AD'); - - \Locale::setDefault('zh_Hant_TW'); - $countryNameHantZhTw = Intl::getRegionBundle()->getCountryName('AD'); - - \Locale::setDefault('zh'); - $countryNameZh = Intl::getRegionBundle()->getCountryName('AD'); - - $this->assertSame($countryNameZhTw, $countryNameHantZhTw, 'zh_TW is an alias to zh_Hant_TW'); - $this->assertNotSame($countryNameZh, $countryNameZhTw, 'zh_TW does not fall back to zh'); - } } From b22cbf41c0f6b0258e97247e7222a10ba32f19a5 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Tue, 28 May 2019 15:53:42 -0400 Subject: [PATCH 015/588] Remove deprecated implementation of ChoiceLoaderInterface in intl forms --- .../Form/Extension/Core/Type/CountryType.php | 74 +------------------ .../Form/Extension/Core/Type/CurrencyType.php | 74 +------------------ .../Form/Extension/Core/Type/LanguageType.php | 74 +------------------ .../Form/Extension/Core/Type/LocaleType.php | 74 +------------------ .../Extension/Core/Type/CountryTypeTest.php | 11 --- .../Extension/Core/Type/CurrencyTypeTest.php | 11 --- .../Extension/Core/Type/LanguageTypeTest.php | 11 --- .../Extension/Core/Type/LocaleTypeTest.php | 11 --- 8 files changed, 4 insertions(+), 336 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php b/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php index e15cd01c22181..4072117a29a9c 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CountryType.php @@ -12,28 +12,13 @@ namespace Symfony\Component\Form\Extension\Core\Type; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\ChoiceList\ArrayChoiceList; -use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader; use Symfony\Component\Intl\Countries; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; -class CountryType extends AbstractType implements ChoiceLoaderInterface +class CountryType extends AbstractType { - /** - * Country loaded choice list. - * - * The choices are lazy loaded and generated from the Intl component. - * - * {@link \Symfony\Component\Intl\Intl::getRegionBundle()}. - * - * @var ArrayChoiceList - * - * @deprecated since Symfony 4.1 - */ - private $choiceList; - /** * {@inheritdoc} */ @@ -69,61 +54,4 @@ public function getBlockPrefix() { return 'country'; } - - /** - * {@inheritdoc} - * - * @deprecated since Symfony 4.1 - */ - public function loadChoiceList($value = null) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.', __METHOD__), E_USER_DEPRECATED); - - if (null !== $this->choiceList) { - return $this->choiceList; - } - - return $this->choiceList = new ArrayChoiceList(array_flip(Countries::getNames()), $value); - } - - /** - * {@inheritdoc} - * - * @deprecated since Symfony 4.1 - */ - public function loadChoicesForValues(array $values, $value = null) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.', __METHOD__), E_USER_DEPRECATED); - - // Optimize - $values = array_filter($values); - if (empty($values)) { - return []; - } - - return $this->loadChoiceList($value)->getChoicesForValues($values); - } - - /** - * {@inheritdoc} - * - * @deprecated since Symfony 4.1 - */ - public function loadValuesForChoices(array $choices, $value = null) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.', __METHOD__), E_USER_DEPRECATED); - - // Optimize - $choices = array_filter($choices); - if (empty($choices)) { - return []; - } - - // If no callable is set, choices are the same as values - if (null === $value) { - return $choices; - } - - return $this->loadChoiceList($value)->getValuesForChoices($choices); - } } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php b/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php index 486bdc7b20206..671991452ce4e 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php @@ -12,28 +12,13 @@ namespace Symfony\Component\Form\Extension\Core\Type; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\ChoiceList\ArrayChoiceList; -use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader; use Symfony\Component\Intl\Currencies; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; -class CurrencyType extends AbstractType implements ChoiceLoaderInterface +class CurrencyType extends AbstractType { - /** - * Currency loaded choice list. - * - * The choices are lazy loaded and generated from the Intl component. - * - * {@link \Symfony\Component\Intl\Intl::getCurrencyBundle()}. - * - * @var ArrayChoiceList - * - * @deprecated since Symfony 4.1 - */ - private $choiceList; - /** * {@inheritdoc} */ @@ -69,61 +54,4 @@ public function getBlockPrefix() { return 'currency'; } - - /** - * {@inheritdoc} - * - * @deprecated since Symfony 4.1 - */ - public function loadChoiceList($value = null) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.', __METHOD__), E_USER_DEPRECATED); - - if (null !== $this->choiceList) { - return $this->choiceList; - } - - return $this->choiceList = new ArrayChoiceList(array_flip(Currencies::getNames()), $value); - } - - /** - * {@inheritdoc} - * - * @deprecated since Symfony 4.1 - */ - public function loadChoicesForValues(array $values, $value = null) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.', __METHOD__), E_USER_DEPRECATED); - - // Optimize - $values = array_filter($values); - if (empty($values)) { - return []; - } - - return $this->loadChoiceList($value)->getChoicesForValues($values); - } - - /** - * {@inheritdoc} - * - * @deprecated since Symfony 4.1 - */ - public function loadValuesForChoices(array $choices, $value = null) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.', __METHOD__), E_USER_DEPRECATED); - - // Optimize - $choices = array_filter($choices); - if (empty($choices)) { - return []; - } - - // If no callable is set, choices are the same as values - if (null === $value) { - return $choices; - } - - return $this->loadChoiceList($value)->getValuesForChoices($choices); - } } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php b/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php index 4a0cbe1f8f459..dc8d43b0b1bad 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php @@ -12,28 +12,13 @@ namespace Symfony\Component\Form\Extension\Core\Type; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\ChoiceList\ArrayChoiceList; -use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader; use Symfony\Component\Intl\Languages; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; -class LanguageType extends AbstractType implements ChoiceLoaderInterface +class LanguageType extends AbstractType { - /** - * Language loaded choice list. - * - * The choices are lazy loaded and generated from the Intl component. - * - * {@link \Symfony\Component\Intl\Intl::getLanguageBundle()}. - * - * @var ArrayChoiceList - * - * @deprecated since Symfony 4.1 - */ - private $choiceList; - /** * {@inheritdoc} */ @@ -69,61 +54,4 @@ public function getBlockPrefix() { return 'language'; } - - /** - * {@inheritdoc} - * - * @deprecated since Symfony 4.1 - */ - public function loadChoiceList($value = null) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.', __METHOD__), E_USER_DEPRECATED); - - if (null !== $this->choiceList) { - return $this->choiceList; - } - - return $this->choiceList = new ArrayChoiceList(array_flip(Languages::getNames()), $value); - } - - /** - * {@inheritdoc} - * - * @deprecated since Symfony 4.1 - */ - public function loadChoicesForValues(array $values, $value = null) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.', __METHOD__), E_USER_DEPRECATED); - - // Optimize - $values = array_filter($values); - if (empty($values)) { - return []; - } - - return $this->loadChoiceList($value)->getChoicesForValues($values); - } - - /** - * {@inheritdoc} - * - * @deprecated since Symfony 4.1 - */ - public function loadValuesForChoices(array $choices, $value = null) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.', __METHOD__), E_USER_DEPRECATED); - - // Optimize - $choices = array_filter($choices); - if (empty($choices)) { - return []; - } - - // If no callable is set, choices are the same as values - if (null === $value) { - return $choices; - } - - return $this->loadChoiceList($value)->getValuesForChoices($choices); - } } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php b/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php index 41e016df1008b..b0a60161a40d9 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php @@ -12,28 +12,13 @@ namespace Symfony\Component\Form\Extension\Core\Type; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\ChoiceList\ArrayChoiceList; -use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Form\ChoiceList\Loader\IntlCallbackChoiceLoader; use Symfony\Component\Intl\Locales; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; -class LocaleType extends AbstractType implements ChoiceLoaderInterface +class LocaleType extends AbstractType { - /** - * Locale loaded choice list. - * - * The choices are lazy loaded and generated from the Intl component. - * - * {@link \Symfony\Component\Intl\Intl::getLocaleBundle()}. - * - * @var ArrayChoiceList - * - * @deprecated since Symfony 4.1 - */ - private $choiceList; - /** * {@inheritdoc} */ @@ -69,61 +54,4 @@ public function getBlockPrefix() { return 'locale'; } - - /** - * {@inheritdoc} - * - * @deprecated since Symfony 4.1 - */ - public function loadChoiceList($value = null) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.', __METHOD__), E_USER_DEPRECATED); - - if (null !== $this->choiceList) { - return $this->choiceList; - } - - return $this->choiceList = new ArrayChoiceList(array_flip(Locales::getNames()), $value); - } - - /** - * {@inheritdoc} - * - * @deprecated since Symfony 4.1 - */ - public function loadChoicesForValues(array $values, $value = null) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.', __METHOD__), E_USER_DEPRECATED); - - // Optimize - $values = array_filter($values); - if (empty($values)) { - return []; - } - - return $this->loadChoiceList($value)->getChoicesForValues($values); - } - - /** - * {@inheritdoc} - * - * @deprecated since Symfony 4.1 - */ - public function loadValuesForChoices(array $choices, $value = null) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.', __METHOD__), E_USER_DEPRECATED); - - // Optimize - $choices = array_filter($choices); - if (empty($choices)) { - return []; - } - - // If no callable is set, choices are the same as values - if (null === $value) { - return $choices; - } - - return $this->loadChoiceList($value)->getValuesForChoices($choices); - } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php index 8c72b46bbcd2e..388fd142aa085 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type; use Symfony\Component\Form\ChoiceList\View\ChoiceView; -use Symfony\Component\Form\Extension\Core\Type\CountryType; use Symfony\Component\Intl\Util\IntlTestHelper; class CountryTypeTest extends BaseTypeTest @@ -81,14 +80,4 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'FR', $expectedD { parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData); } - - /** - * @group legacy - */ - public function testInvalidChoiceValuesAreDropped() - { - $type = new CountryType(); - - $this->assertSame([], $type->loadChoicesForValues(['foo'])); - } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php index a02bae031add8..2cdcd03c6baf6 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type; use Symfony\Component\Form\ChoiceList\View\ChoiceView; -use Symfony\Component\Form\Extension\Core\Type\CurrencyType; use Symfony\Component\Intl\Util\IntlTestHelper; class CurrencyTypeTest extends BaseTypeTest @@ -62,14 +61,4 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'EUR', $expected { parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData); } - - /** - * @group legacy - */ - public function testInvalidChoiceValuesAreDropped() - { - $type = new CurrencyType(); - - $this->assertSame([], $type->loadChoicesForValues(['foo'])); - } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php index 7f25c8dab7772..618cf3b16ab95 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type; use Symfony\Component\Form\ChoiceList\View\ChoiceView; -use Symfony\Component\Form\Extension\Core\Type\LanguageType; use Symfony\Component\Intl\Util\IntlTestHelper; class LanguageTypeTest extends BaseTypeTest @@ -73,14 +72,4 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'en', $expectedD { parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData); } - - /** - * @group legacy - */ - public function testInvalidChoiceValuesAreDropped() - { - $type = new LanguageType(); - - $this->assertSame([], $type->loadChoicesForValues(['foo'])); - } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php index 484d9cede822b..866362bdc1348 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type; use Symfony\Component\Form\ChoiceList\View\ChoiceView; -use Symfony\Component\Form\Extension\Core\Type\LocaleType; use Symfony\Component\Intl\Util\IntlTestHelper; class LocaleTypeTest extends BaseTypeTest @@ -62,14 +61,4 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = 'en', $expectedD { parent::testSubmitNullUsesDefaultEmptyData($emptyData, $expectedData); } - - /** - * @group legacy - */ - public function testInvalidChoiceValuesAreDropped() - { - $type = new LocaleType(); - - $this->assertSame([], $type->loadChoicesForValues(['foo'])); - } } From 795f0fba91eea8811a211c45c986b6b5f7c3e0db Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Wed, 29 May 2019 15:09:14 +0200 Subject: [PATCH 016/588] [Security] Remove deprecated encoders --- .../DependencyInjection/SecurityExtension.php | 33 ----- .../CompleteConfigurationTest.php | 111 -------------- .../Fixtures/php/argon2i_encoder.php | 14 -- .../Fixtures/php/bcrypt_encoder.php | 12 -- .../Fixtures/xml/argon2i_encoder.xml | 16 -- .../Fixtures/xml/bcrypt_encoder.xml | 16 -- .../Fixtures/yml/argon2i_encoder.yml | 10 -- .../Fixtures/yml/bcrypt_encoder.yml | 8 - .../UserPasswordEncoderCommandTest.php | 92 ------------ .../Functional/app/PasswordEncode/argon2i.yml | 7 - .../Functional/app/PasswordEncode/bcrypt.yml | 7 - src/Symfony/Component/Security/CHANGELOG.md | 6 + .../Core/Encoder/Argon2iPasswordEncoder.php | 137 ------------------ .../Core/Encoder/BCryptPasswordEncoder.php | 87 ----------- .../Security/Core/Encoder/EncoderFactory.php | 18 --- .../Encoder/Argon2iPasswordEncoderTest.php | 72 --------- .../Encoder/BCryptPasswordEncoderTest.php | 92 ------------ .../Tests/Encoder/BasePasswordEncoderTest.php | 102 ------------- 18 files changed, 6 insertions(+), 834 deletions(-) delete mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/argon2i_encoder.php delete mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/bcrypt_encoder.php delete mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/argon2i_encoder.xml delete mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/bcrypt_encoder.xml delete mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/argon2i_encoder.yml delete mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/bcrypt_encoder.yml delete mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/argon2i.yml delete mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/bcrypt.yml delete mode 100644 src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php delete mode 100644 src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php delete mode 100644 src/Symfony/Component/Security/Core/Tests/Encoder/Argon2iPasswordEncoderTest.php delete mode 100644 src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php delete mode 100644 src/Symfony/Component/Security/Core/Tests/Encoder/BasePasswordEncoderTest.php diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index af4260f04c428..8cb11887429bd 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -29,7 +29,6 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; -use Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder; use Symfony\Component\Security\Core\Encoder\NativePasswordEncoder; use Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder; use Symfony\Component\Security\Core\User\UserProviderInterface; @@ -556,38 +555,6 @@ private function createEncoder($config, ContainerBuilder $container) ]; } - // bcrypt encoder - if ('bcrypt' === $config['algorithm']) { - @trigger_error('Configuring an encoder with "bcrypt" as algorithm is deprecated since Symfony 4.3, use "auto" instead.', E_USER_DEPRECATED); - - return [ - 'class' => 'Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder', - 'arguments' => [$config['cost'] ?? 13], - ]; - } - - // Argon2i encoder - if ('argon2i' === $config['algorithm']) { - @trigger_error('Configuring an encoder with "argon2i" as algorithm is deprecated since Symfony 4.3, use "auto" instead.', E_USER_DEPRECATED); - - if (!Argon2iPasswordEncoder::isSupported()) { - if (\extension_loaded('sodium') && !\defined('SODIUM_CRYPTO_PWHASH_SALTBYTES')) { - throw new InvalidConfigurationException('The installed libsodium version does not have support for Argon2i. Use "auto" instead.'); - } - - throw new InvalidConfigurationException('Argon2i algorithm is not supported. Install the libsodium extension or use "auto" instead.'); - } - - return [ - 'class' => 'Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder', - 'arguments' => [ - $config['memory_cost'], - $config['time_cost'], - $config['threads'], - ], - ]; - } - if ('native' === $config['algorithm']) { return [ 'class' => NativePasswordEncoder::class, diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index ef318946ce66c..87de35e131c0a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Security\Core\Authorization\AccessDecisionManager; -use Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder; use Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder; abstract class CompleteConfigurationTest extends TestCase @@ -377,116 +376,6 @@ public function testEncodersWithLibsodium() ]], $container->getDefinition('security.encoder_factory.generic')->getArguments()); } - /** - * @group legacy - * - * @expectedDeprecation Configuring an encoder with "argon2i" as algorithm is deprecated since Symfony 4.3, use "auto" instead. - */ - public function testEncodersWithArgon2i() - { - if (!Argon2iPasswordEncoder::isSupported()) { - $this->markTestSkipped('Argon2i algorithm is not supported.'); - } - - $container = $this->getContainer('argon2i_encoder'); - - $this->assertEquals([[ - 'JMS\FooBundle\Entity\User1' => [ - 'class' => 'Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder', - 'arguments' => [false], - ], - 'JMS\FooBundle\Entity\User2' => [ - 'algorithm' => 'sha1', - 'encode_as_base64' => false, - 'iterations' => 5, - 'hash_algorithm' => 'sha512', - 'key_length' => 40, - 'ignore_case' => false, - 'cost' => null, - 'memory_cost' => null, - 'time_cost' => null, - 'threads' => null, - ], - 'JMS\FooBundle\Entity\User3' => [ - 'algorithm' => 'md5', - 'hash_algorithm' => 'sha512', - 'key_length' => 40, - 'ignore_case' => false, - 'encode_as_base64' => true, - 'iterations' => 5000, - 'cost' => null, - 'memory_cost' => null, - 'time_cost' => null, - 'threads' => null, - ], - 'JMS\FooBundle\Entity\User4' => new Reference('security.encoder.foo'), - 'JMS\FooBundle\Entity\User5' => [ - 'class' => 'Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder', - 'arguments' => ['sha1', false, 5, 30], - ], - 'JMS\FooBundle\Entity\User6' => [ - 'class' => 'Symfony\Component\Security\Core\Encoder\NativePasswordEncoder', - 'arguments' => [8, 102400, 15], - ], - 'JMS\FooBundle\Entity\User7' => [ - 'class' => 'Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder', - 'arguments' => [256, 1, 2], - ], - ]], $container->getDefinition('security.encoder_factory.generic')->getArguments()); - } - - /** - * @group legacy - */ - public function testEncodersWithBCrypt() - { - $container = $this->getContainer('bcrypt_encoder'); - - $this->assertEquals([[ - 'JMS\FooBundle\Entity\User1' => [ - 'class' => 'Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder', - 'arguments' => [false], - ], - 'JMS\FooBundle\Entity\User2' => [ - 'algorithm' => 'sha1', - 'encode_as_base64' => false, - 'iterations' => 5, - 'hash_algorithm' => 'sha512', - 'key_length' => 40, - 'ignore_case' => false, - 'cost' => null, - 'memory_cost' => null, - 'time_cost' => null, - 'threads' => null, - ], - 'JMS\FooBundle\Entity\User3' => [ - 'algorithm' => 'md5', - 'hash_algorithm' => 'sha512', - 'key_length' => 40, - 'ignore_case' => false, - 'encode_as_base64' => true, - 'iterations' => 5000, - 'cost' => null, - 'memory_cost' => null, - 'time_cost' => null, - 'threads' => null, - ], - 'JMS\FooBundle\Entity\User4' => new Reference('security.encoder.foo'), - 'JMS\FooBundle\Entity\User5' => [ - 'class' => 'Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder', - 'arguments' => ['sha1', false, 5, 30], - ], - 'JMS\FooBundle\Entity\User6' => [ - 'class' => 'Symfony\Component\Security\Core\Encoder\NativePasswordEncoder', - 'arguments' => [8, 102400, 15], - ], - 'JMS\FooBundle\Entity\User7' => [ - 'class' => 'Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder', - 'arguments' => [15], - ], - ]], $container->getDefinition('security.encoder_factory.generic')->getArguments()); - } - public function testRememberMeThrowExceptionsDefault() { $container = $this->getContainer('container1'); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/argon2i_encoder.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/argon2i_encoder.php deleted file mode 100644 index 88543b7da95d9..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/argon2i_encoder.php +++ /dev/null @@ -1,14 +0,0 @@ -load('container1.php', $container); - -$container->loadFromExtension('security', [ - 'encoders' => [ - 'JMS\FooBundle\Entity\User7' => [ - 'algorithm' => 'argon2i', - 'memory_cost' => 256, - 'time_cost' => 1, - 'threads' => 2, - ], - ], -]); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/bcrypt_encoder.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/bcrypt_encoder.php deleted file mode 100644 index 1afad79e4fca3..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/bcrypt_encoder.php +++ /dev/null @@ -1,12 +0,0 @@ -load('container1.php', $container); - -$container->loadFromExtension('security', [ - 'encoders' => [ - 'JMS\FooBundle\Entity\User7' => [ - 'algorithm' => 'bcrypt', - 'cost' => 15, - ], - ], -]); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/argon2i_encoder.xml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/argon2i_encoder.xml deleted file mode 100644 index 21b0c27443822..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/argon2i_encoder.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/bcrypt_encoder.xml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/bcrypt_encoder.xml deleted file mode 100644 index a98400c5f043a..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/bcrypt_encoder.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/argon2i_encoder.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/argon2i_encoder.yml deleted file mode 100644 index 6abd4d079893e..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/argon2i_encoder.yml +++ /dev/null @@ -1,10 +0,0 @@ -imports: - - { resource: container1.yml } - -security: - encoders: - JMS\FooBundle\Entity\User7: - algorithm: argon2i - memory_cost: 256 - time_cost: 1 - threads: 2 diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/bcrypt_encoder.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/bcrypt_encoder.yml deleted file mode 100644 index 3f1a526215204..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/bcrypt_encoder.yml +++ /dev/null @@ -1,8 +0,0 @@ -imports: - - { resource: container1.yml } - -security: - encoders: - JMS\FooBundle\Entity\User7: - algorithm: bcrypt - cost: 15 diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php index 7e90562246228..724e2c29c68dd 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php @@ -15,8 +15,6 @@ use Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand; use Symfony\Component\Console\Application as ConsoleApplication; use Symfony\Component\Console\Tester\CommandTester; -use Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder; -use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder; use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface; use Symfony\Component\Security\Core\Encoder\NativePasswordEncoder; use Symfony\Component\Security\Core\Encoder\Pbkdf2PasswordEncoder; @@ -55,51 +53,6 @@ public function testEncodeNoPasswordNoInteraction() $this->assertEquals($statusCode, 1); } - /** - * @group legacy - */ - public function testEncodePasswordBcrypt() - { - $this->setupBcrypt(); - $this->passwordEncoderCommandTester->execute([ - 'command' => 'security:encode-password', - 'password' => 'password', - 'user-class' => 'Custom\Class\Bcrypt\User', - ], ['interactive' => false]); - - $output = $this->passwordEncoderCommandTester->getDisplay(); - $this->assertContains('Password encoding succeeded', $output); - - $encoder = new BCryptPasswordEncoder(17); - preg_match('# Encoded password\s{1,}([\w+\/$.]+={0,2})\s+#', $output, $matches); - $hash = $matches[1]; - $this->assertTrue($encoder->isPasswordValid($hash, 'password', null)); - } - - /** - * @group legacy - */ - public function testEncodePasswordArgon2i() - { - if (!Argon2iPasswordEncoder::isSupported()) { - $this->markTestSkipped('Argon2i algorithm not available.'); - } - $this->setupArgon2i(); - $this->passwordEncoderCommandTester->execute([ - 'command' => 'security:encode-password', - 'password' => 'password', - 'user-class' => 'Custom\Class\Argon2i\User', - ], ['interactive' => false]); - - $output = $this->passwordEncoderCommandTester->getDisplay(); - $this->assertContains('Password encoding succeeded', $output); - - $encoder = new Argon2iPasswordEncoder(); - preg_match('# Encoded password\s+(\$argon2id?\$[\w,=\$+\/]+={0,2})\s+#', $output, $matches); - $hash = $matches[1]; - $this->assertTrue($encoder->isPasswordValid($hash, 'password', null)); - } - public function testEncodePasswordNative() { $this->passwordEncoderCommandTester->execute([ @@ -195,25 +148,6 @@ public function testEncodePasswordNativeOutput() $this->assertNotContains(' Generated salt ', $this->passwordEncoderCommandTester->getDisplay()); } - /** - * @group legacy - */ - public function testEncodePasswordArgon2iOutput() - { - if (!Argon2iPasswordEncoder::isSupported()) { - $this->markTestSkipped('Argon2i algorithm not available.'); - } - - $this->setupArgon2i(); - $this->passwordEncoderCommandTester->execute([ - 'command' => 'security:encode-password', - 'password' => 'p@ssw0rd', - 'user-class' => 'Custom\Class\Argon2i\User', - ], ['interactive' => false]); - - $this->assertNotContains(' Generated salt ', $this->passwordEncoderCommandTester->getDisplay()); - } - public function testEncodePasswordSodiumOutput() { if (!SodiumPasswordEncoder::isSupported()) { @@ -310,32 +244,6 @@ protected function tearDown() $this->passwordEncoderCommandTester = null; } - private function setupArgon2i() - { - putenv('COLUMNS='.(119 + \strlen(PHP_EOL))); - $kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'argon2i.yml']); - $kernel->boot(); - - $application = new Application($kernel); - - $passwordEncoderCommand = $application->get('security:encode-password'); - - $this->passwordEncoderCommandTester = new CommandTester($passwordEncoderCommand); - } - - private function setupBcrypt() - { - putenv('COLUMNS='.(119 + \strlen(PHP_EOL))); - $kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'bcrypt.yml']); - $kernel->boot(); - - $application = new Application($kernel); - - $passwordEncoderCommand = $application->get('security:encode-password'); - - $this->passwordEncoderCommandTester = new CommandTester($passwordEncoderCommand); - } - private function setupSodium() { putenv('COLUMNS='.(119 + \strlen(PHP_EOL))); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/argon2i.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/argon2i.yml deleted file mode 100644 index 2ca4f3461a6e9..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/argon2i.yml +++ /dev/null @@ -1,7 +0,0 @@ -imports: - - { resource: config.yml } - -security: - encoders: - Custom\Class\Argon2i\User: - algorithm: argon2i diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/bcrypt.yml b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/bcrypt.yml deleted file mode 100644 index 1928c0400b722..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/PasswordEncode/bcrypt.yml +++ /dev/null @@ -1,7 +0,0 @@ -imports: - - { resource: config.yml } - -security: - encoders: - Custom\Class\Bcrypt\User: - algorithm: bcrypt diff --git a/src/Symfony/Component/Security/CHANGELOG.md b/src/Symfony/Component/Security/CHANGELOG.md index 24d15f7e78467..b6d47712bdf06 100644 --- a/src/Symfony/Component/Security/CHANGELOG.md +++ b/src/Symfony/Component/Security/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +5.0.0 +----- + +* Removed `Argon2iPasswordEncoder`, use `SodiumPasswordEncoder` instead +* Removed `BcryptPasswordEncoder`, use `NativePasswordEncoder` instead + 4.3.0 ----- diff --git a/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php deleted file mode 100644 index d63722c1ec0ae..0000000000000 --- a/src/Symfony/Component/Security/Core/Encoder/Argon2iPasswordEncoder.php +++ /dev/null @@ -1,137 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Encoder; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" instead.', Argon2iPasswordEncoder::class, SodiumPasswordEncoder::class), E_USER_DEPRECATED); - -use Symfony\Component\Security\Core\Exception\BadCredentialsException; - -/** - * Argon2iPasswordEncoder uses the Argon2i hashing algorithm. - * - * @author Zan Baldwin - * @author Dominik Müller - * - * @deprecated since Symfony 4.3, use SodiumPasswordEncoder instead - */ -class Argon2iPasswordEncoder extends BasePasswordEncoder implements SelfSaltingEncoderInterface -{ - private $config = []; - - /** - * Argon2iPasswordEncoder constructor. - * - * @param int|null $memoryCost memory usage of the algorithm - * @param int|null $timeCost number of iterations - * @param int|null $threads number of parallel threads - */ - public function __construct(int $memoryCost = null, int $timeCost = null, int $threads = null) - { - if (\defined('PASSWORD_ARGON2I')) { - $this->config = [ - 'memory_cost' => $memoryCost ?? \PASSWORD_ARGON2_DEFAULT_MEMORY_COST, - 'time_cost' => $timeCost ?? \PASSWORD_ARGON2_DEFAULT_TIME_COST, - 'threads' => $threads ?? \PASSWORD_ARGON2_DEFAULT_THREADS, - ]; - } - } - - public static function isSupported() - { - if (\defined('PASSWORD_ARGON2I')) { - return true; - } - - if (\class_exists('ParagonIE_Sodium_Compat') && \method_exists('ParagonIE_Sodium_Compat', 'crypto_pwhash_is_available')) { - return \ParagonIE_Sodium_Compat::crypto_pwhash_is_available(); - } - - return \function_exists('sodium_crypto_pwhash_str') || \extension_loaded('libsodium'); - } - - /** - * {@inheritdoc} - */ - public function encodePassword($raw, $salt) - { - if ($this->isPasswordTooLong($raw)) { - throw new BadCredentialsException('Invalid password.'); - } - - if (\defined('PASSWORD_ARGON2I')) { - return $this->encodePasswordNative($raw); - } - if (\function_exists('sodium_crypto_pwhash_str')) { - return $this->encodePasswordSodiumFunction($raw); - } - if (\extension_loaded('libsodium')) { - return $this->encodePasswordSodiumExtension($raw); - } - - throw new \LogicException('Argon2i algorithm is not supported. Please install the libsodium extension or upgrade to PHP 7.2+.'); - } - - /** - * {@inheritdoc} - */ - public function isPasswordValid($encoded, $raw, $salt) - { - // If $encoded was created via "sodium_crypto_pwhash_str()", the hashing algorithm may be "argon2id" instead of "argon2i". - // In this case, "password_verify()" cannot be used. - if (\defined('PASSWORD_ARGON2I') && (false === strpos($encoded, '$argon2id$'))) { - return !$this->isPasswordTooLong($raw) && password_verify($raw, $encoded); - } - if (\function_exists('sodium_crypto_pwhash_str_verify')) { - $valid = !$this->isPasswordTooLong($raw) && \sodium_crypto_pwhash_str_verify($encoded, $raw); - \sodium_memzero($raw); - - return $valid; - } - if (\extension_loaded('libsodium')) { - $valid = !$this->isPasswordTooLong($raw) && \Sodium\crypto_pwhash_str_verify($encoded, $raw); - \Sodium\memzero($raw); - - return $valid; - } - - throw new \LogicException('Argon2i algorithm is not supported. Please install the libsodium extension or upgrade to PHP 7.2+.'); - } - - private function encodePasswordNative($raw) - { - return password_hash($raw, \PASSWORD_ARGON2I, $this->config); - } - - private function encodePasswordSodiumFunction($raw) - { - $hash = \sodium_crypto_pwhash_str( - $raw, - \SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE, - \SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE - ); - \sodium_memzero($raw); - - return $hash; - } - - private function encodePasswordSodiumExtension($raw) - { - $hash = \Sodium\crypto_pwhash_str( - $raw, - \Sodium\CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE, - \Sodium\CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE - ); - \Sodium\memzero($raw); - - return $hash; - } -} diff --git a/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php b/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php deleted file mode 100644 index d14949465c0ee..0000000000000 --- a/src/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Encoder; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" instead.', BCryptPasswordEncoder::class, NativePasswordEncoder::class), E_USER_DEPRECATED); - -use Symfony\Component\Security\Core\Exception\BadCredentialsException; - -/** - * @author Elnur Abdurrakhimov - * @author Terje Bråten - * - * @deprecated since Symfony 4.3, use NativePasswordEncoder instead - */ -class BCryptPasswordEncoder extends BasePasswordEncoder implements SelfSaltingEncoderInterface -{ - const MAX_PASSWORD_LENGTH = 72; - - private $cost; - - /** - * @param int $cost The algorithmic cost that should be used - * - * @throws \RuntimeException When no BCrypt encoder is available - * @throws \InvalidArgumentException if cost is out of range - */ - public function __construct(int $cost) - { - if ($cost < 4 || $cost > 31) { - throw new \InvalidArgumentException('Cost must be in the range of 4-31.'); - } - - $this->cost = $cost; - } - - /** - * Encodes the raw password. - * - * It doesn't work with PHP versions lower than 5.3.7, since - * the password compat library uses CRYPT_BLOWFISH hash type with - * the "$2y$" salt prefix (which is not available in the early PHP versions). - * - * @see https://github.com/ircmaxell/password_compat/issues/10#issuecomment-11203833 - * - * It is almost best to **not** pass a salt and let PHP generate one for you. - * - * @param string $raw The password to encode - * @param string $salt The salt - * - * @return string The encoded password - * - * @throws BadCredentialsException when the given password is too long - * - * @see http://lxr.php.net/xref/PHP_5_5/ext/standard/password.c#111 - */ - public function encodePassword($raw, $salt) - { - if ($this->isPasswordTooLong($raw)) { - throw new BadCredentialsException('Invalid password.'); - } - - $options = ['cost' => $this->cost]; - - if ($salt) { - // Ignore $salt, the auto-generated one is always the best - } - - return password_hash($raw, PASSWORD_BCRYPT, $options); - } - - /** - * {@inheritdoc} - */ - public function isPasswordValid($encoded, $raw, $salt) - { - return !$this->isPasswordTooLong($raw) && password_verify($raw, $encoded); - } -} diff --git a/src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php b/src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php index 150190dc4c161..dea910a277d08 100644 --- a/src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php +++ b/src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php @@ -106,13 +106,6 @@ private function getEncoderConfigFromAlgorithm($config) ], ]; - /* @deprecated since Symfony 4.3 */ - case 'bcrypt': - return [ - 'class' => BCryptPasswordEncoder::class, - 'arguments' => [$config['cost']], - ]; - case 'native': return [ 'class' => NativePasswordEncoder::class, @@ -131,17 +124,6 @@ private function getEncoderConfigFromAlgorithm($config) (($config['memory_cost'] ?? 0) << 10) ?: null, ], ]; - - /* @deprecated since Symfony 4.3 */ - case 'argon2i': - return [ - 'class' => Argon2iPasswordEncoder::class, - 'arguments' => [ - $config['memory_cost'], - $config['time_cost'], - $config['threads'], - ], - ]; } return [ diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/Argon2iPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/Argon2iPasswordEncoderTest.php deleted file mode 100644 index a9991749f01fd..0000000000000 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/Argon2iPasswordEncoderTest.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Tests\Encoder; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder; - -/** - * @author Zan Baldwin - * - * @group legacy - */ -class Argon2iPasswordEncoderTest extends TestCase -{ - const PASSWORD = 'password'; - - protected function setUp() - { - if (!Argon2iPasswordEncoder::isSupported()) { - $this->markTestSkipped('Argon2i algorithm is not supported.'); - } - } - - public function testValidationWithConfig() - { - $encoder = new Argon2iPasswordEncoder(8, 4, 1); - $result = $encoder->encodePassword(self::PASSWORD, null); - $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null)); - $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null)); - } - - public function testValidation() - { - $encoder = new Argon2iPasswordEncoder(); - $result = $encoder->encodePassword(self::PASSWORD, null); - $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null)); - $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null)); - } - - /** - * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException - */ - public function testEncodePasswordLength() - { - $encoder = new Argon2iPasswordEncoder(); - $encoder->encodePassword(str_repeat('a', 4097), 'salt'); - } - - public function testCheckPasswordLength() - { - $encoder = new Argon2iPasswordEncoder(); - $result = $encoder->encodePassword(str_repeat('a', 4096), null); - $this->assertFalse($encoder->isPasswordValid($result, str_repeat('a', 4097), null)); - $this->assertTrue($encoder->isPasswordValid($result, str_repeat('a', 4096), null)); - } - - public function testUserProvidedSaltIsNotUsed() - { - $encoder = new Argon2iPasswordEncoder(); - $result = $encoder->encodePassword(self::PASSWORD, 'salt'); - $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, 'anotherSalt')); - } -} diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php deleted file mode 100644 index 4e8fcde7b0692..0000000000000 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php +++ /dev/null @@ -1,92 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Tests\Encoder; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder; - -/** - * @author Elnur Abdurrakhimov - * - * @group legacy - */ -class BCryptPasswordEncoderTest extends TestCase -{ - const PASSWORD = 'password'; - const VALID_COST = '04'; - - /** - * @expectedException \InvalidArgumentException - */ - public function testCostBelowRange() - { - new BCryptPasswordEncoder(3); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testCostAboveRange() - { - new BCryptPasswordEncoder(32); - } - - /** - * @dataProvider validRangeData - */ - public function testCostInRange($cost) - { - $this->assertInstanceOf('Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder', new BCryptPasswordEncoder($cost)); - } - - public function validRangeData() - { - $costs = range(4, 31); - array_walk($costs, function (&$cost) { $cost = [$cost]; }); - - return $costs; - } - - public function testResultLength() - { - $encoder = new BCryptPasswordEncoder(self::VALID_COST); - $result = $encoder->encodePassword(self::PASSWORD, null); - $this->assertEquals(60, \strlen($result)); - } - - public function testValidation() - { - $encoder = new BCryptPasswordEncoder(self::VALID_COST); - $result = $encoder->encodePassword(self::PASSWORD, null); - $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null)); - $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null)); - } - - /** - * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException - */ - public function testEncodePasswordLength() - { - $encoder = new BCryptPasswordEncoder(self::VALID_COST); - - $encoder->encodePassword(str_repeat('a', 73), 'salt'); - } - - public function testCheckPasswordLength() - { - $encoder = new BCryptPasswordEncoder(self::VALID_COST); - $result = $encoder->encodePassword(str_repeat('a', 72), null); - - $this->assertFalse($encoder->isPasswordValid($result, str_repeat('a', 73), 'salt')); - $this->assertTrue($encoder->isPasswordValid($result, str_repeat('a', 72), 'salt')); - } -} diff --git a/src/Symfony/Component/Security/Core/Tests/Encoder/BasePasswordEncoderTest.php b/src/Symfony/Component/Security/Core/Tests/Encoder/BasePasswordEncoderTest.php deleted file mode 100644 index 2251cfdf906e0..0000000000000 --- a/src/Symfony/Component/Security/Core/Tests/Encoder/BasePasswordEncoderTest.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Tests\Encoder; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Security\Core\Encoder\BasePasswordEncoder; - -class PasswordEncoder extends BasePasswordEncoder -{ - public function encodePassword($raw, $salt) - { - } - - public function isPasswordValid($encoded, $raw, $salt) - { - } -} - -class BasePasswordEncoderTest extends TestCase -{ - public function testComparePassword() - { - $this->assertTrue($this->invokeComparePasswords('password', 'password')); - $this->assertFalse($this->invokeComparePasswords('password', 'foo')); - } - - public function testDemergePasswordAndSalt() - { - $this->assertEquals(['password', 'salt'], $this->invokeDemergePasswordAndSalt('password{salt}')); - $this->assertEquals(['password', ''], $this->invokeDemergePasswordAndSalt('password')); - $this->assertEquals(['', ''], $this->invokeDemergePasswordAndSalt('')); - } - - public function testMergePasswordAndSalt() - { - $this->assertEquals('password{salt}', $this->invokeMergePasswordAndSalt('password', 'salt')); - $this->assertEquals('password', $this->invokeMergePasswordAndSalt('password', '')); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testMergePasswordAndSaltWithException() - { - $this->invokeMergePasswordAndSalt('password', '{foo}'); - } - - public function testIsPasswordTooLong() - { - $this->assertTrue($this->invokeIsPasswordTooLong(str_repeat('a', 10000))); - $this->assertFalse($this->invokeIsPasswordTooLong(str_repeat('a', 10))); - } - - protected function invokeDemergePasswordAndSalt($password) - { - $encoder = new PasswordEncoder(); - $r = new \ReflectionObject($encoder); - $m = $r->getMethod('demergePasswordAndSalt'); - $m->setAccessible(true); - - return $m->invoke($encoder, $password); - } - - protected function invokeMergePasswordAndSalt($password, $salt) - { - $encoder = new PasswordEncoder(); - $r = new \ReflectionObject($encoder); - $m = $r->getMethod('mergePasswordAndSalt'); - $m->setAccessible(true); - - return $m->invoke($encoder, $password, $salt); - } - - protected function invokeComparePasswords($p1, $p2) - { - $encoder = new PasswordEncoder(); - $r = new \ReflectionObject($encoder); - $m = $r->getMethod('comparePasswords'); - $m->setAccessible(true); - - return $m->invoke($encoder, $p1, $p2); - } - - protected function invokeIsPasswordTooLong($p) - { - $encoder = new PasswordEncoder(); - $r = new \ReflectionObject($encoder); - $m = $r->getMethod('isPasswordTooLong'); - $m->setAccessible(true); - - return $m->invoke($encoder, $p); - } -} From 5ab6ad409d14689067cdbf997f2e1e6d9cf9fc8c Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Wed, 29 May 2019 16:33:29 +0200 Subject: [PATCH 017/588] [Serializer] Throw exception on invalid normalizers/encoders passed to Serializer --- src/Symfony/Component/Serializer/CHANGELOG.md | 6 ++++++ src/Symfony/Component/Serializer/Serializer.php | 7 +++---- .../Component/Serializer/Tests/SerializerTest.php | 12 ++++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/Serializer/CHANGELOG.md b/src/Symfony/Component/Serializer/CHANGELOG.md index 4bfd664f0aa87..9cdb2243bee8b 100644 --- a/src/Symfony/Component/Serializer/CHANGELOG.md +++ b/src/Symfony/Component/Serializer/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +5.0.0 +----- + + * throw an exception when creating a `Serializer` with normalizers which neither implement `NormalizerInterface` nor `DenormalizerInterface` + * throw an exception when creating a `Serializer` with encoders which neither implement `EncoderInterface` nor `DecoderInterface` + 4.3.0 ----- diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index b950ba58b0a19..01b0f3c3a768e 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -17,6 +17,7 @@ use Symfony\Component\Serializer\Encoder\ContextAwareEncoderInterface; use Symfony\Component\Serializer\Encoder\DecoderInterface; use Symfony\Component\Serializer\Encoder\EncoderInterface; +use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Exception\LogicException; use Symfony\Component\Serializer\Exception\NotEncodableValueException; use Symfony\Component\Serializer\Exception\NotNormalizableValueException; @@ -84,8 +85,7 @@ public function __construct(array $normalizers = [], array $encoders = []) } if (!($normalizer instanceof NormalizerInterface || $normalizer instanceof DenormalizerInterface)) { - @trigger_error(\sprintf('Passing normalizers ("%s") which do not implement either "%s" or "%s" has been deprecated since Symfony 4.2.', \get_class($normalizer), NormalizerInterface::class, DenormalizerInterface::class), E_USER_DEPRECATED); - // throw new \InvalidArgumentException(\sprintf('The class "%s" does not implement "%s" or "%s".', \get_class($normalizer), NormalizerInterface::class, DenormalizerInterface::class)); + throw new InvalidArgumentException(\sprintf('The class "%s" neither implements "%s" nor "%s".', \get_class($normalizer), NormalizerInterface::class, DenormalizerInterface::class)); } } $this->normalizers = $normalizers; @@ -104,8 +104,7 @@ public function __construct(array $normalizers = [], array $encoders = []) } if (!($encoder instanceof EncoderInterface || $encoder instanceof DecoderInterface)) { - @trigger_error(\sprintf('Passing encoders ("%s") which do not implement either "%s" or "%s" has been deprecated since Symfony 4.2.', \get_class($encoder), EncoderInterface::class, DecoderInterface::class), E_USER_DEPRECATED); - // throw new \InvalidArgumentException(\sprintf('The class "%s" does not implement "%s" or "%s".', \get_class($normalizer), EncoderInterface::class, DecoderInterface::class)); + throw new InvalidArgumentException(\sprintf('The class "%s" neither implements "%s" nor "%s".', \get_class($encoder), EncoderInterface::class, DecoderInterface::class)); } } $this->encoder = new ChainEncoder($realEncoders); diff --git a/src/Symfony/Component/Serializer/Tests/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php index ce6be57f3396c..2d7650b64631f 100644 --- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php +++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php @@ -56,19 +56,19 @@ public function testInterface() } /** - * @expectedDeprecation Passing normalizers ("stdClass") which do not implement either "Symfony\Component\Serializer\Normalizer\NormalizerInterface" or "Symfony\Component\Serializer\Normalizer\DenormalizerInterface" has been deprecated since Symfony 4.2. - * @group legacy + * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException + * @expectedExceptionMessage The class "stdClass" neither implements "Symfony\Component\Serializer\Normalizer\NormalizerInterface" nor "Symfony\Component\Serializer\Normalizer\DenormalizerInterface". */ - public function testDeprecationErrorOnInvalidNormalizer() + public function testItThrowsExceptionOnInvalidNormalizer() { new Serializer([new \stdClass()]); } /** - * @expectedDeprecation Passing encoders ("stdClass") which do not implement either "Symfony\Component\Serializer\Encoder\EncoderInterface" or "Symfony\Component\Serializer\Encoder\DecoderInterface" has been deprecated since Symfony 4.2. - * @group legacy + * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException + * @expectedExceptionMessage The class "stdClass" neither implements "Symfony\Component\Serializer\Encoder\EncoderInterface" nor "Symfony\Component\Serializer\Encoder\DecoderInterface" */ - public function testDeprecationErrorOnInvalidEncoder() + public function testItThrowsExceptionOnInvalidEncoder() { new Serializer([], [new \stdClass()]); } From 9a816b59f79fb97edb93dec402eb8301de08ede8 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Wed, 29 May 2019 17:44:56 +0200 Subject: [PATCH 018/588] [SecurityBundle] minor: add missing changelog entry --- src/Symfony/Bundle/SecurityBundle/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md index e26a56b788847..5d30a2d803f03 100644 --- a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.0.0 +----- + +* Deprecated configuring encoders using `argon2i` or `bcrypt` as algorithm, use `auto` instead + 4.3.0 ----- From 880d1d8690bcccaaa21d79a7410d7def6ac73084 Mon Sep 17 00:00:00 2001 From: Amrouche Hamza Date: Wed, 29 May 2019 18:41:13 +0200 Subject: [PATCH 019/588] [Messenger] add the changelog entry about LoggingMiddleware --- src/Symfony/Component/Messenger/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Symfony/Component/Messenger/CHANGELOG.md b/src/Symfony/Component/Messenger/CHANGELOG.md index 49d04feb1f276..400991ecdb8e5 100644 --- a/src/Symfony/Component/Messenger/CHANGELOG.md +++ b/src/Symfony/Component/Messenger/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.0.0 +----- + + * The `LoggingMiddleware` class has been removed, pass a logger to `SendMessageMiddleware` instead. + 4.3.0 ----- From ee3650bad44f8a45822ff1d128902cbc04fb98bf Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Wed, 29 May 2019 12:42:27 -0400 Subject: [PATCH 020/588] Add missing changelog entries from previous PRs --- src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md | 5 +++++ src/Symfony/Bundle/TwigBundle/CHANGELOG.md | 5 +++++ src/Symfony/Component/Form/CHANGELOG.md | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index d32da9541ac5b..bd0f32bfbff57 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.0.0 +----- + + * Removed support to load translation resources from the legacy directories `src/Resources/translations/` and `src/Resources//translations/` + 4.3.0 ----- diff --git a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md index 1be455e4e8288..7a9d02e29a1a0 100644 --- a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.0.0 +----- + + * updated default value for the `strict_variables` option to `%kernel.debug%` parameter + 4.2.0 ----- diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index e41c46e907a89..65cec5df04e03 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.0.0 +----- + + * removed the `ChoiceLoaderInterface` implementation in `CountryType`, `LanguageType`, `LocaleType` and `CurrencyType` + 4.3.0 ----- From 6183d2b84c0aed600347ac6f246fdd72f2d860e5 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Wed, 29 May 2019 18:50:53 +0200 Subject: [PATCH 021/588] [5.0] Update CHANGELOG.md --- src/Symfony/Component/HttpKernel/CHANGELOG.md | 7 +++++++ src/Symfony/Component/Intl/CHANGELOG.md | 5 +++++ src/Symfony/Component/Validator/CHANGELOG.md | 9 +++++++++ 3 files changed, 21 insertions(+) diff --git a/src/Symfony/Component/HttpKernel/CHANGELOG.md b/src/Symfony/Component/HttpKernel/CHANGELOG.md index b1a5f5101b41d..7ca3f8ed9afaf 100644 --- a/src/Symfony/Component/HttpKernel/CHANGELOG.md +++ b/src/Symfony/Component/HttpKernel/CHANGELOG.md @@ -1,6 +1,13 @@ CHANGELOG ========= +5.0.0 +----- + + * removed the first and second constructor argument of `ConfigDataCollector` + * removed `ConfigDataCollector::getApplicationName()` + * removed `ConfigDataCollector::getApplicationVersion()` + 4.3.0 ----- diff --git a/src/Symfony/Component/Intl/CHANGELOG.md b/src/Symfony/Component/Intl/CHANGELOG.md index 930e5c345a666..623eba448f223 100644 --- a/src/Symfony/Component/Intl/CHANGELOG.md +++ b/src/Symfony/Component/Intl/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.0.0 +----- + + * removed `ResourceBundle` namespace + 4.3.0 ----- diff --git a/src/Symfony/Component/Validator/CHANGELOG.md b/src/Symfony/Component/Validator/CHANGELOG.md index 237dc68147b84..cc29d5f45d3aa 100644 --- a/src/Symfony/Component/Validator/CHANGELOG.md +++ b/src/Symfony/Component/Validator/CHANGELOG.md @@ -1,6 +1,15 @@ CHANGELOG ========= +5.0.0 +----- + + * removed the `checkDNS` and `dnsMessage` options of the `Url` constraint + * removed support for validating instances of `\DateTimeInterface` in `DateTimeValidator`, `DateValidator` and `TimeValidator` + * removed support for using the `Bic`, `Country`, `Currency`, `Language` and `Locale` constraints without `symfony/intl` + * removed support for using the `Email` constraint without `egulias/email-validator` + * removed support for using the `Expression` constraint without `symfony/expression-language` + 4.3.0 ----- From 22dd071b03afe3439733bcaace73937b178e2b38 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Wed, 29 May 2019 11:49:47 +0200 Subject: [PATCH 022/588] [Serializer] Remove CsvEncoder "as_collection" deprecation & change default value --- UPGRADE-5.0.md | 1 + src/Symfony/Component/Serializer/CHANGELOG.md | 1 + .../Serializer/Encoder/CsvEncoder.php | 12 ++++------ .../Tests/Encoder/CsvEncoderTest.php | 24 ++----------------- 4 files changed, 9 insertions(+), 29 deletions(-) diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 74c8bd4580609..e6222abe89405 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -382,6 +382,7 @@ SecurityBundle Serializer ---------- + * The default value of the `CsvEncoder` "as_collection" option was changed to `true`. * The `AbstractNormalizer::handleCircularReference()` method has two new `$format` and `$context` arguments. Translation diff --git a/src/Symfony/Component/Serializer/CHANGELOG.md b/src/Symfony/Component/Serializer/CHANGELOG.md index 9cdb2243bee8b..4b05d8af94ece 100644 --- a/src/Symfony/Component/Serializer/CHANGELOG.md +++ b/src/Symfony/Component/Serializer/CHANGELOG.md @@ -6,6 +6,7 @@ CHANGELOG * throw an exception when creating a `Serializer` with normalizers which neither implement `NormalizerInterface` nor `DenormalizerInterface` * throw an exception when creating a `Serializer` with encoders which neither implement `EncoderInterface` nor `DecoderInterface` + * changed the default value of the `CsvEncoder` "as_collection" option to `true` 4.3.0 ----- diff --git a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php index 123ecf7dd14ad..c35107d58357f 100644 --- a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php @@ -33,6 +33,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface private $formulasStartCharacters = ['=', '-', '+', '@']; private $defaultContext = [ + self::AS_COLLECTION_KEY => true, self::DELIMITER_KEY => ',', self::ENCLOSURE_KEY => '"', self::ESCAPE_CHAR_KEY => '\\', @@ -135,7 +136,7 @@ public function decode($data, $format, array $context = []) $headerCount = []; $result = []; - list($delimiter, $enclosure, $escapeChar, $keySeparator) = $this->getCsvOptions($context); + list($delimiter, $enclosure, $escapeChar, $keySeparator, , , $asCollection) = $this->getCsvOptions($context); while (false !== ($cols = fgetcsv($handle, 0, $delimiter, $enclosure, $escapeChar))) { $nbCols = \count($cols); @@ -183,7 +184,7 @@ public function decode($data, $format, array $context = []) } fclose($handle); - if ($context[self::AS_COLLECTION_KEY] ?? false) { + if ($asCollection) { return $result; } @@ -191,10 +192,6 @@ public function decode($data, $format, array $context = []) return $result; } - if (!isset($context['as_collection'])) { - @trigger_error('Relying on the default value (false) of the "as_collection" option is deprecated since 4.2. You should set it to false explicitly instead as true will be the default value in 5.0.', E_USER_DEPRECATED); - } - // If there is only one data line in the document, return it (the line), the result is not considered as a collection return $result[0]; } @@ -233,12 +230,13 @@ private function getCsvOptions(array $context): array $keySeparator = $context[self::KEY_SEPARATOR_KEY] ?? $this->defaultContext[self::KEY_SEPARATOR_KEY]; $headers = $context[self::HEADERS_KEY] ?? $this->defaultContext[self::HEADERS_KEY]; $escapeFormulas = $context[self::ESCAPE_FORMULAS_KEY] ?? $this->defaultContext[self::ESCAPE_FORMULAS_KEY]; + $asCollection = $context[self::AS_COLLECTION_KEY] ?? $this->defaultContext[self::AS_COLLECTION_KEY]; if (!\is_array($headers)) { throw new InvalidArgumentException(sprintf('The "%s" context variable must be an array or null, given "%s".', self::HEADERS_KEY, \gettype($headers))); } - return [$delimiter, $enclosure, $escapeChar, $keySeparator, $headers, $escapeFormulas]; + return [$delimiter, $enclosure, $escapeChar, $keySeparator, $headers, $escapeFormulas, $asCollection]; } /** diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php index 74235c46c1d16..52c4a9b5c4d5b 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php @@ -327,21 +327,6 @@ public function testSupportsDecoding() $this->assertFalse($this->encoder->supportsDecoding('foo')); } - /** - * @group legacy - * @expectedDeprecation Relying on the default value (false) of the "as_collection" option is deprecated since 4.2. You should set it to false explicitly instead as true will be the default value in 5.0. - */ - public function testDecodeLegacy() - { - $expected = ['foo' => 'a', 'bar' => 'b']; - - $this->assertEquals($expected, $this->encoder->decode(<<<'CSV' -foo,bar -a,b -CSV - , 'csv')); - } - public function testDecodeAsSingle() { $expected = ['foo' => 'a', 'bar' => 'b']; @@ -382,9 +367,7 @@ public function testDecode() a CSV - , 'csv', [ - CsvEncoder::AS_COLLECTION_KEY => true, // Can be removed in 5.0 - ])); + , 'csv')); } public function testDecodeToManyRelation() @@ -449,9 +432,7 @@ private function doTestDecodeCustomSettings(bool $legacy = false) a;bar-baz 'hell''o';b;c CSV - , 'csv', [ - CsvEncoder::AS_COLLECTION_KEY => true, // Can be removed in 5.0 - ])); + , 'csv')); } public function testDecodeCustomSettingsPassedInContext() @@ -466,7 +447,6 @@ public function testDecodeCustomSettingsPassedInContext() CsvEncoder::ENCLOSURE_KEY => "'", CsvEncoder::ESCAPE_CHAR_KEY => '|', CsvEncoder::KEY_SEPARATOR_KEY => '-', - CsvEncoder::AS_COLLECTION_KEY => true, // Can be removed in 5.0 ])); } From 208b729bca4371d513129e7f353a8e61fb0609fa Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Wed, 29 May 2019 14:05:02 -0400 Subject: [PATCH 023/588] Remove legacy code related to getExtendedType() method --- .../Component/Form/AbstractExtension.php | 13 +-- .../Component/Form/AbstractTypeExtension.php | 19 ----- src/Symfony/Component/Form/CHANGELOG.md | 2 + .../Form/DependencyInjection/FormPass.php | 9 +-- .../DependencyInjectionExtension.php | 13 +-- .../Component/Form/FormFactoryBuilder.php | 8 +- .../Form/FormTypeExtensionInterface.php | 10 +-- .../Component/Form/PreloadedExtension.php | 8 -- .../Form/Tests/AbstractTypeExtensionTest.php | 53 ------------ .../DependencyInjection/FormPassTest.php | 81 ------------------- .../Type/DataCollectorTypeExtensionTest.php | 5 +- .../Form/Tests/ResolvedFormTypeTest.php | 2 +- 12 files changed, 17 insertions(+), 206 deletions(-) delete mode 100644 src/Symfony/Component/Form/Tests/AbstractTypeExtensionTest.php diff --git a/src/Symfony/Component/Form/AbstractExtension.php b/src/Symfony/Component/Form/AbstractExtension.php index c49edb7c70084..3af81e29e9112 100644 --- a/src/Symfony/Component/Form/AbstractExtension.php +++ b/src/Symfony/Component/Form/AbstractExtension.php @@ -175,16 +175,9 @@ private function initTypeExtensions() throw new UnexpectedTypeException($extension, 'Symfony\Component\Form\FormTypeExtensionInterface'); } - if (method_exists($extension, 'getExtendedTypes')) { - $extendedTypes = []; - - foreach ($extension::getExtendedTypes() as $extendedType) { - $extendedTypes[] = $extendedType; - } - } else { - @trigger_error(sprintf('Not implementing the static getExtendedTypes() method in %s when implementing the %s is deprecated since Symfony 4.2. The method will be added to the interface in 5.0.', \get_class($extension), FormTypeExtensionInterface::class), E_USER_DEPRECATED); - - $extendedTypes = [$extension->getExtendedType()]; + $extendedTypes = []; + foreach ($extension::getExtendedTypes() as $extendedType) { + $extendedTypes[] = $extendedType; } foreach ($extendedTypes as $extendedType) { diff --git a/src/Symfony/Component/Form/AbstractTypeExtension.php b/src/Symfony/Component/Form/AbstractTypeExtension.php index 2305db89ee443..9d369bf294e96 100644 --- a/src/Symfony/Component/Form/AbstractTypeExtension.php +++ b/src/Symfony/Component/Form/AbstractTypeExtension.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Form; -use Symfony\Component\Form\Exception\LogicException; use Symfony\Component\OptionsResolver\OptionsResolver; /** @@ -46,22 +45,4 @@ public function finishView(FormView $view, FormInterface $form, array $options) public function configureOptions(OptionsResolver $resolver) { } - - /** - * {@inheritdoc} - * - * @deprecated since Symfony 4.2, use getExtendedTypes() instead. - */ - public function getExtendedType() - { - if (!method_exists($this, 'getExtendedTypes')) { - throw new LogicException(sprintf('You need to implement the static getExtendedTypes() method when implementing the %s in %s.', FormTypeExtensionInterface::class, static::class)); - } - - @trigger_error(sprintf('The %s::getExtendedType() method is deprecated since Symfony 4.2 and will be removed in 5.0. Use getExtendedTypes() instead.', \get_class($this)), E_USER_DEPRECATED); - - foreach (static::getExtendedTypes() as $extendedType) { - return $extendedType; - } - } } diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index 65cec5df04e03..da4396fc5cdf0 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -5,6 +5,8 @@ CHANGELOG ----- * removed the `ChoiceLoaderInterface` implementation in `CountryType`, `LanguageType`, `LocaleType` and `CurrencyType` + * removed `getExtendedType()` method of the `FormTypeExtensionInterface` + * added static `getExtendedTypes()` method to the `FormTypeExtensionInterface` 4.3.0 ----- diff --git a/src/Symfony/Component/Form/DependencyInjection/FormPass.php b/src/Symfony/Component/Form/DependencyInjection/FormPass.php index f3cb08577eb76..ab00a6247fb0a 100644 --- a/src/Symfony/Component/Form/DependencyInjection/FormPass.php +++ b/src/Symfony/Component/Form/DependencyInjection/FormPass.php @@ -18,7 +18,6 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\Form\FormTypeExtensionInterface; /** * Adds all services with the tags "form.type", "form.type_extension" and @@ -95,13 +94,9 @@ private function processFormTypeExtensions(ContainerBuilder $container) $typeExtensionClass = $container->getParameterBag()->resolveValue($serviceDefinition->getClass()); if (isset($tag[0]['extended_type'])) { - if (!method_exists($typeExtensionClass, 'getExtendedTypes')) { - @trigger_error(sprintf('Not implementing the static getExtendedTypes() method in %s when implementing the %s is deprecated since Symfony 4.2. The method will be added to the interface in 5.0.', $typeExtensionClass, FormTypeExtensionInterface::class), E_USER_DEPRECATED); - } - $typeExtensions[$tag[0]['extended_type']][] = new Reference($serviceId); $typeExtensionsClasses[] = $typeExtensionClass; - } elseif (method_exists($typeExtensionClass, 'getExtendedTypes')) { + } else { $extendsTypes = false; $typeExtensionsClasses[] = $typeExtensionClass; @@ -113,8 +108,6 @@ private function processFormTypeExtensions(ContainerBuilder $container) if (!$extendsTypes) { throw new InvalidArgumentException(sprintf('The getExtendedTypes() method for service "%s" does not return any extended types.', $serviceId)); } - } else { - throw new InvalidArgumentException(sprintf('"%s" tagged services have to implement the static getExtendedTypes() method. Class "%s" for service "%s" does not implement it.', $this->formTypeExtensionTag, $typeExtensionClass, $serviceId)); } } diff --git a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php index a0a82495bde59..487b4f3515da3 100644 --- a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php +++ b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php @@ -58,17 +58,12 @@ public function getTypeExtensions($name) foreach ($this->typeExtensionServices[$name] as $serviceId => $extension) { $extensions[] = $extension; - if (method_exists($extension, 'getExtendedTypes')) { - $extendedTypes = []; - - foreach ($extension::getExtendedTypes() as $extendedType) { - $extendedTypes[] = $extendedType; - } - } else { - $extendedTypes = [$extension->getExtendedType()]; + $extendedTypes = []; + foreach ($extension::getExtendedTypes() as $extendedType) { + $extendedTypes[] = $extendedType; } - // validate the result of getExtendedTypes()/getExtendedType() to ensure it is consistent with the service definition + // validate the result of getExtendedTypes() to ensure it is consistent with the service definition if (!\in_array($name, $extendedTypes, true)) { throw new InvalidArgumentException(sprintf('The extended type specified for the service "%s" does not match the actual extended type. Expected "%s", given "%s".', $serviceId, $name, implode(', ', $extendedTypes))); } diff --git a/src/Symfony/Component/Form/FormFactoryBuilder.php b/src/Symfony/Component/Form/FormFactoryBuilder.php index d73b438b4be7a..4a7ba72dfabe0 100644 --- a/src/Symfony/Component/Form/FormFactoryBuilder.php +++ b/src/Symfony/Component/Form/FormFactoryBuilder.php @@ -112,12 +112,8 @@ public function addTypes(array $types) */ public function addTypeExtension(FormTypeExtensionInterface $typeExtension) { - if (method_exists($typeExtension, 'getExtendedTypes')) { - foreach ($typeExtension::getExtendedTypes() as $extendedType) { - $this->typeExtensions[$extendedType][] = $typeExtension; - } - } else { - $this->typeExtensions[$typeExtension->getExtendedType()][] = $typeExtension; + foreach ($typeExtension::getExtendedTypes() as $extendedType) { + $this->typeExtensions[$extendedType][] = $typeExtension; } return $this; diff --git a/src/Symfony/Component/Form/FormTypeExtensionInterface.php b/src/Symfony/Component/Form/FormTypeExtensionInterface.php index fd842f8cfc7c3..f417064f585cf 100644 --- a/src/Symfony/Component/Form/FormTypeExtensionInterface.php +++ b/src/Symfony/Component/Form/FormTypeExtensionInterface.php @@ -15,8 +15,6 @@ /** * @author Bernhard Schussek - * - * @method static iterable getExtendedTypes() Gets the extended types - not implementing it is deprecated since Symfony 4.2 */ interface FormTypeExtensionInterface { @@ -58,11 +56,9 @@ public function finishView(FormView $view, FormInterface $form, array $options); public function configureOptions(OptionsResolver $resolver); /** - * Returns the name of the type being extended. - * - * @return string The name of the type being extended + * Gets the extended types. * - * @deprecated since Symfony 4.2, use getExtendedTypes() instead. + * @return string[] */ - public function getExtendedType(); + public static function getExtendedTypes(): iterable; } diff --git a/src/Symfony/Component/Form/PreloadedExtension.php b/src/Symfony/Component/Form/PreloadedExtension.php index ce0083234ebae..759ae9ad17b7e 100644 --- a/src/Symfony/Component/Form/PreloadedExtension.php +++ b/src/Symfony/Component/Form/PreloadedExtension.php @@ -33,14 +33,6 @@ class PreloadedExtension implements FormExtensionInterface */ public function __construct(array $types, array $typeExtensions, FormTypeGuesserInterface $typeGuesser = null) { - foreach ($typeExtensions as $extensions) { - foreach ($extensions as $typeExtension) { - if (!method_exists($typeExtension, 'getExtendedTypes')) { - @trigger_error(sprintf('Not implementing the static getExtendedTypes() method in %s when implementing the %s is deprecated since Symfony 4.2. The method will be added to the interface in 5.0.', \get_class($typeExtension), FormTypeExtensionInterface::class), E_USER_DEPRECATED); - } - } - } - $this->typeExtensions = $typeExtensions; $this->typeGuesser = $typeGuesser; diff --git a/src/Symfony/Component/Form/Tests/AbstractTypeExtensionTest.php b/src/Symfony/Component/Form/Tests/AbstractTypeExtensionTest.php deleted file mode 100644 index 73b066a2076c1..0000000000000 --- a/src/Symfony/Component/Form/Tests/AbstractTypeExtensionTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\Form\Extension\Core\Type\DateTimeType; -use Symfony\Component\Form\Extension\Core\Type\DateType; - -class AbstractTypeExtensionTest extends TestCase -{ - /** - * @expectedException \Symfony\Component\Form\Exception\LogicException - * @expectedExceptionMessage You need to implement the static getExtendedTypes() method when implementing the Symfony\Component\Form\FormTypeExtensionInterface in Symfony\Component\Form\Tests\TypeExtensionWithoutExtendedTypes. - */ - public function testImplementingNeitherGetExtendedTypeNorExtendsTypeThrowsException() - { - $extension = new TypeExtensionWithoutExtendedTypes(); - $extension->getExtendedType(); - } - - /** - * @group legacy - */ - public function testGetExtendedTypeReturnsFirstConfiguredExtension() - { - $extension = new MultipleTypesExtension(); - - $this->assertSame(DateTimeType::class, $extension->getExtendedType()); - } -} - -class MultipleTypesExtension extends AbstractTypeExtension -{ - public static function getExtendedTypes(): iterable - { - yield DateTimeType::class; - yield DateType::class; - } -} - -class TypeExtensionWithoutExtendedTypes extends AbstractTypeExtension -{ -} diff --git a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php index 28e1fde10f126..e90dd63c009ab 100644 --- a/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php +++ b/src/Symfony/Component/Form/Tests/DependencyInjection/FormPassTest.php @@ -219,87 +219,6 @@ public function addTaggedTypeExtensionsDataProvider() ]; } - /** - * @group legacy - * @dataProvider addLegacyTaggedTypeExtensionsDataProvider - */ - public function testAddLegacyTaggedTypeExtensions(array $extensions, array $expectedRegisteredExtensions) - { - $container = $this->createContainerBuilder(); - - $container->setDefinition('form.extension', $this->createExtensionDefinition()); - - foreach ($extensions as $serviceId => $tag) { - $container->register($serviceId, 'stdClass')->addTag('form.type_extension', $tag); - } - - $container->compile(); - - $extDefinition = $container->getDefinition('form.extension'); - $this->assertEquals($expectedRegisteredExtensions, $extDefinition->getArgument(1)); - } - - /** - * @return array - */ - public function addLegacyTaggedTypeExtensionsDataProvider() - { - return [ - [ - [ - 'my.type_extension1' => ['extended_type' => 'type1'], - 'my.type_extension2' => ['extended_type' => 'type1'], - 'my.type_extension3' => ['extended_type' => 'type2'], - ], - [ - 'type1' => new IteratorArgument([ - new Reference('my.type_extension1'), - new Reference('my.type_extension2'), - ]), - 'type2' => new IteratorArgument([new Reference('my.type_extension3')]), - ], - ], - [ - [ - 'my.type_extension1' => ['extended_type' => 'type1', 'priority' => 1], - 'my.type_extension2' => ['extended_type' => 'type1', 'priority' => 2], - 'my.type_extension3' => ['extended_type' => 'type1', 'priority' => -1], - 'my.type_extension4' => ['extended_type' => 'type2', 'priority' => 2], - 'my.type_extension5' => ['extended_type' => 'type2', 'priority' => 1], - 'my.type_extension6' => ['extended_type' => 'type2', 'priority' => 1], - ], - [ - 'type1' => new IteratorArgument([ - new Reference('my.type_extension2'), - new Reference('my.type_extension1'), - new Reference('my.type_extension3'), - ]), - 'type2' => new IteratorArgument([ - new Reference('my.type_extension4'), - new Reference('my.type_extension5'), - new Reference('my.type_extension6'), - ]), - ], - ], - ]; - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage "form.type_extension" tagged services have to implement the static getExtendedTypes() method. Class "stdClass" for service "my.type_extension" does not implement it. - */ - public function testAddTaggedFormTypeExtensionWithoutExtendedTypeAttributeNorImplementingGetExtendedTypes() - { - $container = $this->createContainerBuilder(); - - $container->setDefinition('form.extension', $this->createExtensionDefinition()); - $container->register('my.type_extension', 'stdClass') - ->setPublic(true) - ->addTag('form.type_extension'); - - $container->compile(); - } - /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage The getExtendedTypes() method for service "my.type_extension" does not return any extended types. diff --git a/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php index 235188365d810..e8ccbe9ea7711 100644 --- a/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php @@ -32,12 +32,9 @@ protected function setUp() $this->extension = new DataCollectorTypeExtension($this->dataCollector); } - /** - * @group legacy - */ public function testGetExtendedType() { - $this->assertEquals('Symfony\Component\Form\Extension\Core\Type\FormType', $this->extension->getExtendedType()); + $this->assertEquals(['Symfony\Component\Form\Extension\Core\Type\FormType'], $this->extension::getExtendedTypes()); } public function testBuildForm() diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php index 32bb8bb788716..fad20d9d8c9ae 100644 --- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php @@ -371,7 +371,7 @@ private function getMockFormType($typeClass = 'Symfony\Component\Form\AbstractTy */ private function getMockFormTypeExtension() { - return $this->getMockBuilder('Symfony\Component\Form\AbstractTypeExtension')->setMethods(['getExtendedType', 'configureOptions', 'finishView', 'buildView', 'buildForm'])->getMock(); + return $this->getMockBuilder('Symfony\Component\Form\AbstractTypeExtension')->setMethods(['getExtendedTypes', 'configureOptions', 'finishView', 'buildView', 'buildForm'])->getMock(); } /** From 6deeaa42ae77ad82dcb6e448b9b386834e8c748a Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Wed, 29 May 2019 14:47:52 -0400 Subject: [PATCH 024/588] Validating form buttons name --- src/Symfony/Component/Form/ButtonBuilder.php | 12 +----------- src/Symfony/Component/Form/CHANGELOG.md | 2 ++ .../Component/Form/Tests/ButtonBuilderTest.php | 3 ++- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Component/Form/ButtonBuilder.php b/src/Symfony/Component/Form/ButtonBuilder.php index 46ca01c6d435b..a04b019af1127 100644 --- a/src/Symfony/Component/Form/ButtonBuilder.php +++ b/src/Symfony/Component/Form/ButtonBuilder.php @@ -61,17 +61,7 @@ public function __construct(?string $name, array $options = []) $this->name = $name; $this->options = $options; - if (\preg_match('/^([^a-z0-9_].*)?(.*[^a-zA-Z0-9_\-:].*)?$/D', $name, $matches)) { - if (isset($matches[1])) { - @trigger_error(sprintf('Using names for buttons that do not start with a letter, a digit, or an underscore is deprecated since Symfony 4.3 and will throw an exception in 5.0 ("%s" given).', $name), E_USER_DEPRECATED); - } - if (isset($matches[2])) { - @trigger_error(sprintf('Using names for buttons that do not contain only letters, digits, underscores ("_"), hyphens ("-") and colons (":") ("%s" given) is deprecated since Symfony 4.3 and will throw an exception in 5.0.', $name), E_USER_DEPRECATED); - } - } - - // to be added in 5.0 - // FormConfigBuilder::validateName($name); + FormConfigBuilder::validateName($name); } /** diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index 65cec5df04e03..3a0e9bba8d4c9 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -4,6 +4,8 @@ CHANGELOG 5.0.0 ----- + * Using names for buttons that do not start with a letter, a digit, or an underscore throw an exception + * Using names for buttons that do not contain only letters, digits, underscores, hyphens, and colons throw an exception. * removed the `ChoiceLoaderInterface` implementation in `CountryType`, `LanguageType`, `LocaleType` and `CurrencyType` 4.3.0 diff --git a/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php b/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php index e987ef7eabf20..126e550b312f5 100644 --- a/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php +++ b/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php @@ -40,7 +40,8 @@ public function testValidNames($name) } /** - * @group legacy + * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException + * @expectedExceptionMessage The name "button[]" contains illegal characters. Names should start with a letter, digit or underscore and only contain letters, digits, numbers, underscores ("_"), hyphens ("-") and colons (":"). */ public function testNameContainingIllegalCharacters() { From d1bbad063d460042d18ad55636e0127be93eb38f Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Wed, 29 May 2019 14:21:19 -0400 Subject: [PATCH 025/588] Throw exception when render a field which was already rendered --- src/Symfony/Component/Form/CHANGELOG.md | 1 + src/Symfony/Component/Form/FormRenderer.php | 4 +--- .../Component/Form/Tests/FormRendererTest.php | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index da4396fc5cdf0..7db2270623b92 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -7,6 +7,7 @@ CHANGELOG * removed the `ChoiceLoaderInterface` implementation in `CountryType`, `LanguageType`, `LocaleType` and `CurrencyType` * removed `getExtendedType()` method of the `FormTypeExtensionInterface` * added static `getExtendedTypes()` method to the `FormTypeExtensionInterface` + * calling to `FormRenderer::searchAndRenderBlock()` method for fields which were already rendered throw a `BadMethodCallException` 4.3.0 ----- diff --git a/src/Symfony/Component/Form/FormRenderer.php b/src/Symfony/Component/Form/FormRenderer.php index 91e6faa9cc358..810bb2001dbba 100644 --- a/src/Symfony/Component/Form/FormRenderer.php +++ b/src/Symfony/Component/Form/FormRenderer.php @@ -133,9 +133,7 @@ public function searchAndRenderBlock(FormView $view, $blockNameSuffix, array $va if ($renderOnlyOnce && $view->isRendered()) { // This is not allowed, because it would result in rendering same IDs multiple times, which is not valid. - @trigger_error(sprintf('You are calling "form_%s" for field "%s" which has already been rendered before, trying to render fields which were already rendered is deprecated since Symfony 4.2 and will throw an exception in 5.0.', $blockNameSuffix, $view->vars['name']), E_USER_DEPRECATED); - // throw new BadMethodCallException(sprintf('Field "%s" has already been rendered. Save result of previous render call to variable and output that instead.', $view->vars['name'])); - return ''; + throw new BadMethodCallException(sprintf('Field "%s" has already been rendered, save the result of previous render call to a variable and output that instead.', $view->vars['name'])); } // The cache key for storing the variables and types diff --git a/src/Symfony/Component/Form/Tests/FormRendererTest.php b/src/Symfony/Component/Form/Tests/FormRendererTest.php index 452bb71e8905b..43d0bec67ab8e 100644 --- a/src/Symfony/Component/Form/Tests/FormRendererTest.php +++ b/src/Symfony/Component/Form/Tests/FormRendererTest.php @@ -12,6 +12,8 @@ namespace Symfony\Component\Form\Tests; use PHPUnit\Framework\TestCase; +use Symfony\Component\Form\FormRenderer; +use Symfony\Component\Form\FormView; class FormRendererTest extends TestCase { @@ -26,4 +28,19 @@ public function testHumanize() $this->assertEquals('Is active', $renderer->humanize('is_active')); $this->assertEquals('Is active', $renderer->humanize('isActive')); } + + /** + * @expectedException \Symfony\Component\Form\Exception\BadMethodCallException + * @expectedExceptionMessage Field "foo" has already been rendered, save the result of previous render call to a variable and output that instead. + */ + public function testRenderARenderedField() + { + $formView = new FormView(); + $formView->vars['name'] = 'foo'; + $formView->setRendered(); + + $engine = $this->getMockBuilder('Symfony\Component\Form\FormRendererEngineInterface')->getMock(); + $renderer = new FormRenderer($engine); + $renderer->searchAndRenderBlock($formView, 'row'); + } } From 5b5edd10cc6f87427e1d24891ff38bd6c05fc7a1 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Wed, 29 May 2019 08:27:25 +0200 Subject: [PATCH 026/588] [Form] Remove legacy regions option in TimezoneType --- src/Symfony/Component/Form/CHANGELOG.md | 1 + .../Form/Extension/Core/Type/TimezoneType.php | 21 ++++------------- .../Form/Tests/Command/DebugCommandTest.php | 2 +- .../Extension/Core/Type/TimezoneTypeTest.php | 23 ------------------- 4 files changed, 6 insertions(+), 41 deletions(-) diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index 7db2270623b92..7c9edef61b21e 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -8,6 +8,7 @@ CHANGELOG * removed `getExtendedType()` method of the `FormTypeExtensionInterface` * added static `getExtendedTypes()` method to the `FormTypeExtensionInterface` * calling to `FormRenderer::searchAndRenderBlock()` method for fields which were already rendered throw a `BadMethodCallException` + * removed the `regions` option of the `TimezoneType` 4.3.0 ----- diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php index ccf51d1fb5f27..be03a9baf2ac8 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php @@ -54,16 +54,13 @@ public function configureOptions(OptionsResolver $resolver) }); } - $regions = $options->offsetGet('regions', false); - - return new CallbackChoiceLoader(function () use ($regions, $input) { - return self::getPhpTimezones($regions, $input); + return new CallbackChoiceLoader(function () use ($input) { + return self::getPhpTimezones($input); }); }, 'choice_translation_domain' => false, 'choice_translation_locale' => null, 'input' => 'string', - 'regions' => \DateTimeZone::ALL, ]); $resolver->setAllowedTypes('intl', ['bool']); @@ -85,16 +82,6 @@ public function configureOptions(OptionsResolver $resolver) return $value; }); - - $resolver->setAllowedTypes('regions', 'int'); - $resolver->setDeprecated('regions', 'The option "%name%" is deprecated since Symfony 4.2.'); - $resolver->setNormalizer('regions', function (Options $options, $value) { - if ($options['intl'] && \DateTimeZone::ALL !== (\DateTimeZone::ALL & $value)) { - throw new LogicException('The "regions" option can only be used if the "intl" option is set to false.'); - } - - return $value; - }); } /** @@ -113,11 +100,11 @@ public function getBlockPrefix() return 'timezone'; } - private static function getPhpTimezones(int $regions, string $input): array + private static function getPhpTimezones(string $input): array { $timezones = []; - foreach (\DateTimeZone::listIdentifiers($regions) as $timezone) { + foreach (\DateTimeZone::listIdentifiers(\DateTimeZone::ALL) as $timezone) { if ('intltimezone' === $input && 'Etc/Unknown' === \IntlTimeZone::createTimeZone($timezone)->getID()) { continue; } diff --git a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php index 16434073a548f..f2a1b89f0e103 100644 --- a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php @@ -45,7 +45,7 @@ public function testDebugDeprecatedDefaults() Built-in form types (Symfony\Component\Form\Extension\Core\Type) ---------------------------------------------------------------- - BirthdayType, DateTimeType, DateType, IntegerType, TimezoneType + BirthdayType, DateTimeType, DateType, IntegerType Service form types ------------------ diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php index 490e878b7bcd8..d514dc85a86c9 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php @@ -72,29 +72,6 @@ public function testDateTimeZoneInputWithBc() $this->assertContains('Europe/Saratov', $form->getConfig()->getAttribute('choice_list')->getValues()); } - /** - * @group legacy - * @expectedDeprecation The option "regions" is deprecated since Symfony 4.2. - */ - public function testFilterByRegions() - { - $choices = $this->factory->create(static::TESTED_TYPE, null, ['regions' => \DateTimeZone::EUROPE]) - ->createView()->vars['choices']; - - $this->assertContains(new ChoiceView('Europe/Amsterdam', 'Europe/Amsterdam', 'Europe / Amsterdam'), $choices, '', false, false); - } - - /** - * @group legacy - * @expectedDeprecation The option "regions" is deprecated since Symfony 4.2. - * @expectedException \Symfony\Component\Form\Exception\LogicException - * @expectedExceptionMessage The "regions" option can only be used if the "intl" option is set to false. - */ - public function testFilterByRegionsWithIntl() - { - $this->factory->create(static::TESTED_TYPE, null, ['regions' => \DateTimeZone::EUROPE, 'intl' => true]); - } - /** * @requires extension intl */ From 2cef8a2a2a44a71b51772d1fdd78fd5817084d7f Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Wed, 29 May 2019 15:02:23 -0400 Subject: [PATCH 027/588] Remove the scale argument of the IntegerToLocalizedStringTransformer --- src/Symfony/Component/Form/CHANGELOG.md | 1 + .../IntegerToLocalizedStringTransformer.php | 9 +--- ...ntegerToLocalizedStringTransformerTest.php | 43 ------------------- 3 files changed, 2 insertions(+), 51 deletions(-) diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index 91b30426e4ffb..34d3d196d439d 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -11,6 +11,7 @@ CHANGELOG * added static `getExtendedTypes()` method to the `FormTypeExtensionInterface` * calling to `FormRenderer::searchAndRenderBlock()` method for fields which were already rendered throw a `BadMethodCallException` * removed the `regions` option of the `TimezoneType` + * removed the `$scale` argument of the `IntegerToLocalizedStringTransformer` 4.3.0 ----- diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php index 392aa49e51a19..68ba2c0227da4 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php @@ -27,15 +27,8 @@ class IntegerToLocalizedStringTransformer extends NumberToLocalizedStringTransfo * @param bool $grouping Whether thousands should be grouped * @param int $roundingMode One of the ROUND_ constants in this class */ - public function __construct($grouping = false, $roundingMode = self::ROUND_DOWN) + public function __construct(?bool $grouping = false, ?int $roundingMode = self::ROUND_DOWN) { - if (\is_int($grouping) || \is_bool($roundingMode) || 2 < \func_num_args()) { - @trigger_error(sprintf('Passing a precision as the first value to %s::__construct() is deprecated since Symfony 4.2 and support for it will be dropped in 5.0.', __CLASS__), E_USER_DEPRECATED); - - $grouping = $roundingMode; - $roundingMode = 2 < \func_num_args() ? func_get_arg(2) : self::ROUND_DOWN; - } - parent::__construct(0, $grouping, $roundingMode); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php index 691efc6e830b3..adfc0dd63cee4 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php @@ -91,18 +91,6 @@ public function testTransformWithRounding($input, $output, $roundingMode) $this->assertEquals($output, $transformer->transform($input)); } - /** - * @group legacy - * @expectedDeprecation Passing a precision as the first value to %s::__construct() is deprecated since Symfony 4.2 and support for it will be dropped in 5.0. - * @dataProvider transformWithRoundingProvider - */ - public function testTransformWithRoundingUsingLegacyConstructorSignature($input, $output, $roundingMode) - { - $transformer = new IntegerToLocalizedStringTransformer(null, null, $roundingMode); - - $this->assertEquals($output, $transformer->transform($input)); - } - public function testReverseTransform() { // Since we test against "de_AT", we need the full implementation @@ -138,25 +126,6 @@ public function testReverseTransformWithGrouping() $this->assertEquals(12345, $transformer->reverseTransform('12345')); } - /** - * @group legacy - * @expectedDeprecation Passing a precision as the first value to %s::__construct() is deprecated since Symfony 4.2 and support for it will be dropped in 5.0. - */ - public function testReverseTransformWithGroupingUsingLegacyConstructorSignature() - { - // Since we test against "de_DE", we need the full implementation - IntlTestHelper::requireFullIntl($this, false); - - \Locale::setDefault('de_DE'); - - $transformer = new IntegerToLocalizedStringTransformer(null, true); - - $this->assertEquals(1234, $transformer->reverseTransform('1.234')); - $this->assertEquals(12345, $transformer->reverseTransform('12.345')); - $this->assertEquals(1234, $transformer->reverseTransform('1234')); - $this->assertEquals(12345, $transformer->reverseTransform('12345')); - } - public function reverseTransformWithRoundingProvider() { return [ @@ -218,18 +187,6 @@ public function testReverseTransformWithRounding($input, $output, $roundingMode) $this->assertEquals($output, $transformer->reverseTransform($input)); } - /** - * @group legacy - * @expectedDeprecation Passing a precision as the first value to %s::__construct() is deprecated since Symfony 4.2 and support for it will be dropped in 5.0. - * @dataProvider reverseTransformWithRoundingProvider - */ - public function testReverseTransformWithRoundingUsingLegacyConstructorSignature($input, $output, $roundingMode) - { - $transformer = new IntegerToLocalizedStringTransformer(null, null, $roundingMode); - - $this->assertEquals($output, $transformer->reverseTransform($input)); - } - /** * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException */ From 3fec46861abb34b0b3a6f926be6336be73cd144e Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Wed, 29 May 2019 23:10:57 +0200 Subject: [PATCH 028/588] reword changelog entry --- src/Symfony/Bundle/SecurityBundle/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md index 5d30a2d803f03..3986d50f73e74 100644 --- a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md @@ -4,7 +4,7 @@ CHANGELOG 5.0.0 ----- -* Deprecated configuring encoders using `argon2i` or `bcrypt` as algorithm, use `auto` instead +* Removed the ability to configure encoders using `argon2i` or `bcrypt` as algorithm, use `auto` instead 4.3.0 ----- From 4dd84f07201fc51148b51b427a46d8f6bb1b408b Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Thu, 30 May 2019 08:17:44 +0200 Subject: [PATCH 029/588] [DI] removed support for extension config without ConfigurationInterface implem --- .../DependencyInjection/CHANGELOG.md | 5 +++ .../Extension/Extension.php | 6 ++-- .../Tests/Extension/ExtensionTest.php | 36 +++++++++++++++++++ .../Extension/InvalidConfig/Configuration.php | 7 ++++ .../InvalidConfig/InvalidConfigExtension.php | 13 +++++++ .../SemiValidConfig/Configuration.php | 18 ++++++++++ .../SemiValidConfigExtension.php | 13 +++++++ .../Extension/ValidConfig/Configuration.php | 14 ++++++++ .../ValidConfig/ValidConfigExtension.php | 17 +++++++++ 9 files changed, 125 insertions(+), 4 deletions(-) create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/Extension/InvalidConfig/Configuration.php create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/Extension/InvalidConfig/InvalidConfigExtension.php create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/Extension/SemiValidConfig/Configuration.php create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/Extension/SemiValidConfig/SemiValidConfigExtension.php create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/Extension/ValidConfig/Configuration.php create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/Extension/ValidConfig/ValidConfigExtension.php diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md index 152a17ce9a46f..b18f63122ca78 100644 --- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md +++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.0.0 +----- + +* removed support for auto-discovered extension configuration class which does not implement `ConfigurationInterface` + 4.4.0 ----- diff --git a/src/Symfony/Component/DependencyInjection/Extension/Extension.php b/src/Symfony/Component/DependencyInjection/Extension/Extension.php index 1285334f58a77..fd333dc505424 100644 --- a/src/Symfony/Component/DependencyInjection/Extension/Extension.php +++ b/src/Symfony/Component/DependencyInjection/Extension/Extension.php @@ -17,6 +17,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\BadMethodCallException; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; +use Symfony\Component\DependencyInjection\Exception\LogicException; /** * Provides useful features shared by many extensions. @@ -88,10 +89,7 @@ public function getConfiguration(array $config, ContainerBuilder $container) } if (!$class->implementsInterface(ConfigurationInterface::class)) { - @trigger_error(sprintf('Not implementing "%s" in the extension configuration class "%s" is deprecated since Symfony 4.1.', ConfigurationInterface::class, $class->getName()), E_USER_DEPRECATED); - //throw new LogicException(sprintf('The extension configuration class "%s" must implement "%s".', $class->getName(), ConfigurationInterface::class)); - - return null; + throw new LogicException(sprintf('The extension configuration class "%s" must implement "%s".', $class->getName(), ConfigurationInterface::class)); } if (!($constructor = $class->getConstructor()) || !$constructor->getNumberOfRequiredParameters()) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php b/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php index 3c912f2a13678..a57b0576a4b02 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Extension/ExtensionTest.php @@ -14,6 +14,10 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\Extension; +use Symfony\Component\DependencyInjection\Tests\Fixtures\Extension\InvalidConfig\InvalidConfigExtension; +use Symfony\Component\DependencyInjection\Tests\Fixtures\Extension\SemiValidConfig\SemiValidConfigExtension; +use Symfony\Component\DependencyInjection\Tests\Fixtures\Extension\ValidConfig\Configuration; +use Symfony\Component\DependencyInjection\Tests\Fixtures\Extension\ValidConfig\ValidConfigExtension; class ExtensionTest extends TestCase { @@ -44,6 +48,38 @@ public function testIsConfigEnabledOnNonEnableableConfig() $extension->isConfigEnabled(new ContainerBuilder(), []); } + + public function testNoConfiguration() + { + $extension = new EnableableExtension(); + + $this->assertNull($extension->getConfiguration([], new ContainerBuilder())); + } + + public function testValidConfiguration() + { + $extension = new ValidConfigExtension(); + + $this->assertInstanceOf(Configuration::class, $extension->getConfiguration([], new ContainerBuilder())); + } + + public function testSemiValidConfiguration() + { + $extension = new SemiValidConfigExtension(); + + $this->assertNull($extension->getConfiguration([], new ContainerBuilder())); + } + + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException + * @expectedExceptionMessage The extension configuration class "Symfony\Component\DependencyInjection\Tests\Fixtures\Extension\InvalidConfig\Configuration" must implement "Symfony\Component\Config\Definition\ConfigurationInterface". + */ + public function testInvalidConfiguration() + { + $extension = new InvalidConfigExtension(); + + $extension->getConfiguration([], new ContainerBuilder()); + } } class EnableableExtension extends Extension diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Extension/InvalidConfig/Configuration.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Extension/InvalidConfig/Configuration.php new file mode 100644 index 0000000000000..bcb2995f17758 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Extension/InvalidConfig/Configuration.php @@ -0,0 +1,7 @@ + Date: Thu, 30 May 2019 11:26:54 +0200 Subject: [PATCH 030/588] remove the has_role() security expression function --- src/Symfony/Component/Security/CHANGELOG.md | 1 + .../ExpressionLanguageProvider.php | 10 ------- .../Authorization/Voter/ExpressionVoter.php | 19 +------------- .../Authorization/ExpressionLanguageTest.php | 26 ------------------- 4 files changed, 2 insertions(+), 54 deletions(-) diff --git a/src/Symfony/Component/Security/CHANGELOG.md b/src/Symfony/Component/Security/CHANGELOG.md index b6d47712bdf06..6af6cf215b0bf 100644 --- a/src/Symfony/Component/Security/CHANGELOG.md +++ b/src/Symfony/Component/Security/CHANGELOG.md @@ -6,6 +6,7 @@ CHANGELOG * Removed `Argon2iPasswordEncoder`, use `SodiumPasswordEncoder` instead * Removed `BcryptPasswordEncoder`, use `NativePasswordEncoder` instead +* Removed the `has_role()` function from security expressions, use `is_granted()` instead. 4.3.0 ----- diff --git a/src/Symfony/Component/Security/Core/Authorization/ExpressionLanguageProvider.php b/src/Symfony/Component/Security/Core/Authorization/ExpressionLanguageProvider.php index 029c96db8f027..449dbce618276 100644 --- a/src/Symfony/Component/Security/Core/Authorization/ExpressionLanguageProvider.php +++ b/src/Symfony/Component/Security/Core/Authorization/ExpressionLanguageProvider.php @@ -53,16 +53,6 @@ public function getFunctions() }, function (array $variables) { return $variables['trust_resolver']->isRememberMe($variables['token']); }), - - new ExpressionFunction('has_role', function ($role) { - @trigger_error('Using the "has_role()" function in security expressions is deprecated since Symfony 4.2, use "is_granted()" instead.', E_USER_DEPRECATED); - - return sprintf('in_array(%s, $roles)', $role); - }, function (array $variables, $role) { - @trigger_error('Using the "has_role()" function in security expressions is deprecated since Symfony 4.2, use "is_granted()" instead.', E_USER_DEPRECATED); - - return \in_array($role, $variables['roles']); - }), ]; } } diff --git a/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php b/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php index e35583555d60e..b91b83af926b6 100644 --- a/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php +++ b/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php @@ -33,25 +33,8 @@ class ExpressionVoter implements VoterInterface private $authChecker; private $roleHierarchy; - /** - * @param AuthorizationCheckerInterface $authChecker - */ - public function __construct(ExpressionLanguage $expressionLanguage, AuthenticationTrustResolverInterface $trustResolver, $authChecker = null, RoleHierarchyInterface $roleHierarchy = null) + public function __construct(ExpressionLanguage $expressionLanguage, AuthenticationTrustResolverInterface $trustResolver, AuthorizationCheckerInterface $authChecker, RoleHierarchyInterface $roleHierarchy = null) { - if ($authChecker instanceof RoleHierarchyInterface) { - @trigger_error(sprintf('Passing a RoleHierarchyInterface to "%s()" is deprecated since Symfony 4.2. Pass an AuthorizationCheckerInterface instead.', __METHOD__), E_USER_DEPRECATED); - $roleHierarchy = $authChecker; - $authChecker = null; - - if (!method_exists($roleHierarchy, 'getReachableRoleNames')) { - @trigger_error(sprintf('Not implementing the getReachableRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($this->roleHierarchy), RoleHierarchyInterface::class), E_USER_DEPRECATED); - } - } elseif (null === $authChecker) { - @trigger_error(sprintf('Argument 3 passed to "%s()" should be an instance of AuthorizationCheckerInterface, not passing it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED); - } elseif (!$authChecker instanceof AuthorizationCheckerInterface) { - throw new \TypeError(sprintf('Argument 3 passed to %s() must be an instance of %s or null, %s given.', __METHOD__, AuthorizationCheckerInterface::class, \is_object($authChecker) ? \get_class($authChecker) : \gettype($authChecker))); - } - $this->expressionLanguage = $expressionLanguage; $this->trustResolver = $trustResolver; $this->authChecker = $authChecker; diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/ExpressionLanguageTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/ExpressionLanguageTest.php index 2950d3feff7dc..0e0e97dac6a0a 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/ExpressionLanguageTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/ExpressionLanguageTest.php @@ -83,30 +83,4 @@ public function provider() [$usernamePasswordToken, "is_granted('ROLE_USER')", true], ]; } - - /** - * @dataProvider provideLegacyHasRole - * @group legacy - */ - public function testLegacyHasRole($expression, $result, $roles = []) - { - $expressionLanguage = new ExpressionLanguage(); - $context = ['roles' => $roles]; - - $this->assertEquals($result, $expressionLanguage->evaluate($expression, $context)); - } - - public function provideLegacyHasRole() - { - $roles = ['ROLE_USER', 'ROLE_ADMIN']; - - return [ - ["has_role('ROLE_FOO')", false], - ["has_role('ROLE_USER')", false], - ["has_role('ROLE_ADMIN')", false], - ["has_role('ROLE_FOO')", false, $roles], - ["has_role('ROLE_USER')", true, $roles], - ["has_role('ROLE_ADMIN')", true, $roles], - ]; - } } From 614f5da2a6bc2b6ad42e7302ab5a94c0adb9f0f7 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Thu, 30 May 2019 13:44:33 +0200 Subject: [PATCH 031/588] [DI] remove support for non-string default env() parameters --- .../DependencyInjection/CHANGELOG.md | 1 + .../EnvPlaceholderParameterBag.php | 27 +++---------------- .../ValidateEnvPlaceholdersPassTest.php | 6 ++--- .../EnvPlaceholderParameterBagTest.php | 22 ++++++--------- 4 files changed, 15 insertions(+), 41 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md index b18f63122ca78..9f5543b49e79e 100644 --- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md +++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG ----- * removed support for auto-discovered extension configuration class which does not implement `ConfigurationInterface` +* removed support for non-string default env() parameters 4.4.0 ----- diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php index fe27324e54f11..543e871fe5300 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php @@ -45,16 +45,8 @@ public function get($name) if (!preg_match('/^(?:\w*+:)*+\w++$/', $env)) { throw new InvalidArgumentException(sprintf('Invalid %s name: only "word" characters are allowed.', $name)); } - - if ($this->has($name)) { - $defaultValue = parent::get($name); - - if (null !== $defaultValue && !is_scalar($defaultValue)) { // !is_string in 5.0 - //throw new RuntimeException(sprintf('The default value of an env() parameter must be a string or null, but "%s" given to "%s".', \gettype($defaultValue), $name)); - throw new RuntimeException(sprintf('The default value of an env() parameter must be scalar or null, but "%s" given to "%s".', \gettype($defaultValue), $name)); - } elseif (is_scalar($defaultValue) && !\is_string($defaultValue)) { - @trigger_error(sprintf('A non-string default value of an env() parameter is deprecated since 4.3, cast "%s" to string instead.', $name), E_USER_DEPRECATED); - } + if ($this->has($name) && null !== ($defaultValue = parent::get($name)) && !\is_string($defaultValue)) { + throw new RuntimeException(sprintf('The default value of an env() parameter must be a string or null, but "%s" given to "%s".', \gettype($defaultValue), $name)); } $uniqueName = md5($name.uniqid(mt_rand(), true)); @@ -146,19 +138,8 @@ public function resolve() parent::resolve(); foreach ($this->envPlaceholders as $env => $placeholders) { - if (!$this->has($name = "env($env)")) { - continue; - } - if (is_numeric($default = $this->parameters[$name])) { - if (!\is_string($default)) { - @trigger_error(sprintf('A non-string default value of env parameter "%s" is deprecated since 4.3, cast it to string instead.', $env), E_USER_DEPRECATED); - } - $this->parameters[$name] = (string) $default; - } elseif (null !== $default && !is_scalar($default)) { // !is_string in 5.0 - //throw new RuntimeException(sprintf('The default value of env parameter "%s" must be a string or null, %s given.', $env, \gettype($default))); - throw new RuntimeException(sprintf('The default value of env parameter "%s" must be scalar or null, %s given.', $env, \gettype($default))); - } elseif (is_scalar($default) && !\is_string($default)) { - @trigger_error(sprintf('A non-string default value of env parameter "%s" is deprecated since 4.3, cast it to string instead.', $env), E_USER_DEPRECATED); + if ($this->has($name = "env($env)") && null !== ($default = $this->parameters[$name]) && !\is_string($default)) { + throw new RuntimeException(sprintf('The default value of env parameter "%s" must be a string or null, %s given.', $env, \gettype($default))); } } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php index cd1a47a1076b2..47343ec951024 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php @@ -59,8 +59,8 @@ public function testDefaultEnvIsValidatedInConfig() } /** - * @group legacy - * @expectedDeprecation A non-string default value of an env() parameter is deprecated since 4.3, cast "env(FLOATISH)" to string instead. + * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException + * @expectedExceptionMessage The default value of an env() parameter must be a string or null, but "double" given to "env(FLOATISH)". */ public function testDefaultEnvWithoutPrefixIsValidatedInConfig() { @@ -72,8 +72,6 @@ public function testDefaultEnvWithoutPrefixIsValidatedInConfig() ]); $this->doProcess($container); - - $this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig())); } /** diff --git a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php index 999303017c88f..52c2239cbe8d0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ParameterBag/EnvPlaceholderParameterBagTest.php @@ -112,32 +112,26 @@ public function testMergeWithDifferentIdentifiersForPlaceholders() } /** - * @group legacy - * @expectedDeprecation A non-string default value of env parameter "INT_VAR" is deprecated since 4.3, cast it to string instead. + * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException + * @expectedExceptionMessage The default value of env parameter "INT_VAR" must be a string or null, integer given. */ - public function testResolveEnvCastsIntToString() + public function testResolveEnvRequiresStrings() { $bag = new EnvPlaceholderParameterBag(); $bag->get('env(INT_VAR)'); $bag->set('env(INT_VAR)', 2); $bag->resolve(); - $this->assertSame('2', $bag->all()['env(INT_VAR)']); } /** - * @group legacy - * @expectedDeprecation A non-string default value of an env() parameter is deprecated since 4.3, cast "env(INT_VAR)" to string instead. - * @expectedDeprecation A non-string default value of env parameter "INT_VAR" is deprecated since 4.3, cast it to string instead. + * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException + * @expectedExceptionMessage The default value of an env() parameter must be a string or null, but "integer" given to "env(INT_VAR)". */ public function testGetDefaultScalarEnv() { $bag = new EnvPlaceholderParameterBag(); $bag->set('env(INT_VAR)', 2); - $this->assertStringMatchesFormat('env_%s_INT_VAR_%s', $bag->get('env(INT_VAR)')); - $this->assertSame(2, $bag->all()['env(INT_VAR)']); - $bag->resolve(); - $this->assertStringMatchesFormat('env_%s_INT_VAR_%s', $bag->get('env(INT_VAR)')); - $this->assertSame('2', $bag->all()['env(INT_VAR)']); + $bag->get('env(INT_VAR)'); } public function testGetDefaultEnv() @@ -163,7 +157,7 @@ public function testResolveEnvAllowsNull() /** * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException - * @expectedExceptionMessage The default value of env parameter "ARRAY_VAR" must be scalar or null, array given. + * @expectedExceptionMessage The default value of env parameter "ARRAY_VAR" must be a string or null, array given. */ public function testResolveThrowsOnBadDefaultValue() { @@ -185,7 +179,7 @@ public function testGetEnvAllowsNull() /** * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException - * @expectedExceptionMessage The default value of an env() parameter must be scalar or null, but "array" given to "env(ARRAY_VAR)". + * @expectedExceptionMessage The default value of an env() parameter must be a string or null, but "array" given to "env(ARRAY_VAR)". */ public function testGetThrowsOnBadDefaultValue() { From 317b80facc859ab532ff8186fc4f5502a22332c0 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Wed, 29 May 2019 14:54:15 +0200 Subject: [PATCH 032/588] [Console] Remove deprecated features --- src/Symfony/Component/Console/Application.php | 7 +- src/Symfony/Component/Console/CHANGELOG.md | 12 +++ .../Component/Console/Event/ConsoleEvent.php | 2 +- .../Console/Helper/ProcessHelper.php | 5 +- .../Component/Console/Helper/TableStyle.php | 76 ------------------- .../Console/Output/ConsoleOutputInterface.php | 4 +- .../EventListener/DebugHandlersListener.php | 3 +- 7 files changed, 21 insertions(+), 88 deletions(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index fac90216cae0e..21275e6790edd 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -43,8 +43,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\Debug\Exception\FatalThrowableError; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy; +use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; /** * An Application is the container for a collection of commands. @@ -92,11 +91,11 @@ public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN } /** - * @final since Symfony 4.3, the type-hint will be updated to the interface from symfony/contracts in 5.0 + * @final */ public function setDispatcher(EventDispatcherInterface $dispatcher) { - $this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher); + $this->dispatcher = $dispatcher; } public function setCommandLoader(CommandLoaderInterface $commandLoader) diff --git a/src/Symfony/Component/Console/CHANGELOG.md b/src/Symfony/Component/Console/CHANGELOG.md index 67decd30beae3..46b71d345df23 100644 --- a/src/Symfony/Component/Console/CHANGELOG.md +++ b/src/Symfony/Component/Console/CHANGELOG.md @@ -1,6 +1,18 @@ CHANGELOG ========= +5.0.0 +----- + + * removed `TableStyle::setCrossingChar()` method in favor of `TableStyle::setDefaultCrossingChar()` + * removed `TableStyle::setHorizontalBorderChar()` method in favor of `TableStyle::setDefaultCrossingChars()` + * removed `TableStyle::getHorizontalBorderChar()` method in favor of `TableStyle::getBorderChars()` + * removed `TableStyle::setVerticalBorderChar()` method in favor of `TableStyle::setVerticalBorderChars()` + * removed `TableStyle::getVerticalBorderChar()` method in favor of `TableStyle::getBorderChars()` + * `ProcessHelper::run()` accepts only `array|Symfony\Component\Process\Process` for its `command` argument + * `Application::setDispatcher` accepts only `Symfony\Contracts\EventDispatcher\EventDispatcherInterface` + for its `dispatcher` argument + 4.3.0 ----- diff --git a/src/Symfony/Component/Console/Event/ConsoleEvent.php b/src/Symfony/Component/Console/Event/ConsoleEvent.php index 5440da216c96f..89ab645594ce1 100644 --- a/src/Symfony/Component/Console/Event/ConsoleEvent.php +++ b/src/Symfony/Component/Console/Event/ConsoleEvent.php @@ -14,7 +14,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\EventDispatcher\Event; +use Symfony\Contracts\EventDispatcher\Event; /** * Allows to inspect input and output of a command. diff --git a/src/Symfony/Component/Console/Helper/ProcessHelper.php b/src/Symfony/Component/Console/Helper/ProcessHelper.php index e3a7c77b35816..55a3354bcf3b6 100644 --- a/src/Symfony/Component/Console/Helper/ProcessHelper.php +++ b/src/Symfony/Component/Console/Helper/ProcessHelper.php @@ -21,7 +21,7 @@ * * @author Fabien Potencier * - * @final since Symfony 4.2 + * @final */ class ProcessHelper extends Helper { @@ -50,8 +50,7 @@ public function run(OutputInterface $output, $cmd, $error = null, callable $call } if (!\is_array($cmd)) { - @trigger_error(sprintf('Passing a command as a string to "%s()" is deprecated since Symfony 4.2, pass it the command as an array of arguments instead.', __METHOD__), E_USER_DEPRECATED); - $cmd = [\method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($cmd) : new Process($cmd)]; + throw new \TypeError(sprintf('The "command" argument of "%s()" must be an array or a "%s" instance, "%s" given.', __METHOD__, Process::class, \is_object($cmd) ? \get_class($cmd) : \gettype($cmd))); } if (\is_string($cmd[0] ?? null)) { diff --git a/src/Symfony/Component/Console/Helper/TableStyle.php b/src/Symfony/Component/Console/Helper/TableStyle.php index 02dd693c8fe0a..020bce96de882 100644 --- a/src/Symfony/Component/Console/Helper/TableStyle.php +++ b/src/Symfony/Component/Console/Helper/TableStyle.php @@ -101,36 +101,6 @@ public function setHorizontalBorderChars(string $outside, string $inside = null) return $this; } - /** - * Sets horizontal border character. - * - * @param string $horizontalBorderChar - * - * @return $this - * - * @deprecated since Symfony 4.1, use {@link setHorizontalBorderChars()} instead. - */ - public function setHorizontalBorderChar($horizontalBorderChar) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use setHorizontalBorderChars() instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->setHorizontalBorderChars($horizontalBorderChar, $horizontalBorderChar); - } - - /** - * Gets horizontal border character. - * - * @return string - * - * @deprecated since Symfony 4.1, use {@link getBorderChars()} instead. - */ - public function getHorizontalBorderChar() - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use getBorderChars() instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->horizontalOutsideBorderChar; - } - /** * Sets vertical border characters. * @@ -157,36 +127,6 @@ public function setVerticalBorderChars(string $outside, string $inside = null): return $this; } - /** - * Sets vertical border character. - * - * @param string $verticalBorderChar - * - * @return $this - * - * @deprecated since Symfony 4.1, use {@link setVerticalBorderChars()} instead. - */ - public function setVerticalBorderChar($verticalBorderChar) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use setVerticalBorderChars() instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->setVerticalBorderChars($verticalBorderChar, $verticalBorderChar); - } - - /** - * Gets vertical border character. - * - * @return string - * - * @deprecated since Symfony 4.1, use {@link getBorderChars()} instead. - */ - public function getVerticalBorderChar() - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use getBorderChars() instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->verticalOutsideBorderChar; - } - /** * Gets border characters. * @@ -259,22 +199,6 @@ public function setDefaultCrossingChar(string $char): self return $this->setCrossingChars($char, $char, $char, $char, $char, $char, $char, $char, $char); } - /** - * Sets crossing character. - * - * @param string $crossingChar - * - * @return $this - * - * @deprecated since Symfony 4.1. Use {@link setDefaultCrossingChar()} instead. - */ - public function setCrossingChar($crossingChar) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1. Use setDefaultCrossingChar() instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->setDefaultCrossingChar($crossingChar); - } - /** * Gets crossing character. * diff --git a/src/Symfony/Component/Console/Output/ConsoleOutputInterface.php b/src/Symfony/Component/Console/Output/ConsoleOutputInterface.php index f4c2fa623a426..6b6635f580ffa 100644 --- a/src/Symfony/Component/Console/Output/ConsoleOutputInterface.php +++ b/src/Symfony/Component/Console/Output/ConsoleOutputInterface.php @@ -16,8 +16,6 @@ * This adds information about stderr and section output stream. * * @author Dariusz Górecki - * - * @method ConsoleSectionOutput section() Creates a new output section */ interface ConsoleOutputInterface extends OutputInterface { @@ -29,4 +27,6 @@ interface ConsoleOutputInterface extends OutputInterface public function getErrorOutput(); public function setErrorOutput(OutputInterface $error); + + public function section(): ConsoleSectionOutput; } diff --git a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php index 6659e21793ffc..5226f0cc2f144 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php @@ -17,7 +17,6 @@ use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\Debug\ExceptionHandler; -use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; use Symfony\Component\HttpKernel\Event\KernelEvent; @@ -63,7 +62,7 @@ public function __construct(callable $exceptionHandler = null, LoggerInterface $ /** * Configures the error handler. */ - public function configure(Event $event = null) + public function configure(object $event = null) { if (!$event instanceof KernelEvent ? !$this->firstCall : !$event->isMasterRequest()) { return; From 914577eaa9e2f71babcae31c12968d15bd60db18 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Wed, 29 May 2019 17:08:26 +0200 Subject: [PATCH 033/588] [Serializer] Unified normalizers/encoders config through default context solely --- UPGRADE-5.0.md | 18 ++ src/Symfony/Component/Serializer/CHANGELOG.md | 9 + .../Serializer/Encoder/CsvEncoder.php | 17 +- .../Serializer/Encoder/XmlEncoder.php | 44 +---- .../Normalizer/AbstractNormalizer.php | 113 +----------- .../Normalizer/AbstractObjectNormalizer.php | 26 +-- .../Normalizer/DateIntervalNormalizer.php | 11 +- .../Normalizer/DateTimeNormalizer.php | 22 +-- .../Tests/Encoder/CsvEncoderTest.php | 68 ++----- .../Tests/Encoder/XmlEncoderTest.php | 97 ++-------- .../Normalizer/DateIntervalNormalizerTest.php | 30 +-- .../Normalizer/DateTimeNormalizerTest.php | 40 +--- .../Normalizer/GetSetMethodNormalizerTest.php | 99 +--------- .../JsonSerializableNormalizerTest.php | 26 +-- .../Tests/Normalizer/ObjectNormalizerTest.php | 173 +----------------- .../Normalizer/PropertyNormalizerTest.php | 80 -------- 16 files changed, 81 insertions(+), 792 deletions(-) diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index e6222abe89405..ab7c1738c6cd6 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -383,6 +383,24 @@ Serializer ---------- * The default value of the `CsvEncoder` "as_collection" option was changed to `true`. + * Individual encoders & normalizers options as constructor arguments were removed. + Use the default context instead. + * The following method and properties: + - `AbstractNormalizer::$circularReferenceLimit` + - `AbstractNormalizer::$circularReferenceHandler` + - `AbstractNormalizer::$callbacks` + - `AbstractNormalizer::$ignoredAttributes` + - `AbstractNormalizer::$camelizedAttributes` + - `AbstractNormalizer::setCircularReferenceLimit()` + - `AbstractNormalizer::setCircularReferenceHandler()` + - `AbstractNormalizer::setCallbacks()` + - `AbstractNormalizer::setIgnoredAttributes()` + - `AbstractObjectNormalizer::$maxDepthHandler` + - `AbstractObjectNormalizer::setMaxDepthHandler()` + - `XmlEncoder::setRootNodeName()` + - `XmlEncoder::getRootNodeName()` + + were removed, use the default context instead. * The `AbstractNormalizer::handleCircularReference()` method has two new `$format` and `$context` arguments. Translation diff --git a/src/Symfony/Component/Serializer/CHANGELOG.md b/src/Symfony/Component/Serializer/CHANGELOG.md index 4b05d8af94ece..a805f0f90f462 100644 --- a/src/Symfony/Component/Serializer/CHANGELOG.md +++ b/src/Symfony/Component/Serializer/CHANGELOG.md @@ -7,6 +7,15 @@ CHANGELOG * throw an exception when creating a `Serializer` with normalizers which neither implement `NormalizerInterface` nor `DenormalizerInterface` * throw an exception when creating a `Serializer` with encoders which neither implement `EncoderInterface` nor `DecoderInterface` * changed the default value of the `CsvEncoder` "as_collection" option to `true` + * removed `AbstractNormalizer::$circularReferenceLimit`, `AbstractNormalizer::$circularReferenceHandler`, + `AbstractNormalizer::$callbacks`, `AbstractNormalizer::$ignoredAttributes`, + `AbstractNormalizer::$camelizedAttributes`, `AbstractNormalizer::setCircularReferenceLimit()`, + `AbstractNormalizer::setCircularReferenceHandler()`, `AbstractNormalizer::setCallbacks()` and + `AbstractNormalizer::setIgnoredAttributes()`, use the default context instead. + * removed `AbstractObjectNormalizer::$maxDepthHandler` and `AbstractObjectNormalizer::setMaxDepthHandler()`, + use the default context instead. + * removed `XmlEncoder::setRootNodeName()` & `XmlEncoder::getRootNodeName()`, use the default context instead. + * removed individual encoders/normalizers options as constructor arguments. 4.3.0 ----- diff --git a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php index c35107d58357f..f244a1f06d1ba 100644 --- a/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/CsvEncoder.php @@ -43,23 +43,8 @@ class CsvEncoder implements EncoderInterface, DecoderInterface self::NO_HEADERS_KEY => false, ]; - /** - * @param array $defaultContext - */ - public function __construct($defaultContext = [], string $enclosure = '"', string $escapeChar = '\\', string $keySeparator = '.', bool $escapeFormulas = false) + public function __construct(array $defaultContext = []) { - if (!\is_array($defaultContext)) { - @trigger_error('Passing configuration options directly to the constructor is deprecated since Symfony 4.2, use the default context instead.', E_USER_DEPRECATED); - - $defaultContext = [ - self::DELIMITER_KEY => (string) $defaultContext, - self::ENCLOSURE_KEY => $enclosure, - self::ESCAPE_CHAR_KEY => $escapeChar, - self::KEY_SEPARATOR_KEY => $keySeparator, - self::ESCAPE_FORMULAS_KEY => $escapeFormulas, - ]; - } - $this->defaultContext = array_merge($this->defaultContext, $defaultContext); } diff --git a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php index 9c7c01b42aa7d..40dccef814ccf 100644 --- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -71,22 +71,8 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa private $format; private $context; - /** - * @param array $defaultContext - */ - public function __construct($defaultContext = [], int $loadOptions = null, array $decoderIgnoredNodeTypes = [XML_PI_NODE, XML_COMMENT_NODE], array $encoderIgnoredNodeTypes = []) + public function __construct(array $defaultContext = []) { - if (!\is_array($defaultContext)) { - @trigger_error('Passing configuration options directly to the constructor is deprecated since Symfony 4.2, use the default context instead.', E_USER_DEPRECATED); - - $defaultContext = [ - self::DECODER_IGNORED_NODE_TYPES => $decoderIgnoredNodeTypes, - self::ENCODER_IGNORED_NODE_TYPES => $encoderIgnoredNodeTypes, - self::LOAD_OPTIONS => $loadOptions ?? LIBXML_NONET | LIBXML_NOBLANKS, - self::ROOT_NODE_NAME => (string) $defaultContext, - ]; - } - $this->defaultContext = array_merge($this->defaultContext, $defaultContext); } @@ -203,34 +189,6 @@ public function supportsDecoding($format) return self::FORMAT === $format; } - /** - * Sets the root node name. - * - * @deprecated since Symfony 4.2 - * - * @param string $name Root node name - */ - public function setRootNodeName($name) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the context instead.', __METHOD__), E_USER_DEPRECATED); - - $this->defaultContext[self::ROOT_NODE_NAME] = $name; - } - - /** - * Returns the root node name. - * - * @deprecated since Symfony 4.2 - * - * @return string - */ - public function getRootNodeName() - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the context instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->defaultContext[self::ROOT_NODE_NAME]; - } - final protected function appendXMLString(\DOMNode $node, string $val): bool { if ('' !== $val) { diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php index cf7e908107b0f..01db395d24b5d 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php @@ -118,22 +118,11 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn protected $defaultContext = [ self::ALLOW_EXTRA_ATTRIBUTES => true, + self::CIRCULAR_REFERENCE_HANDLER => null, self::CIRCULAR_REFERENCE_LIMIT => 1, self::IGNORED_ATTRIBUTES => [], ]; - /** - * @deprecated since Symfony 4.2 - */ - protected $circularReferenceLimit = 1; - - /** - * @deprecated since Symfony 4.2 - * - * @var callable|null - */ - protected $circularReferenceHandler; - /** * @var ClassMetadataFactoryInterface|null */ @@ -144,21 +133,6 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn */ protected $nameConverter; - /** - * @deprecated since Symfony 4.2 - */ - protected $callbacks = []; - - /** - * @deprecated since Symfony 4.2 - */ - protected $ignoredAttributes = []; - - /** - * @deprecated since Symfony 4.2 - */ - protected $camelizedAttributes = []; - /** * Sets the {@link ClassMetadataFactoryInterface} to use. */ @@ -185,83 +159,6 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory } } - /** - * Sets circular reference limit. - * - * @deprecated since Symfony 4.2 - * - * @param int $circularReferenceLimit Limit of iterations for the same object - * - * @return self - */ - public function setCircularReferenceLimit($circularReferenceLimit) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "circular_reference_limit" key of the context instead.', __METHOD__), E_USER_DEPRECATED); - - $this->defaultContext[self::CIRCULAR_REFERENCE_LIMIT] = $this->circularReferenceLimit = $circularReferenceLimit; - - return $this; - } - - /** - * Sets circular reference handler. - * - * @deprecated since Symfony 4.2 - * - * @param callable $circularReferenceHandler - * - * @return self - */ - public function setCircularReferenceHandler(callable $circularReferenceHandler) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "circular_reference_handler" key of the context instead.', __METHOD__), E_USER_DEPRECATED); - - $this->defaultContext[self::CIRCULAR_REFERENCE_HANDLER] = $this->circularReferenceHandler = $circularReferenceHandler; - - return $this; - } - - /** - * Sets normalization callbacks. - * - * @deprecated since Symfony 4.2 - * - * @param callable[] $callbacks Help normalize the result - * - * @return self - * - * @throws InvalidArgumentException if a non-callable callback is set - */ - public function setCallbacks(array $callbacks) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "callbacks" key of the context instead.', __METHOD__), E_USER_DEPRECATED); - - foreach ($callbacks as $attribute => $callback) { - if (!\is_callable($callback)) { - throw new InvalidArgumentException(sprintf('The given callback for attribute "%s" is not callable.', $attribute)); - } - } - $this->defaultContext[self::CALLBACKS] = $this->callbacks = $callbacks; - - return $this; - } - - /** - * Sets ignored attributes for normalization and denormalization. - * - * @deprecated since Symfony 4.2 - * - * @return self - */ - public function setIgnoredAttributes(array $ignoredAttributes) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "ignored_attributes" key of the context instead.', __METHOD__), E_USER_DEPRECATED); - - $this->defaultContext[self::IGNORED_ATTRIBUTES] = $this->ignoredAttributes = $ignoredAttributes; - - return $this; - } - /** * {@inheritdoc} */ @@ -284,7 +181,7 @@ protected function isCircularReference($object, &$context) { $objectHash = spl_object_hash($object); - $circularReferenceLimit = $context[self::CIRCULAR_REFERENCE_LIMIT] ?? $this->defaultContext[self::CIRCULAR_REFERENCE_LIMIT] ?? $this->circularReferenceLimit; + $circularReferenceLimit = $context[self::CIRCULAR_REFERENCE_LIMIT] ?? $this->defaultContext[self::CIRCULAR_REFERENCE_LIMIT]; if (isset($context[self::CIRCULAR_REFERENCE_LIMIT_COUNTERS][$objectHash])) { if ($context[self::CIRCULAR_REFERENCE_LIMIT_COUNTERS][$objectHash] >= $circularReferenceLimit) { unset($context[self::CIRCULAR_REFERENCE_LIMIT_COUNTERS][$objectHash]); @@ -324,12 +221,12 @@ protected function handleCircularReference($object/*, string $format = null, arr $format = \func_num_args() > 1 ? func_get_arg(1) : null; $context = \func_num_args() > 2 ? func_get_arg(2) : []; - $circularReferenceHandler = $context[self::CIRCULAR_REFERENCE_HANDLER] ?? $this->defaultContext[self::CIRCULAR_REFERENCE_HANDLER] ?? $this->circularReferenceHandler; + $circularReferenceHandler = $context[self::CIRCULAR_REFERENCE_HANDLER] ?? $this->defaultContext[self::CIRCULAR_REFERENCE_HANDLER]; if ($circularReferenceHandler) { return $circularReferenceHandler($object, $format, $context); } - throw new CircularReferenceException(sprintf('A circular reference has been detected when serializing the object of class "%s" (configured limit: %d)', \get_class($object), $this->circularReferenceLimit)); + throw new CircularReferenceException(sprintf('A circular reference has been detected when serializing the object of class "%s" (configured limit: %d)', \get_class($object), $context[self::CIRCULAR_REFERENCE_LIMIT] ?? $this->defaultContext[self::CIRCULAR_REFERENCE_LIMIT])); } /** @@ -387,7 +284,7 @@ protected function getAllowedAttributes($classOrObject, array $context, $attribu */ protected function isAllowedAttribute($classOrObject, $attribute, $format = null, array $context = []) { - $ignoredAttributes = $context[self::IGNORED_ATTRIBUTES] ?? $this->defaultContext[self::IGNORED_ATTRIBUTES] ?? $this->ignoredAttributes; + $ignoredAttributes = $context[self::IGNORED_ATTRIBUTES] ?? $this->defaultContext[self::IGNORED_ATTRIBUTES]; if (\in_array($attribute, $ignoredAttributes)) { return false; } diff --git a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php index 7f22a1df1971e..eb7ea7b4dc08d 100644 --- a/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php @@ -92,12 +92,6 @@ abstract class AbstractObjectNormalizer extends AbstractNormalizer private $typesCache = []; private $attributesCache = []; - /** - * @deprecated since Symfony 4.2 - * - * @var callable|null - */ - private $maxDepthHandler; private $objectClassResolver; /** @@ -168,8 +162,7 @@ public function normalize($object, $format = null, array $context = []) throw new InvalidArgumentException(sprintf('The "%s" given in the context is not callable.', self::MAX_DEPTH_HANDLER)); } } else { - // already validated in constructor resp by type declaration of setMaxDepthHandler - $maxDepthHandler = $this->defaultContext[self::MAX_DEPTH_HANDLER] ?? $this->maxDepthHandler; + $maxDepthHandler = null; } foreach ($attributes as $attribute) { @@ -186,7 +179,7 @@ public function normalize($object, $format = null, array $context = []) /** * @var callable|null */ - $callback = $context[self::CALLBACKS][$attribute] ?? $this->defaultContext[self::CALLBACKS][$attribute] ?? $this->callbacks[$attribute] ?? null; + $callback = $context[self::CALLBACKS][$attribute] ?? $this->defaultContext[self::CALLBACKS][$attribute] ?? null; if ($callback) { $attributeValue = $callback($attributeValue, $object, $attribute, $format, $context); } @@ -295,18 +288,6 @@ abstract protected function extractAttributes($object, $format = null, array $co */ abstract protected function getAttributeValue($object, $attribute, $format = null, array $context = []); - /** - * Sets a handler function that will be called when the max depth is reached. - * - * @deprecated since Symfony 4.2 - */ - public function setMaxDepthHandler(?callable $handler): void - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "max_depth_handler" key of the context instead.', __METHOD__), E_USER_DEPRECATED); - - $this->maxDepthHandler = $handler; - } - /** * {@inheritdoc} */ @@ -595,8 +576,7 @@ private function getCacheKey(?string $format, array $context) try { return md5($format.serialize([ 'context' => $context, - 'ignored' => $this->ignoredAttributes, - 'camelized' => $this->camelizedAttributes, + 'ignored' => $context[self::IGNORED_ATTRIBUTES] ?? $this->defaultContext[self::IGNORED_ATTRIBUTES], ])); } catch (\Exception $exception) { // The context cannot be serialized, skip the cache diff --git a/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php index 0b2d4214bf32e..8ed7a24f84d78 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DateIntervalNormalizer.php @@ -28,17 +28,8 @@ class DateIntervalNormalizer implements NormalizerInterface, DenormalizerInterfa self::FORMAT_KEY => 'P%yY%mM%dDT%hH%iM%sS', ]; - /** - * @param array $defaultContext - */ - public function __construct($defaultContext = []) + public function __construct(array $defaultContext = []) { - if (!\is_array($defaultContext)) { - @trigger_error(sprintf('The "format" parameter is deprecated since Symfony 4.2, use the "%s" key of the context instead.', self::FORMAT_KEY), E_USER_DEPRECATED); - - $defaultContext = [self::FORMAT_KEY => (string) $defaultContext]; - } - $this->defaultContext = array_merge($this->defaultContext, $defaultContext); } diff --git a/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php index 51ad59a7e782e..8b182f72c95ba 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/DateTimeNormalizer.php @@ -25,7 +25,10 @@ class DateTimeNormalizer implements NormalizerInterface, DenormalizerInterface, const FORMAT_KEY = 'datetime_format'; const TIMEZONE_KEY = 'datetime_timezone'; - private $defaultContext; + private $defaultContext = [ + self::FORMAT_KEY => \DateTime::RFC3339, + self::TIMEZONE_KEY => null, + ]; private static $supportedTypes = [ \DateTimeInterface::class => true, @@ -33,23 +36,8 @@ class DateTimeNormalizer implements NormalizerInterface, DenormalizerInterface, \DateTime::class => true, ]; - /** - * @param array $defaultContext - */ - public function __construct($defaultContext = [], \DateTimeZone $timezone = null) + public function __construct(array $defaultContext = []) { - $this->defaultContext = [ - self::FORMAT_KEY => \DateTime::RFC3339, - self::TIMEZONE_KEY => null, - ]; - - if (!\is_array($defaultContext)) { - @trigger_error('Passing configuration options directly to the constructor is deprecated since Symfony 4.2, use the default context instead.', E_USER_DEPRECATED); - - $defaultContext = [self::FORMAT_KEY => (string) $defaultContext]; - $defaultContext[self::TIMEZONE_KEY] = $timezone; - } - $this->defaultContext = array_merge($this->defaultContext, $defaultContext); } diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php index 52c4a9b5c4d5b..eb628478c0b7b 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/CsvEncoderTest.php @@ -100,26 +100,12 @@ public function testEncodeNestedArrays() public function testEncodeCustomSettings() { - $this->doTestEncodeCustomSettings(); - } - - public function testLegacyEncodeCustomSettings() - { - $this->doTestEncodeCustomSettings(true); - } - - private function doTestEncodeCustomSettings(bool $legacy = false) - { - if ($legacy) { - $this->encoder = new CsvEncoder(';', "'", '|', '-'); - } else { - $this->encoder = new CsvEncoder([ - CsvEncoder::DELIMITER_KEY => ';', - CsvEncoder::ENCLOSURE_KEY => "'", - CsvEncoder::ESCAPE_CHAR_KEY => '|', - CsvEncoder::KEY_SEPARATOR_KEY => '-', - ]); - } + $this->encoder = new CsvEncoder([ + CsvEncoder::DELIMITER_KEY => ';', + CsvEncoder::ENCLOSURE_KEY => "'", + CsvEncoder::ESCAPE_CHAR_KEY => '|', + CsvEncoder::KEY_SEPARATOR_KEY => '-', + ]); $value = ['a' => 'he\'llo', 'c' => ['d' => 'foo']]; @@ -194,21 +180,7 @@ public function testEncodeCustomHeaders() public function testEncodeFormulas() { - $this->doTestEncodeFormulas(); - } - - public function testLegacyEncodeFormulas() - { - $this->doTestEncodeFormulas(true); - } - - private function doTestEncodeFormulas(bool $legacy = false) - { - if ($legacy) { - $this->encoder = new CsvEncoder(',', '"', '\\', '.', true); - } else { - $this->encoder = new CsvEncoder([CsvEncoder::ESCAPE_FORMULAS_KEY => true]); - } + $this->encoder = new CsvEncoder([CsvEncoder::ESCAPE_FORMULAS_KEY => true]); $this->assertSame(<<<'CSV' 0 @@ -406,26 +378,12 @@ public function testDecodeNestedArrays() public function testDecodeCustomSettings() { - $this->doTestDecodeCustomSettings(); - } - - public function testLegacyDecodeCustomSettings() - { - $this->doTestDecodeCustomSettings(true); - } - - private function doTestDecodeCustomSettings(bool $legacy = false) - { - if ($legacy) { - $this->encoder = new CsvEncoder(';', "'", '|', '-'); - } else { - $this->encoder = new CsvEncoder([ - CsvEncoder::DELIMITER_KEY => ';', - CsvEncoder::ENCLOSURE_KEY => "'", - CsvEncoder::ESCAPE_CHAR_KEY => '|', - CsvEncoder::KEY_SEPARATOR_KEY => '-', - ]); - } + $this->encoder = new CsvEncoder([ + CsvEncoder::DELIMITER_KEY => ';', + CsvEncoder::ENCLOSURE_KEY => "'", + CsvEncoder::ESCAPE_CHAR_KEY => '|', + CsvEncoder::KEY_SEPARATOR_KEY => '-', + ]); $expected = [['a' => 'hell\'o', 'bar' => ['baz' => 'b']]]; $this->assertEquals($expected, $this->encoder->decode(<<<'CSV' diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php index 74692783ea5e6..6a7ec0224e56a 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php @@ -47,21 +47,6 @@ public function testEncodeScalar() $this->assertEquals($expected, $this->encoder->encode($obj, 'xml')); } - /** - * @group legacy - */ - public function testSetRootNodeName() - { - $obj = new ScalarDummy(); - $obj->xmlFoo = 'foo'; - - $this->encoder->setRootNodeName('test'); - $expected = ''."\n". - 'foo'."\n"; - - $this->assertEquals($expected, $this->encoder->encode($obj, 'xml')); - } - /** * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException * @expectedExceptionMessage Document types are not allowed. @@ -546,16 +531,6 @@ public function testDecodeIgnoreComments() } public function testDecodePreserveComments() - { - $this->doTestDecodePreserveComments(); - } - - public function testLegacyDecodePreserveComments() - { - $this->doTestDecodePreserveComments(true); - } - - private function doTestDecodePreserveComments(bool $legacy = false) { $source = <<<'XML' @@ -572,14 +547,10 @@ private function doTestDecodePreserveComments(bool $legacy = false) XML; - if ($legacy) { - $this->encoder = new XmlEncoder('people', null, [XML_PI_NODE]); - } else { - $this->encoder = new XmlEncoder([ - XmlEncoder::ROOT_NODE_NAME => 'people', - XmlEncoder::DECODER_IGNORED_NODE_TYPES => [XML_PI_NODE], - ]); - } + $this->encoder = new XmlEncoder([ + XmlEncoder::ROOT_NODE_NAME => 'people', + XmlEncoder::DECODER_IGNORED_NODE_TYPES => [XML_PI_NODE], + ]); $serializer = new Serializer([new CustomNormalizer()], ['xml' => new XmlEncoder()]); $this->encoder->setSerializer($serializer); @@ -593,21 +564,7 @@ private function doTestDecodePreserveComments(bool $legacy = false) public function testDecodeAlwaysAsCollection() { - $this->doTestDecodeAlwaysAsCollection(); - } - - public function testLegacyDecodeAlwaysAsCollection() - { - $this->doTestDecodeAlwaysAsCollection(true); - } - - private function doTestDecodeAlwaysAsCollection(bool $legacy = false) - { - if ($legacy) { - $this->encoder = new XmlEncoder('response', null); - } else { - $this->encoder = new XmlEncoder([XmlEncoder::ROOT_NODE_NAME => 'response']); - } + $this->encoder = new XmlEncoder([XmlEncoder::ROOT_NODE_NAME => 'response']); $serializer = new Serializer([new CustomNormalizer()], ['xml' => new XmlEncoder()]); $this->encoder->setSerializer($serializer); @@ -809,24 +766,10 @@ public function testEncodeComment() public function testEncodeWithoutPi() { - $this->doTestEncodeWithoutPi(); - } - - public function testLegacyEncodeWithoutPi() - { - $this->doTestEncodeWithoutPi(true); - } - - private function doTestEncodeWithoutPi(bool $legacy = false) - { - if ($legacy) { - $encoder = new XmlEncoder('response', null, [], [XML_PI_NODE]); - } else { - $encoder = new XmlEncoder([ - XmlEncoder::ROOT_NODE_NAME => 'response', - XmlEncoder::ENCODER_IGNORED_NODE_TYPES => [XML_PI_NODE], - ]); - } + $encoder = new XmlEncoder([ + XmlEncoder::ROOT_NODE_NAME => 'response', + XmlEncoder::ENCODER_IGNORED_NODE_TYPES => [XML_PI_NODE], + ]); $expected = ''; @@ -835,24 +778,10 @@ private function doTestEncodeWithoutPi(bool $legacy = false) public function testEncodeWithoutComment() { - $this->doTestEncodeWithoutComment(); - } - - public function testLegacyEncodeWithoutComment() - { - $this->doTestEncodeWithoutComment(true); - } - - private function doTestEncodeWithoutComment(bool $legacy = false) - { - if ($legacy) { - $encoder = new XmlEncoder('response', null, [], [XML_COMMENT_NODE]); - } else { - $encoder = new XmlEncoder([ - XmlEncoder::ROOT_NODE_NAME => 'response', - XmlEncoder::ENCODER_IGNORED_NODE_TYPES => [XML_COMMENT_NODE], - ]); - } + $encoder = new XmlEncoder([ + XmlEncoder::ROOT_NODE_NAME => 'response', + XmlEncoder::ENCODER_IGNORED_NODE_TYPES => [XML_COMMENT_NODE], + ]); $expected = <<<'XML' diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php index b8ac21b5a6082..fb6bbfe54d813 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DateIntervalNormalizerTest.php @@ -58,20 +58,7 @@ public function testNormalizeUsingFormatPassedInContext($format, $output, $input */ public function testNormalizeUsingFormatPassedInConstructor($format, $output, $input) { - $this->doTestNormalizeUsingFormatPassedInConstructor($format, $output, $input); - } - - /** - * @dataProvider dataProviderISO - */ - public function testLegacyNormalizeUsingFormatPassedInConstructor($format, $output, $input) - { - $this->doTestNormalizeUsingFormatPassedInConstructor($format, $output, $input, true); - } - - private function doTestNormalizeUsingFormatPassedInConstructor($format, $output, $input, bool $legacy = false) - { - $normalizer = $legacy ? new DateIntervalNormalizer($format) : new DateIntervalNormalizer([DateIntervalNormalizer::FORMAT_KEY => $format]); + $normalizer = new DateIntervalNormalizer([DateIntervalNormalizer::FORMAT_KEY => $format]); $this->assertEquals($output, $normalizer->normalize(new \DateInterval($input))); } @@ -108,20 +95,7 @@ public function testDenormalizeUsingFormatPassedInContext($format, $input, $outp */ public function testDenormalizeUsingFormatPassedInConstructor($format, $input, $output) { - $this->doTestDenormalizeUsingFormatPassedInConstructor($format, $input, $output); - } - - /** - * @dataProvider dataProviderISO - */ - public function testLegacyDenormalizeUsingFormatPassedInConstructor($format, $input, $output) - { - $this->doTestDenormalizeUsingFormatPassedInConstructor($format, $input, $output, true); - } - - private function doTestDenormalizeUsingFormatPassedInConstructor($format, $input, $output, bool $legacy = false) - { - $normalizer = $legacy ? new DateIntervalNormalizer($format) : new DateIntervalNormalizer([DateIntervalNormalizer::FORMAT_KEY => $format]); + $normalizer = new DateIntervalNormalizer([DateIntervalNormalizer::FORMAT_KEY => $format]); $this->assertDateIntervalEquals(new \DateInterval($output), $normalizer->denormalize($input, \DateInterval::class)); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php index 7d087d7d5eda5..c213f663eef0f 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/DateTimeNormalizerTest.php @@ -49,37 +49,13 @@ public function testNormalizeUsingFormatPassedInContext() public function testNormalizeUsingFormatPassedInConstructor() { - $this->doTestNormalizeUsingFormatPassedInConstructor(); - } - - public function testLegacyNormalizeUsingFormatPassedInConstructor() - { - $this->doTestNormalizeUsingFormatPassedInConstructor(true); - } - - private function doTestNormalizeUsingFormatPassedInConstructor(bool $legacy = false) - { - $normalizer = $legacy ? new DateTimeNormalizer('y') : new DateTimeNormalizer([DateTimeNormalizer::FORMAT_KEY => 'y']); + $normalizer = new DateTimeNormalizer([DateTimeNormalizer::FORMAT_KEY => 'y']); $this->assertEquals('16', $normalizer->normalize(new \DateTime('2016/01/01', new \DateTimeZone('UTC')))); } public function testNormalizeUsingTimeZonePassedInConstructor() { - $this->doTestNormalizeUsingTimeZonePassedInConstructor(); - } - - public function testLegacyNormalizeUsingTimeZonePassedInConstructor() - { - $this->doTestNormalizeUsingTimeZonePassedInConstructor(true); - } - - private function doTestNormalizeUsingTimeZonePassedInConstructor(bool $legacy = false) - { - if ($legacy) { - $normalizer = new DateTimeNormalizer(\DateTime::RFC3339, new \DateTimeZone('Japan')); - } else { - $normalizer = new DateTimeNormalizer([DateTimeNormalizer::TIMEZONE_KEY => new \DateTimeZone('Japan')]); - } + $normalizer = new DateTimeNormalizer([DateTimeNormalizer::TIMEZONE_KEY => new \DateTimeZone('Japan')]); $this->assertSame('2016-12-01T00:00:00+09:00', $normalizer->normalize(new \DateTime('2016/12/01', new \DateTimeZone('Japan')))); $this->assertSame('2016-12-01T09:00:00+09:00', $normalizer->normalize(new \DateTime('2016/12/01', new \DateTimeZone('UTC')))); @@ -204,20 +180,10 @@ public function testDenormalize() } public function testDenormalizeUsingTimezonePassedInConstructor() - { - $this->doTestDenormalizeUsingTimezonePassedInConstructor(); - } - - public function testLegacyDenormalizeUsingTimezonePassedInConstructor() - { - $this->doTestDenormalizeUsingTimezonePassedInConstructor(true); - } - - private function doTestDenormalizeUsingTimezonePassedInConstructor(bool $legacy = false) { $timezone = new \DateTimeZone('Japan'); $expected = new \DateTime('2016/12/01 17:35:00', $timezone); - $normalizer = $legacy ? new DateTimeNormalizer(null, $timezone) : new DateTimeNormalizer([DateTimeNormalizer::TIMEZONE_KEY => $timezone]); + $normalizer = new DateTimeNormalizer([DateTimeNormalizer::TIMEZONE_KEY => $timezone]); $this->assertEquals($expected, $normalizer->denormalize('2016.12.01 17:35:00', \DateTime::class, null, [ DateTimeNormalizer::FORMAT_KEY => 'Y.m.d H:i:s', diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 049e9cda69515..c95a8196192fa 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -16,7 +16,6 @@ use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor; use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; use Symfony\Component\PropertyInfo\PropertyInfoExtractor; -use Symfony\Component\Serializer\Exception\CircularReferenceException; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter; @@ -31,7 +30,6 @@ use Symfony\Component\Serializer\Tests\Fixtures\CircularReferenceDummy; use Symfony\Component\Serializer\Tests\Fixtures\GroupDummy; use Symfony\Component\Serializer\Tests\Fixtures\SiblingHolder; -use Symfony\Component\Serializer\Tests\Normalizer\Features\CallbacksObject; use Symfony\Component\Serializer\Tests\Normalizer\Features\CallbacksTestTrait; use Symfony\Component\Serializer\Tests\Normalizer\Features\CircularReferenceTestTrait; use Symfony\Component\Serializer\Tests\Normalizer\Features\ConstructorArgumentsTestTrait; @@ -93,7 +91,7 @@ public function testNormalize() ->expects($this->once()) ->method('normalize') ->with($object, 'any') - ->will($this->returnValue('string_object')) + ->willReturn('string_object') ; $this->assertEquals( @@ -233,20 +231,6 @@ protected function getNormalizerForCallbacks(): GetSetMethodNormalizer return new GetSetMethodNormalizer($classMetadataFactory, new MetadataAwareNameConverter($classMetadataFactory)); } - /** - * @dataProvider provideCallbacks - */ - public function testLegacyCallbacks($callbacks, $value, $result) - { - $this->normalizer->setCallbacks($callbacks); - - $obj = new CallbacksObject($value); - $this->assertEquals( - $result, - $this->normalizer->normalize($obj, 'any') - ); - } - protected function getNormalizerForCircularReference(): GetSetMethodNormalizer { $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); @@ -261,34 +245,6 @@ protected function getSelfReferencingModel() return new CircularReferenceDummy(); } - public function testLegacyUnableToNormalizeCircularReference() - { - $this->normalizer->setCircularReferenceLimit(2); - $this->serializer = new Serializer([$this->normalizer]); - $this->normalizer->setSerializer($this->serializer); - - $obj = new CircularReferenceDummy(); - - $this->expectException(CircularReferenceException::class); - $this->normalizer->normalize($obj); - } - - public function testLegacyCircularReferenceHandler() - { - $handler = function ($obj) { - return \get_class($obj); - }; - - $this->normalizer->setCircularReferenceHandler($handler); - $this->serializer = new Serializer([$this->normalizer]); - $this->normalizer->setSerializer($this->serializer); - - $obj = new CircularReferenceDummy(); - - $expected = ['me' => CircularReferenceDummy::class]; - $this->assertEquals($expected, $this->normalizer->normalize($obj)); - } - protected function getDenormalizerForConstructArguments(): GetSetMethodNormalizer { $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); @@ -406,22 +362,6 @@ protected function getDenormalizerForIgnoredAttributes(): GetSetMethodNormalizer return $normalizer; } - public function testLegacyIgnoredAttributes() - { - $ignoredAttributes = ['foo', 'bar', 'baz', 'camelCase', 'object']; - $this->normalizer->setIgnoredAttributes($ignoredAttributes); - - $obj = new GetSetDummy(); - $obj->setFoo('foo'); - $obj->setBar('bar'); - $obj->setBaz(true); - - $this->assertEquals( - ['fooBar' => 'foobar'], - $this->normalizer->normalize($obj, 'any') - ); - } - /** * @expectedException \Symfony\Component\Serializer\Exception\LogicException * @expectedExceptionMessage Cannot normalize attribute "object" because the injected serializer is not a normalizer @@ -687,43 +627,6 @@ public function otherMethod() } } -class GetCamelizedDummy -{ - private $kevinDunglas; - private $fooBar; - private $bar_foo; - - public function __construct($kevinDunglas = null) - { - $this->kevinDunglas = $kevinDunglas; - } - - public function getKevinDunglas() - { - return $this->kevinDunglas; - } - - public function setFooBar($fooBar) - { - $this->fooBar = $fooBar; - } - - public function getFooBar() - { - return $this->fooBar; - } - - public function setBar_foo($bar_foo) - { - $this->bar_foo = $bar_foo; - } - - public function getBar_foo() - { - return $this->bar_foo; - } -} - class ObjectConstructorArgsWithPrivateMutatorDummy { private $foo; diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php index 5f6731b7ca60b..ce4c3f1ce1b07 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/JsonSerializableNormalizerTest.php @@ -55,11 +55,11 @@ public function testNormalize() $this->serializer ->expects($this->once()) ->method('normalize') - ->will($this->returnCallback(function ($data) { + ->willReturnCallback(function ($data) { $this->assertArraySubset(['foo' => 'a', 'bar' => 'b', 'baz' => 'c'], $data); return 'string_object'; - })) + }) ; $this->assertEquals('string_object', $this->normalizer->normalize(new JsonSerializableDummy())); @@ -70,32 +70,16 @@ public function testNormalize() */ public function testCircularNormalize() { - $this->doTestCircularNormalize(); - } - - /** - * @expectedException \Symfony\Component\Serializer\Exception\CircularReferenceException - */ - public function testLegacyCircularNormalize() - { - $this->doTestCircularNormalize(true); - } - - /** - * @expectedException \Symfony\Component\Serializer\Exception\CircularReferenceException - */ - private function doTestCircularNormalize(bool $legacy = false) - { - $legacy ? $this->normalizer->setCircularReferenceLimit(1) : $this->createNormalizer([JsonSerializableNormalizer::CIRCULAR_REFERENCE_LIMIT => 1]); + $this->createNormalizer([JsonSerializableNormalizer::CIRCULAR_REFERENCE_LIMIT => 1]); $this->serializer ->expects($this->once()) ->method('normalize') - ->will($this->returnCallback(function ($data, $format, $context) { + ->willReturnCallback(function ($data, $format, $context) { $this->normalizer->normalize($data['qux'], $format, $context); return 'string_object'; - })) + }) ; $this->assertEquals('string_object', $this->normalizer->normalize(new JsonSerializableDummy())); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index 002f9dc3d587a..2f9bdff22f163 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -16,7 +16,6 @@ use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor; use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; use Symfony\Component\PropertyInfo\PropertyInfoExtractor; -use Symfony\Component\Serializer\Exception\CircularReferenceException; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; @@ -31,10 +30,8 @@ use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\Tests\Fixtures\CircularReferenceDummy; use Symfony\Component\Serializer\Tests\Fixtures\GroupDummy; -use Symfony\Component\Serializer\Tests\Fixtures\MaxDepthDummy; use Symfony\Component\Serializer\Tests\Fixtures\SiblingHolder; use Symfony\Component\Serializer\Tests\Normalizer\Features\AttributesTestTrait; -use Symfony\Component\Serializer\Tests\Normalizer\Features\CallbacksObject; use Symfony\Component\Serializer\Tests\Normalizer\Features\CallbacksTestTrait; use Symfony\Component\Serializer\Tests\Normalizer\Features\CircularReferenceTestTrait; use Symfony\Component\Serializer\Tests\Normalizer\Features\ConstructorArgumentsTestTrait; @@ -97,7 +94,7 @@ public function testNormalize() ->expects($this->once()) ->method('normalize') ->with($object, 'any') - ->will($this->returnValue('string_object')) + ->willReturn('string_object') ; $this->assertEquals( @@ -327,30 +324,6 @@ protected function getNormalizerForCallbacks(): ObjectNormalizer return new ObjectNormalizer(); } - /** - * @dataProvider provideCallbacks - */ - public function testLegacyCallbacks($callbacks, $value, $result) - { - $this->normalizer->setCallbacks($callbacks); - $obj = new CallbacksObject($value); - - $this->assertEquals( - $result, - $this->normalizer->normalize($obj, 'any') - ); - } - - /** - * @dataProvider provideInvalidCallbacks - */ - public function testLegacyUncallableCallbacks($callbacks) - { - $this->expectException(\InvalidArgumentException::class); - - $this->normalizer->setCallbacks($callbacks); - } - // circular reference protected function getNormalizerForCircularReference(): ObjectNormalizer @@ -366,18 +339,6 @@ protected function getSelfReferencingModel() return new CircularReferenceDummy(); } - public function testLegacyUnableToNormalizeCircularReference() - { - $this->normalizer->setCircularReferenceLimit(2); - $serializer = new Serializer([$this->normalizer]); - $this->normalizer->setSerializer($serializer); - - $obj = new CircularReferenceDummy(); - - $this->expectException(CircularReferenceException::class); - $this->normalizer->normalize($obj); - } - public function testSiblingReference() { $serializer = new Serializer([$this->normalizer]); @@ -393,23 +354,6 @@ public function testSiblingReference() $this->assertEquals($expected, $this->normalizer->normalize($siblingHolder)); } - public function testLegacyCircularReferenceHandler() - { - new Serializer([$this->normalizer]); - - $obj = new CircularReferenceDummy(); - $expected = ['me' => CircularReferenceDummy::class]; - - $this->normalizer->setCircularReferenceHandler(function ($obj, string $format, array $context) { - $this->assertInstanceOf(CircularReferenceDummy::class, $obj); - $this->assertSame('test', $format); - $this->assertArrayHasKey('foo', $context); - - return \get_class($obj); - }); - $this->assertEquals($expected, $this->normalizer->normalize($obj, 'test', ['foo' => 'bar'])); - } - // constructor arguments protected function getDenormalizerForConstructArguments(): ObjectNormalizer @@ -503,47 +447,6 @@ protected function getDenormalizerForIgnoredAttributes(): ObjectNormalizer return $normalizer; } - public function testLegacyIgnoredAttributes() - { - $ignoredAttributes = ['foo', 'bar', 'baz', 'camelCase', 'object']; - $this->normalizer->setIgnoredAttributes($ignoredAttributes); - - $obj = new ObjectDummy(); - $obj->setFoo('foo'); - $obj->bar = 'bar'; - $obj->setBaz(true); - - $this->assertEquals( - ['fooBar' => 'foobar'], - $this->normalizer->normalize($obj, 'any') - ); - - $ignoredAttributes = ['foo', 'baz', 'camelCase', 'object']; - $this->normalizer->setIgnoredAttributes($ignoredAttributes); - - $this->assertEquals( - [ - 'fooBar' => 'foobar', - 'bar' => 'bar', - ], - $this->normalizer->normalize($obj, 'any') - ); - } - - public function testLegacyIgnoredAttributesDenormalize() - { - $ignoredAttributes = ['fooBar', 'bar', 'baz']; - $this->normalizer->setIgnoredAttributes($ignoredAttributes); - - $obj = new ObjectDummy(); - $obj->setFoo('foo'); - - $this->assertEquals( - $obj, - $this->normalizer->denormalize(['fooBar' => 'fooBar', 'foo' => 'foo', 'baz' => 'baz'], ObjectDummy::class) - ); - } - // max depth protected function getNormalizerForMaxDepth(): ObjectNormalizer @@ -556,80 +459,6 @@ protected function getNormalizerForMaxDepth(): ObjectNormalizer return $normalizer; } - public function testLegacyMaxDepth() - { - $level1 = new MaxDepthDummy(); - $level1->foo = 'level1'; - - $level2 = new MaxDepthDummy(); - $level2->foo = 'level2'; - $level1->child = $level2; - - $level3 = new MaxDepthDummy(); - $level3->foo = 'level3'; - $level2->child = $level3; - - $this->createNormalizerWithMaxDepthHandler(null); - $result = $this->serializer->normalize($level1, null, [ObjectNormalizer::ENABLE_MAX_DEPTH => true]); - - $expected = [ - 'bar' => null, - 'foo' => 'level1', - 'child' => [ - 'bar' => null, - 'foo' => 'level2', - 'child' => [ - 'bar' => null, - 'child' => null, - ], - ], - ]; - - $this->assertEquals($expected, $result); - - $expected = [ - 'bar' => null, - 'foo' => 'level1', - 'child' => [ - 'bar' => null, - 'foo' => 'level2', - 'child' => [ - 'bar' => null, - 'child' => null, - 'foo' => 'handler', - ], - ], - ]; - - $this->createNormalizerWithMaxDepthHandler(function () { - return 'handler'; - }); - $result = $this->serializer->normalize($level1, null, [ObjectNormalizer::ENABLE_MAX_DEPTH => true]); - $this->assertEquals($expected, $result); - - $this->createNormalizerWithMaxDepthHandler(function ($object, $parentObject, $attributeName, $format, $context) { - $this->assertSame('level3', $object); - $this->assertInstanceOf(MaxDepthDummy::class, $parentObject); - $this->assertSame('foo', $attributeName); - $this->assertSame('test', $format); - $this->assertArrayHasKey(ObjectNormalizer::ENABLE_MAX_DEPTH, $context); - - return 'handler'; - }); - $this->serializer->normalize($level1, 'test', [ObjectNormalizer::ENABLE_MAX_DEPTH => true]); - } - - private function createNormalizerWithMaxDepthHandler(callable $handler = null) - { - $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); - $this->createNormalizer([], $classMetadataFactory); - if (null !== $handler) { - $this->normalizer->setMaxDepthHandler($handler); - } - $this->serializer = new Serializer([$this->normalizer]); - $this->normalizer->setSerializer($this->serializer); - } - // object to populate protected function getDenormalizerForObjectToPopulate(): ObjectNormalizer diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php index b1c9fcef003b8..6f1874125434a 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php @@ -16,8 +16,6 @@ use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor; use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; use Symfony\Component\PropertyInfo\PropertyInfoExtractor; -use Symfony\Component\Serializer\Exception\CircularReferenceException; -use Symfony\Component\Serializer\Exception\InvalidArgumentException; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter; @@ -31,7 +29,6 @@ use Symfony\Component\Serializer\Tests\Fixtures\GroupDummyChild; use Symfony\Component\Serializer\Tests\Fixtures\PropertyCircularReferenceDummy; use Symfony\Component\Serializer\Tests\Fixtures\PropertySiblingHolder; -use Symfony\Component\Serializer\Tests\Normalizer\Features\CallbacksObject; use Symfony\Component\Serializer\Tests\Normalizer\Features\CallbacksTestTrait; use Symfony\Component\Serializer\Tests\Normalizer\Features\CircularReferenceTestTrait; use Symfony\Component\Serializer\Tests\Normalizer\Features\ConstructorArgumentsTestTrait; @@ -152,31 +149,6 @@ protected function getNormalizerForCallbacks(): PropertyNormalizer return new PropertyNormalizer(); } - /** - * @dataProvider provideCallbacks - */ - public function testLegacyCallbacks($callbacks, $value, $result) - { - $this->normalizer->setCallbacks($callbacks); - - $obj = new CallbacksObject($value); - - $this->assertEquals( - $result, - $this->normalizer->normalize($obj, 'any') - ); - } - - /** - * @dataProvider provideInvalidCallbacks - */ - public function testLegacyUncallableCallbacks($callbacks) - { - $this->expectException(InvalidArgumentException::class); - - $this->normalizer->setCallbacks($callbacks); - } - protected function getNormalizerForCircularReference(): PropertyNormalizer { $normalizer = new PropertyNormalizer(); @@ -190,17 +162,6 @@ protected function getSelfReferencingModel() return new PropertyCircularReferenceDummy(); } - public function testLegacyUnableToNormalizeCircularReference() - { - $this->normalizer->setCircularReferenceLimit(2); - new Serializer([$this->normalizer]); - - $obj = new PropertyCircularReferenceDummy(); - - $this->expectException(CircularReferenceException::class); - $this->normalizer->normalize($obj); - } - public function testSiblingReference() { $serializer = new Serializer([$this->normalizer]); @@ -216,20 +177,6 @@ public function testSiblingReference() $this->assertEquals($expected, $this->normalizer->normalize($siblingHolder)); } - public function testLegacyCircularReferenceHandler() - { - $this->normalizer->setCircularReferenceHandler(function ($obj) { - return \get_class($obj); - }); - - new Serializer([$this->normalizer]); - - $obj = new PropertyCircularReferenceDummy(); - - $expected = ['me' => PropertyCircularReferenceDummy::class]; - $this->assertEquals($expected, $this->normalizer->normalize($obj)); - } - protected function getDenormalizerForConstructArguments(): PropertyNormalizer { $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); @@ -319,21 +266,6 @@ public function testIgnoredAttributesContextDenormalizeInherit() $this->markTestSkipped('This has not been tested previously - did not manage to make the test work'); } - public function testLegacyIgnoredAttributes() - { - $ignoredAttributes = ['foo', 'bar', 'camelCase']; - $this->normalizer->setIgnoredAttributes($ignoredAttributes); - - $obj = new PropertyDummy(); - $obj->foo = 'foo'; - $obj->setBar('bar'); - - $this->assertEquals( - [], - $this->normalizer->normalize($obj, 'any') - ); - } - protected function getNormalizerForMaxDepth(): PropertyNormalizer { $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())); @@ -461,18 +393,6 @@ public function getBar() } } -class PropertyCamelizedDummy -{ - private $kevinDunglas; - public $fooBar; - public $bar_foo; - - public function __construct($kevinDunglas = null) - { - $this->kevinDunglas = $kevinDunglas; - } -} - class StaticPropertyDummy { private static $property = 'value'; From 4b6752bf3ec1e0df1c364030dd20c9853af0f5a8 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Tue, 28 May 2019 17:10:04 -0400 Subject: [PATCH 034/588] Removed capability to load Twig template from legacy directories --- .../Bridge/Twig/Command/DebugCommand.php | 34 +---------------- .../Twig/Tests/Command/DebugCommandTest.php | 26 ------------- src/Symfony/Bundle/TwigBundle/CHANGELOG.md | 1 + .../DependencyInjection/TwigExtension.php | 16 -------- .../DependencyInjection/TwigExtensionTest.php | 37 ------------------- .../TwigBundle/views/layout.html.twig | 1 - 6 files changed, 3 insertions(+), 112 deletions(-) delete mode 100644 src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/Resources/TwigBundle/views/layout.html.twig diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index e12fd9c04d34f..fa142d381e747 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -38,15 +38,10 @@ class DebugCommand extends Command private $projectDir; private $bundlesMetadata; private $twigDefaultPath; - private $rootDir; private $filesystemLoaders; private $fileLinkFormatter; - /** - * @param FileLinkFormatter|null $fileLinkFormatter - * @param string|null $rootDir - */ - public function __construct(Environment $twig, string $projectDir = null, array $bundlesMetadata = [], string $twigDefaultPath = null, $fileLinkFormatter = null, $rootDir = null) + public function __construct(Environment $twig, string $projectDir = null, array $bundlesMetadata = [], string $twigDefaultPath = null, FileLinkFormatter $fileLinkFormatter = null) { parent::__construct(); @@ -54,16 +49,7 @@ public function __construct(Environment $twig, string $projectDir = null, array $this->projectDir = $projectDir; $this->bundlesMetadata = $bundlesMetadata; $this->twigDefaultPath = $twigDefaultPath; - - if (\is_string($fileLinkFormatter) || $rootDir instanceof FileLinkFormatter) { - @trigger_error(sprintf('Passing a string as "$fileLinkFormatter" 5th argument or an instance of FileLinkFormatter as "$rootDir" 6th argument of the "%s()" method is deprecated since Symfony 4.4, swap the variables position.', __METHOD__), E_USER_DEPRECATED); - - $this->rootDir = $fileLinkFormatter; - $this->fileLinkFormatter = $rootDir; - } else { - $this->fileLinkFormatter = $fileLinkFormatter; - $this->rootDir = $rootDir; - } + $this->fileLinkFormatter = $fileLinkFormatter; } protected function configure() @@ -397,22 +383,6 @@ private function findWrongBundleOverrides(): array $alternatives = []; $bundleNames = []; - if ($this->rootDir && $this->projectDir) { - $folders = glob($this->rootDir.'/Resources/*/views', GLOB_ONLYDIR); - $relativePath = ltrim(substr($this->rootDir.\DIRECTORY_SEPARATOR.'Resources/', \strlen($this->projectDir)), \DIRECTORY_SEPARATOR); - $bundleNames = array_reduce($folders, function ($carry, $absolutePath) use ($relativePath) { - if (0 === strpos($absolutePath, $this->projectDir)) { - $name = basename(\dirname($absolutePath)); - $path = ltrim($relativePath.$name, \DIRECTORY_SEPARATOR); - $carry[$name] = $path; - - @trigger_error(sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, use "%s" instead.', $absolutePath, $this->twigDefaultPath.'/bundles/'.$name), E_USER_DEPRECATED); - } - - return $carry; - }, $bundleNames); - } - if ($this->twigDefaultPath && $this->projectDir) { $folders = glob($this->twigDefaultPath.'/bundles/*', GLOB_ONLYDIR); $relativePath = ltrim(substr($this->twigDefaultPath.'/bundles/', \strlen($this->projectDir)), \DIRECTORY_SEPARATOR); diff --git a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php index 516dd75387e62..17760e0718afd 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php @@ -63,32 +63,6 @@ public function testWarningsWrongBundleOverriding() $this->assertEquals($expected, json_decode($tester->getDisplay(true), true)); } - /** - * @group legacy - * @expectedDeprecation Loading Twig templates from the "%sResources/BarBundle/views" directory is deprecated since Symfony 4.2, use "%stemplates/bundles/BarBundle" instead. - */ - public function testDeprecationForWrongBundleOverridingInLegacyPath() - { - $bundleMetadata = [ - 'TwigBundle' => 'vendor/twig-bundle/', - 'WebProfilerBundle' => 'vendor/web-profiler-bundle/', - ]; - $defaultPath = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'templates'; - $rootDir = \dirname(__DIR__).\DIRECTORY_SEPARATOR.'Fixtures'; - - $tester = $this->createCommandTester([], $bundleMetadata, $defaultPath, $rootDir); - $ret = $tester->execute(['--filter' => 'unknown', '--format' => 'json'], ['decorated' => false]); - - $expected = ['warnings' => [ - 'Path "Resources/BarBundle" not matching any bundle found', - 'Path "templates/bundles/UnknownBundle" not matching any bundle found', - 'Path "templates/bundles/WebProfileBundle" not matching any bundle found, did you mean "WebProfilerBundle"?', - ]]; - - $this->assertEquals(0, $ret, 'Returns 0 in case of success'); - $this->assertEquals($expected, json_decode($tester->getDisplay(true), true)); - } - /** * @expectedException \Symfony\Component\Console\Exception\InvalidArgumentException * @expectedExceptionMessage Malformed namespaced template name "@foo" (expecting "@namespace/template_name"). diff --git a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md index 7a9d02e29a1a0..9f7ddd9fbe2a6 100644 --- a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG ----- * updated default value for the `strict_variables` option to `%kernel.debug%` parameter + * removed support to load templates from the legacy directories `src/Resources/views/` and `src/Resources//views/` 4.2.0 ----- diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index 8f8b65cf2ec0b..d56dc154c7f43 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -120,15 +120,6 @@ public function load(array $configs, ContainerBuilder $container) } } - if (file_exists($dir = $container->getParameter('kernel.root_dir').'/Resources/views')) { - if ($dir !== $defaultTwigPath) { - @trigger_error(sprintf('Loading Twig templates from the "%s" directory is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultTwigPath), E_USER_DEPRECATED); - } - - $twigFilesystemLoaderDefinition->addMethodCall('addPath', [$dir]); - } - $container->addResource(new FileExistenceResource($dir)); - if (file_exists($defaultTwigPath)) { $twigFilesystemLoaderDefinition->addMethodCall('addPath', [$defaultTwigPath]); } @@ -176,13 +167,6 @@ private function getBundleTemplatePaths(ContainerBuilder $container, array $conf foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) { $defaultOverrideBundlePath = $container->getParameterBag()->resolveValue($config['default_path']).'/bundles/'.$name; - if (file_exists($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$name.'/views')) { - @trigger_error(sprintf('Loading Twig templates for "%s" from the "%s" directory is deprecated since Symfony 4.2, use "%s" instead.', $name, $dir, $defaultOverrideBundlePath), E_USER_DEPRECATED); - - $bundleHierarchy[$name][] = $dir; - } - $container->addResource(new FileExistenceResource($dir)); - if (file_exists($defaultOverrideBundlePath)) { $bundleHierarchy[$name][] = $defaultOverrideBundlePath; } diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index 7b3595e93c0cd..bfff63ab21507 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -197,43 +197,6 @@ public function testTwigLoaderPaths($format) ], $paths); } - /** - * @group legacy - * @dataProvider getFormats - * @expectedDeprecation Loading Twig templates for "TwigBundle" from the "%s/Resources/TwigBundle/views" directory is deprecated since Symfony 4.2, use "%s/templates/bundles/TwigBundle" instead. - * @expectedDeprecation Loading Twig templates from the "%s/Resources/views" directory is deprecated since Symfony 4.2, use "%s/templates" instead. - */ - public function testLegacyTwigLoaderPaths($format) - { - $container = $this->createContainer(__DIR__.'/../Fixtures/templates'); - $container->registerExtension(new TwigExtension()); - $this->loadFromFile($container, 'full', $format); - $this->loadFromFile($container, 'extra', $format); - $this->compileContainer($container); - - $def = $container->getDefinition('twig.loader.native_filesystem'); - $paths = []; - foreach ($def->getMethodCalls() as $call) { - if ('addPath' === $call[0] && false === strpos($call[1][0], 'Form')) { - $paths[] = $call[1]; - } - } - - $this->assertEquals([ - ['path1'], - ['path2'], - ['namespaced_path1', 'namespace1'], - ['namespaced_path2', 'namespace2'], - ['namespaced_path3', 'namespace3'], - [__DIR__.'/../Fixtures/templates/Resources/TwigBundle/views', 'Twig'], - [__DIR__.'/Fixtures/templates/bundles/TwigBundle', 'Twig'], - [realpath(__DIR__.'/../..').'/Resources/views', 'Twig'], - [realpath(__DIR__.'/../..').'/Resources/views', '!Twig'], - [__DIR__.'/../Fixtures/templates/Resources/views'], - [__DIR__.'/Fixtures/templates'], - ], $paths); - } - public function getFormats() { return [ diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/Resources/TwigBundle/views/layout.html.twig b/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/Resources/TwigBundle/views/layout.html.twig deleted file mode 100644 index 1975b0e15986a..0000000000000 --- a/src/Symfony/Bundle/TwigBundle/Tests/Fixtures/templates/Resources/TwigBundle/views/layout.html.twig +++ /dev/null @@ -1 +0,0 @@ -{# Twig template #} From 678e066aa8b2d91bec50c56a081435300f58fcf8 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 29 May 2019 22:50:07 +0200 Subject: [PATCH 035/588] [EventDispatcher] Remove deprecation layer. --- .../Component/EventDispatcher/CHANGELOG.md | 8 ++ .../Debug/TraceableEventDispatcher.php | 60 ++------- .../TraceableEventDispatcherInterface.php | 42 ------ .../EventDispatcher/Debug/WrappedListener.php | 24 ++-- .../Component/EventDispatcher/Event.php | 38 ------ .../EventDispatcher/EventDispatcher.php | 47 ++----- .../EventDispatcherInterface.php | 5 + .../EventDispatcher/GenericEvent.php | 2 + .../ImmutableEventDispatcher.php | 15 +-- .../LegacyEventDispatcherProxy.php | 126 +----------------- .../EventDispatcher/LegacyEventProxy.php | 62 --------- .../Debug/TraceableEventDispatcherTest.php | 16 +-- .../Tests/EventDispatcherTest.php | 21 +-- .../EventDispatcher/Tests/EventTest.php | 55 -------- .../Tests/ImmutableEventDispatcherTest.php | 8 +- .../Tests/LegacyEventDispatcherTest.php | 35 ----- src/Symfony/Component/Form/FormEvent.php | 2 +- .../DataCollector/EventDataCollector.php | 6 +- .../HttpKernel/Event/KernelEvent.php | 2 +- .../Debug/TraceableEventDispatcherTest.php | 2 +- .../Component/Mailer/Event/MessageEvent.php | 2 +- .../Core/Event/AuthenticationEvent.php | 2 +- .../Security/Core/Event/VoteEvent.php | 2 +- .../Http/Event/InteractiveLoginEvent.php | 2 +- .../Security/Http/Event/SwitchUserEvent.php | 2 +- .../Component/Workflow/Event/Event.php | 2 +- .../Component/Workflow/Tests/WorkflowTest.php | 4 +- 27 files changed, 73 insertions(+), 519 deletions(-) delete mode 100644 src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php delete mode 100644 src/Symfony/Component/EventDispatcher/Event.php delete mode 100644 src/Symfony/Component/EventDispatcher/LegacyEventProxy.php delete mode 100644 src/Symfony/Component/EventDispatcher/Tests/EventTest.php delete mode 100644 src/Symfony/Component/EventDispatcher/Tests/LegacyEventDispatcherTest.php diff --git a/src/Symfony/Component/EventDispatcher/CHANGELOG.md b/src/Symfony/Component/EventDispatcher/CHANGELOG.md index 7653cad1c0eb0..6e2360b55b831 100644 --- a/src/Symfony/Component/EventDispatcher/CHANGELOG.md +++ b/src/Symfony/Component/EventDispatcher/CHANGELOG.md @@ -1,6 +1,14 @@ CHANGELOG ========= +5.0.0 +----- + + * The signature of the `EventDispatcherInterface::dispatch()` method has been changed to `dispatch($event, string $eventName = null): object`. + * The `Event` class has been removed in favor of `Symfony\Contracts\EventDispatcher\Event`. + * The `TraceableEventDispatcherInterface` has been removed. + * The `WrappedListener` class is now final. + 4.3.0 ----- diff --git a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php index 7716d8663177e..1f6b0af51e57f 100644 --- a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php @@ -14,14 +14,12 @@ use Psr\EventDispatcher\StoppableEventInterface; use Psr\Log\LoggerInterface; use Symfony\Component\BrowserKit\Request; -use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy; -use Symfony\Component\EventDispatcher\LegacyEventProxy; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Stopwatch\Stopwatch; -use Symfony\Contracts\EventDispatcher\Event as ContractsEvent; +use Symfony\Contracts\EventDispatcher\Event; +use Symfony\Contracts\Service\ResetInterface; /** * Collects some data about event listeners. @@ -30,7 +28,7 @@ * * @author Fabien Potencier */ -class TraceableEventDispatcher implements TraceableEventDispatcherInterface +class TraceableEventDispatcher implements EventDispatcherInterface, ResetInterface { protected $logger; protected $stopwatch; @@ -44,7 +42,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface public function __construct(EventDispatcherInterface $dispatcher, Stopwatch $stopwatch, LoggerInterface $logger = null, RequestStack $requestStack = null) { - $this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher); + $this->dispatcher = $dispatcher; $this->stopwatch = $stopwatch; $this->logger = $logger; $this->wrappedListeners = []; @@ -130,32 +128,22 @@ public function hasListeners($eventName = null) /** * {@inheritdoc} - * - * @param string|null $eventName */ - public function dispatch($event/*, string $eventName = null*/) + public function dispatch($event, string $eventName = null): object { + if (!\is_object($event)) { + throw new \TypeError(sprintf('Argument 1 passed to "%s::dispatch()" must be an object, %s given.', EventDispatcherInterface::class, \gettype($event))); + } + + $eventName = $eventName ?? \get_class($event); + if (null === $this->callStack) { $this->callStack = new \SplObjectStorage(); } $currentRequestHash = $this->currentRequestHash = $this->requestStack && ($request = $this->requestStack->getCurrentRequest()) ? spl_object_hash($request) : ''; - $eventName = 1 < \func_num_args() ? \func_get_arg(1) : null; - - if (\is_object($event)) { - $eventName = $eventName ?? \get_class($event); - } else { - @trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as first argument is deprecated since Symfony 4.3, pass it second and provide the event object first instead.', EventDispatcherInterface::class), E_USER_DEPRECATED); - $swap = $event; - $event = $eventName ?? new Event(); - $eventName = $swap; - - if (!$event instanceof Event) { - throw new \TypeError(sprintf('Argument 1 passed to "%s::dispatch()" must be an instance of %s, %s given.', EventDispatcherInterface::class, Event::class, \is_object($event) ? \get_class($event) : \gettype($event))); - } - } - if (null !== $this->logger && ($event instanceof Event || $event instanceof ContractsEvent || $event instanceof StoppableEventInterface) && $event->isPropagationStopped()) { + if (null !== $this->logger && ($event instanceof Event || $event instanceof StoppableEventInterface) && $event->isPropagationStopped()) { $this->logger->debug(sprintf('The "%s" event is already stopped. No listeners have been called.', $eventName)); } @@ -291,35 +279,15 @@ public function __call($method, $arguments) /** * Called before dispatching the event. - * - * @param object $event */ - protected function beforeDispatch(string $eventName, $event) + protected function beforeDispatch(string $eventName, object $event) { - $this->preDispatch($eventName, $event instanceof Event ? $event : new LegacyEventProxy($event)); } /** * Called after dispatching the event. - * - * @param object $event - */ - protected function afterDispatch(string $eventName, $event) - { - $this->postDispatch($eventName, $event instanceof Event ? $event : new LegacyEventProxy($event)); - } - - /** - * @deprecated since Symfony 4.3, will be removed in 5.0, use beforeDispatch instead - */ - protected function preDispatch($eventName, Event $event) - { - } - - /** - * @deprecated since Symfony 4.3, will be removed in 5.0, use afterDispatch instead */ - protected function postDispatch($eventName, Event $event) + protected function afterDispatch(string $eventName, object $event) { } diff --git a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php b/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php deleted file mode 100644 index 4fedb9a413a3b..0000000000000 --- a/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Debug; - -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Contracts\Service\ResetInterface; - -/** - * @deprecated since Symfony 4.1 - * - * @author Fabien Potencier - */ -interface TraceableEventDispatcherInterface extends EventDispatcherInterface, ResetInterface -{ - /** - * Gets the called listeners. - * - * @param Request|null $request The request to get listeners for - * - * @return array An array of called listeners - */ - public function getCalledListeners(/* Request $request = null */); - - /** - * Gets the not called listeners. - * - * @param Request|null $request The request to get listeners for - * - * @return array An array of not called listeners - */ - public function getNotCalledListeners(/* Request $request = null */); -} diff --git a/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php b/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php index e047639081c78..35905c0c05912 100644 --- a/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php +++ b/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php @@ -12,19 +12,15 @@ namespace Symfony\Component\EventDispatcher\Debug; use Psr\EventDispatcher\StoppableEventInterface; -use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\LegacyEventProxy; use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Component\VarDumper\Caster\ClassStub; -use Symfony\Contracts\EventDispatcher\Event as ContractsEvent; +use Symfony\Contracts\EventDispatcher\Event; /** * @author Fabien Potencier - * - * @final since Symfony 4.3: the "Event" type-hint on __invoke() will be replaced by "object" in 5.0 */ -class WrappedListener +final class WrappedListener { private $listener; private $optimizedListener; @@ -81,22 +77,22 @@ public function getWrappedListener() return $this->listener; } - public function wasCalled() + public function wasCalled(): bool { return $this->called; } - public function stoppedPropagation() + public function stoppedPropagation(): bool { return $this->stoppedPropagation; } - public function getPretty() + public function getPretty(): string { return $this->pretty; } - public function getInfo($eventName) + public function getInfo(string $eventName): array { if (null === $this->stub) { $this->stub = self::$hasClassStub ? new ClassStub($this->pretty.'()', $this->listener) : $this->pretty.'()'; @@ -110,12 +106,8 @@ public function getInfo($eventName) ]; } - public function __invoke(Event $event, $eventName, EventDispatcherInterface $dispatcher) + public function __invoke(object $event, string $eventName, EventDispatcherInterface $dispatcher): void { - if ($event instanceof LegacyEventProxy) { - $event = $event->getEvent(); - } - $dispatcher = $this->dispatcher ?: $dispatcher; $this->called = true; @@ -129,7 +121,7 @@ public function __invoke(Event $event, $eventName, EventDispatcherInterface $dis $e->stop(); } - if (($event instanceof Event || $event instanceof ContractsEvent || $event instanceof StoppableEventInterface) && $event->isPropagationStopped()) { + if (($event instanceof Event || $event instanceof StoppableEventInterface) && $event->isPropagationStopped()) { $this->stoppedPropagation = true; } } diff --git a/src/Symfony/Component/EventDispatcher/Event.php b/src/Symfony/Component/EventDispatcher/Event.php deleted file mode 100644 index 307c4be5de0c2..0000000000000 --- a/src/Symfony/Component/EventDispatcher/Event.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * @deprecated since Symfony 4.3, use "Symfony\Contracts\EventDispatcher\Event" instead - */ -class Event -{ - private $propagationStopped = false; - - /** - * @return bool Whether propagation was already stopped for this event - * - * @deprecated since Symfony 4.3, use "Symfony\Contracts\EventDispatcher\Event" instead - */ - public function isPropagationStopped() - { - return $this->propagationStopped; - } - - /** - * @deprecated since Symfony 4.3, use "Symfony\Contracts\EventDispatcher\Event" instead - */ - public function stopPropagation() - { - $this->propagationStopped = true; - } -} diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcher.php b/src/Symfony/Component/EventDispatcher/EventDispatcher.php index e68918c31c680..ecbb44587429f 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcher.php @@ -13,7 +13,7 @@ use Psr\EventDispatcher\StoppableEventInterface; use Symfony\Component\EventDispatcher\Debug\WrappedListener; -use Symfony\Contracts\EventDispatcher\Event as ContractsEvent; +use Symfony\Contracts\EventDispatcher\Event; /** * The EventDispatcherInterface is the central point of Symfony's event listener system. @@ -45,26 +45,15 @@ public function __construct() /** * {@inheritdoc} - * - * @param string|null $eventName */ - public function dispatch($event/*, string $eventName = null*/) + public function dispatch($event, string $eventName = null): object { - $eventName = 1 < \func_num_args() ? \func_get_arg(1) : null; - - if (\is_object($event)) { - $eventName = $eventName ?? \get_class($event); - } else { - @trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as first argument is deprecated since Symfony 4.3, pass it second and provide the event object first instead.', EventDispatcherInterface::class), E_USER_DEPRECATED); - $swap = $event; - $event = $eventName ?? new Event(); - $eventName = $swap; - - if (!$event instanceof Event) { - throw new \TypeError(sprintf('Argument 1 passed to "%s::dispatch()" must be an instance of %s, %s given.', EventDispatcherInterface::class, Event::class, \is_object($event) ? \get_class($event) : \gettype($event))); - } + if (!\is_object($event)) { + throw new \TypeError(sprintf('Argument 1 passed to "%s::dispatch()" must be an object, %s given.', EventDispatcherInterface::class, \gettype($event))); } + $eventName = $eventName ?? \get_class($event); + if (null !== $this->optimized && null !== $eventName) { $listeners = $this->optimized[$eventName] ?? (empty($this->listeners[$eventName]) ? [] : $this->optimizeListeners($eventName)); } else { @@ -229,34 +218,14 @@ public function removeSubscriber(EventSubscriberInterface $subscriber) * @param string $eventName The name of the event to dispatch * @param object $event The event object to pass to the event handlers/listeners */ - protected function callListeners(iterable $listeners, string $eventName, $event) + protected function callListeners(iterable $listeners, string $eventName, object $event) { - if ($event instanceof Event) { - $this->doDispatch($listeners, $eventName, $event); - - return; - } - - $stoppable = $event instanceof ContractsEvent || $event instanceof StoppableEventInterface; + $stoppable = $event instanceof Event || $event instanceof StoppableEventInterface; foreach ($listeners as $listener) { if ($stoppable && $event->isPropagationStopped()) { break; } - // @deprecated: the ternary operator is part of a BC layer and should be removed in 5.0 - $listener($listener instanceof WrappedListener ? new LegacyEventProxy($event) : $event, $eventName, $this); - } - } - - /** - * @deprecated since Symfony 4.3, use callListeners() instead - */ - protected function doDispatch($listeners, $eventName, Event $event) - { - foreach ($listeners as $listener) { - if ($event->isPropagationStopped()) { - break; - } $listener($event, $eventName, $this); } } diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php index ceaa62aeb0472..146ae5b393caa 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php @@ -22,6 +22,11 @@ */ interface EventDispatcherInterface extends ContractsEventDispatcherInterface { + /** + * {@inheritdoc} + */ + public function dispatch($event, string $eventName = null): object; + /** * Adds an event listener that listens on the specified events. * diff --git a/src/Symfony/Component/EventDispatcher/GenericEvent.php b/src/Symfony/Component/EventDispatcher/GenericEvent.php index f005e3a3db076..62bd59c903c08 100644 --- a/src/Symfony/Component/EventDispatcher/GenericEvent.php +++ b/src/Symfony/Component/EventDispatcher/GenericEvent.php @@ -11,6 +11,8 @@ namespace Symfony\Component\EventDispatcher; +use Symfony\Contracts\EventDispatcher\Event; + /** * Event encapsulation class. * diff --git a/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php b/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php index 082e2a05d48f9..f164e8b29800f 100644 --- a/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php @@ -22,25 +22,14 @@ class ImmutableEventDispatcher implements EventDispatcherInterface public function __construct(EventDispatcherInterface $dispatcher) { - $this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher); + $this->dispatcher = $dispatcher; } /** * {@inheritdoc} - * - * @param string|null $eventName */ - public function dispatch($event/*, string $eventName = null*/) + public function dispatch($event, string $eventName = null): object { - $eventName = 1 < \func_num_args() ? \func_get_arg(1) : null; - - if (\is_scalar($event)) { - // deprecated - $swap = $event; - $event = $eventName ?? new Event(); - $eventName = $swap; - } - return $this->dispatcher->dispatch($event, $eventName); } diff --git a/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php b/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php index 3ae3735e23e52..bde2e0b784906 100644 --- a/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php +++ b/src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php @@ -11,9 +11,7 @@ namespace Symfony\Component\EventDispatcher; -use Psr\EventDispatcher\StoppableEventInterface; -use Symfony\Contracts\EventDispatcher\Event as ContractsEvent; -use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as ContractsEventDispatcherInterface; +use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; /** * An helper class to provide BC/FC with the legacy signature of EventDispatcherInterface::dispatch(). @@ -22,126 +20,10 @@ * * @author Nicolas Grekas */ -final class LegacyEventDispatcherProxy implements EventDispatcherInterface +final class LegacyEventDispatcherProxy { - private $dispatcher; - - public static function decorate(?ContractsEventDispatcherInterface $dispatcher): ?ContractsEventDispatcherInterface - { - if (null === $dispatcher) { - return null; - } - $r = new \ReflectionMethod($dispatcher, 'dispatch'); - $param2 = $r->getParameters()[1] ?? null; - - if (!$param2 || !$param2->hasType() || $param2->getType()->isBuiltin()) { - return $dispatcher; - } - - @trigger_error(sprintf('The signature of the "%s::dispatch()" method should be updated to "dispatch($event, string $eventName = null)", not doing so is deprecated since Symfony 4.3.', $r->class), E_USER_DEPRECATED); - - $self = new self(); - $self->dispatcher = $dispatcher; - - return $self; - } - - /** - * {@inheritdoc} - * - * @param string|null $eventName - */ - public function dispatch($event/*, string $eventName = null*/) - { - $eventName = 1 < \func_num_args() ? \func_get_arg(1) : null; - - if (\is_object($event)) { - $eventName = $eventName ?? \get_class($event); - } else { - @trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as first argument is deprecated since Symfony 4.3, pass it second and provide the event object first instead.', ContractsEventDispatcherInterface::class), E_USER_DEPRECATED); - $swap = $event; - $event = $eventName ?? new Event(); - $eventName = $swap; - - if (!$event instanceof Event) { - throw new \TypeError(sprintf('Argument 1 passed to "%s::dispatch()" must be an instance of %s, %s given.', ContractsEventDispatcherInterface::class, Event::class, \is_object($event) ? \get_class($event) : \gettype($event))); - } - } - - $listeners = $this->getListeners($eventName); - $stoppable = $event instanceof Event || $event instanceof ContractsEvent || $event instanceof StoppableEventInterface; - - foreach ($listeners as $listener) { - if ($stoppable && $event->isPropagationStopped()) { - break; - } - $listener($event, $eventName, $this); - } - - return $event; - } - - /** - * {@inheritdoc} - */ - public function addListener($eventName, $listener, $priority = 0) - { - return $this->dispatcher->addListener($eventName, $listener, $priority); - } - - /** - * {@inheritdoc} - */ - public function addSubscriber(EventSubscriberInterface $subscriber) - { - return $this->dispatcher->addSubscriber($subscriber); - } - - /** - * {@inheritdoc} - */ - public function removeListener($eventName, $listener) - { - return $this->dispatcher->removeListener($eventName, $listener); - } - - /** - * {@inheritdoc} - */ - public function removeSubscriber(EventSubscriberInterface $subscriber) - { - return $this->dispatcher->removeSubscriber($subscriber); - } - - /** - * {@inheritdoc} - */ - public function getListeners($eventName = null) - { - return $this->dispatcher->getListeners($eventName); - } - - /** - * {@inheritdoc} - */ - public function getListenerPriority($eventName, $listener) - { - return $this->dispatcher->getListenerPriority($eventName, $listener); - } - - /** - * {@inheritdoc} - */ - public function hasListeners($eventName = null) - { - return $this->dispatcher->hasListeners($eventName); - } - - /** - * Proxies all method calls to the original event dispatcher. - */ - public function __call($method, $arguments) + public static function decorate(?EventDispatcherInterface $dispatcher): ?EventDispatcherInterface { - return $this->dispatcher->{$method}(...$arguments); + return $dispatcher; } } diff --git a/src/Symfony/Component/EventDispatcher/LegacyEventProxy.php b/src/Symfony/Component/EventDispatcher/LegacyEventProxy.php deleted file mode 100644 index cad8cfaedb724..0000000000000 --- a/src/Symfony/Component/EventDispatcher/LegacyEventProxy.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -use Psr\EventDispatcher\StoppableEventInterface; -use Symfony\Contracts\EventDispatcher\Event as ContractsEvent; - -/** - * @internal to be removed in 5.0. - */ -final class LegacyEventProxy extends Event -{ - private $event; - - /** - * @param object $event - */ - public function __construct($event) - { - $this->event = $event; - } - - /** - * @return object $event - */ - public function getEvent() - { - return $this->event; - } - - public function isPropagationStopped() - { - if (!$this->event instanceof ContractsEvent && !$this->event instanceof StoppableEventInterface) { - return false; - } - - return $this->event->isPropagationStopped(); - } - - public function stopPropagation() - { - if (!$this->event instanceof ContractsEvent) { - return; - } - - $this->event->stopPropagation(); - } - - public function __call($name, $args) - { - return $this->event->{$name}(...$args); - } -} diff --git a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php index ea476eee04c8e..5017d91fa8b4e 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php @@ -13,12 +13,11 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher; -use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Stopwatch\Stopwatch; -use Symfony\Contracts\EventDispatcher\Event as ContractsEvent; +use Symfony\Contracts\EventDispatcher\Event; class TraceableEventDispatcherTest extends TestCase { @@ -140,19 +139,6 @@ public function testClearCalledListeners() $this->assertEquals([['event' => 'foo', 'pretty' => 'closure', 'priority' => 5]], $listeners); } - public function testDispatchContractsEvent() - { - $expectedEvent = new ContractsEvent(); - $tdispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $tdispatcher->addListener('foo', function ($event) use ($expectedEvent) { - $this->assertSame($event, $expectedEvent); - }, 5); - $tdispatcher->dispatch($expectedEvent, 'foo'); - - $listeners = $tdispatcher->getCalledListeners(); - $this->assertArrayHasKey('stub', $listeners[0]); - } - public function testDispatchAfterReset() { $tdispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); diff --git a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php index e89f78cda8e89..c71c3f59f83dd 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php @@ -12,10 +12,9 @@ namespace Symfony\Component\EventDispatcher\Tests; use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Contracts\EventDispatcher\Event as ContractsEvent; +use Symfony\Contracts\EventDispatcher\Event; class EventDispatcherTest extends TestCase { @@ -135,22 +134,8 @@ public function testDispatch() $this->dispatcher->dispatch(new Event(), self::preFoo); $this->assertTrue($this->listener->preFooInvoked); $this->assertFalse($this->listener->postFooInvoked); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), 'noevent')); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), self::preFoo)); - $event = new Event(); - $return = $this->dispatcher->dispatch($event, self::preFoo); - $this->assertSame($event, $return); - } - - public function testDispatchContractsEvent() - { - $this->dispatcher->addListener('pre.foo', [$this->listener, 'preFoo']); - $this->dispatcher->addListener('post.foo', [$this->listener, 'postFoo']); - $this->dispatcher->dispatch(new ContractsEvent(), self::preFoo); - $this->assertTrue($this->listener->preFooInvoked); - $this->assertFalse($this->listener->postFooInvoked); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), 'noevent')); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), self::preFoo)); + $this->assertInstanceOf('Symfony\Contracts\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), 'noevent')); + $this->assertInstanceOf('Symfony\Contracts\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), self::preFoo)); $event = new Event(); $return = $this->dispatcher->dispatch($event, self::preFoo); $this->assertSame($event, $return); diff --git a/src/Symfony/Component/EventDispatcher/Tests/EventTest.php b/src/Symfony/Component/EventDispatcher/Tests/EventTest.php deleted file mode 100644 index ca8e945c649cf..0000000000000 --- a/src/Symfony/Component/EventDispatcher/Tests/EventTest.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\Event; - -/** - * @group legacy - */ -class EventTest extends TestCase -{ - /** - * @var \Symfony\Component\EventDispatcher\Event - */ - protected $event; - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - protected function setUp() - { - $this->event = new Event(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - $this->event = null; - } - - public function testIsPropagationStopped() - { - $this->assertFalse($this->event->isPropagationStopped()); - } - - public function testStopPropagationAndIsPropagationStopped() - { - $this->event->stopPropagation(); - $this->assertTrue($this->event->isPropagationStopped()); - } -} diff --git a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php index f6556f0b1be75..15a40e8614673 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php @@ -12,8 +12,8 @@ namespace Symfony\Component\EventDispatcher\Tests; use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\ImmutableEventDispatcher; +use Symfony\Contracts\EventDispatcher\Event; /** * @author Bernhard Schussek @@ -39,13 +39,15 @@ protected function setUp() public function testDispatchDelegates() { $event = new Event(); + $expectedResult = new class() { + }; $this->innerDispatcher->expects($this->once()) ->method('dispatch') ->with($event, 'event') - ->willReturn('result'); + ->willReturn($expectedResult); - $this->assertSame('result', $this->dispatcher->dispatch($event, 'event')); + $this->assertSame($expectedResult, $this->dispatcher->dispatch($event, 'event')); } public function testGetListenersDelegates() diff --git a/src/Symfony/Component/EventDispatcher/Tests/LegacyEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/LegacyEventDispatcherTest.php deleted file mode 100644 index 49aa2f9ff3f92..0000000000000 --- a/src/Symfony/Component/EventDispatcher/Tests/LegacyEventDispatcherTest.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy; - -/** - * @group legacy - */ -class LegacyEventDispatcherTest extends EventDispatcherTest -{ - protected function createEventDispatcher() - { - return LegacyEventDispatcherProxy::decorate(new TestLegacyEventDispatcher()); - } -} - -class TestLegacyEventDispatcher extends EventDispatcher -{ - public function dispatch($eventName, Event $event = null) - { - return parent::dispatch($event, $eventName); - } -} diff --git a/src/Symfony/Component/Form/FormEvent.php b/src/Symfony/Component/Form/FormEvent.php index 3b6d484e75803..45c3f93b0c581 100644 --- a/src/Symfony/Component/Form/FormEvent.php +++ b/src/Symfony/Component/Form/FormEvent.php @@ -11,7 +11,7 @@ namespace Symfony\Component\Form; -use Symfony\Component\EventDispatcher\Event; +use Symfony\Contracts\EventDispatcher\Event; /** * @author Bernhard Schussek diff --git a/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php index d918ddf786634..37145c4abe734 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\DataCollector; use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher; -use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; @@ -60,12 +59,9 @@ public function reset() public function lateCollect() { - if ($this->dispatcher instanceof TraceableEventDispatcherInterface) { + if ($this->dispatcher instanceof TraceableEventDispatcher) { $this->setCalledListeners($this->dispatcher->getCalledListeners($this->currentRequest)); $this->setNotCalledListeners($this->dispatcher->getNotCalledListeners($this->currentRequest)); - } - - if ($this->dispatcher instanceof TraceableEventDispatcher) { $this->setOrphanedEvents($this->dispatcher->getOrphanedEvents($this->currentRequest)); } diff --git a/src/Symfony/Component/HttpKernel/Event/KernelEvent.php b/src/Symfony/Component/HttpKernel/Event/KernelEvent.php index f3db8a60d9ec2..e46510a95163e 100644 --- a/src/Symfony/Component/HttpKernel/Event/KernelEvent.php +++ b/src/Symfony/Component/HttpKernel/Event/KernelEvent.php @@ -11,9 +11,9 @@ namespace Symfony\Component\HttpKernel\Event; -use Symfony\Component\EventDispatcher\Event; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Contracts\EventDispatcher\Event; /** * Base class for events thrown in the HttpKernel component. diff --git a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php index bd70de9c3b9c8..aa973a7ad707e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Debug/TraceableEventDispatcherTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\Tests\Debug; use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; @@ -20,6 +19,7 @@ use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher; use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\Stopwatch\Stopwatch; +use Symfony\Contracts\EventDispatcher\Event; class TraceableEventDispatcherTest extends TestCase { diff --git a/src/Symfony/Component/Mailer/Event/MessageEvent.php b/src/Symfony/Component/Mailer/Event/MessageEvent.php index a0891e98688ca..7b11d7221c20d 100644 --- a/src/Symfony/Component/Mailer/Event/MessageEvent.php +++ b/src/Symfony/Component/Mailer/Event/MessageEvent.php @@ -11,9 +11,9 @@ namespace Symfony\Component\Mailer\Event; -use Symfony\Component\EventDispatcher\Event; use Symfony\Component\Mailer\SmtpEnvelope; use Symfony\Component\Mime\RawMessage; +use Symfony\Contracts\EventDispatcher\Event; /** * Allows the transformation of a Message. diff --git a/src/Symfony/Component/Security/Core/Event/AuthenticationEvent.php b/src/Symfony/Component/Security/Core/Event/AuthenticationEvent.php index d99aea5084b40..4fc151960b296 100644 --- a/src/Symfony/Component/Security/Core/Event/AuthenticationEvent.php +++ b/src/Symfony/Component/Security/Core/Event/AuthenticationEvent.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Security\Core\Event; -use Symfony\Component\EventDispatcher\Event; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Contracts\EventDispatcher\Event; /** * This is a general purpose authentication event. diff --git a/src/Symfony/Component/Security/Core/Event/VoteEvent.php b/src/Symfony/Component/Security/Core/Event/VoteEvent.php index 433fd1d8d2a87..7fec865a004d1 100644 --- a/src/Symfony/Component/Security/Core/Event/VoteEvent.php +++ b/src/Symfony/Component/Security/Core/Event/VoteEvent.php @@ -11,8 +11,8 @@ namespace Symfony\Component\Security\Core\Event; -use Symfony\Component\EventDispatcher\Event; use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; +use Symfony\Contracts\EventDispatcher\Event; /** * This event is dispatched on voter vote. diff --git a/src/Symfony/Component/Security/Http/Event/InteractiveLoginEvent.php b/src/Symfony/Component/Security/Http/Event/InteractiveLoginEvent.php index 767d50a27aa1c..9caae36661562 100644 --- a/src/Symfony/Component/Security/Http/Event/InteractiveLoginEvent.php +++ b/src/Symfony/Component/Security/Http/Event/InteractiveLoginEvent.php @@ -11,9 +11,9 @@ namespace Symfony\Component\Security\Http\Event; -use Symfony\Component\EventDispatcher\Event; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Contracts\EventDispatcher\Event; /** * @author Fabien Potencier diff --git a/src/Symfony/Component/Security/Http/Event/SwitchUserEvent.php b/src/Symfony/Component/Security/Http/Event/SwitchUserEvent.php index b1b24e3e83355..40d2eef33e650 100644 --- a/src/Symfony/Component/Security/Http/Event/SwitchUserEvent.php +++ b/src/Symfony/Component/Security/Http/Event/SwitchUserEvent.php @@ -11,10 +11,10 @@ namespace Symfony\Component\Security\Http\Event; -use Symfony\Component\EventDispatcher\Event; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\User\UserInterface; +use Symfony\Contracts\EventDispatcher\Event; /** * SwitchUserEvent. diff --git a/src/Symfony/Component/Workflow/Event/Event.php b/src/Symfony/Component/Workflow/Event/Event.php index 09ba70bd306e3..c741d7aab7c1a 100644 --- a/src/Symfony/Component/Workflow/Event/Event.php +++ b/src/Symfony/Component/Workflow/Event/Event.php @@ -11,10 +11,10 @@ namespace Symfony\Component\Workflow\Event; -use Symfony\Component\EventDispatcher\Event as BaseEvent; use Symfony\Component\Workflow\Marking; use Symfony\Component\Workflow\Transition; use Symfony\Component\Workflow\WorkflowInterface; +use Symfony\Contracts\EventDispatcher\Event as BaseEvent; /** * @author Fabien Potencier diff --git a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php index e543836fc9482..6579921d9e642 100644 --- a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php +++ b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php @@ -584,9 +584,11 @@ class EventDispatcherMock implements \Symfony\Component\EventDispatcher\EventDis { public $dispatchedEvents = []; - public function dispatch($event, string $eventName = null) + public function dispatch($event, string $eventName = null): object { $this->dispatchedEvents[] = $eventName; + + return $event; } public function addListener($eventName, $listener, $priority = 0) From 35de7e254541cb1fffebc3a15010740e2bef10e2 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 30 May 2019 11:39:41 +0200 Subject: [PATCH 036/588] remove simple_preauth and simple_form authenticators --- .../Bundle/SecurityBundle/CHANGELOG.md | 4 + .../DependencyInjection/MainConfiguration.php | 6 - .../Security/Factory/SimpleFormFactory.php | 87 -------- .../SimplePreAuthenticationFactory.php | 73 ------- .../Resources/config/security_listeners.xml | 37 ---- .../Bundle/SecurityBundle/SecurityBundle.php | 4 - .../CompleteConfigurationTest.php | 44 ---- .../Fixtures/php/simple_auth.php | 21 -- .../Fixtures/xml/simple_auth.xml | 21 -- .../Fixtures/yml/simple_auth.yml | 12 -- src/Symfony/Component/Security/CHANGELOG.md | 3 + .../Provider/SimpleAuthenticationProvider.php | 68 ------ .../SimpleAuthenticatorInterface.php | 27 --- .../SimpleAuthenticationProviderTest.php | 107 ---------- .../SimpleAuthenticationHandler.php | 108 ---------- .../SimpleFormAuthenticatorInterface.php | 25 --- .../SimplePreAuthenticatorInterface.php | 25 --- .../SimpleFormAuthenticationListener.php | 116 ---------- .../SimplePreAuthenticationListener.php | 152 ------------- .../SimpleAuthenticationHandlerTest.php | 199 ------------------ .../SimplePreAuthenticationListenerTest.php | 133 ------------ 21 files changed, 7 insertions(+), 1265 deletions(-) delete mode 100644 src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleFormFactory.php delete mode 100644 src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimplePreAuthenticationFactory.php delete mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/simple_auth.php delete mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/simple_auth.xml delete mode 100644 src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/simple_auth.yml delete mode 100644 src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php delete mode 100644 src/Symfony/Component/Security/Core/Authentication/SimpleAuthenticatorInterface.php delete mode 100644 src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php delete mode 100644 src/Symfony/Component/Security/Http/Authentication/SimpleAuthenticationHandler.php delete mode 100644 src/Symfony/Component/Security/Http/Authentication/SimpleFormAuthenticatorInterface.php delete mode 100644 src/Symfony/Component/Security/Http/Authentication/SimplePreAuthenticatorInterface.php delete mode 100644 src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php delete mode 100644 src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php delete mode 100644 src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php delete mode 100644 src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php diff --git a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md index 3986d50f73e74..d0cef610d9ced 100644 --- a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md @@ -5,6 +5,10 @@ CHANGELOG ----- * Removed the ability to configure encoders using `argon2i` or `bcrypt` as algorithm, use `auto` instead +* The `simple_form` and `simple_preauth` authentication listeners have been removed, + use Guard instead. +* The `SimpleFormFactory` and `SimplePreAuthenticationFactory` classes have been removed, + use Guard instead. 4.3.0 ----- diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php index eda62ed9ac715..bbeb60d3a7367 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php @@ -12,8 +12,6 @@ namespace Symfony\Bundle\SecurityBundle\DependencyInjection; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory; -use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SimpleFormFactory; -use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SimplePreAuthenticationFactory; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; @@ -292,10 +290,6 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto ->canBeUnset() ; - if ($factory instanceof SimplePreAuthenticationFactory || $factory instanceof SimpleFormFactory) { - $factoryNode->setDeprecated(sprintf('The "%s" security listener is deprecated Symfony 4.2, use Guard instead.', $name)); - } - if ($factory instanceof AbstractFactory) { $abstractFactoryKeys[] = $name; } diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleFormFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleFormFactory.php deleted file mode 100644 index 9ffd624a96d92..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleFormFactory.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; - -use Symfony\Component\Config\Definition\Builder\NodeDefinition; -use Symfony\Component\DependencyInjection\ChildDefinition; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; - -/** - * @author Jordi Boggiano - * - * @deprecated since Symfony 4.2, use Guard instead. - */ -class SimpleFormFactory extends FormLoginFactory -{ - public function __construct(bool $triggerDeprecation = true) - { - parent::__construct(); - - $this->addOption('authenticator', null); - - if ($triggerDeprecation) { - @trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use Guard instead.', __CLASS__), E_USER_DEPRECATED); - } - } - - public function getKey() - { - return 'simple-form'; - } - - public function addConfiguration(NodeDefinition $node) - { - parent::addConfiguration($node); - - $node->children() - ->scalarNode('authenticator')->cannotBeEmpty()->end() - ->end(); - } - - protected function getListenerId() - { - return 'security.authentication.listener.simple_form'; - } - - protected function createAuthProvider(ContainerBuilder $container, $id, $config, $userProviderId) - { - $provider = 'security.authentication.provider.simple_form.'.$id; - $container - ->setDefinition($provider, new ChildDefinition('security.authentication.provider.simple')) - ->replaceArgument(0, new Reference($config['authenticator'])) - ->replaceArgument(1, new Reference($userProviderId)) - ->replaceArgument(2, $id) - ->replaceArgument(3, new Reference('security.user_checker.'.$id)) - ; - - return $provider; - } - - protected function createListener($container, $id, $config, $userProvider) - { - $listenerId = parent::createListener($container, $id, $config, $userProvider); - - $simpleAuthHandlerId = 'security.authentication.simple_success_failure_handler.'.$id; - $simpleAuthHandler = $container->setDefinition($simpleAuthHandlerId, new ChildDefinition('security.authentication.simple_success_failure_handler')); - $simpleAuthHandler->replaceArgument(0, new Reference($config['authenticator'])); - $simpleAuthHandler->replaceArgument(1, new Reference($this->getSuccessHandlerId($id))); - $simpleAuthHandler->replaceArgument(2, new Reference($this->getFailureHandlerId($id))); - - $listener = $container->getDefinition($listenerId); - $listener->replaceArgument(5, new Reference($simpleAuthHandlerId)); - $listener->replaceArgument(6, new Reference($simpleAuthHandlerId)); - $listener->addArgument(new Reference($config['authenticator'])); - - return $listenerId; - } -} diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimplePreAuthenticationFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimplePreAuthenticationFactory.php deleted file mode 100644 index 04c5ce16aed02..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimplePreAuthenticationFactory.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory; - -use Symfony\Component\Config\Definition\Builder\NodeDefinition; -use Symfony\Component\DependencyInjection\ChildDefinition; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; - -/** - * @author Jordi Boggiano - * - * @deprecated since Symfony 4.2, use Guard instead. - */ -class SimplePreAuthenticationFactory implements SecurityFactoryInterface -{ - public function __construct(bool $triggerDeprecation = true) - { - if ($triggerDeprecation) { - @trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use Guard instead.', __CLASS__), E_USER_DEPRECATED); - } - } - - public function getPosition() - { - return 'pre_auth'; - } - - public function getKey() - { - return 'simple-preauth'; - } - - public function addConfiguration(NodeDefinition $node) - { - $node - ->children() - ->scalarNode('provider')->end() - ->scalarNode('authenticator')->cannotBeEmpty()->end() - ->end() - ; - } - - public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint) - { - $provider = 'security.authentication.provider.simple_preauth.'.$id; - $container - ->setDefinition($provider, new ChildDefinition('security.authentication.provider.simple')) - ->replaceArgument(0, new Reference($config['authenticator'])) - ->replaceArgument(1, new Reference($userProvider)) - ->replaceArgument(2, $id) - ->replaceArgument(3, new Reference('security.user_checker.'.$id)) - ; - - // listener - $listenerId = 'security.authentication.listener.simple_preauth.'.$id; - $listener = $container->setDefinition($listenerId, new ChildDefinition('security.authentication.listener.simple_preauth')); - $listener->replaceArgument(2, $id); - $listener->replaceArgument(3, new Reference($config['authenticator'])); - $listener->addMethodCall('setSessionAuthenticationStrategy', [new Reference('security.authentication.session_strategy.'.$id)]); - - return [$provider, $listenerId, null]; - } -} diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml index 9e3f96c366bfc..c27967a8e84ec 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml @@ -109,35 +109,6 @@ public="false" abstract="true" /> - - The "%service_id%" service is deprecated since Symfony 4.2. - - - - - - - - - The "%service_id%" service is deprecated since Symfony 4.2. - - - - - - - - - - - - The "%service_id%" service is deprecated since Symfony 4.2. - - @@ -199,14 +170,6 @@ %security.authentication.hide_user_not_found% - - - - - null - The "%service_id%" service is deprecated since Symfony 4.2. - - diff --git a/src/Symfony/Bundle/SecurityBundle/SecurityBundle.php b/src/Symfony/Bundle/SecurityBundle/SecurityBundle.php index e5035d765d5e3..5b1cc7de50dec 100644 --- a/src/Symfony/Bundle/SecurityBundle/SecurityBundle.php +++ b/src/Symfony/Bundle/SecurityBundle/SecurityBundle.php @@ -24,8 +24,6 @@ use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\JsonLoginLdapFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\RememberMeFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\RemoteUserFactory; -use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SimpleFormFactory; -use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SimplePreAuthenticationFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\X509Factory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\InMemoryFactory; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\LdapFactory; @@ -54,8 +52,6 @@ public function build(ContainerBuilder $container) $extension->addSecurityListenerFactory(new RememberMeFactory()); $extension->addSecurityListenerFactory(new X509Factory()); $extension->addSecurityListenerFactory(new RemoteUserFactory()); - $extension->addSecurityListenerFactory(new SimplePreAuthenticationFactory(false)); - $extension->addSecurityListenerFactory(new SimpleFormFactory(false)); $extension->addSecurityListenerFactory(new GuardAuthenticationFactory()); $extension->addUserProviderFactory(new InMemoryFactory()); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index 87de35e131c0a..6076bb3129c6b 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -474,50 +474,6 @@ public function testFirewallListenerWithProvider() $this->addToAssertionCount(1); } - /** - * @group legacy - * @expectedDeprecation The "simple_form" security listener is deprecated Symfony 4.2, use Guard instead. - */ - public function testSimpleAuth() - { - $container = $this->getContainer('simple_auth'); - $arguments = $container->getDefinition('security.firewall.map')->getArguments(); - $listeners = []; - $configs = []; - foreach (array_keys($arguments[1]->getValues()) as $contextId) { - $contextDef = $container->getDefinition($contextId); - $arguments = $contextDef->getArguments(); - $listeners[] = array_map('strval', $arguments['index_0']->getValues()); - - $configDef = $container->getDefinition((string) $arguments['index_3']); - $configs[] = array_values($configDef->getArguments()); - } - - $this->assertSame([[ - 'simple_auth', - 'security.user_checker', - null, - true, - false, - 'security.user.provider.concrete.default', - 'simple_auth', - 'security.authentication.form_entry_point.simple_auth', - null, - null, - ['simple_form', 'anonymous', - ], - null, - ]], $configs); - - $this->assertSame([[ - 'security.channel_listener', - 'security.context_listener.0', - 'security.authentication.listener.simple_form.simple_auth', - 'security.authentication.listener.anonymous.simple_auth', - 'security.access_listener', - ]], $listeners); - } - /** * @group legacy * @expectedDeprecation Normalization of cookie names is deprecated since Symfony 4.3. Starting from Symfony 5.0, the "cookie1-name" cookie configured in "logout.delete_cookies" will delete the "cookie1-name" cookie instead of the "cookie1_name" cookie. diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/simple_auth.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/simple_auth.php deleted file mode 100644 index 05829defd119d..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/simple_auth.php +++ /dev/null @@ -1,21 +0,0 @@ -loadFromExtension('security', [ - 'providers' => [ - 'default' => [ - 'memory' => [ - 'users' => [ - 'foo' => ['password' => 'foo', 'roles' => 'ROLE_USER'], - ], - ], - ], - ], - - 'firewalls' => [ - 'simple_auth' => [ - 'provider' => 'default', - 'anonymous' => true, - 'simple_form' => ['authenticator' => 'simple_authenticator'], - ], - ], -]); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/simple_auth.xml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/simple_auth.xml deleted file mode 100644 index 85fb312011bea..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/simple_auth.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/simple_auth.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/simple_auth.yml deleted file mode 100644 index b0f19e869b67c..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/simple_auth.yml +++ /dev/null @@ -1,12 +0,0 @@ -security: - providers: - default: - memory: - users: - foo: { password: foo, roles: ROLE_USER } - - firewalls: - simple_auth: - provider: default - anonymous: ~ - simple_form: { authenticator: simple_authenticator } diff --git a/src/Symfony/Component/Security/CHANGELOG.md b/src/Symfony/Component/Security/CHANGELOG.md index 6af6cf215b0bf..b2074b70aca95 100644 --- a/src/Symfony/Component/Security/CHANGELOG.md +++ b/src/Symfony/Component/Security/CHANGELOG.md @@ -7,6 +7,9 @@ CHANGELOG * Removed `Argon2iPasswordEncoder`, use `SodiumPasswordEncoder` instead * Removed `BcryptPasswordEncoder`, use `NativePasswordEncoder` instead * Removed the `has_role()` function from security expressions, use `is_granted()` instead. +* `SimpleAuthenticatorInterface`, `SimpleFormAuthenticatorInterface`, `SimplePreAuthenticatorInterface`, + `SimpleAuthenticationProvider`, `SimpleAuthenticationHandler`, `SimpleFormAuthenticationListener` and + `SimplePreAuthenticationListener` have been removed. Use Guard instead. 4.3.0 ----- diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php deleted file mode 100644 index 6646140057097..0000000000000 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Authentication\Provider; - -use Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\Exception\AuthenticationException; -use Symfony\Component\Security\Core\User\UserChecker; -use Symfony\Component\Security\Core\User\UserCheckerInterface; -use Symfony\Component\Security\Core\User\UserInterface; -use Symfony\Component\Security\Core\User\UserProviderInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use Guard instead.', SimpleAuthenticationProvider::class), E_USER_DEPRECATED); - -/** - * @author Jordi Boggiano - * - * @deprecated since Symfony 4.2, use Guard instead. - */ -class SimpleAuthenticationProvider implements AuthenticationProviderInterface -{ - private $simpleAuthenticator; - private $userProvider; - private $providerKey; - private $userChecker; - - public function __construct(SimpleAuthenticatorInterface $simpleAuthenticator, UserProviderInterface $userProvider, string $providerKey, UserCheckerInterface $userChecker = null) - { - $this->simpleAuthenticator = $simpleAuthenticator; - $this->userProvider = $userProvider; - $this->providerKey = $providerKey; - $this->userChecker = $userChecker ?: new UserChecker(); - } - - public function authenticate(TokenInterface $token) - { - $authToken = $this->simpleAuthenticator->authenticateToken($token, $this->userProvider, $this->providerKey); - - if (!$authToken instanceof TokenInterface) { - throw new AuthenticationException('Simple authenticator failed to return an authenticated token.'); - } - - $user = $authToken->getUser(); - - if (!$user instanceof UserInterface) { - return $authToken; - } - - $this->userChecker->checkPreAuth($user); - $this->userChecker->checkPostAuth($user); - - return $authToken; - } - - public function supports(TokenInterface $token) - { - return $this->simpleAuthenticator->supportsToken($token, $this->providerKey); - } -} diff --git a/src/Symfony/Component/Security/Core/Authentication/SimpleAuthenticatorInterface.php b/src/Symfony/Component/Security/Core/Authentication/SimpleAuthenticatorInterface.php deleted file mode 100644 index 97484210cd663..0000000000000 --- a/src/Symfony/Component/Security/Core/Authentication/SimpleAuthenticatorInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Authentication; - -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\User\UserProviderInterface; - -/** - * @author Jordi Boggiano - * - * @deprecated since Symfony 4.2, use Guard instead. - */ -interface SimpleAuthenticatorInterface -{ - public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey); - - public function supportsToken(TokenInterface $token, $providerKey); -} diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php deleted file mode 100644 index 995c2c19f8d9e..0000000000000 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Tests\Authentication\Provider; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Security\Core\Authentication\Provider\SimpleAuthenticationProvider; -use Symfony\Component\Security\Core\Exception\DisabledException; -use Symfony\Component\Security\Core\Exception\LockedException; -use Symfony\Component\Security\Core\User\UserChecker; - -/** - * @group legacy - */ -class SimpleAuthenticationProviderTest extends TestCase -{ - /** - * @expectedException \Symfony\Component\Security\Core\Exception\DisabledException - */ - public function testAuthenticateWhenPreChecksFails() - { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); - - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $token->expects($this->any()) - ->method('getUser') - ->willReturn($user); - - $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); - $userChecker->expects($this->once()) - ->method('checkPreAuth') - ->willThrowException(new DisabledException()); - - $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); - $authenticator->expects($this->once()) - ->method('authenticateToken') - ->willReturn($token); - - $provider = $this->getProvider($authenticator, null, $userChecker); - - $provider->authenticate($token); - } - - /** - * @expectedException \Symfony\Component\Security\Core\Exception\LockedException - */ - public function testAuthenticateWhenPostChecksFails() - { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); - - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $token->expects($this->any()) - ->method('getUser') - ->willReturn($user); - - $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); - $userChecker->expects($this->once()) - ->method('checkPostAuth') - ->willThrowException(new LockedException()); - - $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); - $authenticator->expects($this->once()) - ->method('authenticateToken') - ->willReturn($token); - - $provider = $this->getProvider($authenticator, null, $userChecker); - - $provider->authenticate($token); - } - - public function testAuthenticateSkipsUserChecksForNonUserInterfaceObjects() - { - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $token->expects($this->any()) - ->method('getUser') - ->willReturn('string-user'); - $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); - $authenticator->expects($this->once()) - ->method('authenticateToken') - ->willReturn($token); - - $this->assertSame($token, $this->getProvider($authenticator, null, new UserChecker())->authenticate($token)); - } - - protected function getProvider($simpleAuthenticator = null, $userProvider = null, $userChecker = null, $key = 'test') - { - if (null === $userChecker) { - $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock(); - } - if (null === $simpleAuthenticator) { - $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); - } - if (null === $userProvider) { - $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); - } - - return new SimpleAuthenticationProvider($simpleAuthenticator, $userProvider, $key, $userChecker); - } -} diff --git a/src/Symfony/Component/Security/Http/Authentication/SimpleAuthenticationHandler.php b/src/Symfony/Component/Security/Http/Authentication/SimpleAuthenticationHandler.php deleted file mode 100644 index e03a5e608db5c..0000000000000 --- a/src/Symfony/Component/Security/Http/Authentication/SimpleAuthenticationHandler.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Http\Authentication; - -use Psr\Log\LoggerInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\Exception\AuthenticationException; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use Guard instead.', SimpleAuthenticationHandler::class), E_USER_DEPRECATED); - -/** - * Class to proxy authentication success/failure handlers. - * - * Events are sent to the SimpleAuthenticatorInterface if it implements - * the right interface, otherwise (or if it fails to return a Response) - * the default handlers are triggered. - * - * @author Jordi Boggiano - * - * @deprecated since Symfony 4.2, use Guard instead. - */ -class SimpleAuthenticationHandler implements AuthenticationFailureHandlerInterface, AuthenticationSuccessHandlerInterface -{ - protected $successHandler; - protected $failureHandler; - protected $simpleAuthenticator; - protected $logger; - - /** - * @param SimpleAuthenticatorInterface $authenticator SimpleAuthenticatorInterface instance - * @param AuthenticationSuccessHandlerInterface $successHandler Default success handler - * @param AuthenticationFailureHandlerInterface $failureHandler Default failure handler - * @param LoggerInterface $logger Optional logger - */ - public function __construct(SimpleAuthenticatorInterface $authenticator, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, LoggerInterface $logger = null) - { - $this->simpleAuthenticator = $authenticator; - $this->successHandler = $successHandler; - $this->failureHandler = $failureHandler; - $this->logger = $logger; - } - - /** - * {@inheritdoc} - */ - public function onAuthenticationSuccess(Request $request, TokenInterface $token) - { - if ($this->simpleAuthenticator instanceof AuthenticationSuccessHandlerInterface) { - if ($this->logger) { - $this->logger->debug('Selected an authentication success handler.', ['handler' => \get_class($this->simpleAuthenticator)]); - } - - $response = $this->simpleAuthenticator->onAuthenticationSuccess($request, $token); - if ($response instanceof Response) { - return $response; - } - - if (null !== $response) { - throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationSuccess method must return null to use the default success handler, or a Response object', \get_class($this->simpleAuthenticator))); - } - } - - if ($this->logger) { - $this->logger->debug('Fallback to the default authentication success handler.'); - } - - return $this->successHandler->onAuthenticationSuccess($request, $token); - } - - /** - * {@inheritdoc} - */ - public function onAuthenticationFailure(Request $request, AuthenticationException $exception) - { - if ($this->simpleAuthenticator instanceof AuthenticationFailureHandlerInterface) { - if ($this->logger) { - $this->logger->debug('Selected an authentication failure handler.', ['handler' => \get_class($this->simpleAuthenticator)]); - } - - $response = $this->simpleAuthenticator->onAuthenticationFailure($request, $exception); - if ($response instanceof Response) { - return $response; - } - - if (null !== $response) { - throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationFailure method must return null to use the default failure handler, or a Response object', \get_class($this->simpleAuthenticator))); - } - } - - if ($this->logger) { - $this->logger->debug('Fallback to the default authentication failure handler.'); - } - - return $this->failureHandler->onAuthenticationFailure($request, $exception); - } -} diff --git a/src/Symfony/Component/Security/Http/Authentication/SimpleFormAuthenticatorInterface.php b/src/Symfony/Component/Security/Http/Authentication/SimpleFormAuthenticatorInterface.php deleted file mode 100644 index 8590c2add0a77..0000000000000 --- a/src/Symfony/Component/Security/Http/Authentication/SimpleFormAuthenticatorInterface.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Http\Authentication; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface; - -/** - * @author Jordi Boggiano - * - * @deprecated since Symfony 4.2, use Guard instead. - */ -interface SimpleFormAuthenticatorInterface extends SimpleAuthenticatorInterface -{ - public function createToken(Request $request, $username, $password, $providerKey); -} diff --git a/src/Symfony/Component/Security/Http/Authentication/SimplePreAuthenticatorInterface.php b/src/Symfony/Component/Security/Http/Authentication/SimplePreAuthenticatorInterface.php deleted file mode 100644 index d7953cf0316db..0000000000000 --- a/src/Symfony/Component/Security/Http/Authentication/SimplePreAuthenticatorInterface.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Http\Authentication; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface; - -/** - * @author Jordi Boggiano - * - * @deprecated since Symfony 4.2, use Guard instead. - */ -interface SimplePreAuthenticatorInterface extends SimpleAuthenticatorInterface -{ - public function createToken(Request $request, $providerKey); -} diff --git a/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php deleted file mode 100644 index a8ccee0f7d557..0000000000000 --- a/src/Symfony/Component/Security/Http/Firewall/SimpleFormAuthenticationListener.php +++ /dev/null @@ -1,116 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Http\Firewall; - -use Psr\Log\LoggerInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; -use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Security\Core\Exception\BadCredentialsException; -use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException; -use Symfony\Component\Security\Core\Security; -use Symfony\Component\Security\Csrf\CsrfToken; -use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; -use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface; -use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface; -use Symfony\Component\Security\Http\Authentication\SimpleFormAuthenticatorInterface; -use Symfony\Component\Security\Http\HttpUtils; -use Symfony\Component\Security\Http\ParameterBagUtils; -use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use Guard instead.', SimpleFormAuthenticationListener::class), E_USER_DEPRECATED); - -/** - * @author Jordi Boggiano - * - * @deprecated since Symfony 4.2, use Guard instead. - */ -class SimpleFormAuthenticationListener extends AbstractAuthenticationListener -{ - private $simpleAuthenticator; - private $csrfTokenManager; - - /** - * @throws \InvalidArgumentException In case no simple authenticator is provided - */ - public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, string $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = [], LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, CsrfTokenManagerInterface $csrfTokenManager = null, SimpleFormAuthenticatorInterface $simpleAuthenticator = null) - { - if (!$simpleAuthenticator) { - throw new \InvalidArgumentException('Missing simple authenticator'); - } - - $this->simpleAuthenticator = $simpleAuthenticator; - $this->csrfTokenManager = $csrfTokenManager; - - $options = array_merge([ - 'username_parameter' => '_username', - 'password_parameter' => '_password', - 'csrf_parameter' => '_csrf_token', - 'csrf_token_id' => 'authenticate', - 'post_only' => true, - ], $options); - - parent::__construct($tokenStorage, $authenticationManager, $sessionStrategy, $httpUtils, $providerKey, $successHandler, $failureHandler, $options, $logger, $dispatcher); - } - - /** - * {@inheritdoc} - */ - protected function requiresAuthentication(Request $request) - { - if ($this->options['post_only'] && !$request->isMethod('POST')) { - return false; - } - - return parent::requiresAuthentication($request); - } - - /** - * {@inheritdoc} - */ - protected function attemptAuthentication(Request $request) - { - if (null !== $this->csrfTokenManager) { - $csrfToken = ParameterBagUtils::getRequestParameterValue($request, $this->options['csrf_parameter']); - - if (false === $this->csrfTokenManager->isTokenValid(new CsrfToken($this->options['csrf_token_id'], $csrfToken))) { - throw new InvalidCsrfTokenException('Invalid CSRF token.'); - } - } - - if ($this->options['post_only']) { - $username = ParameterBagUtils::getParameterBagValue($request->request, $this->options['username_parameter']); - $password = ParameterBagUtils::getParameterBagValue($request->request, $this->options['password_parameter']); - } else { - $username = ParameterBagUtils::getRequestParameterValue($request, $this->options['username_parameter']); - $password = ParameterBagUtils::getRequestParameterValue($request, $this->options['password_parameter']); - } - - if (!\is_string($username) && (!\is_object($username) || !\method_exists($username, '__toString'))) { - throw new BadRequestHttpException(sprintf('The key "%s" must be a string, "%s" given.', $this->options['username_parameter'], \gettype($username))); - } - - $username = trim($username); - - if (\strlen($username) > Security::MAX_USERNAME_LENGTH) { - throw new BadCredentialsException('Invalid username.'); - } - - $request->getSession()->set(Security::LAST_USERNAME, $username); - - $token = $this->simpleAuthenticator->createToken($request, $username, $password, $this->providerKey); - - return $this->authenticationManager->authenticate($token); - } -} diff --git a/src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php deleted file mode 100644 index 2c444e823b6fe..0000000000000 --- a/src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php +++ /dev/null @@ -1,152 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Http\Firewall; - -use Psr\Log\LoggerInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Event\RequestEvent; -use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; -use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver; -use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface; -use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken; -use Symfony\Component\Security\Core\Authentication\Token\RememberMeToken; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\Exception\AuthenticationException; -use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface; -use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface; -use Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface; -use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; -use Symfony\Component\Security\Http\SecurityEvents; -use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use Guard instead.', SimplePreAuthenticationListener::class), E_USER_DEPRECATED); - -/** - * SimplePreAuthenticationListener implements simple proxying to an authenticator. - * - * @author Jordi Boggiano - * - * @deprecated since Symfony 4.2, use Guard instead. - */ -class SimplePreAuthenticationListener implements ListenerInterface -{ - use LegacyListenerTrait; - - private $tokenStorage; - private $authenticationManager; - private $providerKey; - private $simpleAuthenticator; - private $logger; - private $dispatcher; - private $sessionStrategy; - private $trustResolver; - - public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, string $providerKey, SimplePreAuthenticatorInterface $simpleAuthenticator, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, AuthenticationTrustResolverInterface $trustResolver = null) - { - if (empty($providerKey)) { - throw new \InvalidArgumentException('$providerKey must not be empty.'); - } - - $this->tokenStorage = $tokenStorage; - $this->authenticationManager = $authenticationManager; - $this->providerKey = $providerKey; - $this->simpleAuthenticator = $simpleAuthenticator; - $this->logger = $logger; - $this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher); - $this->trustResolver = $trustResolver ?: new AuthenticationTrustResolver(AnonymousToken::class, RememberMeToken::class); - } - - /** - * Call this method if your authentication token is stored to a session. - * - * @final - */ - public function setSessionAuthenticationStrategy(SessionAuthenticationStrategyInterface $sessionStrategy) - { - $this->sessionStrategy = $sessionStrategy; - } - - /** - * Handles basic authentication. - */ - public function __invoke(RequestEvent $event) - { - $request = $event->getRequest(); - - if (null !== $this->logger) { - $this->logger->info('Attempting SimplePreAuthentication.', ['key' => $this->providerKey, 'authenticator' => \get_class($this->simpleAuthenticator)]); - } - - if ((null !== $token = $this->tokenStorage->getToken()) && !$this->trustResolver->isAnonymous($token)) { - return; - } - - try { - $token = $this->simpleAuthenticator->createToken($request, $this->providerKey); - - // allow null to be returned to skip authentication - if (null === $token) { - return; - } - - $token = $this->authenticationManager->authenticate($token); - - $this->migrateSession($request, $token); - - $this->tokenStorage->setToken($token); - - if (null !== $this->dispatcher) { - $loginEvent = new InteractiveLoginEvent($request, $token); - $this->dispatcher->dispatch($loginEvent, SecurityEvents::INTERACTIVE_LOGIN); - } - } catch (AuthenticationException $e) { - $this->tokenStorage->setToken(null); - - if (null !== $this->logger) { - $this->logger->info('SimplePreAuthentication request failed.', ['exception' => $e, 'authenticator' => \get_class($this->simpleAuthenticator)]); - } - - if ($this->simpleAuthenticator instanceof AuthenticationFailureHandlerInterface) { - $response = $this->simpleAuthenticator->onAuthenticationFailure($request, $e); - if ($response instanceof Response) { - $event->setResponse($response); - } elseif (null !== $response) { - throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationFailure method must return null or a Response object', \get_class($this->simpleAuthenticator))); - } - } - - return; - } - - if ($this->simpleAuthenticator instanceof AuthenticationSuccessHandlerInterface) { - $response = $this->simpleAuthenticator->onAuthenticationSuccess($request, $token); - if ($response instanceof Response) { - $event->setResponse($response); - } elseif (null !== $response) { - throw new \UnexpectedValueException(sprintf('The %s::onAuthenticationSuccess method must return null or a Response object', \get_class($this->simpleAuthenticator))); - } - } - } - - private function migrateSession(Request $request, TokenInterface $token) - { - if (!$this->sessionStrategy || !$request->hasSession() || !$request->hasPreviousSession()) { - return; - } - - $this->sessionStrategy->onAuthentication($request, $token); - } -} diff --git a/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php b/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php deleted file mode 100644 index c1c1c66f8256a..0000000000000 --- a/src/Symfony/Component/Security/Http/Tests/Authentication/SimpleAuthenticationHandlerTest.php +++ /dev/null @@ -1,199 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Http\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface; -use Symfony\Component\Security\Core\Exception\AuthenticationException; -use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface; -use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface; -use Symfony\Component\Security\Http\Authentication\SimpleAuthenticationHandler; - -/** - * @group legacy - */ -class SimpleAuthenticationHandlerTest extends TestCase -{ - private $successHandler; - - private $failureHandler; - - private $request; - - private $token; - - private $authenticationException; - - private $response; - - protected function setUp() - { - $this->successHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock(); - $this->failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock(); - - $this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); - $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - // No methods are invoked on the exception; we just assert on its class - $this->authenticationException = new AuthenticationException(); - - $this->response = new Response(); - } - - public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfSimpleIsNotASuccessHandler() - { - $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); - - $this->successHandler->expects($this->once()) - ->method('onAuthenticationSuccess') - ->with($this->request, $this->token) - ->willReturn($this->response); - - $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); - $result = $handler->onAuthenticationSuccess($this->request, $this->token); - - $this->assertSame($this->response, $result); - } - - public function testOnAuthenticationSuccessCallsSimpleAuthenticator() - { - $this->successHandler->expects($this->never()) - ->method('onAuthenticationSuccess'); - - $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\TestSuccessHandlerInterface'); - $authenticator->expects($this->once()) - ->method('onAuthenticationSuccess') - ->with($this->request, $this->token) - ->willReturn($this->response); - - $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); - $result = $handler->onAuthenticationSuccess($this->request, $this->token); - - $this->assertSame($this->response, $result); - } - - /** - * @expectedException \UnexpectedValueException - * @expectedExceptionMessage onAuthenticationSuccess method must return null to use the default success handler, or a Response object - */ - public function testOnAuthenticationSuccessThrowsAnExceptionIfNonResponseIsReturned() - { - $this->successHandler->expects($this->never()) - ->method('onAuthenticationSuccess'); - - $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\TestSuccessHandlerInterface'); - $authenticator->expects($this->once()) - ->method('onAuthenticationSuccess') - ->with($this->request, $this->token) - ->willReturn(new \stdClass()); - - $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); - $handler->onAuthenticationSuccess($this->request, $this->token); - } - - public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfNullIsReturned() - { - $this->successHandler->expects($this->once()) - ->method('onAuthenticationSuccess') - ->with($this->request, $this->token) - ->willReturn($this->response); - - $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\TestSuccessHandlerInterface'); - $authenticator->expects($this->once()) - ->method('onAuthenticationSuccess') - ->with($this->request, $this->token) - ->willReturn(null); - - $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); - $result = $handler->onAuthenticationSuccess($this->request, $this->token); - - $this->assertSame($this->response, $result); - } - - public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfSimpleIsNotAFailureHandler() - { - $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); - - $this->failureHandler->expects($this->once()) - ->method('onAuthenticationFailure') - ->with($this->request, $this->authenticationException) - ->willReturn($this->response); - - $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); - $result = $handler->onAuthenticationFailure($this->request, $this->authenticationException); - - $this->assertSame($this->response, $result); - } - - public function testOnAuthenticationFailureCallsSimpleAuthenticator() - { - $this->failureHandler->expects($this->never()) - ->method('onAuthenticationFailure'); - - $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\TestFailureHandlerInterface'); - $authenticator->expects($this->once()) - ->method('onAuthenticationFailure') - ->with($this->request, $this->authenticationException) - ->willReturn($this->response); - - $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); - $result = $handler->onAuthenticationFailure($this->request, $this->authenticationException); - - $this->assertSame($this->response, $result); - } - - /** - * @expectedException \UnexpectedValueException - * @expectedExceptionMessage onAuthenticationFailure method must return null to use the default failure handler, or a Response object - */ - public function testOnAuthenticationFailureThrowsAnExceptionIfNonResponseIsReturned() - { - $this->failureHandler->expects($this->never()) - ->method('onAuthenticationFailure'); - - $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\TestFailureHandlerInterface'); - $authenticator->expects($this->once()) - ->method('onAuthenticationFailure') - ->with($this->request, $this->authenticationException) - ->willReturn(new \stdClass()); - - $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); - $handler->onAuthenticationFailure($this->request, $this->authenticationException); - } - - public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfNullIsReturned() - { - $this->failureHandler->expects($this->once()) - ->method('onAuthenticationFailure') - ->with($this->request, $this->authenticationException) - ->willReturn($this->response); - - $authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\TestFailureHandlerInterface'); - $authenticator->expects($this->once()) - ->method('onAuthenticationFailure') - ->with($this->request, $this->authenticationException) - ->willReturn(null); - - $handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler); - $result = $handler->onAuthenticationFailure($this->request, $this->authenticationException); - - $this->assertSame($this->response, $result); - } -} - -interface TestSuccessHandlerInterface extends AuthenticationSuccessHandlerInterface, SimpleAuthenticatorInterface -{ -} - -interface TestFailureHandlerInterface extends AuthenticationFailureHandlerInterface, SimpleAuthenticatorInterface -{ -} diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php deleted file mode 100644 index a9e1459a648cf..0000000000000 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SimplePreAuthenticationListenerTest.php +++ /dev/null @@ -1,133 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Http\Tests\Firewall; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Event\RequestEvent; -use Symfony\Component\Security\Core\Exception\AuthenticationException; -use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; -use Symfony\Component\Security\Http\Firewall\SimplePreAuthenticationListener; -use Symfony\Component\Security\Http\SecurityEvents; - -/** - * @group legacy - */ -class SimplePreAuthenticationListenerTest extends TestCase -{ - private $authenticationManager; - private $dispatcher; - private $event; - private $logger; - private $request; - private $tokenStorage; - private $token; - - public function testHandle() - { - $this->tokenStorage - ->expects($this->once()) - ->method('setToken') - ->with($this->equalTo($this->token)) - ; - - $this->authenticationManager - ->expects($this->once()) - ->method('authenticate') - ->with($this->equalTo($this->token)) - ->willReturn($this->token) - ; - - $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface')->getMock(); - $simpleAuthenticator - ->expects($this->once()) - ->method('createToken') - ->with($this->equalTo($this->request), $this->equalTo('secured_area')) - ->willReturn($this->token) - ; - - $loginEvent = new InteractiveLoginEvent($this->request, $this->token); - - $this->dispatcher - ->expects($this->once()) - ->method('dispatch') - ->with($this->equalTo($loginEvent), $this->equalTo(SecurityEvents::INTERACTIVE_LOGIN)) - ; - - $listener = new SimplePreAuthenticationListener($this->tokenStorage, $this->authenticationManager, 'secured_area', $simpleAuthenticator, $this->logger, $this->dispatcher); - - $listener($this->event); - } - - public function testHandlecatchAuthenticationException() - { - $exception = new AuthenticationException('Authentication failed.'); - - $this->authenticationManager - ->expects($this->once()) - ->method('authenticate') - ->with($this->equalTo($this->token)) - ->willThrowException($exception) - ; - - $this->tokenStorage->expects($this->once()) - ->method('setToken') - ->with($this->equalTo(null)) - ; - - $simpleAuthenticator = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface')->getMock(); - $simpleAuthenticator - ->expects($this->once()) - ->method('createToken') - ->with($this->equalTo($this->request), $this->equalTo('secured_area')) - ->willReturn($this->token) - ; - - $listener = new SimplePreAuthenticationListener($this->tokenStorage, $this->authenticationManager, 'secured_area', $simpleAuthenticator, $this->logger, $this->dispatcher); - - $listener($this->event); - } - - protected function setUp() - { - $this->authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager') - ->disableOriginalConstructor() - ->getMock() - ; - - $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); - - $this->request = new Request([], [], [], [], [], []); - - $this->event = $this->getMockBuilder(RequestEvent::class)->disableOriginalConstructor()->getMock(); - $this->event - ->expects($this->any()) - ->method('getRequest') - ->willReturn($this->request) - ; - - $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - $this->tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - } - - protected function tearDown() - { - $this->authenticationManager = null; - $this->dispatcher = null; - $this->event = null; - $this->logger = null; - $this->request = null; - $this->tokenStorage = null; - $this->token = null; - } -} From 38a67f84cd7d5d4a4e0ec148cc547eaac2f50c75 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 31 May 2019 10:35:56 +0200 Subject: [PATCH 037/588] [Cache] remove deprecated PSR-16 implementations et al. --- .../Component/Cache/Adapter/ApcuAdapter.php | 103 ++++- .../Component/Cache/Adapter/ArrayAdapter.php | 147 +++++- .../Cache/Adapter/DoctrineAdapter.php | 82 +++- .../Cache/Adapter/MemcachedAdapter.php | 309 ++++++++++++- .../Component/Cache/Adapter/PdoAdapter.php | 399 +++++++++++++++- .../Cache/Adapter/PhpArrayAdapter.php | 129 +++++- .../Cache/Adapter/PhpFilesAdapter.php | 226 +++++++++- .../Cache/Adapter/SimpleCacheAdapter.php | 21 - src/Symfony/Component/Cache/CHANGELOG.md | 8 + src/Symfony/Component/Cache/CacheItem.php | 14 - src/Symfony/Component/Cache/LockRegistry.php | 1 - .../Component/Cache/Simple/AbstractCache.php | 186 -------- .../Component/Cache/Simple/ApcuCache.php | 29 -- .../Component/Cache/Simple/ArrayCache.php | 160 ------- .../Component/Cache/Simple/ChainCache.php | 257 ----------- .../Component/Cache/Simple/DoctrineCache.php | 34 -- .../Cache/Simple/FilesystemCache.php | 36 -- .../Component/Cache/Simple/MemcachedCache.php | 34 -- .../Component/Cache/Simple/NullCache.php | 90 ---- .../Component/Cache/Simple/PdoCache.php | 59 --- .../Component/Cache/Simple/PhpArrayCache.php | 248 ---------- .../Component/Cache/Simple/PhpFilesCache.php | 45 -- .../Component/Cache/Simple/Psr6Cache.php | 23 - .../Component/Cache/Simple/RedisCache.php | 37 -- .../Component/Cache/Simple/TraceableCache.php | 243 ---------- .../Tests/Adapter/SimpleCacheAdapterTest.php | 31 -- .../Tests/Simple/AbstractRedisCacheTest.php | 49 -- .../Cache/Tests/Simple/ApcuCacheTest.php | 38 -- .../Cache/Tests/Simple/ArrayCacheTest.php | 26 -- .../Cache/Tests/Simple/CacheTestCase.php | 141 ------ .../Cache/Tests/Simple/ChainCacheTest.php | 117 ----- .../Cache/Tests/Simple/DoctrineCacheTest.php | 32 -- .../Tests/Simple/FilesystemCacheTest.php | 35 -- .../Cache/Tests/Simple/MemcachedCacheTest.php | 177 -------- .../Simple/MemcachedCacheTextModeTest.php | 28 -- .../Cache/Tests/Simple/NullCacheTest.php | 97 ---- .../Cache/Tests/Simple/PdoCacheTest.php | 48 -- .../Cache/Tests/Simple/PdoDbalCacheTest.php | 49 -- .../Cache/Tests/Simple/PhpArrayCacheTest.php | 130 ------ .../Simple/PhpArrayCacheWithFallbackTest.php | 56 --- .../Tests/Simple/PhpArrayCacheWrapper.php | 46 -- .../Cache/Tests/Simple/PhpFilesCacheTest.php | 39 -- .../Cache/Tests/Simple/Psr6CacheTest.php | 31 -- .../Tests/Simple/Psr6CacheWithAdapterTest.php | 26 -- .../Simple/Psr6CacheWithoutAdapterTest.php | 26 -- .../Tests/Simple/RedisArrayCacheTest.php | 27 -- .../Cache/Tests/Simple/RedisCacheTest.php | 85 ---- .../Tests/Simple/RedisClusterCacheTest.php | 30 -- .../Cache/Tests/Simple/TraceableCacheTest.php | 172 ------- .../Cache/Tests/Traits/TagAwareTestTrait.php | 14 - .../Cache/Traits/AbstractAdapterTrait.php | 231 +++++++++- .../Component/Cache/Traits/AbstractTrait.php | 284 ------------ .../Component/Cache/Traits/ApcuTrait.php | 121 ----- .../Component/Cache/Traits/ArrayTrait.php | 165 ------- .../Component/Cache/Traits/DoctrineTrait.php | 98 ---- .../Component/Cache/Traits/MemcachedTrait.php | 328 -------------- .../Component/Cache/Traits/PdoTrait.php | 424 ------------------ .../Component/Cache/Traits/PhpArrayTrait.php | 152 ------- .../Component/Cache/Traits/PhpFilesTrait.php | 243 ---------- 59 files changed, 1611 insertions(+), 4905 deletions(-) delete mode 100644 src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php delete mode 100644 src/Symfony/Component/Cache/Simple/AbstractCache.php delete mode 100644 src/Symfony/Component/Cache/Simple/ApcuCache.php delete mode 100644 src/Symfony/Component/Cache/Simple/ArrayCache.php delete mode 100644 src/Symfony/Component/Cache/Simple/ChainCache.php delete mode 100644 src/Symfony/Component/Cache/Simple/DoctrineCache.php delete mode 100644 src/Symfony/Component/Cache/Simple/FilesystemCache.php delete mode 100644 src/Symfony/Component/Cache/Simple/MemcachedCache.php delete mode 100644 src/Symfony/Component/Cache/Simple/NullCache.php delete mode 100644 src/Symfony/Component/Cache/Simple/PdoCache.php delete mode 100644 src/Symfony/Component/Cache/Simple/PhpArrayCache.php delete mode 100644 src/Symfony/Component/Cache/Simple/PhpFilesCache.php delete mode 100644 src/Symfony/Component/Cache/Simple/Psr6Cache.php delete mode 100644 src/Symfony/Component/Cache/Simple/RedisCache.php delete mode 100644 src/Symfony/Component/Cache/Simple/TraceableCache.php delete mode 100644 src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/ArrayCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/CacheTestCase.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/FilesystemCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTextModeTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/NullCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/PdoCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWrapper.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/PhpFilesCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/Psr6CacheWithAdapterTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/Psr6CacheWithoutAdapterTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/RedisCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/RedisClusterCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Tests/Simple/TraceableCacheTest.php delete mode 100644 src/Symfony/Component/Cache/Traits/AbstractTrait.php delete mode 100644 src/Symfony/Component/Cache/Traits/ApcuTrait.php delete mode 100644 src/Symfony/Component/Cache/Traits/ArrayTrait.php delete mode 100644 src/Symfony/Component/Cache/Traits/DoctrineTrait.php delete mode 100644 src/Symfony/Component/Cache/Traits/MemcachedTrait.php delete mode 100644 src/Symfony/Component/Cache/Traits/PdoTrait.php delete mode 100644 src/Symfony/Component/Cache/Traits/PhpArrayTrait.php delete mode 100644 src/Symfony/Component/Cache/Traits/PhpFilesTrait.php diff --git a/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php b/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php index 7db3956588026..a9b599f05ca4e 100644 --- a/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php @@ -11,17 +11,112 @@ namespace Symfony\Component\Cache\Adapter; -use Symfony\Component\Cache\Traits\ApcuTrait; +use Symfony\Component\Cache\CacheItem; +use Symfony\Component\Cache\Exception\CacheException; +/** + * @author Nicolas Grekas + */ class ApcuAdapter extends AbstractAdapter { - use ApcuTrait; - /** * @throws CacheException if APCu is not enabled */ public function __construct(string $namespace = '', int $defaultLifetime = 0, string $version = null) { - $this->init($namespace, $defaultLifetime, $version); + if (!static::isSupported()) { + throw new CacheException('APCu is not enabled'); + } + if ('cli' === \PHP_SAPI) { + ini_set('apc.use_request_time', 0); + } + parent::__construct($namespace, $defaultLifetime); + + if (null !== $version) { + CacheItem::validateKey($version); + + if (!apcu_exists($version.'@'.$namespace)) { + $this->doClear($namespace); + apcu_add($version.'@'.$namespace, null); + } + } + } + + public static function isSupported() + { + return \function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN); + } + + /** + * {@inheritdoc} + */ + protected function doFetch(array $ids) + { + $unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback'); + try { + $values = []; + foreach (apcu_fetch($ids, $ok) ?: [] as $k => $v) { + if (null !== $v || $ok) { + $values[$k] = $v; + } + } + + return $values; + } catch (\Error $e) { + throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); + } finally { + ini_set('unserialize_callback_func', $unserializeCallbackHandler); + } + } + + /** + * {@inheritdoc} + */ + protected function doHave($id) + { + return apcu_exists($id); + } + + /** + * {@inheritdoc} + */ + protected function doClear($namespace) + { + return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) + ? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), APC_ITER_KEY)) + : apcu_clear_cache(); + } + + /** + * {@inheritdoc} + */ + protected function doDelete(array $ids) + { + foreach ($ids as $id) { + apcu_delete($id); + } + + return true; + } + + /** + * {@inheritdoc} + */ + protected function doSave(array $values, $lifetime) + { + try { + if (false === $failures = apcu_store($values, null, $lifetime)) { + $failures = $values; + } + + return array_keys($failures); + } catch (\Throwable $e) { + if (1 === \count($values)) { + // Workaround https://github.com/krakjoe/apcu/issues/170 + apcu_delete(key($values)); + } + + throw $e; + } } } diff --git a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php index bbb1f846e4cf5..c356c2bbd2ea0 100644 --- a/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php @@ -13,9 +13,9 @@ use Psr\Cache\CacheItemInterface; use Psr\Log\LoggerAwareInterface; +use Psr\Log\LoggerAwareTrait; use Symfony\Component\Cache\CacheItem; use Symfony\Component\Cache\ResettableInterface; -use Symfony\Component\Cache\Traits\ArrayTrait; use Symfony\Contracts\Cache\CacheInterface; /** @@ -23,8 +23,11 @@ */ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInterface, ResettableInterface { - use ArrayTrait; + use LoggerAwareTrait; + private $storeSerialized; + private $values = []; + private $expiries = []; private $createCacheItem; /** @@ -65,6 +68,27 @@ public function get(string $key, callable $callback, float $beta = null, array & return $item->get(); } + /** + * {@inheritdoc} + */ + public function delete(string $key): bool + { + return $this->deleteItem($key); + } + + /** + * {@inheritdoc} + */ + public function hasItem($key) + { + if (\is_string($key) && isset($this->expiries[$key]) && $this->expiries[$key] > microtime(true)) { + return true; + } + CacheItem::validateKey($key); + + return isset($this->expiries[$key]) && !$this->deleteItem($key); + } + /** * {@inheritdoc} */ @@ -94,6 +118,19 @@ public function getItems(array $keys = []) return $this->generateItems($keys, microtime(true), $this->createCacheItem); } + /** + * {@inheritdoc} + */ + public function deleteItem($key) + { + if (!\is_string($key) || !isset($this->expiries[$key])) { + CacheItem::validateKey($key); + } + unset($this->values[$key], $this->expiries[$key]); + + return true; + } + /** * {@inheritdoc} */ @@ -156,8 +193,110 @@ public function commit() /** * {@inheritdoc} */ - public function delete(string $key): bool + public function clear() { - return $this->deleteItem($key); + $this->values = $this->expiries = []; + + return true; + } + + /** + * Returns all cached values, with cache miss as null. + * + * @return array + */ + public function getValues() + { + if (!$this->storeSerialized) { + return $this->values; + } + + $values = $this->values; + foreach ($values as $k => $v) { + if (null === $v || 'N;' === $v) { + continue; + } + if (!\is_string($v) || !isset($v[2]) || ':' !== $v[1]) { + $values[$k] = serialize($v); + } + } + + return $values; + } + + /** + * {@inheritdoc} + */ + public function reset() + { + $this->clear(); + } + + private function generateItems(array $keys, $now, $f) + { + foreach ($keys as $i => $key) { + if (!$isHit = isset($this->expiries[$key]) && ($this->expiries[$key] > $now || !$this->deleteItem($key))) { + $this->values[$key] = $value = null; + } else { + $value = $this->storeSerialized ? $this->unfreeze($key, $isHit) : $this->values[$key]; + } + unset($keys[$i]); + + yield $key => $f($key, $value, $isHit); + } + + foreach ($keys as $key) { + yield $key => $f($key, null, false); + } + } + + private function freeze($value, $key) + { + if (null === $value) { + return 'N;'; + } + if (\is_string($value)) { + // Serialize strings if they could be confused with serialized objects or arrays + if ('N;' === $value || (isset($value[2]) && ':' === $value[1])) { + return serialize($value); + } + } elseif (!\is_scalar($value)) { + try { + $serialized = serialize($value); + } catch (\Exception $e) { + $type = \is_object($value) ? \get_class($value) : \gettype($value); + $message = sprintf('Failed to save key "{key}" of type %s: %s', $type, $e->getMessage()); + CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e]); + + return; + } + // Keep value serialized if it contains any objects or any internal references + if ('C' === $serialized[0] || 'O' === $serialized[0] || preg_match('/;[OCRr]:[1-9]/', $serialized)) { + return $serialized; + } + } + + return $value; + } + + private function unfreeze(string $key, bool &$isHit) + { + if ('N;' === $value = $this->values[$key]) { + return null; + } + if (\is_string($value) && isset($value[2]) && ':' === $value[1]) { + try { + $value = unserialize($value); + } catch (\Exception $e) { + CacheItem::log($this->logger, 'Failed to unserialize key "{key}": '.$e->getMessage(), ['key' => $key, 'exception' => $e]); + $value = false; + } + if (false === $value) { + $this->values[$key] = $value = null; + $isHit = false; + } + } + + return $value; } } diff --git a/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php b/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php index 75ae4cb7015c8..80a8713e0ef87 100644 --- a/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php @@ -12,11 +12,13 @@ namespace Symfony\Component\Cache\Adapter; use Doctrine\Common\Cache\CacheProvider; -use Symfony\Component\Cache\Traits\DoctrineTrait; +/** + * @author Nicolas Grekas + */ class DoctrineAdapter extends AbstractAdapter { - use DoctrineTrait; + private $provider; public function __construct(CacheProvider $provider, string $namespace = '', int $defaultLifetime = 0) { @@ -24,4 +26,80 @@ public function __construct(CacheProvider $provider, string $namespace = '', int $this->provider = $provider; $provider->setNamespace($namespace); } + + /** + * {@inheritdoc} + */ + public function reset() + { + parent::reset(); + $this->provider->setNamespace($this->provider->getNamespace()); + } + + /** + * {@inheritdoc} + */ + protected function doFetch(array $ids) + { + $unserializeCallbackHandler = ini_set('unserialize_callback_func', parent::class.'::handleUnserializeCallback'); + try { + return $this->provider->fetchMultiple($ids); + } catch (\Error $e) { + $trace = $e->getTrace(); + + if (isset($trace[0]['function']) && !isset($trace[0]['class'])) { + switch ($trace[0]['function']) { + case 'unserialize': + case 'apcu_fetch': + case 'apc_fetch': + throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); + } + } + + throw $e; + } finally { + ini_set('unserialize_callback_func', $unserializeCallbackHandler); + } + } + + /** + * {@inheritdoc} + */ + protected function doHave($id) + { + return $this->provider->contains($id); + } + + /** + * {@inheritdoc} + */ + protected function doClear($namespace) + { + $namespace = $this->provider->getNamespace(); + + return isset($namespace[0]) + ? $this->provider->deleteAll() + : $this->provider->flushAll(); + } + + /** + * {@inheritdoc} + */ + protected function doDelete(array $ids) + { + $ok = true; + foreach ($ids as $id) { + $ok = $this->provider->delete($id) && $ok; + } + + return $ok; + } + + /** + * {@inheritdoc} + */ + protected function doSave(array $values, $lifetime) + { + return $this->provider->saveMultiple($values, $lifetime); + } } diff --git a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php index b678bb5d8883e..ce29d84bf2ff0 100644 --- a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php @@ -11,15 +11,30 @@ namespace Symfony\Component\Cache\Adapter; +use Symfony\Component\Cache\Exception\CacheException; +use Symfony\Component\Cache\Exception\InvalidArgumentException; +use Symfony\Component\Cache\Marshaller\DefaultMarshaller; use Symfony\Component\Cache\Marshaller\MarshallerInterface; -use Symfony\Component\Cache\Traits\MemcachedTrait; +/** + * @author Rob Frawley 2nd + * @author Nicolas Grekas + */ class MemcachedAdapter extends AbstractAdapter { - use MemcachedTrait; - protected $maxIdLength = 250; + private static $defaultClientOptions = [ + 'persistent_id' => null, + 'username' => null, + 'password' => null, + 'serializer' => 'php', + ]; + + private $marshaller; + private $client; + private $lazyClient; + /** * Using a MemcachedAdapter with a TagAwareAdapter for storing tags is discouraged. * Using a RedisAdapter is recommended instead. If you cannot do otherwise, be aware that: @@ -32,6 +47,292 @@ class MemcachedAdapter extends AbstractAdapter */ public function __construct(\Memcached $client, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null) { - $this->init($client, $namespace, $defaultLifetime, $marshaller); + if (!static::isSupported()) { + throw new CacheException('Memcached >= 2.2.0 is required'); + } + if ('Memcached' === \get_class($client)) { + $opt = $client->getOption(\Memcached::OPT_SERIALIZER); + if (\Memcached::SERIALIZER_PHP !== $opt && \Memcached::SERIALIZER_IGBINARY !== $opt) { + throw new CacheException('MemcachedAdapter: "serializer" option must be "php" or "igbinary".'); + } + $this->maxIdLength -= \strlen($client->getOption(\Memcached::OPT_PREFIX_KEY)); + $this->client = $client; + } else { + $this->lazyClient = $client; + } + + parent::__construct($namespace, $defaultLifetime); + $this->enableVersioning(); + $this->marshaller = $marshaller ?? new DefaultMarshaller(); + } + + public static function isSupported() + { + return \extension_loaded('memcached') && version_compare(phpversion('memcached'), '2.2.0', '>='); + } + + /** + * Creates a Memcached instance. + * + * By default, the binary protocol, no block, and libketama compatible options are enabled. + * + * Examples for servers: + * - 'memcached://user:pass@localhost?weight=33' + * - [['localhost', 11211, 33]] + * + * @param array[]|string|string[] $servers An array of servers, a DSN, or an array of DSNs + * @param array $options An array of options + * + * @return \Memcached + * + * @throws \ErrorException When invalid options or servers are provided + */ + public static function createConnection($servers, array $options = []) + { + if (\is_string($servers)) { + $servers = [$servers]; + } elseif (!\is_array($servers)) { + throw new InvalidArgumentException(sprintf('MemcachedAdapter::createClient() expects array or string as first argument, %s given.', \gettype($servers))); + } + if (!static::isSupported()) { + throw new CacheException('Memcached >= 2.2.0 is required'); + } + set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); }); + try { + $options += static::$defaultClientOptions; + $client = new \Memcached($options['persistent_id']); + $username = $options['username']; + $password = $options['password']; + + // parse any DSN in $servers + foreach ($servers as $i => $dsn) { + if (\is_array($dsn)) { + continue; + } + if (0 !== strpos($dsn, 'memcached:')) { + throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s does not start with "memcached:"', $dsn)); + } + $params = preg_replace_callback('#^memcached:(//)?(?:([^@]*+)@)?#', function ($m) use (&$username, &$password) { + if (!empty($m[2])) { + list($username, $password) = explode(':', $m[2], 2) + [1 => null]; + } + + return 'file:'.($m[1] ?? ''); + }, $dsn); + if (false === $params = parse_url($params)) { + throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn)); + } + $query = $hosts = []; + if (isset($params['query'])) { + parse_str($params['query'], $query); + + if (isset($query['host'])) { + if (!\is_array($hosts = $query['host'])) { + throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn)); + } + foreach ($hosts as $host => $weight) { + if (false === $port = strrpos($host, ':')) { + $hosts[$host] = [$host, 11211, (int) $weight]; + } else { + $hosts[$host] = [substr($host, 0, $port), (int) substr($host, 1 + $port), (int) $weight]; + } + } + $hosts = array_values($hosts); + unset($query['host']); + } + if ($hosts && !isset($params['host']) && !isset($params['path'])) { + unset($servers[$i]); + $servers = array_merge($servers, $hosts); + continue; + } + } + if (!isset($params['host']) && !isset($params['path'])) { + throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn)); + } + if (isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) { + $params['weight'] = $m[1]; + $params['path'] = substr($params['path'], 0, -\strlen($m[0])); + } + $params += [ + 'host' => isset($params['host']) ? $params['host'] : $params['path'], + 'port' => isset($params['host']) ? 11211 : null, + 'weight' => 0, + ]; + if ($query) { + $params += $query; + $options = $query + $options; + } + + $servers[$i] = [$params['host'], $params['port'], $params['weight']]; + + if ($hosts) { + $servers = array_merge($servers, $hosts); + } + } + + // set client's options + unset($options['persistent_id'], $options['username'], $options['password'], $options['weight'], $options['lazy']); + $options = array_change_key_case($options, CASE_UPPER); + $client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); + $client->setOption(\Memcached::OPT_NO_BLOCK, true); + $client->setOption(\Memcached::OPT_TCP_NODELAY, true); + if (!\array_key_exists('LIBKETAMA_COMPATIBLE', $options) && !\array_key_exists(\Memcached::OPT_LIBKETAMA_COMPATIBLE, $options)) { + $client->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true); + } + foreach ($options as $name => $value) { + if (\is_int($name)) { + continue; + } + if ('HASH' === $name || 'SERIALIZER' === $name || 'DISTRIBUTION' === $name) { + $value = \constant('Memcached::'.$name.'_'.strtoupper($value)); + } + $opt = \constant('Memcached::OPT_'.$name); + + unset($options[$name]); + $options[$opt] = $value; + } + $client->setOptions($options); + + // set client's servers, taking care of persistent connections + if (!$client->isPristine()) { + $oldServers = []; + foreach ($client->getServerList() as $server) { + $oldServers[] = [$server['host'], $server['port']]; + } + + $newServers = []; + foreach ($servers as $server) { + if (1 < \count($server)) { + $server = array_values($server); + unset($server[2]); + $server[1] = (int) $server[1]; + } + $newServers[] = $server; + } + + if ($oldServers !== $newServers) { + $client->resetServerList(); + $client->addServers($servers); + } + } else { + $client->addServers($servers); + } + + if (null !== $username || null !== $password) { + if (!method_exists($client, 'setSaslAuthData')) { + trigger_error('Missing SASL support: the memcached extension must be compiled with --enable-memcached-sasl.'); + } + $client->setSaslAuthData($username, $password); + } + + return $client; + } finally { + restore_error_handler(); + } + } + + /** + * {@inheritdoc} + */ + protected function doSave(array $values, $lifetime) + { + if (!$values = $this->marshaller->marshall($values, $failed)) { + return $failed; + } + + if ($lifetime && $lifetime > 30 * 86400) { + $lifetime += time(); + } + + $encodedValues = []; + foreach ($values as $key => $value) { + $encodedValues[rawurlencode($key)] = $value; + } + + return $this->checkResultCode($this->getClient()->setMulti($encodedValues, $lifetime)) ? $failed : false; + } + + /** + * {@inheritdoc} + */ + protected function doFetch(array $ids) + { + try { + $encodedIds = array_map('rawurlencode', $ids); + + $encodedResult = $this->checkResultCode($this->getClient()->getMulti($encodedIds)); + + $result = []; + foreach ($encodedResult as $key => $value) { + $result[rawurldecode($key)] = $this->marshaller->unmarshall($value); + } + + return $result; + } catch (\Error $e) { + throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); + } + } + + /** + * {@inheritdoc} + */ + protected function doHave($id) + { + return false !== $this->getClient()->get(rawurlencode($id)) || $this->checkResultCode(\Memcached::RES_SUCCESS === $this->client->getResultCode()); + } + + /** + * {@inheritdoc} + */ + protected function doDelete(array $ids) + { + $ok = true; + $encodedIds = array_map('rawurlencode', $ids); + foreach ($this->checkResultCode($this->getClient()->deleteMulti($encodedIds)) as $result) { + if (\Memcached::RES_SUCCESS !== $result && \Memcached::RES_NOTFOUND !== $result) { + $ok = false; + } + } + + return $ok; + } + + /** + * {@inheritdoc} + */ + protected function doClear($namespace) + { + return '' === $namespace && $this->getClient()->flush(); + } + + private function checkResultCode($result) + { + $code = $this->client->getResultCode(); + + if (\Memcached::RES_SUCCESS === $code || \Memcached::RES_NOTFOUND === $code) { + return $result; + } + + throw new CacheException(sprintf('MemcachedAdapter client error: %s.', strtolower($this->client->getResultMessage()))); + } + + /** + * @return \Memcached + */ + private function getClient() + { + if ($this->client) { + return $this->client; + } + + $opt = $this->lazyClient->getOption(\Memcached::OPT_SERIALIZER); + if (\Memcached::SERIALIZER_PHP !== $opt && \Memcached::SERIALIZER_IGBINARY !== $opt) { + throw new CacheException('MemcachedAdapter: "serializer" option must be "php" or "igbinary".'); + } + if ('' !== $prefix = (string) $this->lazyClient->getOption(\Memcached::OPT_PREFIX_KEY)) { + throw new CacheException(sprintf('MemcachedAdapter: "prefix_key" option must be empty when using proxified connections, "%s" given.', $prefix)); + } + + return $this->client = $this->lazyClient; } } diff --git a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php index d118736aec067..2bb4c4df6ca6c 100644 --- a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php @@ -12,17 +12,34 @@ namespace Symfony\Component\Cache\Adapter; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Driver\ServerInfoAwareConnection; +use Doctrine\DBAL\Exception\TableNotFoundException; +use Doctrine\DBAL\Schema\Schema; use Symfony\Component\Cache\Exception\InvalidArgumentException; +use Symfony\Component\Cache\Marshaller\DefaultMarshaller; use Symfony\Component\Cache\Marshaller\MarshallerInterface; use Symfony\Component\Cache\PruneableInterface; -use Symfony\Component\Cache\Traits\PdoTrait; class PdoAdapter extends AbstractAdapter implements PruneableInterface { - use PdoTrait; - protected $maxIdLength = 255; + private $marshaller; + private $conn; + private $dsn; + private $driver; + private $serverVersion; + private $table = 'cache_items'; + private $idCol = 'item_id'; + private $dataCol = 'item_data'; + private $lifetimeCol = 'item_lifetime'; + private $timeCol = 'item_time'; + private $username = ''; + private $password = ''; + private $connectionOptions = []; + private $namespace; + /** * You can either pass an existing database connection as PDO instance or * a Doctrine DBAL Connection or a DSN string that will be used to @@ -49,6 +66,380 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface */ public function __construct($connOrDsn, string $namespace = '', int $defaultLifetime = 0, array $options = [], MarshallerInterface $marshaller = null) { - $this->init($connOrDsn, $namespace, $defaultLifetime, $options, $marshaller); + if (isset($namespace[0]) && preg_match('#[^-+.A-Za-z0-9]#', $namespace, $match)) { + throw new InvalidArgumentException(sprintf('Namespace contains "%s" but only characters in [-+.A-Za-z0-9] are allowed.', $match[0])); + } + + if ($connOrDsn instanceof \PDO) { + if (\PDO::ERRMODE_EXCEPTION !== $connOrDsn->getAttribute(\PDO::ATTR_ERRMODE)) { + throw new InvalidArgumentException(sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION))', __CLASS__)); + } + + $this->conn = $connOrDsn; + } elseif ($connOrDsn instanceof Connection) { + $this->conn = $connOrDsn; + } elseif (\is_string($connOrDsn)) { + $this->dsn = $connOrDsn; + } else { + throw new InvalidArgumentException(sprintf('"%s" requires PDO or Doctrine\DBAL\Connection instance or DSN string as first argument, "%s" given.', __CLASS__, \is_object($connOrDsn) ? \get_class($connOrDsn) : \gettype($connOrDsn))); + } + + $this->table = isset($options['db_table']) ? $options['db_table'] : $this->table; + $this->idCol = isset($options['db_id_col']) ? $options['db_id_col'] : $this->idCol; + $this->dataCol = isset($options['db_data_col']) ? $options['db_data_col'] : $this->dataCol; + $this->lifetimeCol = isset($options['db_lifetime_col']) ? $options['db_lifetime_col'] : $this->lifetimeCol; + $this->timeCol = isset($options['db_time_col']) ? $options['db_time_col'] : $this->timeCol; + $this->username = isset($options['db_username']) ? $options['db_username'] : $this->username; + $this->password = isset($options['db_password']) ? $options['db_password'] : $this->password; + $this->connectionOptions = isset($options['db_connection_options']) ? $options['db_connection_options'] : $this->connectionOptions; + $this->namespace = $namespace; + $this->marshaller = $marshaller ?? new DefaultMarshaller(); + + parent::__construct($namespace, $defaultLifetime); + } + + /** + * Creates the table to store cache items which can be called once for setup. + * + * Cache ID are saved in a column of maximum length 255. Cache data is + * saved in a BLOB. + * + * @throws \PDOException When the table already exists + * @throws DBALException When the table already exists + * @throws \DomainException When an unsupported PDO driver is used + */ + public function createTable() + { + // connect if we are not yet + $conn = $this->getConnection(); + + if ($conn instanceof Connection) { + $types = [ + 'mysql' => 'binary', + 'sqlite' => 'text', + 'pgsql' => 'string', + 'oci' => 'string', + 'sqlsrv' => 'string', + ]; + if (!isset($types[$this->driver])) { + throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver)); + } + + $schema = new Schema(); + $table = $schema->createTable($this->table); + $table->addColumn($this->idCol, $types[$this->driver], ['length' => 255]); + $table->addColumn($this->dataCol, 'blob', ['length' => 16777215]); + $table->addColumn($this->lifetimeCol, 'integer', ['unsigned' => true, 'notnull' => false]); + $table->addColumn($this->timeCol, 'integer', ['unsigned' => true]); + $table->setPrimaryKey([$this->idCol]); + + foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) { + $conn->exec($sql); + } + + return; + } + + switch ($this->driver) { + case 'mysql': + // We use varbinary for the ID column because it prevents unwanted conversions: + // - character set conversions between server and client + // - trailing space removal + // - case-insensitivity + // - language processing like é == e + $sql = "CREATE TABLE $this->table ($this->idCol VARBINARY(255) NOT NULL PRIMARY KEY, $this->dataCol MEDIUMBLOB NOT NULL, $this->lifetimeCol INTEGER UNSIGNED, $this->timeCol INTEGER UNSIGNED NOT NULL) COLLATE utf8_bin, ENGINE = InnoDB"; + break; + case 'sqlite': + $sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)"; + break; + case 'pgsql': + $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(255) NOT NULL PRIMARY KEY, $this->dataCol BYTEA NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)"; + break; + case 'oci': + $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR2(255) NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)"; + break; + case 'sqlsrv': + $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(255) NOT NULL PRIMARY KEY, $this->dataCol VARBINARY(MAX) NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)"; + break; + default: + throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver)); + } + + $conn->exec($sql); + } + + /** + * {@inheritdoc} + */ + public function prune() + { + $deleteSql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol <= :time"; + + if ('' !== $this->namespace) { + $deleteSql .= " AND $this->idCol LIKE :namespace"; + } + + try { + $delete = $this->getConnection()->prepare($deleteSql); + } catch (TableNotFoundException $e) { + return true; + } + $delete->bindValue(':time', time(), \PDO::PARAM_INT); + + if ('' !== $this->namespace) { + $delete->bindValue(':namespace', sprintf('%s%%', $this->namespace), \PDO::PARAM_STR); + } + try { + return $delete->execute(); + } catch (TableNotFoundException $e) { + return true; + } + } + + /** + * {@inheritdoc} + */ + protected function doFetch(array $ids) + { + $now = time(); + $expired = []; + + $sql = str_pad('', (\count($ids) << 1) - 1, '?,'); + $sql = "SELECT $this->idCol, CASE WHEN $this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > ? THEN $this->dataCol ELSE NULL END FROM $this->table WHERE $this->idCol IN ($sql)"; + $stmt = $this->getConnection()->prepare($sql); + $stmt->bindValue($i = 1, $now, \PDO::PARAM_INT); + foreach ($ids as $id) { + $stmt->bindValue(++$i, $id); + } + $stmt->execute(); + + while ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + if (null === $row[1]) { + $expired[] = $row[0]; + } else { + yield $row[0] => $this->marshaller->unmarshall(\is_resource($row[1]) ? stream_get_contents($row[1]) : $row[1]); + } + } + + if ($expired) { + $sql = str_pad('', (\count($expired) << 1) - 1, '?,'); + $sql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol <= ? AND $this->idCol IN ($sql)"; + $stmt = $this->getConnection()->prepare($sql); + $stmt->bindValue($i = 1, $now, \PDO::PARAM_INT); + foreach ($expired as $id) { + $stmt->bindValue(++$i, $id); + } + $stmt->execute(); + } + } + + /** + * {@inheritdoc} + */ + protected function doHave($id) + { + $sql = "SELECT 1 FROM $this->table WHERE $this->idCol = :id AND ($this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > :time)"; + $stmt = $this->getConnection()->prepare($sql); + + $stmt->bindValue(':id', $id); + $stmt->bindValue(':time', time(), \PDO::PARAM_INT); + $stmt->execute(); + + return (bool) $stmt->fetchColumn(); + } + + /** + * {@inheritdoc} + */ + protected function doClear($namespace) + { + $conn = $this->getConnection(); + + if ('' === $namespace) { + if ('sqlite' === $this->driver) { + $sql = "DELETE FROM $this->table"; + } else { + $sql = "TRUNCATE TABLE $this->table"; + } + } else { + $sql = "DELETE FROM $this->table WHERE $this->idCol LIKE '$namespace%'"; + } + + try { + $conn->exec($sql); + } catch (TableNotFoundException $e) { + } + + return true; + } + + /** + * {@inheritdoc} + */ + protected function doDelete(array $ids) + { + $sql = str_pad('', (\count($ids) << 1) - 1, '?,'); + $sql = "DELETE FROM $this->table WHERE $this->idCol IN ($sql)"; + try { + $stmt = $this->getConnection()->prepare($sql); + $stmt->execute(array_values($ids)); + } catch (TableNotFoundException $e) { + } + + return true; + } + + /** + * {@inheritdoc} + */ + protected function doSave(array $values, $lifetime) + { + if (!$values = $this->marshaller->marshall($values, $failed)) { + return $failed; + } + + $conn = $this->getConnection(); + $driver = $this->driver; + $insertSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)"; + + switch (true) { + case 'mysql' === $driver: + $sql = $insertSql." ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->lifetimeCol = VALUES($this->lifetimeCol), $this->timeCol = VALUES($this->timeCol)"; + break; + case 'oci' === $driver: + // DUAL is Oracle specific dummy table + $sql = "MERGE INTO $this->table USING DUAL ON ($this->idCol = ?) ". + "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ". + "WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?"; + break; + case 'sqlsrv' === $driver && version_compare($this->getServerVersion(), '10', '>='): + // MERGE is only available since SQL Server 2008 and must be terminated by semicolon + // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx + $sql = "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = ?) ". + "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ". + "WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?;"; + break; + case 'sqlite' === $driver: + $sql = 'INSERT OR REPLACE'.substr($insertSql, 6); + break; + case 'pgsql' === $driver && version_compare($this->getServerVersion(), '9.5', '>='): + $sql = $insertSql." ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->lifetimeCol, $this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->lifetimeCol, EXCLUDED.$this->timeCol)"; + break; + default: + $driver = null; + $sql = "UPDATE $this->table SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id"; + break; + } + + $now = time(); + $lifetime = $lifetime ?: null; + try { + $stmt = $conn->prepare($sql); + } catch (TableNotFoundException $e) { + if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) { + $this->createTable(); + } + $stmt = $conn->prepare($sql); + } + + if ('sqlsrv' === $driver || 'oci' === $driver) { + $stmt->bindParam(1, $id); + $stmt->bindParam(2, $id); + $stmt->bindParam(3, $data, \PDO::PARAM_LOB); + $stmt->bindValue(4, $lifetime, \PDO::PARAM_INT); + $stmt->bindValue(5, $now, \PDO::PARAM_INT); + $stmt->bindParam(6, $data, \PDO::PARAM_LOB); + $stmt->bindValue(7, $lifetime, \PDO::PARAM_INT); + $stmt->bindValue(8, $now, \PDO::PARAM_INT); + } else { + $stmt->bindParam(':id', $id); + $stmt->bindParam(':data', $data, \PDO::PARAM_LOB); + $stmt->bindValue(':lifetime', $lifetime, \PDO::PARAM_INT); + $stmt->bindValue(':time', $now, \PDO::PARAM_INT); + } + if (null === $driver) { + $insertStmt = $conn->prepare($insertSql); + + $insertStmt->bindParam(':id', $id); + $insertStmt->bindParam(':data', $data, \PDO::PARAM_LOB); + $insertStmt->bindValue(':lifetime', $lifetime, \PDO::PARAM_INT); + $insertStmt->bindValue(':time', $now, \PDO::PARAM_INT); + } + + foreach ($values as $id => $data) { + try { + $stmt->execute(); + } catch (TableNotFoundException $e) { + if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) { + $this->createTable(); + } + $stmt->execute(); + } + if (null === $driver && !$stmt->rowCount()) { + try { + $insertStmt->execute(); + } catch (DBALException $e) { + } catch (\PDOException $e) { + // A concurrent write won, let it be + } + } + } + + return $failed; + } + + /** + * @return \PDO|Connection + */ + private function getConnection() + { + if (null === $this->conn) { + $this->conn = new \PDO($this->dsn, $this->username, $this->password, $this->connectionOptions); + $this->conn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + } + if (null === $this->driver) { + if ($this->conn instanceof \PDO) { + $this->driver = $this->conn->getAttribute(\PDO::ATTR_DRIVER_NAME); + } else { + switch ($this->driver = $this->conn->getDriver()->getName()) { + case 'mysqli': + case 'pdo_mysql': + case 'drizzle_pdo_mysql': + $this->driver = 'mysql'; + break; + case 'pdo_sqlite': + $this->driver = 'sqlite'; + break; + case 'pdo_pgsql': + $this->driver = 'pgsql'; + break; + case 'oci8': + case 'pdo_oracle': + $this->driver = 'oci'; + break; + case 'pdo_sqlsrv': + $this->driver = 'sqlsrv'; + break; + } + } + } + + return $this->conn; + } + + private function getServerVersion(): string + { + if (null === $this->serverVersion) { + $conn = $this->conn instanceof \PDO ? $this->conn : $this->conn->getWrappedConnection(); + if ($conn instanceof \PDO) { + $this->serverVersion = $conn->getAttribute(\PDO::ATTR_SERVER_VERSION); + } elseif ($conn instanceof ServerInfoAwareConnection) { + $this->serverVersion = $conn->getServerVersion(); + } else { + $this->serverVersion = '0'; + } + } + + return $this->serverVersion; } } diff --git a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php index 129a9e7df4143..038d4ee37f4c5 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php @@ -18,7 +18,8 @@ use Symfony\Component\Cache\PruneableInterface; use Symfony\Component\Cache\ResettableInterface; use Symfony\Component\Cache\Traits\ContractsTrait; -use Symfony\Component\Cache\Traits\PhpArrayTrait; +use Symfony\Component\Cache\Traits\ProxyTrait; +use Symfony\Component\VarExporter\VarExporter; use Symfony\Contracts\Cache\CacheInterface; /** @@ -30,9 +31,12 @@ */ class PhpArrayAdapter implements AdapterInterface, CacheInterface, PruneableInterface, ResettableInterface { - use PhpArrayTrait; use ContractsTrait; + use ProxyTrait; + private $file; + private $keys; + private $values; private $createCacheItem; /** @@ -255,6 +259,127 @@ public function commit() return $this->pool->commit(); } + /** + * {@inheritdoc} + */ + public function clear() + { + $this->keys = $this->values = []; + + $cleared = @unlink($this->file) || !file_exists($this->file); + + return $this->pool->clear() && $cleared; + } + + /** + * Store an array of cached values. + * + * @param array $values The cached values + */ + public function warmUp(array $values) + { + if (file_exists($this->file)) { + if (!is_file($this->file)) { + throw new InvalidArgumentException(sprintf('Cache path exists and is not a file: %s.', $this->file)); + } + + if (!is_writable($this->file)) { + throw new InvalidArgumentException(sprintf('Cache file is not writable: %s.', $this->file)); + } + } else { + $directory = \dirname($this->file); + + if (!is_dir($directory) && !@mkdir($directory, 0777, true)) { + throw new InvalidArgumentException(sprintf('Cache directory does not exist and cannot be created: %s.', $directory)); + } + + if (!is_writable($directory)) { + throw new InvalidArgumentException(sprintf('Cache directory is not writable: %s.', $directory)); + } + } + + $dumpedValues = ''; + $dumpedMap = []; + $dump = <<<'EOF' + $value) { + CacheItem::validateKey(\is_int($key) ? (string) $key : $key); + $isStaticValue = true; + + if (null === $value) { + $value = "'N;'"; + } elseif (\is_object($value) || \is_array($value)) { + try { + $value = VarExporter::export($value, $isStaticValue); + } catch (\Exception $e) { + throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \is_object($value) ? \get_class($value) : 'array'), 0, $e); + } + } elseif (\is_string($value)) { + // Wrap "N;" in a closure to not confuse it with an encoded `null` + if ('N;' === $value) { + $isStaticValue = false; + } + $value = var_export($value, true); + } elseif (!\is_scalar($value)) { + throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \gettype($value))); + } else { + $value = var_export($value, true); + } + + if (!$isStaticValue) { + $value = str_replace("\n", "\n ", $value); + $value = "static function () {\n return {$value};\n}"; + } + $hash = hash('md5', $value); + + if (null === $id = $dumpedMap[$hash] ?? null) { + $id = $dumpedMap[$hash] = \count($dumpedMap); + $dumpedValues .= "{$id} => {$value},\n"; + } + + $dump .= var_export($key, true)." => {$id},\n"; + } + + $dump .= "\n], [\n\n{$dumpedValues}\n]];\n"; + + $tmpFile = uniqid($this->file, true); + + file_put_contents($tmpFile, $dump); + @chmod($tmpFile, 0666 & ~umask()); + unset($serialized, $value, $dump); + + @rename($tmpFile, $this->file); + + $this->initialize(); + } + + /** + * Load the cache file. + */ + private function initialize() + { + if (!file_exists($this->file)) { + $this->keys = $this->values = []; + + return; + } + $values = (include $this->file) ?: [[], []]; + + if (2 !== \count($values) || !isset($values[0], $values[1])) { + $this->keys = $this->values = []; + } else { + list($this->keys, $this->values) = $values; + } + } + private function generateItems(array $keys): \Generator { $f = $this->createCacheItem; diff --git a/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php index 10938a0a9e921..095350eb1b981 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php @@ -12,12 +12,29 @@ namespace Symfony\Component\Cache\Adapter; use Symfony\Component\Cache\Exception\CacheException; +use Symfony\Component\Cache\Exception\InvalidArgumentException; use Symfony\Component\Cache\PruneableInterface; -use Symfony\Component\Cache\Traits\PhpFilesTrait; +use Symfony\Component\Cache\Traits\FilesystemCommonTrait; +use Symfony\Component\VarExporter\VarExporter; +/** + * @author Piotr Stankowski + * @author Nicolas Grekas + * @author Rob Frawley 2nd + */ class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface { - use PhpFilesTrait; + use FilesystemCommonTrait { + doClear as private doCommonClear; + doDelete as private doCommonDelete; + } + + private $includeHandler; + private $appendOnly; + private $values = []; + private $files = []; + + private static $startTime; /** * @param $appendOnly Set to `true` to gain extra performance when the items stored in this pool never expire. @@ -35,4 +52,209 @@ public function __construct(string $namespace = '', int $defaultLifetime = 0, st throw new \ErrorException($msg, 0, $type, $file, $line); }; } + + public static function isSupported() + { + self::$startTime = self::$startTime ?? $_SERVER['REQUEST_TIME'] ?? time(); + + return \function_exists('opcache_invalidate') && ('cli' !== \PHP_SAPI || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN)) && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN); + } + + /** + * @return bool + */ + public function prune() + { + $time = time(); + $pruned = true; + + set_error_handler($this->includeHandler); + try { + foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->directory, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) { + try { + list($expiresAt) = include $file; + } catch (\ErrorException $e) { + $expiresAt = $time; + } + + if ($time >= $expiresAt) { + $pruned = $this->doUnlink($file) && !file_exists($file) && $pruned; + } + } + } finally { + restore_error_handler(); + } + + return $pruned; + } + + /** + * {@inheritdoc} + */ + protected function doFetch(array $ids) + { + if ($this->appendOnly) { + $now = 0; + $missingIds = []; + } else { + $now = time(); + $missingIds = $ids; + $ids = []; + } + $values = []; + + begin: + foreach ($ids as $id) { + if (null === $value = $this->values[$id] ?? null) { + $missingIds[] = $id; + } elseif ('N;' === $value) { + $values[$id] = null; + } elseif ($value instanceof \Closure) { + $values[$id] = $value(); + } else { + $values[$id] = $value; + } + if (!$this->appendOnly) { + unset($this->values[$id]); + } + } + + if (!$missingIds) { + return $values; + } + + set_error_handler($this->includeHandler); + try { + foreach ($missingIds as $k => $id) { + try { + $file = $this->files[$id] ?? $this->files[$id] = $this->getFile($id); + list($expiresAt, $this->values[$id]) = include $file; + if ($now >= $expiresAt) { + unset($this->values[$id], $missingIds[$k]); + } + } catch (\ErrorException $e) { + unset($missingIds[$k]); + } + } + } finally { + restore_error_handler(); + } + + $ids = $missingIds; + $missingIds = []; + goto begin; + } + + /** + * {@inheritdoc} + */ + protected function doHave($id) + { + if ($this->appendOnly && isset($this->values[$id])) { + return true; + } + + set_error_handler($this->includeHandler); + try { + $file = $this->files[$id] ?? $this->files[$id] = $this->getFile($id); + list($expiresAt, $value) = include $file; + } catch (\ErrorException $e) { + return false; + } finally { + restore_error_handler(); + } + if ($this->appendOnly) { + $now = 0; + $this->values[$id] = $value; + } else { + $now = time(); + } + + return $now < $expiresAt; + } + + /** + * {@inheritdoc} + */ + protected function doSave(array $values, $lifetime) + { + $ok = true; + $expiry = $lifetime ? time() + $lifetime : 'PHP_INT_MAX'; + $allowCompile = self::isSupported(); + + foreach ($values as $key => $value) { + unset($this->values[$key]); + $isStaticValue = true; + if (null === $value) { + $value = "'N;'"; + } elseif (\is_object($value) || \is_array($value)) { + try { + $value = VarExporter::export($value, $isStaticValue); + } catch (\Exception $e) { + throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \is_object($value) ? \get_class($value) : 'array'), 0, $e); + } + } elseif (\is_string($value)) { + // Wrap "N;" in a closure to not confuse it with an encoded `null` + if ('N;' === $value) { + $isStaticValue = false; + } + $value = var_export($value, true); + } elseif (!\is_scalar($value)) { + throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \gettype($value))); + } else { + $value = var_export($value, true); + } + + if (!$isStaticValue) { + $value = str_replace("\n", "\n ", $value); + $value = "static function () {\n\n return {$value};\n\n}"; + } + + $file = $this->files[$key] = $this->getFile($key, true); + // Since OPcache only compiles files older than the script execution start, set the file's mtime in the past + $ok = $this->write($file, "directory)) { + throw new CacheException(sprintf('Cache directory is not writable (%s)', $this->directory)); + } + + return $ok; + } + + /** + * {@inheritdoc} + */ + protected function doClear($namespace) + { + $this->values = []; + + return $this->doCommonClear($namespace); + } + + /** + * {@inheritdoc} + */ + protected function doDelete(array $ids) + { + foreach ($ids as $id) { + unset($this->values[$id]); + } + + return $this->doCommonDelete($ids); + } + + protected function doUnlink($file) + { + if (self::isSupported()) { + @opcache_invalidate($file, true); + } + + return @unlink($file); + } } diff --git a/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php b/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php deleted file mode 100644 index d0d42e57f0a7c..0000000000000 --- a/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Adapter; - -@trigger_error(sprintf('The "%s" class is @deprecated since Symfony 4.3, use "Psr16Adapter" instead.', SimpleCacheAdapter::class), E_USER_DEPRECATED); - -/** - * @deprecated since Symfony 4.3, use Psr16Adapter instead. - */ -class SimpleCacheAdapter extends Psr16Adapter -{ -} diff --git a/src/Symfony/Component/Cache/CHANGELOG.md b/src/Symfony/Component/Cache/CHANGELOG.md index 1d24a97ed84ed..1ca36f0c452f7 100644 --- a/src/Symfony/Component/Cache/CHANGELOG.md +++ b/src/Symfony/Component/Cache/CHANGELOG.md @@ -1,6 +1,14 @@ CHANGELOG ========= +5.0.0 +----- + + * removed all PSR-16 implementations in the `Simple` namespace + * removed `SimpleCacheAdapter` + * removed `AbstractAdapter::unserialize()` + * removed `CacheItem::getPreviousTags()` + 4.4.0 ----- diff --git a/src/Symfony/Component/Cache/CacheItem.php b/src/Symfony/Component/Cache/CacheItem.php index 92eb9c39dfa32..cd599d23d2ac2 100644 --- a/src/Symfony/Component/Cache/CacheItem.php +++ b/src/Symfony/Component/Cache/CacheItem.php @@ -140,20 +140,6 @@ public function getMetadata(): array return $this->metadata; } - /** - * Returns the list of tags bound to the value coming from the pool storage if any. - * - * @return array - * - * @deprecated since Symfony 4.2, use the "getMetadata()" method instead. - */ - public function getPreviousTags() - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "getMetadata()" method instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->metadata[self::METADATA_TAGS] ?? []; - } - /** * Validates a cache key according to PSR-6. * diff --git a/src/Symfony/Component/Cache/LockRegistry.php b/src/Symfony/Component/Cache/LockRegistry.php index 676fba5dca3f7..9993e8978eb6a 100644 --- a/src/Symfony/Component/Cache/LockRegistry.php +++ b/src/Symfony/Component/Cache/LockRegistry.php @@ -51,7 +51,6 @@ final class LockRegistry __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'Psr16Adapter.php', __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'RedisAdapter.php', __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'RedisTagAwareAdapter.php', - __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'SimpleCacheAdapter.php', __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'TagAwareAdapter.php', __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'TagAwareAdapterInterface.php', __DIR__.\DIRECTORY_SEPARATOR.'Adapter'.\DIRECTORY_SEPARATOR.'TraceableAdapter.php', diff --git a/src/Symfony/Component/Cache/Simple/AbstractCache.php b/src/Symfony/Component/Cache/Simple/AbstractCache.php deleted file mode 100644 index 312a7dbfd0d6e..0000000000000 --- a/src/Symfony/Component/Cache/Simple/AbstractCache.php +++ /dev/null @@ -1,186 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Simple; - -use Psr\Log\LoggerAwareInterface; -use Psr\SimpleCache\CacheInterface as Psr16CacheInterface; -use Symfony\Component\Cache\Adapter\AbstractAdapter; -use Symfony\Component\Cache\CacheItem; -use Symfony\Component\Cache\Exception\InvalidArgumentException; -use Symfony\Component\Cache\ResettableInterface; -use Symfony\Component\Cache\Traits\AbstractTrait; -use Symfony\Contracts\Cache\CacheInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', AbstractCache::class, AbstractAdapter::class, CacheInterface::class), E_USER_DEPRECATED); - -/** - * @deprecated since Symfony 4.3, use AbstractAdapter and type-hint for CacheInterface instead. - */ -abstract class AbstractCache implements Psr16CacheInterface, LoggerAwareInterface, ResettableInterface -{ - use AbstractTrait { - deleteItems as private; - AbstractTrait::deleteItem as delete; - AbstractTrait::hasItem as has; - } - - private $defaultLifetime; - - protected function __construct(string $namespace = '', int $defaultLifetime = 0) - { - $this->defaultLifetime = max(0, $defaultLifetime); - $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).':'; - if (null !== $this->maxIdLength && \strlen($namespace) > $this->maxIdLength - 24) { - throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, \strlen($namespace), $namespace)); - } - } - - /** - * {@inheritdoc} - */ - public function get($key, $default = null) - { - $id = $this->getId($key); - - try { - foreach ($this->doFetch([$id]) as $value) { - return $value; - } - } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to fetch key "{key}": '.$e->getMessage(), ['key' => $key, 'exception' => $e]); - } - - return $default; - } - - /** - * {@inheritdoc} - */ - public function set($key, $value, $ttl = null) - { - CacheItem::validateKey($key); - - return $this->setMultiple([$key => $value], $ttl); - } - - /** - * {@inheritdoc} - */ - public function getMultiple($keys, $default = null) - { - if ($keys instanceof \Traversable) { - $keys = iterator_to_array($keys, false); - } elseif (!\is_array($keys)) { - throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', \is_object($keys) ? \get_class($keys) : \gettype($keys))); - } - $ids = []; - - foreach ($keys as $key) { - $ids[] = $this->getId($key); - } - try { - $values = $this->doFetch($ids); - } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to fetch values: '.$e->getMessage(), ['keys' => $keys, 'exception' => $e]); - $values = []; - } - $ids = array_combine($ids, $keys); - - return $this->generateValues($values, $ids, $default); - } - - /** - * {@inheritdoc} - */ - public function setMultiple($values, $ttl = null) - { - if (!\is_array($values) && !$values instanceof \Traversable) { - throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given', \is_object($values) ? \get_class($values) : \gettype($values))); - } - $valuesById = []; - - foreach ($values as $key => $value) { - if (\is_int($key)) { - $key = (string) $key; - } - $valuesById[$this->getId($key)] = $value; - } - if (false === $ttl = $this->normalizeTtl($ttl)) { - return $this->doDelete(array_keys($valuesById)); - } - - try { - $e = $this->doSave($valuesById, $ttl); - } catch (\Exception $e) { - } - if (true === $e || [] === $e) { - return true; - } - $keys = []; - foreach (\is_array($e) ? $e : array_keys($valuesById) as $id) { - $keys[] = substr($id, \strlen($this->namespace)); - } - $message = 'Failed to save values'.($e instanceof \Exception ? ': '.$e->getMessage() : '.'); - CacheItem::log($this->logger, $message, ['keys' => $keys, 'exception' => $e instanceof \Exception ? $e : null]); - - return false; - } - - /** - * {@inheritdoc} - */ - public function deleteMultiple($keys) - { - if ($keys instanceof \Traversable) { - $keys = iterator_to_array($keys, false); - } elseif (!\is_array($keys)) { - throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', \is_object($keys) ? \get_class($keys) : \gettype($keys))); - } - - return $this->deleteItems($keys); - } - - private function normalizeTtl($ttl) - { - if (null === $ttl) { - return $this->defaultLifetime; - } - if ($ttl instanceof \DateInterval) { - $ttl = (int) \DateTime::createFromFormat('U', 0)->add($ttl)->format('U'); - } - if (\is_int($ttl)) { - return 0 < $ttl ? $ttl : false; - } - - throw new InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given', \is_object($ttl) ? \get_class($ttl) : \gettype($ttl))); - } - - private function generateValues($values, &$keys, $default) - { - try { - foreach ($values as $id => $value) { - if (!isset($keys[$id])) { - $id = key($keys); - } - $key = $keys[$id]; - unset($keys[$id]); - yield $key => $value; - } - } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to fetch values: '.$e->getMessage(), ['keys' => array_values($keys), 'exception' => $e]); - } - - foreach ($keys as $key) { - yield $key => $default; - } - } -} diff --git a/src/Symfony/Component/Cache/Simple/ApcuCache.php b/src/Symfony/Component/Cache/Simple/ApcuCache.php deleted file mode 100644 index c22771e8227c5..0000000000000 --- a/src/Symfony/Component/Cache/Simple/ApcuCache.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Simple; - -use Symfony\Component\Cache\Traits\ApcuTrait; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', ApcuCache::class, ApcuAdapter::class, CacheInterface::class), E_USER_DEPRECATED); - -/** - * @deprecated since Symfony 4.3, use ApcuAdapter and type-hint for CacheInterface instead. - */ -class ApcuCache extends AbstractCache -{ - use ApcuTrait; - - public function __construct(string $namespace = '', int $defaultLifetime = 0, string $version = null) - { - $this->init($namespace, $defaultLifetime, $version); - } -} diff --git a/src/Symfony/Component/Cache/Simple/ArrayCache.php b/src/Symfony/Component/Cache/Simple/ArrayCache.php deleted file mode 100644 index 3df5b4990c241..0000000000000 --- a/src/Symfony/Component/Cache/Simple/ArrayCache.php +++ /dev/null @@ -1,160 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Simple; - -use Psr\Log\LoggerAwareInterface; -use Psr\SimpleCache\CacheInterface as Psr16CacheInterface; -use Symfony\Component\Cache\Adapter\ArrayAdapter; -use Symfony\Component\Cache\CacheItem; -use Symfony\Component\Cache\Exception\InvalidArgumentException; -use Symfony\Component\Cache\ResettableInterface; -use Symfony\Component\Cache\Traits\ArrayTrait; -use Symfony\Contracts\Cache\CacheInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', ArrayCache::class, ArrayAdapter::class, CacheInterface::class), E_USER_DEPRECATED); - -/** - * @deprecated since Symfony 4.3, use ArrayAdapter and type-hint for CacheInterface instead. - */ -class ArrayCache implements Psr16CacheInterface, LoggerAwareInterface, ResettableInterface -{ - use ArrayTrait { - ArrayTrait::deleteItem as delete; - ArrayTrait::hasItem as has; - } - - private $defaultLifetime; - - /** - * @param int $defaultLifetime - * @param bool $storeSerialized Disabling serialization can lead to cache corruptions when storing mutable values but increases performance otherwise - */ - public function __construct(int $defaultLifetime = 0, bool $storeSerialized = true) - { - $this->defaultLifetime = $defaultLifetime; - $this->storeSerialized = $storeSerialized; - } - - /** - * {@inheritdoc} - */ - public function get($key, $default = null) - { - if (!\is_string($key) || !isset($this->expiries[$key])) { - CacheItem::validateKey($key); - } - if (!$isHit = isset($this->expiries[$key]) && ($this->expiries[$key] > microtime(true) || !$this->delete($key))) { - $this->values[$key] = null; - - return $default; - } - if (!$this->storeSerialized) { - return $this->values[$key]; - } - $value = $this->unfreeze($key, $isHit); - - return $isHit ? $value : $default; - } - - /** - * {@inheritdoc} - */ - public function getMultiple($keys, $default = null) - { - if ($keys instanceof \Traversable) { - $keys = iterator_to_array($keys, false); - } elseif (!\is_array($keys)) { - throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', \is_object($keys) ? \get_class($keys) : \gettype($keys))); - } - foreach ($keys as $key) { - if (!\is_string($key) || !isset($this->expiries[$key])) { - CacheItem::validateKey($key); - } - } - - return $this->generateItems($keys, microtime(true), function ($k, $v, $hit) use ($default) { return $hit ? $v : $default; }); - } - - /** - * {@inheritdoc} - */ - public function deleteMultiple($keys) - { - if (!\is_array($keys) && !$keys instanceof \Traversable) { - throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', \is_object($keys) ? \get_class($keys) : \gettype($keys))); - } - foreach ($keys as $key) { - $this->delete($key); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function set($key, $value, $ttl = null) - { - if (!\is_string($key)) { - CacheItem::validateKey($key); - } - - return $this->setMultiple([$key => $value], $ttl); - } - - /** - * {@inheritdoc} - */ - public function setMultiple($values, $ttl = null) - { - if (!\is_array($values) && !$values instanceof \Traversable) { - throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given', \is_object($values) ? \get_class($values) : \gettype($values))); - } - $valuesArray = []; - - foreach ($values as $key => $value) { - if (!\is_int($key) && !(\is_string($key) && isset($this->expiries[$key]))) { - CacheItem::validateKey($key); - } - $valuesArray[$key] = $value; - } - if (false === $ttl = $this->normalizeTtl($ttl)) { - return $this->deleteMultiple(array_keys($valuesArray)); - } - $expiry = 0 < $ttl ? microtime(true) + $ttl : PHP_INT_MAX; - - foreach ($valuesArray as $key => $value) { - if ($this->storeSerialized && null === $value = $this->freeze($value, $key)) { - return false; - } - $this->values[$key] = $value; - $this->expiries[$key] = $expiry; - } - - return true; - } - - private function normalizeTtl($ttl) - { - if (null === $ttl) { - return $this->defaultLifetime; - } - if ($ttl instanceof \DateInterval) { - $ttl = (int) \DateTime::createFromFormat('U', 0)->add($ttl)->format('U'); - } - if (\is_int($ttl)) { - return 0 < $ttl ? $ttl : false; - } - - throw new InvalidArgumentException(sprintf('Expiration date must be an integer, a DateInterval or null, "%s" given', \is_object($ttl) ? \get_class($ttl) : \gettype($ttl))); - } -} diff --git a/src/Symfony/Component/Cache/Simple/ChainCache.php b/src/Symfony/Component/Cache/Simple/ChainCache.php deleted file mode 100644 index a0122fdee9292..0000000000000 --- a/src/Symfony/Component/Cache/Simple/ChainCache.php +++ /dev/null @@ -1,257 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Simple; - -use Psr\SimpleCache\CacheInterface as Psr16CacheInterface; -use Symfony\Component\Cache\Adapter\ChainAdapter; -use Symfony\Component\Cache\Exception\InvalidArgumentException; -use Symfony\Component\Cache\PruneableInterface; -use Symfony\Component\Cache\ResettableInterface; -use Symfony\Contracts\Cache\CacheInterface; -use Symfony\Contracts\Service\ResetInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', ChainCache::class, ChainAdapter::class, CacheInterface::class), E_USER_DEPRECATED); - -/** - * Chains several caches together. - * - * Cached items are fetched from the first cache having them in its data store. - * They are saved and deleted in all caches at once. - * - * @deprecated since Symfony 4.3, use ChainAdapter and type-hint for CacheInterface instead. - */ -class ChainCache implements Psr16CacheInterface, PruneableInterface, ResettableInterface -{ - private $miss; - private $caches = []; - private $defaultLifetime; - private $cacheCount; - - /** - * @param Psr16CacheInterface[] $caches The ordered list of caches used to fetch cached items - * @param int $defaultLifetime The lifetime of items propagated from lower caches to upper ones - */ - public function __construct(array $caches, int $defaultLifetime = 0) - { - if (!$caches) { - throw new InvalidArgumentException('At least one cache must be specified.'); - } - - foreach ($caches as $cache) { - if (!$cache instanceof Psr16CacheInterface) { - throw new InvalidArgumentException(sprintf('The class "%s" does not implement the "%s" interface.', \get_class($cache), Psr16CacheInterface::class)); - } - } - - $this->miss = new \stdClass(); - $this->caches = array_values($caches); - $this->cacheCount = \count($this->caches); - $this->defaultLifetime = 0 < $defaultLifetime ? $defaultLifetime : null; - } - - /** - * {@inheritdoc} - */ - public function get($key, $default = null) - { - $miss = null !== $default && \is_object($default) ? $default : $this->miss; - - foreach ($this->caches as $i => $cache) { - $value = $cache->get($key, $miss); - - if ($miss !== $value) { - while (0 <= --$i) { - $this->caches[$i]->set($key, $value, $this->defaultLifetime); - } - - return $value; - } - } - - return $default; - } - - /** - * {@inheritdoc} - */ - public function getMultiple($keys, $default = null) - { - $miss = null !== $default && \is_object($default) ? $default : $this->miss; - - return $this->generateItems($this->caches[0]->getMultiple($keys, $miss), 0, $miss, $default); - } - - private function generateItems($values, $cacheIndex, $miss, $default) - { - $missing = []; - $nextCacheIndex = $cacheIndex + 1; - $nextCache = isset($this->caches[$nextCacheIndex]) ? $this->caches[$nextCacheIndex] : null; - - foreach ($values as $k => $value) { - if ($miss !== $value) { - yield $k => $value; - } elseif (!$nextCache) { - yield $k => $default; - } else { - $missing[] = $k; - } - } - - if ($missing) { - $cache = $this->caches[$cacheIndex]; - $values = $this->generateItems($nextCache->getMultiple($missing, $miss), $nextCacheIndex, $miss, $default); - - foreach ($values as $k => $value) { - if ($miss !== $value) { - $cache->set($k, $value, $this->defaultLifetime); - yield $k => $value; - } else { - yield $k => $default; - } - } - } - } - - /** - * {@inheritdoc} - */ - public function has($key) - { - foreach ($this->caches as $cache) { - if ($cache->has($key)) { - return true; - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - $cleared = true; - $i = $this->cacheCount; - - while ($i--) { - $cleared = $this->caches[$i]->clear() && $cleared; - } - - return $cleared; - } - - /** - * {@inheritdoc} - */ - public function delete($key) - { - $deleted = true; - $i = $this->cacheCount; - - while ($i--) { - $deleted = $this->caches[$i]->delete($key) && $deleted; - } - - return $deleted; - } - - /** - * {@inheritdoc} - */ - public function deleteMultiple($keys) - { - if ($keys instanceof \Traversable) { - $keys = iterator_to_array($keys, false); - } - $deleted = true; - $i = $this->cacheCount; - - while ($i--) { - $deleted = $this->caches[$i]->deleteMultiple($keys) && $deleted; - } - - return $deleted; - } - - /** - * {@inheritdoc} - */ - public function set($key, $value, $ttl = null) - { - $saved = true; - $i = $this->cacheCount; - - while ($i--) { - $saved = $this->caches[$i]->set($key, $value, $ttl) && $saved; - } - - return $saved; - } - - /** - * {@inheritdoc} - */ - public function setMultiple($values, $ttl = null) - { - if ($values instanceof \Traversable) { - $valuesIterator = $values; - $values = function () use ($valuesIterator, &$values) { - $generatedValues = []; - - foreach ($valuesIterator as $key => $value) { - yield $key => $value; - $generatedValues[$key] = $value; - } - - $values = $generatedValues; - }; - $values = $values(); - } - $saved = true; - $i = $this->cacheCount; - - while ($i--) { - $saved = $this->caches[$i]->setMultiple($values, $ttl) && $saved; - } - - return $saved; - } - - /** - * {@inheritdoc} - */ - public function prune() - { - $pruned = true; - - foreach ($this->caches as $cache) { - if ($cache instanceof PruneableInterface) { - $pruned = $cache->prune() && $pruned; - } - } - - return $pruned; - } - - /** - * {@inheritdoc} - */ - public function reset() - { - foreach ($this->caches as $cache) { - if ($cache instanceof ResetInterface) { - $cache->reset(); - } - } - } -} diff --git a/src/Symfony/Component/Cache/Simple/DoctrineCache.php b/src/Symfony/Component/Cache/Simple/DoctrineCache.php deleted file mode 100644 index 6a6d0031533e8..0000000000000 --- a/src/Symfony/Component/Cache/Simple/DoctrineCache.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Simple; - -use Doctrine\Common\Cache\CacheProvider; -use Symfony\Component\Cache\Adapter\DoctrineAdapter; -use Symfony\Component\Cache\Traits\DoctrineTrait; -use Symfony\Contracts\Cache\CacheInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', DoctrineCache::class, DoctrineAdapter::class, CacheInterface::class), E_USER_DEPRECATED); - -/** - * @deprecated since Symfony 4.3, use DoctrineAdapter and type-hint for CacheInterface instead. - */ -class DoctrineCache extends AbstractCache -{ - use DoctrineTrait; - - public function __construct(CacheProvider $provider, string $namespace = '', int $defaultLifetime = 0) - { - parent::__construct('', $defaultLifetime); - $this->provider = $provider; - $provider->setNamespace($namespace); - } -} diff --git a/src/Symfony/Component/Cache/Simple/FilesystemCache.php b/src/Symfony/Component/Cache/Simple/FilesystemCache.php deleted file mode 100644 index 8891abd94c9fe..0000000000000 --- a/src/Symfony/Component/Cache/Simple/FilesystemCache.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Simple; - -use Symfony\Component\Cache\Adapter\FilesystemAdapter; -use Symfony\Component\Cache\Marshaller\DefaultMarshaller; -use Symfony\Component\Cache\Marshaller\MarshallerInterface; -use Symfony\Component\Cache\PruneableInterface; -use Symfony\Component\Cache\Traits\FilesystemTrait; -use Symfony\Contracts\Cache\CacheInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', FilesystemCache::class, FilesystemAdapter::class, CacheInterface::class), E_USER_DEPRECATED); - -/** - * @deprecated since Symfony 4.3, use FilesystemAdapter and type-hint for CacheInterface instead. - */ -class FilesystemCache extends AbstractCache implements PruneableInterface -{ - use FilesystemTrait; - - public function __construct(string $namespace = '', int $defaultLifetime = 0, string $directory = null, MarshallerInterface $marshaller = null) - { - $this->marshaller = $marshaller ?? new DefaultMarshaller(); - parent::__construct('', $defaultLifetime); - $this->init($namespace, $directory); - } -} diff --git a/src/Symfony/Component/Cache/Simple/MemcachedCache.php b/src/Symfony/Component/Cache/Simple/MemcachedCache.php deleted file mode 100644 index e1934119aa74a..0000000000000 --- a/src/Symfony/Component/Cache/Simple/MemcachedCache.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Simple; - -use Symfony\Component\Cache\Adapter\MemcachedAdapter; -use Symfony\Component\Cache\Marshaller\MarshallerInterface; -use Symfony\Component\Cache\Traits\MemcachedTrait; -use Symfony\Contracts\Cache\CacheInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', MemcachedCache::class, MemcachedAdapter::class, CacheInterface::class), E_USER_DEPRECATED); - -/** - * @deprecated since Symfony 4.3, use MemcachedAdapter and type-hint for CacheInterface instead. - */ -class MemcachedCache extends AbstractCache -{ - use MemcachedTrait; - - protected $maxIdLength = 250; - - public function __construct(\Memcached $client, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null) - { - $this->init($client, $namespace, $defaultLifetime, $marshaller); - } -} diff --git a/src/Symfony/Component/Cache/Simple/NullCache.php b/src/Symfony/Component/Cache/Simple/NullCache.php deleted file mode 100644 index d1ca6f71873b0..0000000000000 --- a/src/Symfony/Component/Cache/Simple/NullCache.php +++ /dev/null @@ -1,90 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Simple; - -use Psr\SimpleCache\CacheInterface as Psr16CacheInterface; -use Symfony\Components\Cache\Adapter\NullAdapter; -use Symfony\Contracts\Cache\CacheInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', NullCache::class, NullAdapter::class, CacheInterface::class), E_USER_DEPRECATED); - -/** - * @deprecated since Symfony 4.3, use NullAdapter and type-hint for CacheInterface instead. - */ -class NullCache implements Psr16CacheInterface -{ - /** - * {@inheritdoc} - */ - public function get($key, $default = null) - { - return $default; - } - - /** - * {@inheritdoc} - */ - public function getMultiple($keys, $default = null) - { - foreach ($keys as $key) { - yield $key => $default; - } - } - - /** - * {@inheritdoc} - */ - public function has($key) - { - return false; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function delete($key) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function deleteMultiple($keys) - { - return true; - } - - /** - * {@inheritdoc} - */ - public function set($key, $value, $ttl = null) - { - return false; - } - - /** - * {@inheritdoc} - */ - public function setMultiple($values, $ttl = null) - { - return false; - } -} diff --git a/src/Symfony/Component/Cache/Simple/PdoCache.php b/src/Symfony/Component/Cache/Simple/PdoCache.php deleted file mode 100644 index 07849e93feb9a..0000000000000 --- a/src/Symfony/Component/Cache/Simple/PdoCache.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Simple; - -use Symfony\Component\Cache\Adapter\PdoAdapter; -use Symfony\Component\Cache\Marshaller\MarshallerInterface; -use Symfony\Component\Cache\PruneableInterface; -use Symfony\Component\Cache\Traits\PdoTrait; -use Symfony\Contracts\Cache\CacheInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', PdoCache::class, PdoAdapter::class, CacheInterface::class), E_USER_DEPRECATED); - -/** - * @deprecated since Symfony 4.3, use PdoAdapter and type-hint for CacheInterface instead. - */ -class PdoCache extends AbstractCache implements PruneableInterface -{ - use PdoTrait; - - protected $maxIdLength = 255; - - /** - * You can either pass an existing database connection as PDO instance or - * a Doctrine DBAL Connection or a DSN string that will be used to - * lazy-connect to the database when the cache is actually used. - * - * When a Doctrine DBAL Connection is passed, the cache table is created - * automatically when possible. Otherwise, use the createTable() method. - * - * List of available options: - * * db_table: The name of the table [default: cache_items] - * * db_id_col: The column where to store the cache id [default: item_id] - * * db_data_col: The column where to store the cache data [default: item_data] - * * db_lifetime_col: The column where to store the lifetime [default: item_lifetime] - * * db_time_col: The column where to store the timestamp [default: item_time] - * * db_username: The username when lazy-connect [default: ''] - * * db_password: The password when lazy-connect [default: ''] - * * db_connection_options: An array of driver-specific connection options [default: []] - * - * @param \PDO|Connection|string $connOrDsn a \PDO or Connection instance or DSN string or null - * - * @throws InvalidArgumentException When first argument is not PDO nor Connection nor string - * @throws InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION - * @throws InvalidArgumentException When namespace contains invalid characters - */ - public function __construct($connOrDsn, string $namespace = '', int $defaultLifetime = 0, array $options = [], MarshallerInterface $marshaller = null) - { - $this->init($connOrDsn, $namespace, $defaultLifetime, $options, $marshaller); - } -} diff --git a/src/Symfony/Component/Cache/Simple/PhpArrayCache.php b/src/Symfony/Component/Cache/Simple/PhpArrayCache.php deleted file mode 100644 index 566609359d568..0000000000000 --- a/src/Symfony/Component/Cache/Simple/PhpArrayCache.php +++ /dev/null @@ -1,248 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Simple; - -use Psr\SimpleCache\CacheInterface as Psr16CacheInterface; -use Symfony\Component\Cache\Adapter\PhpArrayAdapter; -use Symfony\Component\Cache\Exception\InvalidArgumentException; -use Symfony\Component\Cache\PruneableInterface; -use Symfony\Component\Cache\ResettableInterface; -use Symfony\Component\Cache\Traits\PhpArrayTrait; -use Symfony\Contracts\Cache\CacheInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', PhpArrayCache::class, PhpArrayAdapter::class, CacheInterface::class), E_USER_DEPRECATED); - -/** - * @deprecated since Symfony 4.3, use PhpArrayAdapter and type-hint for CacheInterface instead. - */ -class PhpArrayCache implements Psr16CacheInterface, PruneableInterface, ResettableInterface -{ - use PhpArrayTrait; - - /** - * @param string $file The PHP file were values are cached - * @param Psr16CacheInterface $fallbackPool A pool to fallback on when an item is not hit - */ - public function __construct(string $file, Psr16CacheInterface $fallbackPool) - { - $this->file = $file; - $this->pool = $fallbackPool; - } - - /** - * This adapter takes advantage of how PHP stores arrays in its latest versions. - * - * @param string $file The PHP file were values are cached - * - * @return Psr16CacheInterface - */ - public static function create($file, Psr16CacheInterface $fallbackPool) - { - // Shared memory is available in PHP 7.0+ with OPCache enabled - if (filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) { - return new static($file, $fallbackPool); - } - - return $fallbackPool; - } - - /** - * {@inheritdoc} - */ - public function get($key, $default = null) - { - if (!\is_string($key)) { - throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key))); - } - if (null === $this->values) { - $this->initialize(); - } - if (!isset($this->keys[$key])) { - return $this->pool->get($key, $default); - } - $value = $this->values[$this->keys[$key]]; - - if ('N;' === $value) { - return null; - } - if ($value instanceof \Closure) { - try { - return $value(); - } catch (\Throwable $e) { - return $default; - } - } - - return $value; - } - - /** - * {@inheritdoc} - */ - public function getMultiple($keys, $default = null) - { - if ($keys instanceof \Traversable) { - $keys = iterator_to_array($keys, false); - } elseif (!\is_array($keys)) { - throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', \is_object($keys) ? \get_class($keys) : \gettype($keys))); - } - foreach ($keys as $key) { - if (!\is_string($key)) { - throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key))); - } - } - if (null === $this->values) { - $this->initialize(); - } - - return $this->generateItems($keys, $default); - } - - /** - * {@inheritdoc} - */ - public function has($key) - { - if (!\is_string($key)) { - throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key))); - } - if (null === $this->values) { - $this->initialize(); - } - - return isset($this->keys[$key]) || $this->pool->has($key); - } - - /** - * {@inheritdoc} - */ - public function delete($key) - { - if (!\is_string($key)) { - throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key))); - } - if (null === $this->values) { - $this->initialize(); - } - - return !isset($this->keys[$key]) && $this->pool->delete($key); - } - - /** - * {@inheritdoc} - */ - public function deleteMultiple($keys) - { - if (!\is_array($keys) && !$keys instanceof \Traversable) { - throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', \is_object($keys) ? \get_class($keys) : \gettype($keys))); - } - - $deleted = true; - $fallbackKeys = []; - - foreach ($keys as $key) { - if (!\is_string($key)) { - throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key))); - } - - if (isset($this->keys[$key])) { - $deleted = false; - } else { - $fallbackKeys[] = $key; - } - } - if (null === $this->values) { - $this->initialize(); - } - - if ($fallbackKeys) { - $deleted = $this->pool->deleteMultiple($fallbackKeys) && $deleted; - } - - return $deleted; - } - - /** - * {@inheritdoc} - */ - public function set($key, $value, $ttl = null) - { - if (!\is_string($key)) { - throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key))); - } - if (null === $this->values) { - $this->initialize(); - } - - return !isset($this->keys[$key]) && $this->pool->set($key, $value, $ttl); - } - - /** - * {@inheritdoc} - */ - public function setMultiple($values, $ttl = null) - { - if (!\is_array($values) && !$values instanceof \Traversable) { - throw new InvalidArgumentException(sprintf('Cache values must be array or Traversable, "%s" given', \is_object($values) ? \get_class($values) : \gettype($values))); - } - - $saved = true; - $fallbackValues = []; - - foreach ($values as $key => $value) { - if (!\is_string($key) && !\is_int($key)) { - throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key))); - } - - if (isset($this->keys[$key])) { - $saved = false; - } else { - $fallbackValues[$key] = $value; - } - } - - if ($fallbackValues) { - $saved = $this->pool->setMultiple($fallbackValues, $ttl) && $saved; - } - - return $saved; - } - - private function generateItems(array $keys, $default) - { - $fallbackKeys = []; - - foreach ($keys as $key) { - if (isset($this->keys[$key])) { - $value = $this->values[$this->keys[$key]]; - - if ('N;' === $value) { - yield $key => null; - } elseif ($value instanceof \Closure) { - try { - yield $key => $value(); - } catch (\Throwable $e) { - yield $key => $default; - } - } else { - yield $key => $value; - } - } else { - $fallbackKeys[] = $key; - } - } - - if ($fallbackKeys) { - yield from $this->pool->getMultiple($fallbackKeys, $default); - } - } -} diff --git a/src/Symfony/Component/Cache/Simple/PhpFilesCache.php b/src/Symfony/Component/Cache/Simple/PhpFilesCache.php deleted file mode 100644 index 060244a086643..0000000000000 --- a/src/Symfony/Component/Cache/Simple/PhpFilesCache.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Simple; - -use Symfony\Component\Cache\Adapter\PhpFilesAdapter; -use Symfony\Component\Cache\Exception\CacheException; -use Symfony\Component\Cache\PruneableInterface; -use Symfony\Component\Cache\Traits\PhpFilesTrait; -use Symfony\Contracts\Cache\CacheInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', PhpFilesCache::class, PhpFilesAdapter::class, CacheInterface::class), E_USER_DEPRECATED); - -/** - * @deprecated since Symfony 4.3, use PhpFilesAdapter and type-hint for CacheInterface instead. - */ -class PhpFilesCache extends AbstractCache implements PruneableInterface -{ - use PhpFilesTrait; - - /** - * @param $appendOnly Set to `true` to gain extra performance when the items stored in this pool never expire. - * Doing so is encouraged because it fits perfectly OPcache's memory model. - * - * @throws CacheException if OPcache is not enabled - */ - public function __construct(string $namespace = '', int $defaultLifetime = 0, string $directory = null, bool $appendOnly = false) - { - $this->appendOnly = $appendOnly; - self::$startTime = self::$startTime ?? $_SERVER['REQUEST_TIME'] ?? time(); - parent::__construct('', $defaultLifetime); - $this->init($namespace, $directory); - $this->includeHandler = static function ($type, $msg, $file, $line) { - throw new \ErrorException($msg, 0, $type, $file, $line); - }; - } -} diff --git a/src/Symfony/Component/Cache/Simple/Psr6Cache.php b/src/Symfony/Component/Cache/Simple/Psr6Cache.php deleted file mode 100644 index 090f48c172860..0000000000000 --- a/src/Symfony/Component/Cache/Simple/Psr6Cache.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Simple; - -use Symfony\Component\Cache\Psr16Cache; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" instead.', Psr6Cache::class, Psr16Cache::class), E_USER_DEPRECATED); - -/** - * @deprecated since Symfony 4.3, use Psr16Cache instead. - */ -class Psr6Cache extends Psr16Cache -{ -} diff --git a/src/Symfony/Component/Cache/Simple/RedisCache.php b/src/Symfony/Component/Cache/Simple/RedisCache.php deleted file mode 100644 index 2933bf15b3b52..0000000000000 --- a/src/Symfony/Component/Cache/Simple/RedisCache.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Simple; - -use Symfony\Component\Cache\Adapter\RedisAdapter; -use Symfony\Component\Cache\Marshaller\MarshallerInterface; -use Symfony\Component\Cache\Traits\RedisTrait; -use Symfony\Contracts\Cache\CacheInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', RedisCache::class, RedisAdapter::class, CacheInterface::class), E_USER_DEPRECATED); - -/** - * @deprecated since Symfony 4.3, use RedisAdapter and type-hint for CacheInterface instead. - */ -class RedisCache extends AbstractCache -{ - use RedisTrait; - - /** - * @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient - * @param string $namespace - * @param int $defaultLifetime - */ - public function __construct($redisClient, string $namespace = '', int $defaultLifetime = 0, MarshallerInterface $marshaller = null) - { - $this->init($redisClient, $namespace, $defaultLifetime, $marshaller); - } -} diff --git a/src/Symfony/Component/Cache/Simple/TraceableCache.php b/src/Symfony/Component/Cache/Simple/TraceableCache.php deleted file mode 100644 index ad9bfcf09ca60..0000000000000 --- a/src/Symfony/Component/Cache/Simple/TraceableCache.php +++ /dev/null @@ -1,243 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Simple; - -use Psr\SimpleCache\CacheInterface as Psr16CacheInterface; -use Symfony\Component\Cache\PruneableInterface; -use Symfony\Component\Cache\ResettableInterface; -use Symfony\Contracts\Cache\CacheInterface; -use Symfony\Contracts\Service\ResetInterface; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" and type-hint for "%s" instead.', TraceableCache::class, TraceableAdapter::class, CacheInterface::class), E_USER_DEPRECATED); - -/** - * @deprecated since Symfony 4.3, use TraceableAdapter and type-hint for CacheInterface instead. - */ -class TraceableCache implements Psr16CacheInterface, PruneableInterface, ResettableInterface -{ - private $pool; - private $miss; - private $calls = []; - - public function __construct(Psr16CacheInterface $pool) - { - $this->pool = $pool; - $this->miss = new \stdClass(); - } - - /** - * {@inheritdoc} - */ - public function get($key, $default = null) - { - $miss = null !== $default && \is_object($default) ? $default : $this->miss; - $event = $this->start(__FUNCTION__); - try { - $value = $this->pool->get($key, $miss); - } finally { - $event->end = microtime(true); - } - if ($event->result[$key] = $miss !== $value) { - ++$event->hits; - } else { - ++$event->misses; - $value = $default; - } - - return $value; - } - - /** - * {@inheritdoc} - */ - public function has($key) - { - $event = $this->start(__FUNCTION__); - try { - return $event->result[$key] = $this->pool->has($key); - } finally { - $event->end = microtime(true); - } - } - - /** - * {@inheritdoc} - */ - public function delete($key) - { - $event = $this->start(__FUNCTION__); - try { - return $event->result[$key] = $this->pool->delete($key); - } finally { - $event->end = microtime(true); - } - } - - /** - * {@inheritdoc} - */ - public function set($key, $value, $ttl = null) - { - $event = $this->start(__FUNCTION__); - try { - return $event->result[$key] = $this->pool->set($key, $value, $ttl); - } finally { - $event->end = microtime(true); - } - } - - /** - * {@inheritdoc} - */ - public function setMultiple($values, $ttl = null) - { - $event = $this->start(__FUNCTION__); - $event->result['keys'] = []; - - if ($values instanceof \Traversable) { - $values = function () use ($values, $event) { - foreach ($values as $k => $v) { - $event->result['keys'][] = $k; - yield $k => $v; - } - }; - $values = $values(); - } elseif (\is_array($values)) { - $event->result['keys'] = array_keys($values); - } - - try { - return $event->result['result'] = $this->pool->setMultiple($values, $ttl); - } finally { - $event->end = microtime(true); - } - } - - /** - * {@inheritdoc} - */ - public function getMultiple($keys, $default = null) - { - $miss = null !== $default && \is_object($default) ? $default : $this->miss; - $event = $this->start(__FUNCTION__); - try { - $result = $this->pool->getMultiple($keys, $miss); - } finally { - $event->end = microtime(true); - } - $f = function () use ($result, $event, $miss, $default) { - $event->result = []; - foreach ($result as $key => $value) { - if ($event->result[$key] = $miss !== $value) { - ++$event->hits; - } else { - ++$event->misses; - $value = $default; - } - yield $key => $value; - } - }; - - return $f(); - } - - /** - * {@inheritdoc} - */ - public function clear() - { - $event = $this->start(__FUNCTION__); - try { - return $event->result = $this->pool->clear(); - } finally { - $event->end = microtime(true); - } - } - - /** - * {@inheritdoc} - */ - public function deleteMultiple($keys) - { - $event = $this->start(__FUNCTION__); - if ($keys instanceof \Traversable) { - $keys = $event->result['keys'] = iterator_to_array($keys, false); - } else { - $event->result['keys'] = $keys; - } - try { - return $event->result['result'] = $this->pool->deleteMultiple($keys); - } finally { - $event->end = microtime(true); - } - } - - /** - * {@inheritdoc} - */ - public function prune() - { - if (!$this->pool instanceof PruneableInterface) { - return false; - } - $event = $this->start(__FUNCTION__); - try { - return $event->result = $this->pool->prune(); - } finally { - $event->end = microtime(true); - } - } - - /** - * {@inheritdoc} - */ - public function reset() - { - if (!$this->pool instanceof ResetInterface) { - return; - } - $event = $this->start(__FUNCTION__); - try { - $this->pool->reset(); - } finally { - $event->end = microtime(true); - } - } - - public function getCalls() - { - try { - return $this->calls; - } finally { - $this->calls = []; - } - } - - private function start($name) - { - $this->calls[] = $event = new TraceableCacheEvent(); - $event->name = $name; - $event->start = microtime(true); - - return $event; - } -} - -class TraceableCacheEvent -{ - public $name; - public $start; - public $end; - public $result; - public $hits = 0; - public $misses = 0; -} diff --git a/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php deleted file mode 100644 index b11f72d5a395b..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Adapter; - -use Symfony\Component\Cache\Adapter\SimpleCacheAdapter; -use Symfony\Component\Cache\Simple\FilesystemCache; - -/** - * @group time-sensitive - * @group legacy - */ -class SimpleCacheAdapterTest extends AdapterTestCase -{ - protected $skippedTests = [ - 'testPrune' => 'SimpleCache just proxies', - ]; - - public function createCachePool($defaultLifetime = 0) - { - return new SimpleCacheAdapter(new FilesystemCache(), '', $defaultLifetime); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php deleted file mode 100644 index a9f5d98b92a44..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/AbstractRedisCacheTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Symfony\Component\Cache\Simple\RedisCache; - -/** - * @group legacy - */ -abstract class AbstractRedisCacheTest extends CacheTestCase -{ - protected $skippedTests = [ - 'testSetTtl' => 'Testing expiration slows down the test suite', - 'testSetMultipleTtl' => 'Testing expiration slows down the test suite', - 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', - ]; - - protected static $redis; - - public function createSimpleCache($defaultLifetime = 0) - { - return new RedisCache(self::$redis, str_replace('\\', '.', __CLASS__), $defaultLifetime); - } - - public static function setupBeforeClass() - { - if (!\extension_loaded('redis')) { - self::markTestSkipped('Extension redis required.'); - } - if (!@((new \Redis())->connect(getenv('REDIS_HOST')))) { - $e = error_get_last(); - self::markTestSkipped($e['message']); - } - } - - public static function tearDownAfterClass() - { - self::$redis = null; - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php deleted file mode 100644 index b3220946038cd..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/ApcuCacheTest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Symfony\Component\Cache\Simple\ApcuCache; - -/** - * @group legacy - */ -class ApcuCacheTest extends CacheTestCase -{ - protected $skippedTests = [ - 'testSetTtl' => 'Testing expiration slows down the test suite', - 'testSetMultipleTtl' => 'Testing expiration slows down the test suite', - 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', - ]; - - public function createSimpleCache($defaultLifetime = 0) - { - if (!\function_exists('apcu_fetch') || !filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) || ('cli' === \PHP_SAPI && !filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN))) { - $this->markTestSkipped('APCu extension is required.'); - } - if ('\\' === \DIRECTORY_SEPARATOR) { - $this->markTestSkipped('Fails transiently on Windows.'); - } - - return new ApcuCache(str_replace('\\', '.', __CLASS__), $defaultLifetime); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/ArrayCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/ArrayCacheTest.php deleted file mode 100644 index 587304a5db1c4..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/ArrayCacheTest.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Symfony\Component\Cache\Simple\ArrayCache; - -/** - * @group time-sensitive - * @group legacy - */ -class ArrayCacheTest extends CacheTestCase -{ - public function createSimpleCache($defaultLifetime = 0) - { - return new ArrayCache($defaultLifetime); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/CacheTestCase.php b/src/Symfony/Component/Cache/Tests/Simple/CacheTestCase.php deleted file mode 100644 index d4b3d07f62729..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/CacheTestCase.php +++ /dev/null @@ -1,141 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Cache\IntegrationTests\SimpleCacheTest; -use Psr\SimpleCache\CacheInterface; -use Symfony\Component\Cache\PruneableInterface; - -abstract class CacheTestCase extends SimpleCacheTest -{ - protected function setUp() - { - parent::setUp(); - - if (!\array_key_exists('testPrune', $this->skippedTests) && !$this->createSimpleCache() instanceof PruneableInterface) { - $this->skippedTests['testPrune'] = 'Not a pruneable cache pool.'; - } - } - - public static function validKeys() - { - return array_merge(parent::validKeys(), [["a\0b"]]); - } - - public function testDefaultLifeTime() - { - if (isset($this->skippedTests[__FUNCTION__])) { - $this->markTestSkipped($this->skippedTests[__FUNCTION__]); - } - - $cache = $this->createSimpleCache(2); - $cache->clear(); - - $cache->set('key.dlt', 'value'); - sleep(1); - - $this->assertSame('value', $cache->get('key.dlt')); - - sleep(2); - $this->assertNull($cache->get('key.dlt')); - - $cache->clear(); - } - - public function testNotUnserializable() - { - if (isset($this->skippedTests[__FUNCTION__])) { - $this->markTestSkipped($this->skippedTests[__FUNCTION__]); - } - - $cache = $this->createSimpleCache(); - $cache->clear(); - - $cache->set('foo', new NotUnserializable()); - - $this->assertNull($cache->get('foo')); - - $cache->setMultiple(['foo' => new NotUnserializable()]); - - foreach ($cache->getMultiple(['foo']) as $value) { - } - $this->assertNull($value); - - $cache->clear(); - } - - public function testPrune() - { - if (isset($this->skippedTests[__FUNCTION__])) { - $this->markTestSkipped($this->skippedTests[__FUNCTION__]); - } - - if (!method_exists($this, 'isPruned')) { - $this->fail('Test classes for pruneable caches must implement `isPruned($cache, $name)` method.'); - } - - /** @var PruneableInterface|CacheInterface $cache */ - $cache = $this->createSimpleCache(); - $cache->clear(); - - $cache->set('foo', 'foo-val', new \DateInterval('PT05S')); - $cache->set('bar', 'bar-val', new \DateInterval('PT10S')); - $cache->set('baz', 'baz-val', new \DateInterval('PT15S')); - $cache->set('qux', 'qux-val', new \DateInterval('PT20S')); - - sleep(30); - $cache->prune(); - $this->assertTrue($this->isPruned($cache, 'foo')); - $this->assertTrue($this->isPruned($cache, 'bar')); - $this->assertTrue($this->isPruned($cache, 'baz')); - $this->assertTrue($this->isPruned($cache, 'qux')); - - $cache->set('foo', 'foo-val'); - $cache->set('bar', 'bar-val', new \DateInterval('PT20S')); - $cache->set('baz', 'baz-val', new \DateInterval('PT40S')); - $cache->set('qux', 'qux-val', new \DateInterval('PT80S')); - - $cache->prune(); - $this->assertFalse($this->isPruned($cache, 'foo')); - $this->assertFalse($this->isPruned($cache, 'bar')); - $this->assertFalse($this->isPruned($cache, 'baz')); - $this->assertFalse($this->isPruned($cache, 'qux')); - - sleep(30); - $cache->prune(); - $this->assertFalse($this->isPruned($cache, 'foo')); - $this->assertTrue($this->isPruned($cache, 'bar')); - $this->assertFalse($this->isPruned($cache, 'baz')); - $this->assertFalse($this->isPruned($cache, 'qux')); - - sleep(30); - $cache->prune(); - $this->assertFalse($this->isPruned($cache, 'foo')); - $this->assertTrue($this->isPruned($cache, 'baz')); - $this->assertFalse($this->isPruned($cache, 'qux')); - - sleep(30); - $cache->prune(); - $this->assertFalse($this->isPruned($cache, 'foo')); - $this->assertTrue($this->isPruned($cache, 'qux')); - - $cache->clear(); - } -} - -class NotUnserializable -{ - public function __wakeup() - { - throw new \Exception(__CLASS__); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php deleted file mode 100644 index 0af56cd30dc55..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/ChainCacheTest.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Psr\SimpleCache\CacheInterface; -use Symfony\Component\Cache\PruneableInterface; -use Symfony\Component\Cache\Simple\ArrayCache; -use Symfony\Component\Cache\Simple\ChainCache; -use Symfony\Component\Cache\Simple\FilesystemCache; - -/** - * @group time-sensitive - * @group legacy - */ -class ChainCacheTest extends CacheTestCase -{ - public function createSimpleCache($defaultLifetime = 0) - { - return new ChainCache([new ArrayCache($defaultLifetime), new FilesystemCache('', $defaultLifetime)], $defaultLifetime); - } - - /** - * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException - * @expectedExceptionMessage At least one cache must be specified. - */ - public function testEmptyCachesException() - { - new ChainCache([]); - } - - /** - * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException - * @expectedExceptionMessage The class "stdClass" does not implement - */ - public function testInvalidCacheException() - { - new ChainCache([new \stdClass()]); - } - - public function testPrune() - { - if (isset($this->skippedTests[__FUNCTION__])) { - $this->markTestSkipped($this->skippedTests[__FUNCTION__]); - } - - $cache = new ChainCache([ - $this->getPruneableMock(), - $this->getNonPruneableMock(), - $this->getPruneableMock(), - ]); - $this->assertTrue($cache->prune()); - - $cache = new ChainCache([ - $this->getPruneableMock(), - $this->getFailingPruneableMock(), - $this->getPruneableMock(), - ]); - $this->assertFalse($cache->prune()); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject|PruneableCacheInterface - */ - private function getPruneableMock() - { - $pruneable = $this - ->getMockBuilder(PruneableCacheInterface::class) - ->getMock(); - - $pruneable - ->expects($this->atLeastOnce()) - ->method('prune') - ->willReturn(true); - - return $pruneable; - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject|PruneableCacheInterface - */ - private function getFailingPruneableMock() - { - $pruneable = $this - ->getMockBuilder(PruneableCacheInterface::class) - ->getMock(); - - $pruneable - ->expects($this->atLeastOnce()) - ->method('prune') - ->willReturn(false); - - return $pruneable; - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject|CacheInterface - */ - private function getNonPruneableMock() - { - return $this - ->getMockBuilder(CacheInterface::class) - ->getMock(); - } -} - -interface PruneableCacheInterface extends PruneableInterface, CacheInterface -{ -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php deleted file mode 100644 index 5d78c00cac841..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/DoctrineCacheTest.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Symfony\Component\Cache\Simple\DoctrineCache; -use Symfony\Component\Cache\Tests\Fixtures\ArrayCache; - -/** - * @group time-sensitive - * @group legacy - */ -class DoctrineCacheTest extends CacheTestCase -{ - protected $skippedTests = [ - 'testObjectDoesNotChangeInCache' => 'ArrayCache does not use serialize/unserialize', - 'testNotUnserializable' => 'ArrayCache does not use serialize/unserialize', - ]; - - public function createSimpleCache($defaultLifetime = 0) - { - return new DoctrineCache(new ArrayCache($defaultLifetime), '', $defaultLifetime); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/FilesystemCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/FilesystemCacheTest.php deleted file mode 100644 index 9f423ba641c93..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/FilesystemCacheTest.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Psr\SimpleCache\CacheInterface; -use Symfony\Component\Cache\Simple\FilesystemCache; - -/** - * @group time-sensitive - * @group legacy - */ -class FilesystemCacheTest extends CacheTestCase -{ - public function createSimpleCache($defaultLifetime = 0) - { - return new FilesystemCache('', $defaultLifetime); - } - - protected function isPruned(CacheInterface $cache, $name) - { - $getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile'); - $getFileMethod->setAccessible(true); - - return !file_exists($getFileMethod->invoke($cache, $name)); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php deleted file mode 100644 index 692259296f21d..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTest.php +++ /dev/null @@ -1,177 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Symfony\Component\Cache\Adapter\AbstractAdapter; -use Symfony\Component\Cache\Simple\MemcachedCache; - -/** - * @group legacy - */ -class MemcachedCacheTest extends CacheTestCase -{ - protected $skippedTests = [ - 'testSetTtl' => 'Testing expiration slows down the test suite', - 'testSetMultipleTtl' => 'Testing expiration slows down the test suite', - 'testDefaultLifeTime' => 'Testing expiration slows down the test suite', - ]; - - protected static $client; - - public static function setupBeforeClass() - { - if (!MemcachedCache::isSupported()) { - self::markTestSkipped('Extension memcached >=2.2.0 required.'); - } - self::$client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST')); - self::$client->get('foo'); - $code = self::$client->getResultCode(); - - if (\Memcached::RES_SUCCESS !== $code && \Memcached::RES_NOTFOUND !== $code) { - self::markTestSkipped('Memcached error: '.strtolower(self::$client->getResultMessage())); - } - } - - public function createSimpleCache($defaultLifetime = 0) - { - $client = $defaultLifetime ? AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]) : self::$client; - - return new MemcachedCache($client, str_replace('\\', '.', __CLASS__), $defaultLifetime); - } - - public function testCreatePersistentConnectionShouldNotDupServerList() - { - $instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['persistent_id' => 'persistent']); - $this->assertCount(1, $instance->getServerList()); - - $instance = MemcachedCache::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['persistent_id' => 'persistent']); - $this->assertCount(1, $instance->getServerList()); - } - - public function testOptions() - { - $client = MemcachedCache::createConnection([], [ - 'libketama_compatible' => false, - 'distribution' => 'modula', - 'compression' => true, - 'serializer' => 'php', - 'hash' => 'md5', - ]); - - $this->assertSame(\Memcached::SERIALIZER_PHP, $client->getOption(\Memcached::OPT_SERIALIZER)); - $this->assertSame(\Memcached::HASH_MD5, $client->getOption(\Memcached::OPT_HASH)); - $this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION)); - $this->assertSame(0, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE)); - $this->assertSame(\Memcached::DISTRIBUTION_MODULA, $client->getOption(\Memcached::OPT_DISTRIBUTION)); - } - - /** - * @dataProvider provideBadOptions - * @expectedException \ErrorException - * @expectedExceptionMessage constant(): Couldn't find constant Memcached:: - */ - public function testBadOptions($name, $value) - { - MemcachedCache::createConnection([], [$name => $value]); - } - - public function provideBadOptions() - { - return [ - ['foo', 'bar'], - ['hash', 'zyx'], - ['serializer', 'zyx'], - ['distribution', 'zyx'], - ]; - } - - public function testDefaultOptions() - { - $this->assertTrue(MemcachedCache::isSupported()); - - $client = MemcachedCache::createConnection([]); - - $this->assertTrue($client->getOption(\Memcached::OPT_COMPRESSION)); - $this->assertSame(1, $client->getOption(\Memcached::OPT_BINARY_PROTOCOL)); - $this->assertSame(1, $client->getOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE)); - } - - /** - * @expectedException \Symfony\Component\Cache\Exception\CacheException - * @expectedExceptionMessage MemcachedAdapter: "serializer" option must be "php" or "igbinary". - */ - public function testOptionSerializer() - { - if (!\Memcached::HAVE_JSON) { - $this->markTestSkipped('Memcached::HAVE_JSON required'); - } - - new MemcachedCache(MemcachedCache::createConnection([], ['serializer' => 'json'])); - } - - /** - * @dataProvider provideServersSetting - */ - public function testServersSetting($dsn, $host, $port) - { - $client1 = MemcachedCache::createConnection($dsn); - $client2 = MemcachedCache::createConnection([$dsn]); - $client3 = MemcachedCache::createConnection([[$host, $port]]); - $expect = [ - 'host' => $host, - 'port' => $port, - ]; - - $f = function ($s) { return ['host' => $s['host'], 'port' => $s['port']]; }; - $this->assertSame([$expect], array_map($f, $client1->getServerList())); - $this->assertSame([$expect], array_map($f, $client2->getServerList())); - $this->assertSame([$expect], array_map($f, $client3->getServerList())); - } - - public function provideServersSetting() - { - yield [ - 'memcached://127.0.0.1/50', - '127.0.0.1', - 11211, - ]; - yield [ - 'memcached://localhost:11222?weight=25', - 'localhost', - 11222, - ]; - if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { - yield [ - 'memcached://user:password@127.0.0.1?weight=50', - '127.0.0.1', - 11211, - ]; - } - yield [ - 'memcached:///var/run/memcached.sock?weight=25', - '/var/run/memcached.sock', - 0, - ]; - yield [ - 'memcached:///var/local/run/memcached.socket?weight=25', - '/var/local/run/memcached.socket', - 0, - ]; - if (filter_var(ini_get('memcached.use_sasl'), FILTER_VALIDATE_BOOLEAN)) { - yield [ - 'memcached://user:password@/var/local/run/memcached.socket?weight=25', - '/var/local/run/memcached.socket', - 0, - ]; - } - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTextModeTest.php b/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTextModeTest.php deleted file mode 100644 index d68131a1db7bd..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/MemcachedCacheTextModeTest.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Symfony\Component\Cache\Adapter\AbstractAdapter; -use Symfony\Component\Cache\Simple\MemcachedCache; - -/** - * @group legacy - */ -class MemcachedCacheTextModeTest extends MemcachedCacheTest -{ - public function createSimpleCache($defaultLifetime = 0) - { - $client = AbstractAdapter::createConnection('memcached://'.getenv('MEMCACHED_HOST'), ['binary_protocol' => false]); - - return new MemcachedCache($client, str_replace('\\', '.', __CLASS__), $defaultLifetime); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/NullCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/NullCacheTest.php deleted file mode 100644 index cf0dde92b33f4..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/NullCacheTest.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Cache\Simple\NullCache; - -/** - * @group time-sensitive - * @group legacy - */ -class NullCacheTest extends TestCase -{ - public function createCachePool() - { - return new NullCache(); - } - - public function testGetItem() - { - $cache = $this->createCachePool(); - - $this->assertNull($cache->get('key')); - } - - public function testHas() - { - $this->assertFalse($this->createCachePool()->has('key')); - } - - public function testGetMultiple() - { - $cache = $this->createCachePool(); - - $keys = ['foo', 'bar', 'baz', 'biz']; - - $default = new \stdClass(); - $items = $cache->getMultiple($keys, $default); - $count = 0; - - foreach ($items as $key => $item) { - $this->assertContains($key, $keys, 'Cache key can not change.'); - $this->assertSame($default, $item); - - // Remove $key for $keys - foreach ($keys as $k => $v) { - if ($v === $key) { - unset($keys[$k]); - } - } - - ++$count; - } - - $this->assertSame(4, $count); - } - - public function testClear() - { - $this->assertTrue($this->createCachePool()->clear()); - } - - public function testDelete() - { - $this->assertTrue($this->createCachePool()->delete('key')); - } - - public function testDeleteMultiple() - { - $this->assertTrue($this->createCachePool()->deleteMultiple(['key', 'foo', 'bar'])); - } - - public function testSet() - { - $cache = $this->createCachePool(); - - $this->assertFalse($cache->set('key', 'val')); - $this->assertNull($cache->get('key')); - } - - public function testSetMultiple() - { - $cache = $this->createCachePool(); - - $this->assertFalse($cache->setMultiple(['key' => 'val'])); - $this->assertNull($cache->get('key')); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/PdoCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/PdoCacheTest.php deleted file mode 100644 index fbdf03be7ee50..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/PdoCacheTest.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Symfony\Component\Cache\Simple\PdoCache; -use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; - -/** - * @group time-sensitive - * @group legacy - */ -class PdoCacheTest extends CacheTestCase -{ - use PdoPruneableTrait; - - protected static $dbFile; - - public static function setupBeforeClass() - { - if (!\extension_loaded('pdo_sqlite')) { - self::markTestSkipped('Extension pdo_sqlite required.'); - } - - self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); - - $pool = new PdoCache('sqlite:'.self::$dbFile); - $pool->createTable(); - } - - public static function tearDownAfterClass() - { - @unlink(self::$dbFile); - } - - public function createSimpleCache($defaultLifetime = 0) - { - return new PdoCache('sqlite:'.self::$dbFile, 'ns', $defaultLifetime); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php deleted file mode 100644 index af5c42340b4fc..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/PdoDbalCacheTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Doctrine\DBAL\DriverManager; -use Symfony\Component\Cache\Simple\PdoCache; -use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; - -/** - * @group time-sensitive - * @group legacy - */ -class PdoDbalCacheTest extends CacheTestCase -{ - use PdoPruneableTrait; - - protected static $dbFile; - - public static function setupBeforeClass() - { - if (!\extension_loaded('pdo_sqlite')) { - self::markTestSkipped('Extension pdo_sqlite required.'); - } - - self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); - - $pool = new PdoCache(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile])); - $pool->createTable(); - } - - public static function tearDownAfterClass() - { - @unlink(self::$dbFile); - } - - public function createSimpleCache($defaultLifetime = 0) - { - return new PdoCache(DriverManager::getConnection(['driver' => 'pdo_sqlite', 'path' => self::$dbFile]), '', $defaultLifetime); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheTest.php deleted file mode 100644 index 5272604dc32cf..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheTest.php +++ /dev/null @@ -1,130 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Symfony\Component\Cache\Simple\NullCache; -use Symfony\Component\Cache\Simple\PhpArrayCache; -use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest; - -/** - * @group time-sensitive - * @group legacy - */ -class PhpArrayCacheTest extends CacheTestCase -{ - protected $skippedTests = [ - 'testBasicUsageWithLongKey' => 'PhpArrayCache does no writes', - - 'testDelete' => 'PhpArrayCache does no writes', - 'testDeleteMultiple' => 'PhpArrayCache does no writes', - 'testDeleteMultipleGenerator' => 'PhpArrayCache does no writes', - - 'testSetTtl' => 'PhpArrayCache does no expiration', - 'testSetMultipleTtl' => 'PhpArrayCache does no expiration', - 'testSetExpiredTtl' => 'PhpArrayCache does no expiration', - 'testSetMultipleExpiredTtl' => 'PhpArrayCache does no expiration', - - 'testGetInvalidKeys' => 'PhpArrayCache does no validation', - 'testGetMultipleInvalidKeys' => 'PhpArrayCache does no validation', - 'testSetInvalidKeys' => 'PhpArrayCache does no validation', - 'testDeleteInvalidKeys' => 'PhpArrayCache does no validation', - 'testDeleteMultipleInvalidKeys' => 'PhpArrayCache does no validation', - 'testSetInvalidTtl' => 'PhpArrayCache does no validation', - 'testSetMultipleInvalidKeys' => 'PhpArrayCache does no validation', - 'testSetMultipleInvalidTtl' => 'PhpArrayCache does no validation', - 'testHasInvalidKeys' => 'PhpArrayCache does no validation', - 'testSetValidData' => 'PhpArrayCache does no validation', - - 'testDefaultLifeTime' => 'PhpArrayCache does not allow configuring a default lifetime.', - 'testPrune' => 'PhpArrayCache just proxies', - ]; - - protected static $file; - - public static function setupBeforeClass() - { - self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php'; - } - - protected function tearDown() - { - if (file_exists(sys_get_temp_dir().'/symfony-cache')) { - FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache'); - } - } - - public function createSimpleCache() - { - return new PhpArrayCacheWrapper(self::$file, new NullCache()); - } - - public function testStore() - { - $arrayWithRefs = []; - $arrayWithRefs[0] = 123; - $arrayWithRefs[1] = &$arrayWithRefs[0]; - - $object = (object) [ - 'foo' => 'bar', - 'foo2' => 'bar2', - ]; - - $expected = [ - 'null' => null, - 'serializedString' => serialize($object), - 'arrayWithRefs' => $arrayWithRefs, - 'object' => $object, - 'arrayWithObject' => ['bar' => $object], - ]; - - $cache = new PhpArrayCache(self::$file, new NullCache()); - $cache->warmUp($expected); - - foreach ($expected as $key => $value) { - $this->assertSame(serialize($value), serialize($cache->get($key)), 'Warm up should create a PHP file that OPCache can load in memory'); - } - } - - public function testStoredFile() - { - $data = [ - 'integer' => 42, - 'float' => 42.42, - 'boolean' => true, - 'array_simple' => ['foo', 'bar'], - 'array_associative' => ['foo' => 'bar', 'foo2' => 'bar2'], - ]; - $expected = [ - [ - 'integer' => 0, - 'float' => 1, - 'boolean' => 2, - 'array_simple' => 3, - 'array_associative' => 4, - ], - [ - 0 => 42, - 1 => 42.42, - 2 => true, - 3 => ['foo', 'bar'], - 4 => ['foo' => 'bar', 'foo2' => 'bar2'], - ], - ]; - - $cache = new PhpArrayCache(self::$file, new NullCache()); - $cache->warmUp($data); - - $values = eval(substr(file_get_contents(self::$file), 6)); - - $this->assertSame($expected, $values, 'Warm up should create a PHP file that OPCache can load in memory'); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php b/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php deleted file mode 100644 index 90aa7bb6ef835..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWithFallbackTest.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Symfony\Component\Cache\Simple\FilesystemCache; -use Symfony\Component\Cache\Simple\PhpArrayCache; -use Symfony\Component\Cache\Tests\Adapter\FilesystemAdapterTest; - -/** - * @group time-sensitive - * @group legacy - */ -class PhpArrayCacheWithFallbackTest extends CacheTestCase -{ - protected $skippedTests = [ - 'testGetInvalidKeys' => 'PhpArrayCache does no validation', - 'testGetMultipleInvalidKeys' => 'PhpArrayCache does no validation', - 'testDeleteInvalidKeys' => 'PhpArrayCache does no validation', - 'testDeleteMultipleInvalidKeys' => 'PhpArrayCache does no validation', - //'testSetValidData' => 'PhpArrayCache does no validation', - 'testSetInvalidKeys' => 'PhpArrayCache does no validation', - 'testSetInvalidTtl' => 'PhpArrayCache does no validation', - 'testSetMultipleInvalidKeys' => 'PhpArrayCache does no validation', - 'testSetMultipleInvalidTtl' => 'PhpArrayCache does no validation', - 'testHasInvalidKeys' => 'PhpArrayCache does no validation', - 'testPrune' => 'PhpArrayCache just proxies', - ]; - - protected static $file; - - public static function setupBeforeClass() - { - self::$file = sys_get_temp_dir().'/symfony-cache/php-array-adapter-test.php'; - } - - protected function tearDown() - { - if (file_exists(sys_get_temp_dir().'/symfony-cache')) { - FilesystemAdapterTest::rmdir(sys_get_temp_dir().'/symfony-cache'); - } - } - - public function createSimpleCache($defaultLifetime = 0) - { - return new PhpArrayCache(self::$file, new FilesystemCache('php-array-fallback', $defaultLifetime)); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWrapper.php b/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWrapper.php deleted file mode 100644 index 1e102fe1ff2e3..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/PhpArrayCacheWrapper.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\Cache\Tests\Simple; - -use Symfony\Component\Cache\Simple\PhpArrayCache; - -class PhpArrayCacheWrapper extends PhpArrayCache -{ - protected $data = []; - - public function set($key, $value, $ttl = null) - { - (\Closure::bind(function () use ($key, $value) { - $this->data[$key] = $value; - $this->warmUp($this->data); - list($this->keys, $this->values) = eval(substr(file_get_contents($this->file), 6)); - }, $this, PhpArrayCache::class))(); - - return true; - } - - public function setMultiple($values, $ttl = null) - { - if (!\is_array($values) && !$values instanceof \Traversable) { - return parent::setMultiple($values, $ttl); - } - (\Closure::bind(function () use ($values) { - foreach ($values as $key => $value) { - $this->data[$key] = $value; - } - $this->warmUp($this->data); - list($this->keys, $this->values) = eval(substr(file_get_contents($this->file), 6)); - }, $this, PhpArrayCache::class))(); - - return true; - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/PhpFilesCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/PhpFilesCacheTest.php deleted file mode 100644 index 7e40df7de5fbd..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/PhpFilesCacheTest.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Psr\SimpleCache\CacheInterface; -use Symfony\Component\Cache\Simple\PhpFilesCache; - -/** - * @group time-sensitive - * @group legacy - */ -class PhpFilesCacheTest extends CacheTestCase -{ - protected $skippedTests = [ - 'testDefaultLifeTime' => 'PhpFilesCache does not allow configuring a default lifetime.', - ]; - - public function createSimpleCache() - { - return new PhpFilesCache('sf-cache'); - } - - protected function isPruned(CacheInterface $cache, $name) - { - $getFileMethod = (new \ReflectionObject($cache))->getMethod('getFile'); - $getFileMethod->setAccessible(true); - - return !file_exists($getFileMethod->invoke($cache, $name)); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php deleted file mode 100644 index 9fff36e402dee..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheTest.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Symfony\Component\Cache\Simple\Psr6Cache; - -/** - * @group legacy - */ -abstract class Psr6CacheTest extends CacheTestCase -{ - protected $skippedTests = [ - 'testPrune' => 'Psr6Cache just proxies', - ]; - - public function createSimpleCache($defaultLifetime = 0) - { - return new Psr6Cache($this->createCacheItemPool($defaultLifetime)); - } - - abstract protected function createCacheItemPool($defaultLifetime = 0); -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheWithAdapterTest.php b/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheWithAdapterTest.php deleted file mode 100644 index e5c7a6a4c7e9a..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheWithAdapterTest.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Symfony\Component\Cache\Adapter\FilesystemAdapter; - -/** - * @group time-sensitive - * @group legacy - */ -class Psr6CacheWithAdapterTest extends Psr6CacheTest -{ - protected function createCacheItemPool($defaultLifetime = 0) - { - return new FilesystemAdapter('', $defaultLifetime); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheWithoutAdapterTest.php b/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheWithoutAdapterTest.php deleted file mode 100644 index f987d405396c6..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/Psr6CacheWithoutAdapterTest.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Symfony\Component\Cache\Tests\Fixtures\ExternalAdapter; - -/** - * @group time-sensitive - * @group legacy - */ -class Psr6CacheWithoutAdapterTest extends Psr6CacheTest -{ - protected function createCacheItemPool($defaultLifetime = 0) - { - return new ExternalAdapter($defaultLifetime); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php deleted file mode 100644 index b52f5f9acde9f..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/RedisArrayCacheTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -/** - * @group legacy - */ -class RedisArrayCacheTest extends AbstractRedisCacheTest -{ - public static function setupBeforeClass() - { - parent::setupBeforeClass(); - if (!class_exists('RedisArray')) { - self::markTestSkipped('The RedisArray class is required.'); - } - self::$redis = new \RedisArray([getenv('REDIS_HOST')], ['lazy_connect' => true]); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/RedisCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/RedisCacheTest.php deleted file mode 100644 index ddb674b285dda..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/RedisCacheTest.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Symfony\Component\Cache\Simple\RedisCache; - -/** - * @group legacy - */ -class RedisCacheTest extends AbstractRedisCacheTest -{ - public static function setupBeforeClass() - { - parent::setupBeforeClass(); - self::$redis = RedisCache::createConnection('redis://'.getenv('REDIS_HOST')); - } - - public function testCreateConnection() - { - $redisHost = getenv('REDIS_HOST'); - - $redis = RedisCache::createConnection('redis://'.$redisHost); - $this->assertInstanceOf(\Redis::class, $redis); - $this->assertTrue($redis->isConnected()); - $this->assertSame(0, $redis->getDbNum()); - - $redis = RedisCache::createConnection('redis://'.$redisHost.'/2'); - $this->assertSame(2, $redis->getDbNum()); - - $redis = RedisCache::createConnection('redis://'.$redisHost, ['timeout' => 3]); - $this->assertEquals(3, $redis->getTimeout()); - - $redis = RedisCache::createConnection('redis://'.$redisHost.'?timeout=4'); - $this->assertEquals(4, $redis->getTimeout()); - - $redis = RedisCache::createConnection('redis://'.$redisHost, ['read_timeout' => 5]); - $this->assertEquals(5, $redis->getReadTimeout()); - } - - /** - * @dataProvider provideFailedCreateConnection - * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException - * @expectedExceptionMessage Redis connection failed - */ - public function testFailedCreateConnection($dsn) - { - RedisCache::createConnection($dsn); - } - - public function provideFailedCreateConnection() - { - return [ - ['redis://localhost:1234'], - ['redis://foo@localhost'], - ['redis://localhost/123'], - ]; - } - - /** - * @dataProvider provideInvalidCreateConnection - * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException - * @expectedExceptionMessage Invalid Redis DSN - */ - public function testInvalidCreateConnection($dsn) - { - RedisCache::createConnection($dsn); - } - - public function provideInvalidCreateConnection() - { - return [ - ['foo://localhost'], - ['redis://'], - ]; - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/RedisClusterCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/RedisClusterCacheTest.php deleted file mode 100644 index 33c7acae0b822..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/RedisClusterCacheTest.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -/** - * @group legacy - */ -class RedisClusterCacheTest extends AbstractRedisCacheTest -{ - public static function setupBeforeClass() - { - if (!class_exists('RedisCluster')) { - self::markTestSkipped('The RedisCluster class is required.'); - } - if (!$hosts = getenv('REDIS_CLUSTER_HOSTS')) { - self::markTestSkipped('REDIS_CLUSTER_HOSTS env var is not defined.'); - } - - self::$redis = new \RedisCluster(null, explode(' ', $hosts)); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Simple/TraceableCacheTest.php b/src/Symfony/Component/Cache/Tests/Simple/TraceableCacheTest.php deleted file mode 100644 index c2e8a477b4771..0000000000000 --- a/src/Symfony/Component/Cache/Tests/Simple/TraceableCacheTest.php +++ /dev/null @@ -1,172 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Tests\Simple; - -use Symfony\Component\Cache\Simple\FilesystemCache; -use Symfony\Component\Cache\Simple\TraceableCache; - -/** - * @group time-sensitive - * @group legacy - */ -class TraceableCacheTest extends CacheTestCase -{ - protected $skippedTests = [ - 'testPrune' => 'TraceableCache just proxies', - ]; - - public function createSimpleCache($defaultLifetime = 0) - { - return new TraceableCache(new FilesystemCache('', $defaultLifetime)); - } - - public function testGetMissTrace() - { - $pool = $this->createSimpleCache(); - $pool->get('k'); - $calls = $pool->getCalls(); - $this->assertCount(1, $calls); - - $call = $calls[0]; - $this->assertSame('get', $call->name); - $this->assertSame(['k' => false], $call->result); - $this->assertSame(0, $call->hits); - $this->assertSame(1, $call->misses); - $this->assertNotEmpty($call->start); - $this->assertNotEmpty($call->end); - } - - public function testGetHitTrace() - { - $pool = $this->createSimpleCache(); - $pool->set('k', 'foo'); - $pool->get('k'); - $calls = $pool->getCalls(); - $this->assertCount(2, $calls); - - $call = $calls[1]; - $this->assertSame(1, $call->hits); - $this->assertSame(0, $call->misses); - } - - public function testGetMultipleMissTrace() - { - $pool = $this->createSimpleCache(); - $pool->set('k1', 123); - $values = $pool->getMultiple(['k0', 'k1']); - foreach ($values as $value) { - } - $calls = $pool->getCalls(); - $this->assertCount(2, $calls); - - $call = $calls[1]; - $this->assertSame('getMultiple', $call->name); - $this->assertSame(['k1' => true, 'k0' => false], $call->result); - $this->assertSame(1, $call->misses); - $this->assertNotEmpty($call->start); - $this->assertNotEmpty($call->end); - } - - public function testHasMissTrace() - { - $pool = $this->createSimpleCache(); - $pool->has('k'); - $calls = $pool->getCalls(); - $this->assertCount(1, $calls); - - $call = $calls[0]; - $this->assertSame('has', $call->name); - $this->assertSame(['k' => false], $call->result); - $this->assertNotEmpty($call->start); - $this->assertNotEmpty($call->end); - } - - public function testHasHitTrace() - { - $pool = $this->createSimpleCache(); - $pool->set('k', 'foo'); - $pool->has('k'); - $calls = $pool->getCalls(); - $this->assertCount(2, $calls); - - $call = $calls[1]; - $this->assertSame('has', $call->name); - $this->assertSame(['k' => true], $call->result); - $this->assertNotEmpty($call->start); - $this->assertNotEmpty($call->end); - } - - public function testDeleteTrace() - { - $pool = $this->createSimpleCache(); - $pool->delete('k'); - $calls = $pool->getCalls(); - $this->assertCount(1, $calls); - - $call = $calls[0]; - $this->assertSame('delete', $call->name); - $this->assertSame(['k' => true], $call->result); - $this->assertSame(0, $call->hits); - $this->assertSame(0, $call->misses); - $this->assertNotEmpty($call->start); - $this->assertNotEmpty($call->end); - } - - public function testDeleteMultipleTrace() - { - $pool = $this->createSimpleCache(); - $arg = ['k0', 'k1']; - $pool->deleteMultiple($arg); - $calls = $pool->getCalls(); - $this->assertCount(1, $calls); - - $call = $calls[0]; - $this->assertSame('deleteMultiple', $call->name); - $this->assertSame(['keys' => $arg, 'result' => true], $call->result); - $this->assertSame(0, $call->hits); - $this->assertSame(0, $call->misses); - $this->assertNotEmpty($call->start); - $this->assertNotEmpty($call->end); - } - - public function testTraceSetTrace() - { - $pool = $this->createSimpleCache(); - $pool->set('k', 'foo'); - $calls = $pool->getCalls(); - $this->assertCount(1, $calls); - - $call = $calls[0]; - $this->assertSame('set', $call->name); - $this->assertSame(['k' => true], $call->result); - $this->assertSame(0, $call->hits); - $this->assertSame(0, $call->misses); - $this->assertNotEmpty($call->start); - $this->assertNotEmpty($call->end); - } - - public function testSetMultipleTrace() - { - $pool = $this->createSimpleCache(); - $pool->setMultiple(['k' => 'foo']); - $calls = $pool->getCalls(); - $this->assertCount(1, $calls); - - $call = $calls[0]; - $this->assertSame('setMultiple', $call->name); - $this->assertSame(['keys' => ['k'], 'result' => true], $call->result); - $this->assertSame(0, $call->hits); - $this->assertSame(0, $call->misses); - $this->assertNotEmpty($call->start); - $this->assertNotEmpty($call->end); - } -} diff --git a/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php b/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php index 38cc4dc9cc990..6fda3e1ad26e2 100644 --- a/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php +++ b/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php @@ -133,20 +133,6 @@ public function testTagItemExpiry() $this->assertFalse($pool->getItem('foo')->isHit()); } - /** - * @group legacy - */ - public function testGetPreviousTags() - { - $pool = $this->createCachePool(); - - $i = $pool->getItem('k'); - $pool->save($i->tag('foo')); - - $i = $pool->getItem('k'); - $this->assertSame(['foo' => 'foo'], $i->getPreviousTags()); - } - public function testGetMetadata() { $pool = $this->createCachePool(); diff --git a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php index eb464c319eff1..3d1d836d921fa 100644 --- a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php +++ b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Cache\Traits; use Psr\Cache\CacheItemInterface; +use Psr\Log\LoggerAwareTrait; use Symfony\Component\Cache\CacheItem; /** @@ -21,7 +22,7 @@ */ trait AbstractAdapterTrait { - use AbstractTrait; + use LoggerAwareTrait; /** * @var \Closure needs to be set by class, signature is function(string , mixed , bool ) @@ -33,6 +34,157 @@ trait AbstractAdapterTrait */ private $mergeByLifetime; + private $namespace; + private $namespaceVersion = ''; + private $versioningIsEnabled = false; + private $deferred = []; + private $ids = []; + + /** + * @var int|null The maximum length to enforce for identifiers or null when no limit applies + */ + protected $maxIdLength; + + /** + * Fetches several cache items. + * + * @param array $ids The cache identifiers to fetch + * + * @return array|\Traversable The corresponding values found in the cache + */ + abstract protected function doFetch(array $ids); + + /** + * Confirms if the cache contains specified cache item. + * + * @param string $id The identifier for which to check existence + * + * @return bool True if item exists in the cache, false otherwise + */ + abstract protected function doHave($id); + + /** + * Deletes all items in the pool. + * + * @param string $namespace The prefix used for all identifiers managed by this pool + * + * @return bool True if the pool was successfully cleared, false otherwise + */ + abstract protected function doClear($namespace); + + /** + * Removes multiple items from the pool. + * + * @param array $ids An array of identifiers that should be removed from the pool + * + * @return bool True if the items were successfully removed, false otherwise + */ + abstract protected function doDelete(array $ids); + + /** + * Persists several cache items immediately. + * + * @param array $values The values to cache, indexed by their cache identifier + * @param int $lifetime The lifetime of the cached values, 0 for persisting until manual cleaning + * + * @return array|bool The identifiers that failed to be cached or a boolean stating if caching succeeded or not + */ + abstract protected function doSave(array $values, $lifetime); + + /** + * {@inheritdoc} + */ + public function hasItem($key) + { + $id = $this->getId($key); + + if (isset($this->deferred[$key])) { + $this->commit(); + } + + try { + return $this->doHave($id); + } catch (\Exception $e) { + CacheItem::log($this->logger, 'Failed to check if key "{key}" is cached: '.$e->getMessage(), ['key' => $key, 'exception' => $e]); + + return false; + } + } + + /** + * {@inheritdoc} + */ + public function clear() + { + $this->deferred = []; + if ($cleared = $this->versioningIsEnabled) { + $namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), ':', 5); + try { + $cleared = $this->doSave(['/'.$this->namespace => $namespaceVersion], 0); + } catch (\Exception $e) { + $cleared = false; + } + if ($cleared = true === $cleared || [] === $cleared) { + $this->namespaceVersion = $namespaceVersion; + $this->ids = []; + } + } + + try { + return $this->doClear($this->namespace) || $cleared; + } catch (\Exception $e) { + CacheItem::log($this->logger, 'Failed to clear the cache: '.$e->getMessage(), ['exception' => $e]); + + return false; + } + } + + /** + * {@inheritdoc} + */ + public function deleteItem($key) + { + return $this->deleteItems([$key]); + } + + /** + * {@inheritdoc} + */ + public function deleteItems(array $keys) + { + $ids = []; + + foreach ($keys as $key) { + $ids[$key] = $this->getId($key); + unset($this->deferred[$key]); + } + + try { + if ($this->doDelete($ids)) { + return true; + } + } catch (\Exception $e) { + } + + $ok = true; + + // When bulk-delete failed, retry each item individually + foreach ($ids as $key => $id) { + try { + $e = null; + if ($this->doDelete([$id])) { + continue; + } + } catch (\Exception $e) { + } + $message = 'Failed to delete key "{key}"'.($e instanceof \Exception ? ': '.$e->getMessage() : '.'); + CacheItem::log($this->logger, $message, ['key' => $key, 'exception' => $e]); + $ok = false; + } + + return $ok; + } + /** * {@inheritdoc} */ @@ -108,6 +260,40 @@ public function saveDeferred(CacheItemInterface $item) return true; } + /** + * Enables/disables versioning of items. + * + * When versioning is enabled, clearing the cache is atomic and doesn't require listing existing keys to proceed, + * but old keys may need garbage collection and extra round-trips to the back-end are required. + * + * Calling this method also clears the memoized namespace version and thus forces a resynchonization of it. + * + * @param bool $enable + * + * @return bool the previous state of versioning + */ + public function enableVersioning($enable = true) + { + $wasEnabled = $this->versioningIsEnabled; + $this->versioningIsEnabled = (bool) $enable; + $this->namespaceVersion = ''; + $this->ids = []; + + return $wasEnabled; + } + + /** + * {@inheritdoc} + */ + public function reset() + { + if ($this->deferred) { + $this->commit(); + } + $this->namespaceVersion = ''; + $this->ids = []; + } + public function __destruct() { if ($this->deferred) { @@ -136,4 +322,47 @@ private function generateItems($items, &$keys) yield $key => $f($key, null, false); } } + + private function getId($key) + { + if ($this->versioningIsEnabled && '' === $this->namespaceVersion) { + $this->ids = []; + $this->namespaceVersion = '1/'; + try { + foreach ($this->doFetch(['/'.$this->namespace]) as $v) { + $this->namespaceVersion = $v; + } + if ('1:' === $this->namespaceVersion) { + $this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), ':', 5); + $this->doSave(['@'.$this->namespace => $this->namespaceVersion], 0); + } + } catch (\Exception $e) { + } + } + + if (\is_string($key) && isset($this->ids[$key])) { + return $this->namespace.$this->namespaceVersion.$this->ids[$key]; + } + CacheItem::validateKey($key); + $this->ids[$key] = $key; + + if (null === $this->maxIdLength) { + return $this->namespace.$this->namespaceVersion.$key; + } + if (\strlen($id = $this->namespace.$this->namespaceVersion.$key) > $this->maxIdLength) { + // Use MD5 to favor speed over security, which is not an issue here + $this->ids[$key] = $id = substr_replace(base64_encode(hash('md5', $key, true)), ':', -(\strlen($this->namespaceVersion) + 2)); + $id = $this->namespace.$this->namespaceVersion.$id; + } + + return $id; + } + + /** + * @internal + */ + public static function handleUnserializeCallback($class) + { + throw new \DomainException('Class not found: '.$class); + } } diff --git a/src/Symfony/Component/Cache/Traits/AbstractTrait.php b/src/Symfony/Component/Cache/Traits/AbstractTrait.php deleted file mode 100644 index 1d6c189c814c4..0000000000000 --- a/src/Symfony/Component/Cache/Traits/AbstractTrait.php +++ /dev/null @@ -1,284 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Traits; - -use Psr\Log\LoggerAwareTrait; -use Symfony\Component\Cache\CacheItem; - -/** - * @author Nicolas Grekas - * - * @internal - */ -trait AbstractTrait -{ - use LoggerAwareTrait; - - private $namespace; - private $namespaceVersion = ''; - private $versioningIsEnabled = false; - private $deferred = []; - private $ids = []; - - /** - * @var int|null The maximum length to enforce for identifiers or null when no limit applies - */ - protected $maxIdLength; - - /** - * Fetches several cache items. - * - * @param array $ids The cache identifiers to fetch - * - * @return array|\Traversable The corresponding values found in the cache - */ - abstract protected function doFetch(array $ids); - - /** - * Confirms if the cache contains specified cache item. - * - * @param string $id The identifier for which to check existence - * - * @return bool True if item exists in the cache, false otherwise - */ - abstract protected function doHave($id); - - /** - * Deletes all items in the pool. - * - * @param string $namespace The prefix used for all identifiers managed by this pool - * - * @return bool True if the pool was successfully cleared, false otherwise - */ - abstract protected function doClear($namespace); - - /** - * Removes multiple items from the pool. - * - * @param array $ids An array of identifiers that should be removed from the pool - * - * @return bool True if the items were successfully removed, false otherwise - */ - abstract protected function doDelete(array $ids); - - /** - * Persists several cache items immediately. - * - * @param array $values The values to cache, indexed by their cache identifier - * @param int $lifetime The lifetime of the cached values, 0 for persisting until manual cleaning - * - * @return array|bool The identifiers that failed to be cached or a boolean stating if caching succeeded or not - */ - abstract protected function doSave(array $values, $lifetime); - - /** - * {@inheritdoc} - */ - public function hasItem($key) - { - $id = $this->getId($key); - - if (isset($this->deferred[$key])) { - $this->commit(); - } - - try { - return $this->doHave($id); - } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to check if key "{key}" is cached: '.$e->getMessage(), ['key' => $key, 'exception' => $e]); - - return false; - } - } - - /** - * {@inheritdoc} - */ - public function clear() - { - $this->deferred = []; - if ($cleared = $this->versioningIsEnabled) { - $namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), ':', 5); - try { - $cleared = $this->doSave(['/'.$this->namespace => $namespaceVersion], 0); - } catch (\Exception $e) { - $cleared = false; - } - if ($cleared = true === $cleared || [] === $cleared) { - $this->namespaceVersion = $namespaceVersion; - $this->ids = []; - } - } - - try { - return $this->doClear($this->namespace) || $cleared; - } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to clear the cache: '.$e->getMessage(), ['exception' => $e]); - - return false; - } - } - - /** - * {@inheritdoc} - */ - public function deleteItem($key) - { - return $this->deleteItems([$key]); - } - - /** - * {@inheritdoc} - */ - public function deleteItems(array $keys) - { - $ids = []; - - foreach ($keys as $key) { - $ids[$key] = $this->getId($key); - unset($this->deferred[$key]); - } - - try { - if ($this->doDelete($ids)) { - return true; - } - } catch (\Exception $e) { - } - - $ok = true; - - // When bulk-delete failed, retry each item individually - foreach ($ids as $key => $id) { - try { - $e = null; - if ($this->doDelete([$id])) { - continue; - } - } catch (\Exception $e) { - } - $message = 'Failed to delete key "{key}"'.($e instanceof \Exception ? ': '.$e->getMessage() : '.'); - CacheItem::log($this->logger, $message, ['key' => $key, 'exception' => $e]); - $ok = false; - } - - return $ok; - } - - /** - * Enables/disables versioning of items. - * - * When versioning is enabled, clearing the cache is atomic and doesn't require listing existing keys to proceed, - * but old keys may need garbage collection and extra round-trips to the back-end are required. - * - * Calling this method also clears the memoized namespace version and thus forces a resynchonization of it. - * - * @param bool $enable - * - * @return bool the previous state of versioning - */ - public function enableVersioning($enable = true) - { - $wasEnabled = $this->versioningIsEnabled; - $this->versioningIsEnabled = (bool) $enable; - $this->namespaceVersion = ''; - $this->ids = []; - - return $wasEnabled; - } - - /** - * {@inheritdoc} - */ - public function reset() - { - if ($this->deferred) { - $this->commit(); - } - $this->namespaceVersion = ''; - $this->ids = []; - } - - /** - * Like the native unserialize() function but throws an exception if anything goes wrong. - * - * @param string $value - * - * @return mixed - * - * @throws \Exception - * - * @deprecated since Symfony 4.2, use DefaultMarshaller instead. - */ - protected static function unserialize($value) - { - @trigger_error(sprintf('The "%s::unserialize()" method is deprecated since Symfony 4.2, use DefaultMarshaller instead.', __CLASS__), E_USER_DEPRECATED); - - if ('b:0;' === $value) { - return false; - } - $unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback'); - try { - if (false !== $value = unserialize($value)) { - return $value; - } - throw new \DomainException('Failed to unserialize cached value'); - } catch (\Error $e) { - throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); - } finally { - ini_set('unserialize_callback_func', $unserializeCallbackHandler); - } - } - - private function getId($key) - { - if ($this->versioningIsEnabled && '' === $this->namespaceVersion) { - $this->ids = []; - $this->namespaceVersion = '1/'; - try { - foreach ($this->doFetch(['/'.$this->namespace]) as $v) { - $this->namespaceVersion = $v; - } - if ('1:' === $this->namespaceVersion) { - $this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), ':', 5); - $this->doSave(['@'.$this->namespace => $this->namespaceVersion], 0); - } - } catch (\Exception $e) { - } - } - - if (\is_string($key) && isset($this->ids[$key])) { - return $this->namespace.$this->namespaceVersion.$this->ids[$key]; - } - CacheItem::validateKey($key); - $this->ids[$key] = $key; - - if (null === $this->maxIdLength) { - return $this->namespace.$this->namespaceVersion.$key; - } - if (\strlen($id = $this->namespace.$this->namespaceVersion.$key) > $this->maxIdLength) { - // Use MD5 to favor speed over security, which is not an issue here - $this->ids[$key] = $id = substr_replace(base64_encode(hash('md5', $key, true)), ':', -(\strlen($this->namespaceVersion) + 2)); - $id = $this->namespace.$this->namespaceVersion.$id; - } - - return $id; - } - - /** - * @internal - */ - public static function handleUnserializeCallback($class) - { - throw new \DomainException('Class not found: '.$class); - } -} diff --git a/src/Symfony/Component/Cache/Traits/ApcuTrait.php b/src/Symfony/Component/Cache/Traits/ApcuTrait.php deleted file mode 100644 index c86b043ae120c..0000000000000 --- a/src/Symfony/Component/Cache/Traits/ApcuTrait.php +++ /dev/null @@ -1,121 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Traits; - -use Symfony\Component\Cache\CacheItem; -use Symfony\Component\Cache\Exception\CacheException; - -/** - * @author Nicolas Grekas - * - * @internal - */ -trait ApcuTrait -{ - public static function isSupported() - { - return \function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN); - } - - private function init($namespace, $defaultLifetime, $version) - { - if (!static::isSupported()) { - throw new CacheException('APCu is not enabled'); - } - if ('cli' === \PHP_SAPI) { - ini_set('apc.use_request_time', 0); - } - parent::__construct($namespace, $defaultLifetime); - - if (null !== $version) { - CacheItem::validateKey($version); - - if (!apcu_exists($version.'@'.$namespace)) { - $this->doClear($namespace); - apcu_add($version.'@'.$namespace, null); - } - } - } - - /** - * {@inheritdoc} - */ - protected function doFetch(array $ids) - { - $unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback'); - try { - $values = []; - foreach (apcu_fetch($ids, $ok) ?: [] as $k => $v) { - if (null !== $v || $ok) { - $values[$k] = $v; - } - } - - return $values; - } catch (\Error $e) { - throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); - } finally { - ini_set('unserialize_callback_func', $unserializeCallbackHandler); - } - } - - /** - * {@inheritdoc} - */ - protected function doHave($id) - { - return apcu_exists($id); - } - - /** - * {@inheritdoc} - */ - protected function doClear($namespace) - { - return isset($namespace[0]) && class_exists('APCuIterator', false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) - ? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), APC_ITER_KEY)) - : apcu_clear_cache(); - } - - /** - * {@inheritdoc} - */ - protected function doDelete(array $ids) - { - foreach ($ids as $id) { - apcu_delete($id); - } - - return true; - } - - /** - * {@inheritdoc} - */ - protected function doSave(array $values, $lifetime) - { - try { - if (false === $failures = apcu_store($values, null, $lifetime)) { - $failures = $values; - } - - return array_keys($failures); - } catch (\Throwable $e) { - if (1 === \count($values)) { - // Workaround https://github.com/krakjoe/apcu/issues/170 - apcu_delete(key($values)); - } - - throw $e; - } - } -} diff --git a/src/Symfony/Component/Cache/Traits/ArrayTrait.php b/src/Symfony/Component/Cache/Traits/ArrayTrait.php deleted file mode 100644 index 8ae9cad59b1ae..0000000000000 --- a/src/Symfony/Component/Cache/Traits/ArrayTrait.php +++ /dev/null @@ -1,165 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Traits; - -use Psr\Log\LoggerAwareTrait; -use Symfony\Component\Cache\CacheItem; - -/** - * @author Nicolas Grekas - * - * @internal - */ -trait ArrayTrait -{ - use LoggerAwareTrait; - - private $storeSerialized; - private $values = []; - private $expiries = []; - - /** - * Returns all cached values, with cache miss as null. - * - * @return array - */ - public function getValues() - { - if (!$this->storeSerialized) { - return $this->values; - } - - $values = $this->values; - foreach ($values as $k => $v) { - if (null === $v || 'N;' === $v) { - continue; - } - if (!\is_string($v) || !isset($v[2]) || ':' !== $v[1]) { - $values[$k] = serialize($v); - } - } - - return $values; - } - - /** - * {@inheritdoc} - */ - public function hasItem($key) - { - if (\is_string($key) && isset($this->expiries[$key]) && $this->expiries[$key] > microtime(true)) { - return true; - } - CacheItem::validateKey($key); - - return isset($this->expiries[$key]) && !$this->deleteItem($key); - } - - /** - * {@inheritdoc} - */ - public function clear() - { - $this->values = $this->expiries = []; - - return true; - } - - /** - * {@inheritdoc} - */ - public function deleteItem($key) - { - if (!\is_string($key) || !isset($this->expiries[$key])) { - CacheItem::validateKey($key); - } - unset($this->values[$key], $this->expiries[$key]); - - return true; - } - - /** - * {@inheritdoc} - */ - public function reset() - { - $this->clear(); - } - - private function generateItems(array $keys, $now, $f) - { - foreach ($keys as $i => $key) { - if (!$isHit = isset($this->expiries[$key]) && ($this->expiries[$key] > $now || !$this->deleteItem($key))) { - $this->values[$key] = $value = null; - } else { - $value = $this->storeSerialized ? $this->unfreeze($key, $isHit) : $this->values[$key]; - } - unset($keys[$i]); - - yield $key => $f($key, $value, $isHit); - } - - foreach ($keys as $key) { - yield $key => $f($key, null, false); - } - } - - private function freeze($value, $key) - { - if (null === $value) { - return 'N;'; - } - if (\is_string($value)) { - // Serialize strings if they could be confused with serialized objects or arrays - if ('N;' === $value || (isset($value[2]) && ':' === $value[1])) { - return serialize($value); - } - } elseif (!\is_scalar($value)) { - try { - $serialized = serialize($value); - } catch (\Exception $e) { - $type = \is_object($value) ? \get_class($value) : \gettype($value); - $message = sprintf('Failed to save key "{key}" of type %s: %s', $type, $e->getMessage()); - CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e]); - - return; - } - // Keep value serialized if it contains any objects or any internal references - if ('C' === $serialized[0] || 'O' === $serialized[0] || preg_match('/;[OCRr]:[1-9]/', $serialized)) { - return $serialized; - } - } - - return $value; - } - - private function unfreeze(string $key, bool &$isHit) - { - if ('N;' === $value = $this->values[$key]) { - return null; - } - if (\is_string($value) && isset($value[2]) && ':' === $value[1]) { - try { - $value = unserialize($value); - } catch (\Exception $e) { - CacheItem::log($this->logger, 'Failed to unserialize key "{key}": '.$e->getMessage(), ['key' => $key, 'exception' => $e]); - $value = false; - } - if (false === $value) { - $this->values[$key] = $value = null; - $isHit = false; - } - } - - return $value; - } -} diff --git a/src/Symfony/Component/Cache/Traits/DoctrineTrait.php b/src/Symfony/Component/Cache/Traits/DoctrineTrait.php deleted file mode 100644 index c87ecabafc803..0000000000000 --- a/src/Symfony/Component/Cache/Traits/DoctrineTrait.php +++ /dev/null @@ -1,98 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Traits; - -/** - * @author Nicolas Grekas - * - * @internal - */ -trait DoctrineTrait -{ - private $provider; - - /** - * {@inheritdoc} - */ - public function reset() - { - parent::reset(); - $this->provider->setNamespace($this->provider->getNamespace()); - } - - /** - * {@inheritdoc} - */ - protected function doFetch(array $ids) - { - $unserializeCallbackHandler = ini_set('unserialize_callback_func', parent::class.'::handleUnserializeCallback'); - try { - return $this->provider->fetchMultiple($ids); - } catch (\Error $e) { - $trace = $e->getTrace(); - - if (isset($trace[0]['function']) && !isset($trace[0]['class'])) { - switch ($trace[0]['function']) { - case 'unserialize': - case 'apcu_fetch': - case 'apc_fetch': - throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); - } - } - - throw $e; - } finally { - ini_set('unserialize_callback_func', $unserializeCallbackHandler); - } - } - - /** - * {@inheritdoc} - */ - protected function doHave($id) - { - return $this->provider->contains($id); - } - - /** - * {@inheritdoc} - */ - protected function doClear($namespace) - { - $namespace = $this->provider->getNamespace(); - - return isset($namespace[0]) - ? $this->provider->deleteAll() - : $this->provider->flushAll(); - } - - /** - * {@inheritdoc} - */ - protected function doDelete(array $ids) - { - $ok = true; - foreach ($ids as $id) { - $ok = $this->provider->delete($id) && $ok; - } - - return $ok; - } - - /** - * {@inheritdoc} - */ - protected function doSave(array $values, $lifetime) - { - return $this->provider->saveMultiple($values, $lifetime); - } -} diff --git a/src/Symfony/Component/Cache/Traits/MemcachedTrait.php b/src/Symfony/Component/Cache/Traits/MemcachedTrait.php deleted file mode 100644 index 9c52323943b58..0000000000000 --- a/src/Symfony/Component/Cache/Traits/MemcachedTrait.php +++ /dev/null @@ -1,328 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Traits; - -use Symfony\Component\Cache\Exception\CacheException; -use Symfony\Component\Cache\Exception\InvalidArgumentException; -use Symfony\Component\Cache\Marshaller\DefaultMarshaller; -use Symfony\Component\Cache\Marshaller\MarshallerInterface; - -/** - * @author Rob Frawley 2nd - * @author Nicolas Grekas - * - * @internal - */ -trait MemcachedTrait -{ - private static $defaultClientOptions = [ - 'persistent_id' => null, - 'username' => null, - 'password' => null, - 'serializer' => 'php', - ]; - - private $marshaller; - private $client; - private $lazyClient; - - public static function isSupported() - { - return \extension_loaded('memcached') && version_compare(phpversion('memcached'), '2.2.0', '>='); - } - - private function init(\Memcached $client, $namespace, $defaultLifetime, ?MarshallerInterface $marshaller) - { - if (!static::isSupported()) { - throw new CacheException('Memcached >= 2.2.0 is required'); - } - if ('Memcached' === \get_class($client)) { - $opt = $client->getOption(\Memcached::OPT_SERIALIZER); - if (\Memcached::SERIALIZER_PHP !== $opt && \Memcached::SERIALIZER_IGBINARY !== $opt) { - throw new CacheException('MemcachedAdapter: "serializer" option must be "php" or "igbinary".'); - } - $this->maxIdLength -= \strlen($client->getOption(\Memcached::OPT_PREFIX_KEY)); - $this->client = $client; - } else { - $this->lazyClient = $client; - } - - parent::__construct($namespace, $defaultLifetime); - $this->enableVersioning(); - $this->marshaller = $marshaller ?? new DefaultMarshaller(); - } - - /** - * Creates a Memcached instance. - * - * By default, the binary protocol, no block, and libketama compatible options are enabled. - * - * Examples for servers: - * - 'memcached://user:pass@localhost?weight=33' - * - [['localhost', 11211, 33]] - * - * @param array[]|string|string[] $servers An array of servers, a DSN, or an array of DSNs - * @param array $options An array of options - * - * @return \Memcached - * - * @throws \ErrorException When invalid options or servers are provided - */ - public static function createConnection($servers, array $options = []) - { - if (\is_string($servers)) { - $servers = [$servers]; - } elseif (!\is_array($servers)) { - throw new InvalidArgumentException(sprintf('MemcachedAdapter::createClient() expects array or string as first argument, %s given.', \gettype($servers))); - } - if (!static::isSupported()) { - throw new CacheException('Memcached >= 2.2.0 is required'); - } - set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); }); - try { - $options += static::$defaultClientOptions; - $client = new \Memcached($options['persistent_id']); - $username = $options['username']; - $password = $options['password']; - - // parse any DSN in $servers - foreach ($servers as $i => $dsn) { - if (\is_array($dsn)) { - continue; - } - if (0 !== strpos($dsn, 'memcached:')) { - throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s does not start with "memcached:"', $dsn)); - } - $params = preg_replace_callback('#^memcached:(//)?(?:([^@]*+)@)?#', function ($m) use (&$username, &$password) { - if (!empty($m[2])) { - list($username, $password) = explode(':', $m[2], 2) + [1 => null]; - } - - return 'file:'.($m[1] ?? ''); - }, $dsn); - if (false === $params = parse_url($params)) { - throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn)); - } - $query = $hosts = []; - if (isset($params['query'])) { - parse_str($params['query'], $query); - - if (isset($query['host'])) { - if (!\is_array($hosts = $query['host'])) { - throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn)); - } - foreach ($hosts as $host => $weight) { - if (false === $port = strrpos($host, ':')) { - $hosts[$host] = [$host, 11211, (int) $weight]; - } else { - $hosts[$host] = [substr($host, 0, $port), (int) substr($host, 1 + $port), (int) $weight]; - } - } - $hosts = array_values($hosts); - unset($query['host']); - } - if ($hosts && !isset($params['host']) && !isset($params['path'])) { - unset($servers[$i]); - $servers = array_merge($servers, $hosts); - continue; - } - } - if (!isset($params['host']) && !isset($params['path'])) { - throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn)); - } - if (isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) { - $params['weight'] = $m[1]; - $params['path'] = substr($params['path'], 0, -\strlen($m[0])); - } - $params += [ - 'host' => isset($params['host']) ? $params['host'] : $params['path'], - 'port' => isset($params['host']) ? 11211 : null, - 'weight' => 0, - ]; - if ($query) { - $params += $query; - $options = $query + $options; - } - - $servers[$i] = [$params['host'], $params['port'], $params['weight']]; - - if ($hosts) { - $servers = array_merge($servers, $hosts); - } - } - - // set client's options - unset($options['persistent_id'], $options['username'], $options['password'], $options['weight'], $options['lazy']); - $options = array_change_key_case($options, CASE_UPPER); - $client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true); - $client->setOption(\Memcached::OPT_NO_BLOCK, true); - $client->setOption(\Memcached::OPT_TCP_NODELAY, true); - if (!\array_key_exists('LIBKETAMA_COMPATIBLE', $options) && !\array_key_exists(\Memcached::OPT_LIBKETAMA_COMPATIBLE, $options)) { - $client->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true); - } - foreach ($options as $name => $value) { - if (\is_int($name)) { - continue; - } - if ('HASH' === $name || 'SERIALIZER' === $name || 'DISTRIBUTION' === $name) { - $value = \constant('Memcached::'.$name.'_'.strtoupper($value)); - } - $opt = \constant('Memcached::OPT_'.$name); - - unset($options[$name]); - $options[$opt] = $value; - } - $client->setOptions($options); - - // set client's servers, taking care of persistent connections - if (!$client->isPristine()) { - $oldServers = []; - foreach ($client->getServerList() as $server) { - $oldServers[] = [$server['host'], $server['port']]; - } - - $newServers = []; - foreach ($servers as $server) { - if (1 < \count($server)) { - $server = array_values($server); - unset($server[2]); - $server[1] = (int) $server[1]; - } - $newServers[] = $server; - } - - if ($oldServers !== $newServers) { - $client->resetServerList(); - $client->addServers($servers); - } - } else { - $client->addServers($servers); - } - - if (null !== $username || null !== $password) { - if (!method_exists($client, 'setSaslAuthData')) { - trigger_error('Missing SASL support: the memcached extension must be compiled with --enable-memcached-sasl.'); - } - $client->setSaslAuthData($username, $password); - } - - return $client; - } finally { - restore_error_handler(); - } - } - - /** - * {@inheritdoc} - */ - protected function doSave(array $values, $lifetime) - { - if (!$values = $this->marshaller->marshall($values, $failed)) { - return $failed; - } - - if ($lifetime && $lifetime > 30 * 86400) { - $lifetime += time(); - } - - $encodedValues = []; - foreach ($values as $key => $value) { - $encodedValues[rawurlencode($key)] = $value; - } - - return $this->checkResultCode($this->getClient()->setMulti($encodedValues, $lifetime)) ? $failed : false; - } - - /** - * {@inheritdoc} - */ - protected function doFetch(array $ids) - { - try { - $encodedIds = array_map('rawurlencode', $ids); - - $encodedResult = $this->checkResultCode($this->getClient()->getMulti($encodedIds)); - - $result = []; - foreach ($encodedResult as $key => $value) { - $result[rawurldecode($key)] = $this->marshaller->unmarshall($value); - } - - return $result; - } catch (\Error $e) { - throw new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine()); - } - } - - /** - * {@inheritdoc} - */ - protected function doHave($id) - { - return false !== $this->getClient()->get(rawurlencode($id)) || $this->checkResultCode(\Memcached::RES_SUCCESS === $this->client->getResultCode()); - } - - /** - * {@inheritdoc} - */ - protected function doDelete(array $ids) - { - $ok = true; - $encodedIds = array_map('rawurlencode', $ids); - foreach ($this->checkResultCode($this->getClient()->deleteMulti($encodedIds)) as $result) { - if (\Memcached::RES_SUCCESS !== $result && \Memcached::RES_NOTFOUND !== $result) { - $ok = false; - } - } - - return $ok; - } - - /** - * {@inheritdoc} - */ - protected function doClear($namespace) - { - return '' === $namespace && $this->getClient()->flush(); - } - - private function checkResultCode($result) - { - $code = $this->client->getResultCode(); - - if (\Memcached::RES_SUCCESS === $code || \Memcached::RES_NOTFOUND === $code) { - return $result; - } - - throw new CacheException(sprintf('MemcachedAdapter client error: %s.', strtolower($this->client->getResultMessage()))); - } - - /** - * @return \Memcached - */ - private function getClient() - { - if ($this->client) { - return $this->client; - } - - $opt = $this->lazyClient->getOption(\Memcached::OPT_SERIALIZER); - if (\Memcached::SERIALIZER_PHP !== $opt && \Memcached::SERIALIZER_IGBINARY !== $opt) { - throw new CacheException('MemcachedAdapter: "serializer" option must be "php" or "igbinary".'); - } - if ('' !== $prefix = (string) $this->lazyClient->getOption(\Memcached::OPT_PREFIX_KEY)) { - throw new CacheException(sprintf('MemcachedAdapter: "prefix_key" option must be empty when using proxified connections, "%s" given.', $prefix)); - } - - return $this->client = $this->lazyClient; - } -} diff --git a/src/Symfony/Component/Cache/Traits/PdoTrait.php b/src/Symfony/Component/Cache/Traits/PdoTrait.php deleted file mode 100644 index ec34e72fb530a..0000000000000 --- a/src/Symfony/Component/Cache/Traits/PdoTrait.php +++ /dev/null @@ -1,424 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Traits; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Driver\ServerInfoAwareConnection; -use Doctrine\DBAL\Exception\TableNotFoundException; -use Doctrine\DBAL\Schema\Schema; -use Symfony\Component\Cache\Exception\InvalidArgumentException; -use Symfony\Component\Cache\Marshaller\DefaultMarshaller; -use Symfony\Component\Cache\Marshaller\MarshallerInterface; - -/** - * @internal - */ -trait PdoTrait -{ - private $marshaller; - private $conn; - private $dsn; - private $driver; - private $serverVersion; - private $table = 'cache_items'; - private $idCol = 'item_id'; - private $dataCol = 'item_data'; - private $lifetimeCol = 'item_lifetime'; - private $timeCol = 'item_time'; - private $username = ''; - private $password = ''; - private $connectionOptions = []; - private $namespace; - - private function init($connOrDsn, $namespace, $defaultLifetime, array $options, ?MarshallerInterface $marshaller) - { - if (isset($namespace[0]) && preg_match('#[^-+.A-Za-z0-9]#', $namespace, $match)) { - throw new InvalidArgumentException(sprintf('Namespace contains "%s" but only characters in [-+.A-Za-z0-9] are allowed.', $match[0])); - } - - if ($connOrDsn instanceof \PDO) { - if (\PDO::ERRMODE_EXCEPTION !== $connOrDsn->getAttribute(\PDO::ATTR_ERRMODE)) { - throw new InvalidArgumentException(sprintf('"%s" requires PDO error mode attribute be set to throw Exceptions (i.e. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION))', __CLASS__)); - } - - $this->conn = $connOrDsn; - } elseif ($connOrDsn instanceof Connection) { - $this->conn = $connOrDsn; - } elseif (\is_string($connOrDsn)) { - $this->dsn = $connOrDsn; - } else { - throw new InvalidArgumentException(sprintf('"%s" requires PDO or Doctrine\DBAL\Connection instance or DSN string as first argument, "%s" given.', __CLASS__, \is_object($connOrDsn) ? \get_class($connOrDsn) : \gettype($connOrDsn))); - } - - $this->table = isset($options['db_table']) ? $options['db_table'] : $this->table; - $this->idCol = isset($options['db_id_col']) ? $options['db_id_col'] : $this->idCol; - $this->dataCol = isset($options['db_data_col']) ? $options['db_data_col'] : $this->dataCol; - $this->lifetimeCol = isset($options['db_lifetime_col']) ? $options['db_lifetime_col'] : $this->lifetimeCol; - $this->timeCol = isset($options['db_time_col']) ? $options['db_time_col'] : $this->timeCol; - $this->username = isset($options['db_username']) ? $options['db_username'] : $this->username; - $this->password = isset($options['db_password']) ? $options['db_password'] : $this->password; - $this->connectionOptions = isset($options['db_connection_options']) ? $options['db_connection_options'] : $this->connectionOptions; - $this->namespace = $namespace; - $this->marshaller = $marshaller ?? new DefaultMarshaller(); - - parent::__construct($namespace, $defaultLifetime); - } - - /** - * Creates the table to store cache items which can be called once for setup. - * - * Cache ID are saved in a column of maximum length 255. Cache data is - * saved in a BLOB. - * - * @throws \PDOException When the table already exists - * @throws DBALException When the table already exists - * @throws \DomainException When an unsupported PDO driver is used - */ - public function createTable() - { - // connect if we are not yet - $conn = $this->getConnection(); - - if ($conn instanceof Connection) { - $types = [ - 'mysql' => 'binary', - 'sqlite' => 'text', - 'pgsql' => 'string', - 'oci' => 'string', - 'sqlsrv' => 'string', - ]; - if (!isset($types[$this->driver])) { - throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver)); - } - - $schema = new Schema(); - $table = $schema->createTable($this->table); - $table->addColumn($this->idCol, $types[$this->driver], ['length' => 255]); - $table->addColumn($this->dataCol, 'blob', ['length' => 16777215]); - $table->addColumn($this->lifetimeCol, 'integer', ['unsigned' => true, 'notnull' => false]); - $table->addColumn($this->timeCol, 'integer', ['unsigned' => true]); - $table->setPrimaryKey([$this->idCol]); - - foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) { - $conn->exec($sql); - } - - return; - } - - switch ($this->driver) { - case 'mysql': - // We use varbinary for the ID column because it prevents unwanted conversions: - // - character set conversions between server and client - // - trailing space removal - // - case-insensitivity - // - language processing like é == e - $sql = "CREATE TABLE $this->table ($this->idCol VARBINARY(255) NOT NULL PRIMARY KEY, $this->dataCol MEDIUMBLOB NOT NULL, $this->lifetimeCol INTEGER UNSIGNED, $this->timeCol INTEGER UNSIGNED NOT NULL) COLLATE utf8_bin, ENGINE = InnoDB"; - break; - case 'sqlite': - $sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)"; - break; - case 'pgsql': - $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(255) NOT NULL PRIMARY KEY, $this->dataCol BYTEA NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)"; - break; - case 'oci': - $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR2(255) NOT NULL PRIMARY KEY, $this->dataCol BLOB NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)"; - break; - case 'sqlsrv': - $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(255) NOT NULL PRIMARY KEY, $this->dataCol VARBINARY(MAX) NOT NULL, $this->lifetimeCol INTEGER, $this->timeCol INTEGER NOT NULL)"; - break; - default: - throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver)); - } - - $conn->exec($sql); - } - - /** - * {@inheritdoc} - */ - public function prune() - { - $deleteSql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol <= :time"; - - if ('' !== $this->namespace) { - $deleteSql .= " AND $this->idCol LIKE :namespace"; - } - - try { - $delete = $this->getConnection()->prepare($deleteSql); - } catch (TableNotFoundException $e) { - return true; - } - $delete->bindValue(':time', time(), \PDO::PARAM_INT); - - if ('' !== $this->namespace) { - $delete->bindValue(':namespace', sprintf('%s%%', $this->namespace), \PDO::PARAM_STR); - } - try { - return $delete->execute(); - } catch (TableNotFoundException $e) { - return true; - } - } - - /** - * {@inheritdoc} - */ - protected function doFetch(array $ids) - { - $now = time(); - $expired = []; - - $sql = str_pad('', (\count($ids) << 1) - 1, '?,'); - $sql = "SELECT $this->idCol, CASE WHEN $this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > ? THEN $this->dataCol ELSE NULL END FROM $this->table WHERE $this->idCol IN ($sql)"; - $stmt = $this->getConnection()->prepare($sql); - $stmt->bindValue($i = 1, $now, \PDO::PARAM_INT); - foreach ($ids as $id) { - $stmt->bindValue(++$i, $id); - } - $stmt->execute(); - - while ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - if (null === $row[1]) { - $expired[] = $row[0]; - } else { - yield $row[0] => $this->marshaller->unmarshall(\is_resource($row[1]) ? stream_get_contents($row[1]) : $row[1]); - } - } - - if ($expired) { - $sql = str_pad('', (\count($expired) << 1) - 1, '?,'); - $sql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol <= ? AND $this->idCol IN ($sql)"; - $stmt = $this->getConnection()->prepare($sql); - $stmt->bindValue($i = 1, $now, \PDO::PARAM_INT); - foreach ($expired as $id) { - $stmt->bindValue(++$i, $id); - } - $stmt->execute(); - } - } - - /** - * {@inheritdoc} - */ - protected function doHave($id) - { - $sql = "SELECT 1 FROM $this->table WHERE $this->idCol = :id AND ($this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > :time)"; - $stmt = $this->getConnection()->prepare($sql); - - $stmt->bindValue(':id', $id); - $stmt->bindValue(':time', time(), \PDO::PARAM_INT); - $stmt->execute(); - - return (bool) $stmt->fetchColumn(); - } - - /** - * {@inheritdoc} - */ - protected function doClear($namespace) - { - $conn = $this->getConnection(); - - if ('' === $namespace) { - if ('sqlite' === $this->driver) { - $sql = "DELETE FROM $this->table"; - } else { - $sql = "TRUNCATE TABLE $this->table"; - } - } else { - $sql = "DELETE FROM $this->table WHERE $this->idCol LIKE '$namespace%'"; - } - - try { - $conn->exec($sql); - } catch (TableNotFoundException $e) { - } - - return true; - } - - /** - * {@inheritdoc} - */ - protected function doDelete(array $ids) - { - $sql = str_pad('', (\count($ids) << 1) - 1, '?,'); - $sql = "DELETE FROM $this->table WHERE $this->idCol IN ($sql)"; - try { - $stmt = $this->getConnection()->prepare($sql); - $stmt->execute(array_values($ids)); - } catch (TableNotFoundException $e) { - } - - return true; - } - - /** - * {@inheritdoc} - */ - protected function doSave(array $values, $lifetime) - { - if (!$values = $this->marshaller->marshall($values, $failed)) { - return $failed; - } - - $conn = $this->getConnection(); - $driver = $this->driver; - $insertSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)"; - - switch (true) { - case 'mysql' === $driver: - $sql = $insertSql." ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->lifetimeCol = VALUES($this->lifetimeCol), $this->timeCol = VALUES($this->timeCol)"; - break; - case 'oci' === $driver: - // DUAL is Oracle specific dummy table - $sql = "MERGE INTO $this->table USING DUAL ON ($this->idCol = ?) ". - "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ". - "WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?"; - break; - case 'sqlsrv' === $driver && version_compare($this->getServerVersion(), '10', '>='): - // MERGE is only available since SQL Server 2008 and must be terminated by semicolon - // It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx - $sql = "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = ?) ". - "WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ". - "WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?;"; - break; - case 'sqlite' === $driver: - $sql = 'INSERT OR REPLACE'.substr($insertSql, 6); - break; - case 'pgsql' === $driver && version_compare($this->getServerVersion(), '9.5', '>='): - $sql = $insertSql." ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->lifetimeCol, $this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->lifetimeCol, EXCLUDED.$this->timeCol)"; - break; - default: - $driver = null; - $sql = "UPDATE $this->table SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id"; - break; - } - - $now = time(); - $lifetime = $lifetime ?: null; - try { - $stmt = $conn->prepare($sql); - } catch (TableNotFoundException $e) { - if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) { - $this->createTable(); - } - $stmt = $conn->prepare($sql); - } - - if ('sqlsrv' === $driver || 'oci' === $driver) { - $stmt->bindParam(1, $id); - $stmt->bindParam(2, $id); - $stmt->bindParam(3, $data, \PDO::PARAM_LOB); - $stmt->bindValue(4, $lifetime, \PDO::PARAM_INT); - $stmt->bindValue(5, $now, \PDO::PARAM_INT); - $stmt->bindParam(6, $data, \PDO::PARAM_LOB); - $stmt->bindValue(7, $lifetime, \PDO::PARAM_INT); - $stmt->bindValue(8, $now, \PDO::PARAM_INT); - } else { - $stmt->bindParam(':id', $id); - $stmt->bindParam(':data', $data, \PDO::PARAM_LOB); - $stmt->bindValue(':lifetime', $lifetime, \PDO::PARAM_INT); - $stmt->bindValue(':time', $now, \PDO::PARAM_INT); - } - if (null === $driver) { - $insertStmt = $conn->prepare($insertSql); - - $insertStmt->bindParam(':id', $id); - $insertStmt->bindParam(':data', $data, \PDO::PARAM_LOB); - $insertStmt->bindValue(':lifetime', $lifetime, \PDO::PARAM_INT); - $insertStmt->bindValue(':time', $now, \PDO::PARAM_INT); - } - - foreach ($values as $id => $data) { - try { - $stmt->execute(); - } catch (TableNotFoundException $e) { - if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) { - $this->createTable(); - } - $stmt->execute(); - } - if (null === $driver && !$stmt->rowCount()) { - try { - $insertStmt->execute(); - } catch (DBALException $e) { - } catch (\PDOException $e) { - // A concurrent write won, let it be - } - } - } - - return $failed; - } - - /** - * @return \PDO|Connection - */ - private function getConnection() - { - if (null === $this->conn) { - $this->conn = new \PDO($this->dsn, $this->username, $this->password, $this->connectionOptions); - $this->conn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - } - if (null === $this->driver) { - if ($this->conn instanceof \PDO) { - $this->driver = $this->conn->getAttribute(\PDO::ATTR_DRIVER_NAME); - } else { - switch ($this->driver = $this->conn->getDriver()->getName()) { - case 'mysqli': - case 'pdo_mysql': - case 'drizzle_pdo_mysql': - $this->driver = 'mysql'; - break; - case 'pdo_sqlite': - $this->driver = 'sqlite'; - break; - case 'pdo_pgsql': - $this->driver = 'pgsql'; - break; - case 'oci8': - case 'pdo_oracle': - $this->driver = 'oci'; - break; - case 'pdo_sqlsrv': - $this->driver = 'sqlsrv'; - break; - } - } - } - - return $this->conn; - } - - /** - * @return string - */ - private function getServerVersion() - { - if (null === $this->serverVersion) { - $conn = $this->conn instanceof \PDO ? $this->conn : $this->conn->getWrappedConnection(); - if ($conn instanceof \PDO) { - $this->serverVersion = $conn->getAttribute(\PDO::ATTR_SERVER_VERSION); - } elseif ($conn instanceof ServerInfoAwareConnection) { - $this->serverVersion = $conn->getServerVersion(); - } else { - $this->serverVersion = '0'; - } - } - - return $this->serverVersion; - } -} diff --git a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php b/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php deleted file mode 100644 index 0bec18a07aa56..0000000000000 --- a/src/Symfony/Component/Cache/Traits/PhpArrayTrait.php +++ /dev/null @@ -1,152 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Traits; - -use Symfony\Component\Cache\CacheItem; -use Symfony\Component\Cache\Exception\InvalidArgumentException; -use Symfony\Component\VarExporter\VarExporter; - -/** - * @author Titouan Galopin - * @author Nicolas Grekas - * - * @internal - */ -trait PhpArrayTrait -{ - use ProxyTrait; - - private $file; - private $keys; - private $values; - - /** - * Store an array of cached values. - * - * @param array $values The cached values - */ - public function warmUp(array $values) - { - if (file_exists($this->file)) { - if (!is_file($this->file)) { - throw new InvalidArgumentException(sprintf('Cache path exists and is not a file: %s.', $this->file)); - } - - if (!is_writable($this->file)) { - throw new InvalidArgumentException(sprintf('Cache file is not writable: %s.', $this->file)); - } - } else { - $directory = \dirname($this->file); - - if (!is_dir($directory) && !@mkdir($directory, 0777, true)) { - throw new InvalidArgumentException(sprintf('Cache directory does not exist and cannot be created: %s.', $directory)); - } - - if (!is_writable($directory)) { - throw new InvalidArgumentException(sprintf('Cache directory is not writable: %s.', $directory)); - } - } - - $dumpedValues = ''; - $dumpedMap = []; - $dump = <<<'EOF' - $value) { - CacheItem::validateKey(\is_int($key) ? (string) $key : $key); - $isStaticValue = true; - - if (null === $value) { - $value = "'N;'"; - } elseif (\is_object($value) || \is_array($value)) { - try { - $value = VarExporter::export($value, $isStaticValue); - } catch (\Exception $e) { - throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \is_object($value) ? \get_class($value) : 'array'), 0, $e); - } - } elseif (\is_string($value)) { - // Wrap "N;" in a closure to not confuse it with an encoded `null` - if ('N;' === $value) { - $isStaticValue = false; - } - $value = var_export($value, true); - } elseif (!\is_scalar($value)) { - throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \gettype($value))); - } else { - $value = var_export($value, true); - } - - if (!$isStaticValue) { - $value = str_replace("\n", "\n ", $value); - $value = "static function () {\n return {$value};\n}"; - } - $hash = hash('md5', $value); - - if (null === $id = $dumpedMap[$hash] ?? null) { - $id = $dumpedMap[$hash] = \count($dumpedMap); - $dumpedValues .= "{$id} => {$value},\n"; - } - - $dump .= var_export($key, true)." => {$id},\n"; - } - - $dump .= "\n], [\n\n{$dumpedValues}\n]];\n"; - - $tmpFile = uniqid($this->file, true); - - file_put_contents($tmpFile, $dump); - @chmod($tmpFile, 0666 & ~umask()); - unset($serialized, $value, $dump); - - @rename($tmpFile, $this->file); - - $this->initialize(); - } - - /** - * {@inheritdoc} - */ - public function clear() - { - $this->keys = $this->values = []; - - $cleared = @unlink($this->file) || !file_exists($this->file); - - return $this->pool->clear() && $cleared; - } - - /** - * Load the cache file. - */ - private function initialize() - { - if (!file_exists($this->file)) { - $this->keys = $this->values = []; - - return; - } - $values = (include $this->file) ?: [[], []]; - - if (2 !== \count($values) || !isset($values[0], $values[1])) { - $this->keys = $this->values = []; - } else { - list($this->keys, $this->values) = $values; - } - } -} diff --git a/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php b/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php deleted file mode 100644 index 37d25f87a98fa..0000000000000 --- a/src/Symfony/Component/Cache/Traits/PhpFilesTrait.php +++ /dev/null @@ -1,243 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Cache\Traits; - -use Symfony\Component\Cache\Exception\CacheException; -use Symfony\Component\Cache\Exception\InvalidArgumentException; -use Symfony\Component\VarExporter\VarExporter; - -/** - * @author Piotr Stankowski - * @author Nicolas Grekas - * @author Rob Frawley 2nd - * - * @internal - */ -trait PhpFilesTrait -{ - use FilesystemCommonTrait { - doClear as private doCommonClear; - doDelete as private doCommonDelete; - } - - private $includeHandler; - private $appendOnly; - private $values = []; - private $files = []; - - private static $startTime; - - public static function isSupported() - { - self::$startTime = self::$startTime ?? $_SERVER['REQUEST_TIME'] ?? time(); - - return \function_exists('opcache_invalidate') && ('cli' !== \PHP_SAPI || filter_var(ini_get('opcache.enable_cli'), FILTER_VALIDATE_BOOLEAN)) && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN); - } - - /** - * @return bool - */ - public function prune() - { - $time = time(); - $pruned = true; - - set_error_handler($this->includeHandler); - try { - foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->directory, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) { - try { - list($expiresAt) = include $file; - } catch (\ErrorException $e) { - $expiresAt = $time; - } - - if ($time >= $expiresAt) { - $pruned = $this->doUnlink($file) && !file_exists($file) && $pruned; - } - } - } finally { - restore_error_handler(); - } - - return $pruned; - } - - /** - * {@inheritdoc} - */ - protected function doFetch(array $ids) - { - if ($this->appendOnly) { - $now = 0; - $missingIds = []; - } else { - $now = time(); - $missingIds = $ids; - $ids = []; - } - $values = []; - - begin: - foreach ($ids as $id) { - if (null === $value = $this->values[$id] ?? null) { - $missingIds[] = $id; - } elseif ('N;' === $value) { - $values[$id] = null; - } elseif ($value instanceof \Closure) { - $values[$id] = $value(); - } else { - $values[$id] = $value; - } - if (!$this->appendOnly) { - unset($this->values[$id]); - } - } - - if (!$missingIds) { - return $values; - } - - set_error_handler($this->includeHandler); - try { - foreach ($missingIds as $k => $id) { - try { - $file = $this->files[$id] ?? $this->files[$id] = $this->getFile($id); - list($expiresAt, $this->values[$id]) = include $file; - if ($now >= $expiresAt) { - unset($this->values[$id], $missingIds[$k]); - } - } catch (\ErrorException $e) { - unset($missingIds[$k]); - } - } - } finally { - restore_error_handler(); - } - - $ids = $missingIds; - $missingIds = []; - goto begin; - } - - /** - * {@inheritdoc} - */ - protected function doHave($id) - { - if ($this->appendOnly && isset($this->values[$id])) { - return true; - } - - set_error_handler($this->includeHandler); - try { - $file = $this->files[$id] ?? $this->files[$id] = $this->getFile($id); - list($expiresAt, $value) = include $file; - } catch (\ErrorException $e) { - return false; - } finally { - restore_error_handler(); - } - if ($this->appendOnly) { - $now = 0; - $this->values[$id] = $value; - } else { - $now = time(); - } - - return $now < $expiresAt; - } - - /** - * {@inheritdoc} - */ - protected function doSave(array $values, $lifetime) - { - $ok = true; - $expiry = $lifetime ? time() + $lifetime : 'PHP_INT_MAX'; - $allowCompile = self::isSupported(); - - foreach ($values as $key => $value) { - unset($this->values[$key]); - $isStaticValue = true; - if (null === $value) { - $value = "'N;'"; - } elseif (\is_object($value) || \is_array($value)) { - try { - $value = VarExporter::export($value, $isStaticValue); - } catch (\Exception $e) { - throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \is_object($value) ? \get_class($value) : 'array'), 0, $e); - } - } elseif (\is_string($value)) { - // Wrap "N;" in a closure to not confuse it with an encoded `null` - if ('N;' === $value) { - $isStaticValue = false; - } - $value = var_export($value, true); - } elseif (!\is_scalar($value)) { - throw new InvalidArgumentException(sprintf('Cache key "%s" has non-serializable %s value.', $key, \gettype($value))); - } else { - $value = var_export($value, true); - } - - if (!$isStaticValue) { - $value = str_replace("\n", "\n ", $value); - $value = "static function () {\n\n return {$value};\n\n}"; - } - - $file = $this->files[$key] = $this->getFile($key, true); - // Since OPcache only compiles files older than the script execution start, set the file's mtime in the past - $ok = $this->write($file, "directory)) { - throw new CacheException(sprintf('Cache directory is not writable (%s)', $this->directory)); - } - - return $ok; - } - - /** - * {@inheritdoc} - */ - protected function doClear($namespace) - { - $this->values = []; - - return $this->doCommonClear($namespace); - } - - /** - * {@inheritdoc} - */ - protected function doDelete(array $ids) - { - foreach ($ids as $id) { - unset($this->values[$id]); - } - - return $this->doCommonDelete($ids); - } - - protected function doUnlink($file) - { - if (self::isSupported()) { - @opcache_invalidate($file, true); - } - - return @unlink($file); - } -} From a47cf7e2c4eba06595bfe5ca281bd73810b03013 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 31 May 2019 12:40:44 +0200 Subject: [PATCH 038/588] remove the deprecated AdvancedUserInterface --- .../Security/User/EntityUserProviderTest.php | 3 +- src/Symfony/Component/Security/CHANGELOG.md | 1 + .../Authentication/Token/AbstractToken.php | 24 ----- .../Token/AbstractTokenTest.php | 41 -------- .../Core/Tests/User/UserCheckerTest.php | 93 ------------------- .../Core/User/AdvancedUserInterface.php | 88 ------------------ .../Component/Security/Core/User/User.php | 2 +- .../Security/Core/User/UserChecker.php | 12 +-- 8 files changed, 6 insertions(+), 258 deletions(-) delete mode 100644 src/Symfony/Component/Security/Core/User/AdvancedUserInterface.php diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index 0b616a588f9ca..ace44202b61e3 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\Doctrine\Tests\Security\User; +use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Tools\SchemaTool; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider; @@ -172,7 +173,7 @@ public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided( */ public function testLoadUserByUserNameShouldDeclineInvalidInterface() { - $repository = $this->getMockBuilder('\Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); + $repository = $this->getMockBuilder(EntityRepository::class)->disableOriginalConstructor()->getMock(); $provider = new EntityUserProvider( $this->getManager($this->getObjectManager($repository)), diff --git a/src/Symfony/Component/Security/CHANGELOG.md b/src/Symfony/Component/Security/CHANGELOG.md index b2074b70aca95..4b8e97884bb3e 100644 --- a/src/Symfony/Component/Security/CHANGELOG.md +++ b/src/Symfony/Component/Security/CHANGELOG.md @@ -4,6 +4,7 @@ CHANGELOG 5.0.0 ----- +* Removed the `AdvancedUserInterface`, use a custom user checker instead. * Removed `Argon2iPasswordEncoder`, use `SodiumPasswordEncoder` instead * Removed `BcryptPasswordEncoder`, use `NativePasswordEncoder` instead * Removed the `has_role()` function from security expressions, use `is_granted()` instead. diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php index b30d136821539..f8a7b97ae261c 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Security\Core\Authentication\Token; use Symfony\Component\Security\Core\Role\Role; -use Symfony\Component\Security\Core\User\AdvancedUserInterface; use Symfony\Component\Security\Core\User\EquatableInterface; use Symfony\Component\Security\Core\User\UserInterface; @@ -321,29 +320,6 @@ private function hasUserChanged(UserInterface $user) return true; } - if ($this->user instanceof AdvancedUserInterface && $user instanceof AdvancedUserInterface) { - @trigger_error(sprintf('Checking for the AdvancedUserInterface in "%s()" is deprecated since Symfony 4.1 and support for it will be removed in 5.0. Implement the %s to check if the user has been changed,', __METHOD__, EquatableInterface::class), E_USER_DEPRECATED); - if ($this->user->isAccountNonExpired() !== $user->isAccountNonExpired()) { - return true; - } - - if ($this->user->isAccountNonLocked() !== $user->isAccountNonLocked()) { - return true; - } - - if ($this->user->isCredentialsNonExpired() !== $user->isCredentialsNonExpired()) { - return true; - } - - if ($this->user->isEnabled() !== $user->isEnabled()) { - return true; - } - } elseif ($this->user instanceof AdvancedUserInterface xor $user instanceof AdvancedUserInterface) { - @trigger_error(sprintf('Checking for the AdvancedUserInterface in "%s()" is deprecated since Symfony 4.1 and support for it will be removed in 5.0. Implement the %s to check if the user has been changed,', __METHOD__, EquatableInterface::class), E_USER_DEPRECATED); - - return true; - } - return false; } } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php index c8b5fed8d77f3..ba718689eae28 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php @@ -192,47 +192,6 @@ public function getUserChanges() ]; } - /** - * @group legacy - * - * @dataProvider getUserChangesAdvancedUser - */ - public function testSetUserSetsAuthenticatedToFalseWhenUserChangesAdvancedUser($firstUser, $secondUser) - { - $token = new ConcreteToken(); - $token->setAuthenticated(true); - $this->assertTrue($token->isAuthenticated()); - - $token->setUser($firstUser); - $this->assertTrue($token->isAuthenticated()); - - $token->setUser($secondUser); - $this->assertFalse($token->isAuthenticated()); - } - - public function getUserChangesAdvancedUser() - { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); - $advancedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - - return [ - ['foo', 'bar'], - ['foo', new TestUser('bar')], - ['foo', $user], - ['foo', $advancedUser], - [$user, 'foo'], - [$advancedUser, 'foo'], - [$user, new TestUser('foo')], - [$advancedUser, new TestUser('foo')], - [new TestUser('foo'), new TestUser('bar')], - [new TestUser('foo'), 'bar'], - [new TestUser('foo'), $user], - [new TestUser('foo'), $advancedUser], - [$user, $advancedUser], - [$advancedUser, $user], - ]; - } - /** * @dataProvider getUsers */ diff --git a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php index a1f62aa5db904..b7eeaea0dbea6 100644 --- a/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php +++ b/src/Symfony/Component/Security/Core/Tests/User/UserCheckerTest.php @@ -30,20 +30,6 @@ public function testCheckPostAuthPass() $this->assertNull($checker->checkPostAuth(new User('John', 'password'))); } - /** - * @group legacy - * @expectedDeprecation Calling "Symfony\Component\Security\Core\User\UserChecker::checkPostAuth()" with an AdvancedUserInterface is deprecated since Symfony 4.1. Create a custom user checker if you wish to keep this functionality. - */ - public function testCheckPostAuthPassAdvancedUser() - { - $checker = new UserChecker(); - - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isCredentialsNonExpired')->willReturn(true); - - $this->assertNull($checker->checkPostAuth($account)); - } - /** * @expectedException \Symfony\Component\Security\Core\Exception\CredentialsExpiredException */ @@ -53,37 +39,6 @@ public function testCheckPostAuthCredentialsExpired() $checker->checkPostAuth(new User('John', 'password', [], true, true, false, true)); } - /** - * @group legacy - * @expectedDeprecation Calling "Symfony\Component\Security\Core\User\UserChecker::checkPostAuth()" with an AdvancedUserInterface is deprecated since Symfony 4.1. Create a custom user checker if you wish to keep this functionality. - * @expectedException \Symfony\Component\Security\Core\Exception\CredentialsExpiredException - */ - public function testCheckPostAuthCredentialsExpiredAdvancedUser() - { - $checker = new UserChecker(); - - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isCredentialsNonExpired')->willReturn(false); - - $checker->checkPostAuth($account); - } - - /** - * @group legacy - * @expectedDeprecation Calling "Symfony\Component\Security\Core\User\UserChecker::checkPreAuth()" with an AdvancedUserInterface is deprecated since Symfony 4.1. Create a custom user checker if you wish to keep this functionality. - */ - public function testCheckPreAuthPassAdvancedUser() - { - $checker = new UserChecker(); - - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isAccountNonLocked')->willReturn(true); - $account->expects($this->once())->method('isEnabled')->willReturn(true); - $account->expects($this->once())->method('isAccountNonExpired')->willReturn(true); - - $this->assertNull($checker->checkPreAuth($account)); - } - /** * @expectedException \Symfony\Component\Security\Core\Exception\LockedException */ @@ -93,21 +48,6 @@ public function testCheckPreAuthAccountLocked() $checker->checkPreAuth(new User('John', 'password', [], true, true, false, false)); } - /** - * @group legacy - * @expectedDeprecation Calling "Symfony\Component\Security\Core\User\UserChecker::checkPreAuth()" with an AdvancedUserInterface is deprecated since Symfony 4.1. Create a custom user checker if you wish to keep this functionality. - * @expectedException \Symfony\Component\Security\Core\Exception\LockedException - */ - public function testCheckPreAuthAccountLockedAdvancedUser() - { - $checker = new UserChecker(); - - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isAccountNonLocked')->willReturn(false); - - $checker->checkPreAuth($account); - } - /** * @expectedException \Symfony\Component\Security\Core\Exception\DisabledException */ @@ -117,22 +57,6 @@ public function testCheckPreAuthDisabled() $checker->checkPreAuth(new User('John', 'password', [], false, true, false, true)); } - /** - * @group legacy - * @expectedDeprecation Calling "Symfony\Component\Security\Core\User\UserChecker::checkPreAuth()" with an AdvancedUserInterface is deprecated since Symfony 4.1. Create a custom user checker if you wish to keep this functionality. - * @expectedException \Symfony\Component\Security\Core\Exception\DisabledException - */ - public function testCheckPreAuthDisabledAdvancedUser() - { - $checker = new UserChecker(); - - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isAccountNonLocked')->willReturn(true); - $account->expects($this->once())->method('isEnabled')->willReturn(false); - - $checker->checkPreAuth($account); - } - /** * @expectedException \Symfony\Component\Security\Core\Exception\AccountExpiredException */ @@ -141,21 +65,4 @@ public function testCheckPreAuthAccountExpired() $checker = new UserChecker(); $checker->checkPreAuth(new User('John', 'password', [], true, false, true, true)); } - - /** - * @group legacy - * @expectedDeprecation Calling "Symfony\Component\Security\Core\User\UserChecker::checkPreAuth()" with an AdvancedUserInterface is deprecated since Symfony 4.1. Create a custom user checker if you wish to keep this functionality. - * @expectedException \Symfony\Component\Security\Core\Exception\AccountExpiredException - */ - public function testCheckPreAuthAccountExpiredAdvancedUser() - { - $checker = new UserChecker(); - - $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); - $account->expects($this->once())->method('isAccountNonLocked')->willReturn(true); - $account->expects($this->once())->method('isEnabled')->willReturn(true); - $account->expects($this->once())->method('isAccountNonExpired')->willReturn(false); - - $checker->checkPreAuth($account); - } } diff --git a/src/Symfony/Component/Security/Core/User/AdvancedUserInterface.php b/src/Symfony/Component/Security/Core/User/AdvancedUserInterface.php deleted file mode 100644 index 66d5a22416ecc..0000000000000 --- a/src/Symfony/Component/Security/Core/User/AdvancedUserInterface.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\User; - -use Symfony\Component\Security\Core\Exception\AccountExpiredException; -use Symfony\Component\Security\Core\Exception\AccountStatusException; -use Symfony\Component\Security\Core\Exception\CredentialsExpiredException; -use Symfony\Component\Security\Core\Exception\DisabledException; -use Symfony\Component\Security\Core\Exception\LockedException; - -/** - * Adds extra features to a user class related to account status flags. - * - * This interface can be implemented in place of UserInterface if you'd like - * the authentication system to consider different account status flags - * during authentication. If any of the methods in this interface return - * false, authentication will fail. - * - * If you need to perform custom logic for any of these situations, then - * you will need to register an exception listener and watch for the specific - * exception instances thrown in each case. All exceptions are a subclass - * of AccountStatusException - * - * @see UserInterface - * @see AccountStatusException - * @deprecated since Symfony 4.1 - * - * @author Fabien Potencier - */ -interface AdvancedUserInterface extends UserInterface -{ - /** - * Checks whether the user's account has expired. - * - * Internally, if this method returns false, the authentication system - * will throw an AccountExpiredException and prevent login. - * - * @return bool true if the user's account is non expired, false otherwise - * - * @see AccountExpiredException - */ - public function isAccountNonExpired(); - - /** - * Checks whether the user is locked. - * - * Internally, if this method returns false, the authentication system - * will throw a LockedException and prevent login. - * - * @return bool true if the user is not locked, false otherwise - * - * @see LockedException - */ - public function isAccountNonLocked(); - - /** - * Checks whether the user's credentials (password) has expired. - * - * Internally, if this method returns false, the authentication system - * will throw a CredentialsExpiredException and prevent login. - * - * @return bool true if the user's credentials are non expired, false otherwise - * - * @see CredentialsExpiredException - */ - public function isCredentialsNonExpired(); - - /** - * Checks whether the user is enabled. - * - * Internally, if this method returns false, the authentication system - * will throw a DisabledException and prevent login. - * - * @return bool true if the user is enabled, false otherwise - * - * @see DisabledException - */ - public function isEnabled(); -} diff --git a/src/Symfony/Component/Security/Core/User/User.php b/src/Symfony/Component/Security/Core/User/User.php index 18faeb7af0402..dca5c4fe2bbc8 100644 --- a/src/Symfony/Component/Security/Core/User/User.php +++ b/src/Symfony/Component/Security/Core/User/User.php @@ -18,7 +18,7 @@ * * @author Fabien Potencier */ -final class User implements UserInterface, EquatableInterface, AdvancedUserInterface +final class User implements UserInterface, EquatableInterface { private $username; private $password; diff --git a/src/Symfony/Component/Security/Core/User/UserChecker.php b/src/Symfony/Component/Security/Core/User/UserChecker.php index e715f06c14984..810ab21c0b402 100644 --- a/src/Symfony/Component/Security/Core/User/UserChecker.php +++ b/src/Symfony/Component/Security/Core/User/UserChecker.php @@ -28,14 +28,10 @@ class UserChecker implements UserCheckerInterface */ public function checkPreAuth(UserInterface $user) { - if (!$user instanceof AdvancedUserInterface && !$user instanceof User) { + if (!$user instanceof User) { return; } - if ($user instanceof AdvancedUserInterface && !$user instanceof User) { - @trigger_error(sprintf('Calling "%s()" with an AdvancedUserInterface is deprecated since Symfony 4.1. Create a custom user checker if you wish to keep this functionality.', __METHOD__), E_USER_DEPRECATED); - } - if (!$user->isAccountNonLocked()) { $ex = new LockedException('User account is locked.'); $ex->setUser($user); @@ -60,14 +56,10 @@ public function checkPreAuth(UserInterface $user) */ public function checkPostAuth(UserInterface $user) { - if (!$user instanceof AdvancedUserInterface && !$user instanceof User) { + if (!$user instanceof User) { return; } - if ($user instanceof AdvancedUserInterface && !$user instanceof User) { - @trigger_error(sprintf('Calling "%s()" with an AdvancedUserInterface is deprecated since Symfony 4.1. Create a custom user checker if you wish to keep this functionality.', __METHOD__), E_USER_DEPRECATED); - } - if (!$user->isCredentialsNonExpired()) { $ex = new CredentialsExpiredException('User credentials have expired.'); $ex->setUser($user); From b80cff153a42b5873626a79db4addb1a61f6b040 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 31 May 2019 12:46:22 +0200 Subject: [PATCH 039/588] drop support for mappings in multi-line blocks --- src/Symfony/Component/Yaml/CHANGELOG.md | 5 +++++ src/Symfony/Component/Yaml/Parser.php | 2 +- src/Symfony/Component/Yaml/Tests/ParserTest.php | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Yaml/CHANGELOG.md b/src/Symfony/Component/Yaml/CHANGELOG.md index 1bc5561ba3db8..eb91b1de2a1f6 100644 --- a/src/Symfony/Component/Yaml/CHANGELOG.md +++ b/src/Symfony/Component/Yaml/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.0.0 +----- + + * Removed support for mappings inside multi-line strings. + 4.3.0 ----- diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 4519edb840c7b..4a84b39521e1b 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -392,7 +392,7 @@ private function doParse(string $value, int $flags) } if (false !== strpos($line, ': ')) { - @trigger_error('Support for mapping keys in multi-line blocks is deprecated since Symfony 4.3 and will throw a ParseException in 5.0.', E_USER_DEPRECATED); + throw new ParseException('Mapping values are not allowed in multi-line blocks.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); } if ('' === trim($line)) { diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 6fc02e1d1f105..1bfd22cfe3836 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -526,8 +526,8 @@ public function testObjectsSupportDisabledWithExceptions() } /** - * @group legacy - * @expectedDeprecation Support for mapping keys in multi-line blocks is deprecated since Symfony 4.3 and will throw a ParseException in 5.0. + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + * @expectedExceptionMessage Mapping values are not allowed in multi-line blocks at line 2 (near "dbal:wrong"). */ public function testMappingKeyInMultiLineStringTriggersDeprecationNotice() { From d64372df8c8d63e124d14de5c08fcbbb4674a12e Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 30 May 2019 11:18:52 +0200 Subject: [PATCH 040/588] remove deprecated role classes --- .../Monolog/Processor/TokenProcessor.php | 6 +- .../DataCollector/SecurityDataCollector.php | 24 +------- .../SecurityDataCollectorTest.php | 42 ------------- src/Symfony/Component/Security/CHANGELOG.md | 5 ++ .../Provider/UserAuthenticationProvider.php | 25 +------- .../Authentication/Token/AbstractToken.php | 40 +++--------- .../Token/Storage/TokenStorage.php | 4 -- .../Authentication/Token/TokenInterface.php | 13 ++-- .../Authorization/Voter/ExpressionVoter.php | 18 +----- .../Voter/RoleHierarchyVoter.php | 20 +----- .../Core/Authorization/Voter/RoleVoter.php | 13 +--- .../Component/Security/Core/Role/Role.php | 48 --------------- .../Security/Core/Role/RoleHierarchy.php | 25 -------- .../Core/Role/RoleHierarchyInterface.php | 11 ++-- .../Security/Core/Role/SwitchUserRole.php | 61 ------------------- .../AuthenticationTrustResolverTest.php | 2 +- .../UserAuthenticationProviderTest.php | 45 -------------- .../Token/AbstractTokenTest.php | 47 +------------- .../Voter/ExpressionVoterTest.php | 28 --------- .../Voter/RoleHierarchyVoterTest.php | 33 ---------- .../Authorization/Voter/RoleVoterTest.php | 44 ------------- .../Core/Tests/Role/RoleHierarchyTest.php | 18 ------ .../Security/Core/Tests/Role/RoleTest.php | 28 --------- .../Core/Tests/Role/SwitchUserRoleTest.php | 35 ----------- .../Security/Core/User/UserInterface.php | 4 +- .../Http/Firewall/ContextListener.php | 8 --- .../Http/Firewall/SwitchUserListener.php | 8 --- .../Tests/Firewall/SwitchUserListenerTest.php | 23 +------ .../Workflow/EventListener/GuardListener.php | 23 +------ 29 files changed, 39 insertions(+), 662 deletions(-) delete mode 100644 src/Symfony/Component/Security/Core/Role/Role.php delete mode 100644 src/Symfony/Component/Security/Core/Role/SwitchUserRole.php delete mode 100644 src/Symfony/Component/Security/Core/Tests/Role/RoleTest.php delete mode 100644 src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php diff --git a/src/Symfony/Bridge/Monolog/Processor/TokenProcessor.php b/src/Symfony/Bridge/Monolog/Processor/TokenProcessor.php index 7613d01361962..78d8dd3249c6d 100644 --- a/src/Symfony/Bridge/Monolog/Processor/TokenProcessor.php +++ b/src/Symfony/Bridge/Monolog/Processor/TokenProcessor.php @@ -31,11 +31,7 @@ public function __invoke(array $records) { $records['extra']['token'] = null; if (null !== $token = $this->tokenStorage->getToken()) { - if (method_exists($token, 'getRoleNames')) { - $roles = $token->getRoleNames(); - } else { - $roles = array_map(function ($role) { return $role->getRole(); }, $token->getRoles(false)); - } + $roles = $token->getRoleNames(); $records['extra']['token'] = [ 'username' => $token->getUsername(), diff --git a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php index 0d122efe7fd81..275f14dedc650 100644 --- a/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php +++ b/src/Symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.php @@ -22,9 +22,7 @@ use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager; use Symfony\Component\Security\Core\Authorization\Voter\TraceableVoter; -use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\RoleHierarchyInterface; -use Symfony\Component\Security\Core\Role\SwitchUserRole; use Symfony\Component\Security\Http\Firewall\SwitchUserListener; use Symfony\Component\Security\Http\FirewallMapInterface; use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator; @@ -92,33 +90,15 @@ public function collect(Request $request, Response $response, \Exception $except ]; } else { $inheritedRoles = []; - - if (method_exists($token, 'getRoleNames')) { - $assignedRoles = $token->getRoleNames(); - } else { - $assignedRoles = array_map(function (Role $role) { return $role->getRole(); }, $token->getRoles(false)); - } + $assignedRoles = $token->getRoleNames(); $impersonatorUser = null; if ($token instanceof SwitchUserToken) { $impersonatorUser = $token->getOriginalToken()->getUsername(); - } else { - foreach ($token->getRoles(false) as $role) { - if ($role instanceof SwitchUserRole) { - $impersonatorUser = $role->getSource()->getUsername(); - break; - } - } } if (null !== $this->roleHierarchy) { - if (method_exists($this->roleHierarchy, 'getReachableRoleNames')) { - $allRoles = $this->roleHierarchy->getReachableRoleNames($assignedRoles); - } else { - $allRoles = array_map(function (Role $role) { return (string) $role; }, $this->roleHierarchy->getReachableRoles($token->getRoles(false))); - } - - foreach ($allRoles as $role) { + foreach ($this->roleHierarchy->getReachableRoleNames($assignedRoles) as $role) { if (!\in_array($role, $assignedRoles, true)) { $inheritedRoles[] = $role; } diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php index 7e583facf7b09..2e970dcaa7124 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php @@ -28,9 +28,7 @@ use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager; use Symfony\Component\Security\Core\Authorization\Voter\TraceableVoter; use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; -use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\RoleHierarchy; -use Symfony\Component\Security\Core\Role\SwitchUserRole; use Symfony\Component\Security\Http\FirewallMapInterface; use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; @@ -97,36 +95,6 @@ public function testCollectAuthenticationTokenAndRoles(array $roles, array $norm $this->assertSame('hhamon', $collector->getUser()); } - /** - * @group legacy - */ - public function testCollectImpersonatedToken() - { - $adminToken = new UsernamePasswordToken('yceruto', 'P4$$w0rD', 'provider', ['ROLE_ADMIN']); - - $userRoles = [ - 'ROLE_USER', - new SwitchUserRole('ROLE_PREVIOUS_ADMIN', $adminToken), - ]; - - $tokenStorage = new TokenStorage(); - $tokenStorage->setToken(new UsernamePasswordToken('hhamon', 'P4$$w0rD', 'provider', $userRoles)); - - $collector = new SecurityDataCollector($tokenStorage, $this->getRoleHierarchy()); - $collector->collect(new Request(), new Response()); - $collector->lateCollect(); - - $this->assertTrue($collector->isEnabled()); - $this->assertTrue($collector->isAuthenticated()); - $this->assertTrue($collector->isImpersonated()); - $this->assertSame('yceruto', $collector->getImpersonatorUser()); - $this->assertSame('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $collector->getTokenClass()->getValue()); - $this->assertTrue($collector->supportsRoleHierarchy()); - $this->assertSame(['ROLE_USER', 'ROLE_PREVIOUS_ADMIN'], $collector->getRoles()->getValue(true)); - $this->assertSame([], $collector->getInheritedRoles()->getValue(true)); - $this->assertSame('hhamon', $collector->getUser()); - } - public function testCollectSwitchUserToken() { $adminToken = new UsernamePasswordToken('yceruto', 'P4$$w0rD', 'provider', ['ROLE_ADMIN']); @@ -391,22 +359,12 @@ public function provideRoles() ['ROLE_USER'], [], ], - [ - [new Role('ROLE_USER', false)], - ['ROLE_USER'], - [], - ], // Inherited roles [ ['ROLE_ADMIN'], ['ROLE_ADMIN'], ['ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'], ], - [ - [new Role('ROLE_ADMIN', false)], - ['ROLE_ADMIN'], - ['ROLE_USER', 'ROLE_ALLOWED_TO_SWITCH'], - ], [ ['ROLE_ADMIN', 'ROLE_OPERATOR'], ['ROLE_ADMIN', 'ROLE_OPERATOR'], diff --git a/src/Symfony/Component/Security/CHANGELOG.md b/src/Symfony/Component/Security/CHANGELOG.md index 4b8e97884bb3e..1afdfa175b9f5 100644 --- a/src/Symfony/Component/Security/CHANGELOG.md +++ b/src/Symfony/Component/Security/CHANGELOG.md @@ -11,6 +11,11 @@ CHANGELOG * `SimpleAuthenticatorInterface`, `SimpleFormAuthenticatorInterface`, `SimplePreAuthenticatorInterface`, `SimpleAuthenticationProvider`, `SimpleAuthenticationHandler`, `SimpleFormAuthenticationListener` and `SimplePreAuthenticationListener` have been removed. Use Guard instead. +* Removed the `Role` and `SwitchUserRole` classes. Use strings for roles instead. +* Removed the `getReachableRoles()` method from the `RoleHierarchyInterface`. Role hierarchies must implement + the `getReachableRoleNames()` method instead and return roles as strings. +* Removed the `getRoles()` method from the `TokenInterface`. Tokens must implement the `getRoleNames()` method + instead and return roles as strings. 4.3.0 ----- diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php index 7a35bb056a720..32f53d5a0e7f4 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php @@ -18,7 +18,6 @@ use Symfony\Component\Security\Core\Exception\AuthenticationServiceException; use Symfony\Component\Security\Core\Exception\BadCredentialsException; use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; -use Symfony\Component\Security\Core\Role\SwitchUserRole; use Symfony\Component\Security\Core\User\UserCheckerInterface; use Symfony\Component\Security\Core\User\UserInterface; @@ -89,9 +88,9 @@ public function authenticate(TokenInterface $token) } if ($token instanceof SwitchUserToken) { - $authenticatedToken = new SwitchUserToken($user, $token->getCredentials(), $this->providerKey, $this->getRoles($user, $token), $token->getOriginalToken()); + $authenticatedToken = new SwitchUserToken($user, $token->getCredentials(), $this->providerKey, $user->getRoles(), $token->getOriginalToken()); } else { - $authenticatedToken = new UsernamePasswordToken($user, $token->getCredentials(), $this->providerKey, $this->getRoles($user, $token)); + $authenticatedToken = new UsernamePasswordToken($user, $token->getCredentials(), $this->providerKey, $user->getRoles()); } $authenticatedToken->setAttributes($token->getAttributes()); @@ -107,26 +106,6 @@ public function supports(TokenInterface $token) return $token instanceof UsernamePasswordToken && $this->providerKey === $token->getProviderKey(); } - /** - * Retrieves roles from user and appends SwitchUserRole if original token contained one. - * - * @return array The user roles - */ - private function getRoles(UserInterface $user, TokenInterface $token) - { - $roles = $user->getRoles(); - - foreach ($token->getRoles(false) as $role) { - if ($role instanceof SwitchUserRole) { - $roles[] = $role; - - break; - } - } - - return $roles; - } - /** * Retrieves the user from an implementation-specific location. * diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php index f8a7b97ae261c..f0fd97d4d4450 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Security\Core\Authentication\Token; -use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\User\EquatableInterface; use Symfony\Component\Security\Core\User\UserInterface; @@ -24,7 +23,6 @@ abstract class AbstractToken implements TokenInterface { private $user; - private $roles = []; private $roleNames = []; private $authenticated = false; private $attributes = []; @@ -37,32 +35,16 @@ abstract class AbstractToken implements TokenInterface public function __construct(array $roles = []) { foreach ($roles as $role) { - if (\is_string($role)) { - $role = new Role($role, false); - } elseif (!$role instanceof Role) { - throw new \InvalidArgumentException(sprintf('$roles must be an array of strings, or Role instances, but got %s.', \gettype($role))); - } - - $this->roles[] = $role; - $this->roleNames[] = (string) $role; + $this->roleNames[] = $role; } } - public function getRoleNames(): array - { - return $this->roleNames; - } - /** * {@inheritdoc} */ - public function getRoles() + public function getRoleNames(): array { - if (0 === \func_num_args() || func_get_arg(0)) { - @trigger_error(sprintf('The %s() method is deprecated since Symfony 4.3. Use the getRoleNames() method instead.', __METHOD__), E_USER_DEPRECATED); - } - - return $this->roles; + return $this->roleNames; } /** @@ -158,7 +140,7 @@ public function eraseCredentials() */ public function __serialize(): array { - return [$this->user, $this->authenticated, $this->roles, $this->attributes, $this->roleNames]; + return [$this->user, $this->authenticated, null, $this->attributes, $this->roleNames]; } /** @@ -198,15 +180,7 @@ public function serialize() */ public function __unserialize(array $data): void { - [$this->user, $this->authenticated, $this->roles, $this->attributes] = $data; - - // migration path to 4.3+ - if (null === $this->roleNames = $data[4] ?? null) { - $this->roleNames = []; - foreach ($this->roles as $role) { - $this->roleNames[] = (string) $role; - } - } + [$this->user, $this->authenticated, , $this->attributes, $this->roleNames] = $data; } /** @@ -291,8 +265,8 @@ public function __toString() $class = substr($class, strrpos($class, '\\') + 1); $roles = []; - foreach ($this->roles as $role) { - $roles[] = $role->getRole(); + foreach ($this->roleNames as $role) { + $roles[] = $role; } return sprintf('%s(user="%s", authenticated=%s, roles="%s")', $class, $this->getUsername(), json_encode($this->authenticated), implode(', ', $roles)); diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php b/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php index 97534b8f70044..f1f5391ba7800 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php @@ -39,10 +39,6 @@ public function getToken() */ public function setToken(TokenInterface $token = null) { - if (null !== $token && !method_exists($token, 'getRoleNames')) { - @trigger_error(sprintf('Not implementing the getRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($token), TokenInterface::class), E_USER_DEPRECATED); - } - $this->token = $token; } diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.php b/src/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.php index 984966a9c81b4..9a2da1670d9d3 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.php @@ -11,17 +11,14 @@ namespace Symfony\Component\Security\Core\Authentication\Token; -use Symfony\Component\Security\Core\Role\Role; - /** * TokenInterface is the interface for the user authentication information. * * @author Fabien Potencier * @author Johannes M. Schmitt * - * @method array __serialize() Returns all the necessary state of the object for serialization purposes - not implementing it is deprecated since Symfony 4.3 - * @method void __unserialize(array $data) Restores the object state from an array given by __serialize() - not implementing it is deprecated since Symfony 4.3 - * @method string[] getRoleNames() The associated roles - not implementing it is deprecated since Symfony 4.3 + * @method array __serialize() Returns all the necessary state of the object for serialization purposes - not implementing it is deprecated since Symfony 4.3 + * @method void __unserialize(array $data) Restores the object state from an array given by __serialize() - not implementing it is deprecated since Symfony 4.3 */ interface TokenInterface extends \Serializable { @@ -37,11 +34,9 @@ public function __toString(); /** * Returns the user roles. * - * @return Role[] An array of Role instances - * - * @deprecated since Symfony 4.3, use the getRoleNames() method instead + * @return string[] The associated roles */ - public function getRoles(); + public function getRoleNames(): array; /** * Returns the user credentials. diff --git a/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php b/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php index b91b83af926b6..254627f698bf2 100644 --- a/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php +++ b/src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php @@ -18,7 +18,6 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Authorization\ExpressionLanguage; -use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\RoleHierarchyInterface; /** @@ -78,22 +77,10 @@ public function vote(TokenInterface $token, $subject, array $attributes) private function getVariables(TokenInterface $token, $subject) { - if (method_exists($token, 'getRoleNames')) { - $roleNames = $token->getRoleNames(); - $roles = array_map(function (string $role) { return new Role($role, false); }, $roleNames); - } else { - @trigger_error(sprintf('Not implementing the getRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($token), TokenInterface::class), E_USER_DEPRECATED); - - $roles = $token->getRoles(false); - $roleNames = array_map(function (Role $role) { return $role->getRole(); }, $roles); - } + $roleNames = $token->getRoleNames(); - if (null !== $this->roleHierarchy && method_exists($this->roleHierarchy, 'getReachableRoleNames')) { + if (null !== $this->roleHierarchy) { $roleNames = $this->roleHierarchy->getReachableRoleNames($roleNames); - $roles = array_map(function (string $role) { return new Role($role, false); }, $roleNames); - } elseif (null !== $this->roleHierarchy) { - $roles = $this->roleHierarchy->getReachableRoles($roles); - $roleNames = array_map(function (Role $role) { return $role->getRole(); }, $roles); } $variables = [ @@ -101,7 +88,6 @@ private function getVariables(TokenInterface $token, $subject) 'user' => $token->getUser(), 'object' => $subject, 'subject' => $subject, - 'roles' => $roles, 'role_names' => $roleNames, 'trust_resolver' => $this->trustResolver, 'auth_checker' => $this->authChecker, diff --git a/src/Symfony/Component/Security/Core/Authorization/Voter/RoleHierarchyVoter.php b/src/Symfony/Component/Security/Core/Authorization/Voter/RoleHierarchyVoter.php index d4524667c5715..d8f2b34c94aad 100644 --- a/src/Symfony/Component/Security/Core/Authorization/Voter/RoleHierarchyVoter.php +++ b/src/Symfony/Component/Security/Core/Authorization/Voter/RoleHierarchyVoter.php @@ -12,8 +12,6 @@ namespace Symfony\Component\Security\Core\Authorization\Voter; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\Role\Role; -use Symfony\Component\Security\Core\Role\RoleHierarchy; use Symfony\Component\Security\Core\Role\RoleHierarchyInterface; /** @@ -28,10 +26,6 @@ class RoleHierarchyVoter extends RoleVoter public function __construct(RoleHierarchyInterface $roleHierarchy, string $prefix = 'ROLE_') { - if (!method_exists($roleHierarchy, 'getReachableRoleNames')) { - @trigger_error(sprintf('Not implementing the getReachableRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($roleHierarchy), RoleHierarchyInterface::class), E_USER_DEPRECATED); - } - $this->roleHierarchy = $roleHierarchy; parent::__construct($prefix); @@ -42,18 +36,6 @@ public function __construct(RoleHierarchyInterface $roleHierarchy, string $prefi */ protected function extractRoles(TokenInterface $token) { - if (method_exists($this->roleHierarchy, 'getReachableRoleNames')) { - if (method_exists($token, 'getRoleNames')) { - $roles = $token->getRoleNames(); - } else { - @trigger_error(sprintf('Not implementing the getRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($token), TokenInterface::class), E_USER_DEPRECATED); - - $roles = array_map(function (Role $role) { return $role->getRole(); }, $token->getRoles(false)); - } - - return $this->roleHierarchy->getReachableRoleNames($roles); - } - - return $this->roleHierarchy->getReachableRoles($token->getRoles(false)); + return $this->roleHierarchy->getReachableRoleNames($token->getRoleNames()); } } diff --git a/src/Symfony/Component/Security/Core/Authorization/Voter/RoleVoter.php b/src/Symfony/Component/Security/Core/Authorization/Voter/RoleVoter.php index deb542255c513..b1468b07d86f3 100644 --- a/src/Symfony/Component/Security/Core/Authorization/Voter/RoleVoter.php +++ b/src/Symfony/Component/Security/Core/Authorization/Voter/RoleVoter.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Security\Core\Authorization\Voter; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\Role\Role; /** * RoleVoter votes if any attribute starts with a given prefix. @@ -37,10 +36,6 @@ public function vote(TokenInterface $token, $subject, array $attributes) $roles = $this->extractRoles($token); foreach ($attributes as $attribute) { - if ($attribute instanceof Role) { - $attribute = $attribute->getRole(); - } - if (!\is_string($attribute) || 0 !== strpos($attribute, $this->prefix)) { continue; } @@ -58,12 +53,6 @@ public function vote(TokenInterface $token, $subject, array $attributes) protected function extractRoles(TokenInterface $token) { - if (method_exists($token, 'getRoleNames')) { - return $token->getRoleNames(); - } - - @trigger_error(sprintf('Not implementing the getRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($token), TokenInterface::class), E_USER_DEPRECATED); - - return array_map(function (Role $role) { return $role->getRole(); }, $token->getRoles(false)); + return $token->getRoleNames(); } } diff --git a/src/Symfony/Component/Security/Core/Role/Role.php b/src/Symfony/Component/Security/Core/Role/Role.php deleted file mode 100644 index df6ccf7636225..0000000000000 --- a/src/Symfony/Component/Security/Core/Role/Role.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Role; - -/** - * Role is a simple implementation representing a role identified by a string. - * - * @author Fabien Potencier - * - * @deprecated since Symfony 4.3, to be removed in 5.0. Use strings as roles instead. - */ -class Role -{ - private $role; - - public function __construct(string $role) - { - if (\func_num_args() < 2 || func_get_arg(1)) { - @trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3 and will be removed in 5.0. Use strings as roles instead.', __CLASS__), E_USER_DEPRECATED); - } - - $this->role = $role; - } - - /** - * Returns a string representation of the role. - * - * @return string - */ - public function getRole() - { - return $this->role; - } - - public function __toString(): string - { - return $this->role; - } -} diff --git a/src/Symfony/Component/Security/Core/Role/RoleHierarchy.php b/src/Symfony/Component/Security/Core/Role/RoleHierarchy.php index c1116cd2c3d55..d911fe3dab16e 100644 --- a/src/Symfony/Component/Security/Core/Role/RoleHierarchy.php +++ b/src/Symfony/Component/Security/Core/Role/RoleHierarchy.php @@ -34,31 +34,6 @@ public function __construct(array $hierarchy) /** * {@inheritdoc} */ - public function getReachableRoles(array $roles) - { - if (0 === \func_num_args() || func_get_arg(0)) { - @trigger_error(sprintf('The %s() method is deprecated since Symfony 4.3 and will be removed in 5.0. Use roles as strings and the getReachableRoleNames() method instead.', __METHOD__), E_USER_DEPRECATED); - } - - $reachableRoles = $roles; - foreach ($roles as $role) { - if (!isset($this->map[$role->getRole()])) { - continue; - } - - foreach ($this->map[$role->getRole()] as $r) { - $reachableRoles[] = new Role($r); - } - } - - return $reachableRoles; - } - - /** - * @param string[] $roles - * - * @return string[] - */ public function getReachableRoleNames(array $roles): array { $reachableRoles = $roles; diff --git a/src/Symfony/Component/Security/Core/Role/RoleHierarchyInterface.php b/src/Symfony/Component/Security/Core/Role/RoleHierarchyInterface.php index 9f54042db0e4b..6e8fa81d07f40 100644 --- a/src/Symfony/Component/Security/Core/Role/RoleHierarchyInterface.php +++ b/src/Symfony/Component/Security/Core/Role/RoleHierarchyInterface.php @@ -14,13 +14,14 @@ /** * RoleHierarchyInterface is the interface for a role hierarchy. * - * The getReachableRoles(Role[] $roles) method that returns an array of all reachable Role objects is deprecated - * since Symfony 4.3. - * * @author Fabien Potencier - * - * @method string[] getReachableRoleNames(string[] $roles) The associated roles - not implementing it is deprecated since Symfony 4.3 */ interface RoleHierarchyInterface { + /** + * @param string[] $roles + * + * @return string[] + */ + public function getReachableRoleNames(array $roles): array; } diff --git a/src/Symfony/Component/Security/Core/Role/SwitchUserRole.php b/src/Symfony/Component/Security/Core/Role/SwitchUserRole.php deleted file mode 100644 index 85d7ddb1a56a6..0000000000000 --- a/src/Symfony/Component/Security/Core/Role/SwitchUserRole.php +++ /dev/null @@ -1,61 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Role; - -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; - -/** - * SwitchUserRole is used when the current user temporarily impersonates - * another one. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0. Use strings as roles instead. - */ -class SwitchUserRole extends Role -{ - private $deprecationTriggered = false; - private $source; - - /** - * @param string $role The role as a string - * @param TokenInterface $source The original token - */ - public function __construct(string $role, TokenInterface $source) - { - if ($triggerDeprecation = \func_num_args() < 3 || func_get_arg(2)) { - @trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3 and will be removed in 5.0. Use strings as roles instead.', __CLASS__), E_USER_DEPRECATED); - - $this->deprecationTriggered = true; - } - - parent::__construct($role, $triggerDeprecation); - - $this->source = $source; - } - - /** - * Returns the original Token. - * - * @return TokenInterface The original TokenInterface instance - */ - public function getSource() - { - if (!$this->deprecationTriggered && (\func_num_args() < 1 || func_get_arg(0))) { - @trigger_error(sprintf('The "%s" class is deprecated since version 4.3 and will be removed in 5.0. Use strings as roles instead.', __CLASS__), E_USER_DEPRECATED); - - $this->deprecationTriggered = true; - } - - return $this->source; - } -} diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php index 940dcaffaa958..e6e199e94771e 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationTrustResolverTest.php @@ -168,7 +168,7 @@ public function __toString() { } - public function getRoles() + public function getRoleNames(): array { } diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php index 7ff05e95eef54..f00d71241e2e8 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php @@ -17,7 +17,6 @@ use Symfony\Component\Security\Core\Exception\BadCredentialsException; use Symfony\Component\Security\Core\Exception\CredentialsExpiredException; use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; -use Symfony\Component\Security\Core\Role\SwitchUserRole; class UserAuthenticationProviderTest extends TestCase { @@ -180,11 +179,6 @@ public function testAuthenticate() ->willReturn('foo') ; - $token->expects($this->once()) - ->method('getRoles') - ->willReturn([]) - ; - $authToken = $provider->authenticate($token); $this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $authToken); @@ -194,45 +188,6 @@ public function testAuthenticate() $this->assertEquals(['foo' => 'bar'], $authToken->getAttributes(), '->authenticate() copies token attributes'); } - /** - * @group legacy - */ - public function testAuthenticateWithPreservingRoleSwitchUserRole() - { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); - $user->expects($this->once()) - ->method('getRoles') - ->willReturn(['ROLE_FOO']) - ; - - $provider = $this->getProvider(); - $provider->expects($this->once()) - ->method('retrieveUser') - ->willReturn($user) - ; - - $token = $this->getSupportedToken(); - $token->expects($this->once()) - ->method('getCredentials') - ->willReturn('foo') - ; - - $switchUserRole = new SwitchUserRole('foo', $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); - $token->expects($this->once()) - ->method('getRoles') - ->willReturn([$switchUserRole]) - ; - - $authToken = $provider->authenticate($token); - - $this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $authToken); - $this->assertSame($user, $authToken->getUser()); - $this->assertContains('ROLE_FOO', $authToken->getRoleNames(), '', false, false); - $this->assertContains($switchUserRole, $authToken->getRoles(), '', false, false); - $this->assertEquals('foo', $authToken->getCredentials()); - $this->assertEquals(['foo' => 'bar'], $authToken->getAttributes(), '->authenticate() copies token attributes'); - } - public function testAuthenticatePreservesOriginalToken() { $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php index ba718689eae28..791e51c77b410 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php @@ -13,8 +13,6 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Security\Core\Authentication\Token\AbstractToken; -use Symfony\Component\Security\Core\Role\Role; -use Symfony\Component\Security\Core\User\User; use Symfony\Component\Security\Core\User\UserInterface; class AbstractTokenTest extends TestCase @@ -47,7 +45,7 @@ public function testEraseCredentials() public function testSerialize() { - $token = new ConcreteToken(['ROLE_FOO', new Role('ROLE_BAR', false)]); + $token = new ConcreteToken(['ROLE_FOO', 'ROLE_BAR']); $token->setAttributes(['foo' => 'bar']); $uToken = unserialize(serialize($token)); @@ -56,55 +54,12 @@ public function testSerialize() $this->assertEquals($token->getAttributes(), $uToken->getAttributes()); } - /** - * @group legacy - */ - public function testSerializeWithRoleObjects() - { - $user = new User('name', 'password', [new Role('ROLE_FOO'), new Role('ROLE_BAR')]); - $token = new ConcreteToken($user->getRoles(), $user); - - $serialized = serialize($token); - $unserialized = unserialize($serialized); - - $roles = $unserialized->getRoles(); - - $this->assertEquals($roles, $user->getRoles()); - } - public function testConstructor() { $token = new ConcreteToken(['ROLE_FOO']); $this->assertEquals(['ROLE_FOO'], $token->getRoleNames()); } - /** - * @group legacy - */ - public function testConstructorWithRoleObjects() - { - $token = new ConcreteToken([new Role('ROLE_FOO')]); - $this->assertEquals(['ROLE_FOO'], $token->getRoleNames()); - - $token = new ConcreteToken([new Role('ROLE_FOO'), 'ROLE_BAR']); - $this->assertEquals(['ROLE_FOO', 'ROLE_BAR'], $token->getRoleNames()); - } - - /** - * @group legacy - */ - public function testGetRoles() - { - $token = new ConcreteToken(['ROLE_FOO']); - $this->assertEquals([new Role('ROLE_FOO')], $token->getRoles()); - - $token = new ConcreteToken([new Role('ROLE_FOO')]); - $this->assertEquals([new Role('ROLE_FOO')], $token->getRoles()); - - $token = new ConcreteToken([new Role('ROLE_FOO'), 'ROLE_BAR']); - $this->assertEquals([new Role('ROLE_FOO'), new Role('ROLE_BAR')], $token->getRoles()); - } - public function testAuthenticatedFlag() { $token = new ConcreteToken(); diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php index b5bb2fe7c2a7d..3beb9bdb31fea 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/ExpressionVoterTest.php @@ -16,21 +16,9 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Authorization\Voter\ExpressionVoter; use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; -use Symfony\Component\Security\Core\Role\Role; class ExpressionVoterTest extends TestCase { - /** - * @group legacy - * @dataProvider getVoteTests - */ - public function testVote($roles, $attributes, $expected, $tokenExpectsGetRoles = true, $expressionLanguageExpectsEvaluate = true) - { - $voter = new ExpressionVoter($this->createExpressionLanguage($expressionLanguageExpectsEvaluate), $this->createTrustResolver(), $this->createAuthorizationChecker()); - - $this->assertSame($expected, $voter->vote($this->getToken($roles, $tokenExpectsGetRoles), null, $attributes)); - } - /** * @dataProvider getVoteTests */ @@ -54,22 +42,6 @@ public function getVoteTests() ]; } - protected function getToken(array $roles, $tokenExpectsGetRoles = true) - { - foreach ($roles as $i => $role) { - $roles[$i] = new Role($role); - } - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - - if ($tokenExpectsGetRoles) { - $token->expects($this->once()) - ->method('getRoles') - ->willReturn($roles); - } - - return $token; - } - protected function getTokenWithRoleNames(array $roles, $tokenExpectsGetRoles = true) { $token = $this->getMockBuilder(AbstractToken::class)->getMock(); diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleHierarchyVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleHierarchyVoterTest.php index ec21779a68ea8..571270072706b 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleHierarchyVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleHierarchyVoterTest.php @@ -17,17 +17,6 @@ class RoleHierarchyVoterTest extends RoleVoterTest { - /** - * @group legacy - * @dataProvider getVoteTests - */ - public function testVote($roles, $attributes, $expected) - { - $voter = new RoleHierarchyVoter(new RoleHierarchy(['ROLE_FOO' => ['ROLE_FOOBAR']])); - - $this->assertSame($expected, $voter->vote($this->getToken($roles), null, $attributes)); - } - /** * @dataProvider getVoteTests */ @@ -45,28 +34,6 @@ public function getVoteTests() ]); } - /** - * @group legacy - * @dataProvider getLegacyVoteOnRoleObjectsTests - */ - public function testVoteOnRoleObjects($roles, $attributes, $expected) - { - $voter = new RoleHierarchyVoter(new RoleHierarchy(['ROLE_FOO' => ['ROLE_FOOBAR']])); - - $this->assertSame($expected, $voter->vote($this->getToken($roles), null, $attributes)); - } - - /** - * @group legacy - * @dataProvider getVoteWithEmptyHierarchyTests - */ - public function testVoteWithEmptyHierarchy($roles, $attributes, $expected) - { - $voter = new RoleHierarchyVoter(new RoleHierarchy([])); - - $this->assertSame($expected, $voter->vote($this->getToken($roles), null, $attributes)); - } - /** * @dataProvider getVoteWithEmptyHierarchyTests */ diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php index 7f417b2dfa76d..6b473c6ffc14f 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/Voter/RoleVoterTest.php @@ -15,21 +15,9 @@ use Symfony\Component\Security\Core\Authentication\Token\AbstractToken; use Symfony\Component\Security\Core\Authorization\Voter\RoleVoter; use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; -use Symfony\Component\Security\Core\Role\Role; class RoleVoterTest extends TestCase { - /** - * @group legacy - * @dataProvider getVoteTests - */ - public function testVote($roles, $attributes, $expected) - { - $voter = new RoleVoter(); - - $this->assertSame($expected, $voter->vote($this->getToken($roles), null, $attributes)); - } - /** * @dataProvider getVoteTests */ @@ -56,38 +44,6 @@ public function getVoteTests() ]; } - /** - * @group legacy - * @dataProvider getLegacyVoteOnRoleObjectsTests - */ - public function testVoteOnRoleObjects($roles, $attributes, $expected) - { - $voter = new RoleVoter(); - - $this->assertSame($expected, $voter->vote($this->getToken($roles), null, $attributes)); - } - - public function getLegacyVoteOnRoleObjectsTests() - { - return [ - [['ROLE_BAR'], [new Role('ROLE_BAR')], VoterInterface::ACCESS_GRANTED], - [['ROLE_BAR'], [new Role('ROLE_FOO')], VoterInterface::ACCESS_DENIED], - ]; - } - - protected function getToken(array $roles) - { - foreach ($roles as $i => $role) { - $roles[$i] = new Role($role); - } - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $token->expects($this->once()) - ->method('getRoles') - ->willReturn($roles); - - return $token; - } - protected function getTokenWithRoleNames(array $roles) { $token = $this->getMockBuilder(AbstractToken::class)->getMock(); diff --git a/src/Symfony/Component/Security/Core/Tests/Role/RoleHierarchyTest.php b/src/Symfony/Component/Security/Core/Tests/Role/RoleHierarchyTest.php index e24ed84d2dd74..b84889f57a6cd 100644 --- a/src/Symfony/Component/Security/Core/Tests/Role/RoleHierarchyTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Role/RoleHierarchyTest.php @@ -12,28 +12,10 @@ namespace Symfony\Component\Security\Core\Tests\Role; use PHPUnit\Framework\TestCase; -use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\RoleHierarchy; class RoleHierarchyTest extends TestCase { - /** - * @group legacy - */ - public function testGetReachableRoles() - { - $role = new RoleHierarchy([ - 'ROLE_ADMIN' => ['ROLE_USER'], - 'ROLE_SUPER_ADMIN' => ['ROLE_ADMIN', 'ROLE_FOO'], - ]); - - $this->assertEquals([new Role('ROLE_USER')], $role->getReachableRoles([new Role('ROLE_USER')])); - $this->assertEquals([new Role('ROLE_FOO')], $role->getReachableRoles([new Role('ROLE_FOO')])); - $this->assertEquals([new Role('ROLE_ADMIN'), new Role('ROLE_USER')], $role->getReachableRoles([new Role('ROLE_ADMIN')])); - $this->assertEquals([new Role('ROLE_FOO'), new Role('ROLE_ADMIN'), new Role('ROLE_USER')], $role->getReachableRoles([new Role('ROLE_FOO'), new Role('ROLE_ADMIN')])); - $this->assertEquals([new Role('ROLE_SUPER_ADMIN'), new Role('ROLE_ADMIN'), new Role('ROLE_FOO'), new Role('ROLE_USER')], $role->getReachableRoles([new Role('ROLE_SUPER_ADMIN')])); - } - public function testGetReachableRoleNames() { $role = new RoleHierarchy([ diff --git a/src/Symfony/Component/Security/Core/Tests/Role/RoleTest.php b/src/Symfony/Component/Security/Core/Tests/Role/RoleTest.php deleted file mode 100644 index e872a8c36b4ab..0000000000000 --- a/src/Symfony/Component/Security/Core/Tests/Role/RoleTest.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Tests\Role; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Security\Core\Role\Role; - -/** - * @group legacy - */ -class RoleTest extends TestCase -{ - public function testGetRole() - { - $role = new Role('FOO'); - - $this->assertEquals('FOO', $role->getRole()); - } -} diff --git a/src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php b/src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php deleted file mode 100644 index 88f6a18abf7d1..0000000000000 --- a/src/Symfony/Component/Security/Core/Tests/Role/SwitchUserRoleTest.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Tests\Role; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Security\Core\Role\SwitchUserRole; - -/** - * @group legacy - */ -class SwitchUserRoleTest extends TestCase -{ - public function testGetSource() - { - $role = new SwitchUserRole('FOO', $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); - - $this->assertSame($token, $role->getSource()); - } - - public function testGetRole() - { - $role = new SwitchUserRole('FOO', $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()); - - $this->assertEquals('FOO', $role->getRole()); - } -} diff --git a/src/Symfony/Component/Security/Core/User/UserInterface.php b/src/Symfony/Component/Security/Core/User/UserInterface.php index 043ca815803d5..80f1654c61109 100644 --- a/src/Symfony/Component/Security/Core/User/UserInterface.php +++ b/src/Symfony/Component/Security/Core/User/UserInterface.php @@ -11,8 +11,6 @@ namespace Symfony\Component\Security\Core\User; -use Symfony\Component\Security\Core\Role\Role; - /** * Represents the interface that all user classes must implement. * @@ -44,7 +42,7 @@ interface UserInterface * and populated in any number of different ways when the user object * is created. * - * @return (Role|string)[] The user roles + * @return string[] The user roles */ public function getRoles(); diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index 16cdc8f9e23f8..98f84d04c0b54 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -25,7 +25,6 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Exception\UnsupportedUserException; use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; -use Symfony\Component\Security\Core\Role\SwitchUserRole; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Http\Event\DeauthenticatedEvent; @@ -197,13 +196,6 @@ protected function refreshUser(TokenInterface $token) if ($token instanceof SwitchUserToken) { $context['impersonator_username'] = $token->getOriginalToken()->getUsername(); - } else { - foreach ($token->getRoles(false) as $role) { - if ($role instanceof SwitchUserRole) { - $context['impersonator_username'] = $role->getSource(false)->getUsername(); - break; - } - } } $this->logger->debug('User was reloaded from a user provider.', $context); diff --git a/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php b/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php index c94eb7e89b380..e0fa3134f7424 100644 --- a/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php @@ -23,7 +23,6 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException; use Symfony\Component\Security\Core\Exception\AuthenticationException; -use Symfony\Component\Security\Core\Role\SwitchUserRole; use Symfony\Component\Security\Core\User\UserCheckerInterface; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserProviderInterface; @@ -151,7 +150,6 @@ private function attemptSwitchUser(Request $request, $username) $this->userChecker->checkPostAuth($user); $roles = $user->getRoles(); - $roles[] = new SwitchUserRole('ROLE_PREVIOUS_ADMIN', $this->tokenStorage->getToken(), false); $token = new SwitchUserToken($user, $user->getPassword(), $this->providerKey, $roles, $token); @@ -194,12 +192,6 @@ private function getOriginalToken(TokenInterface $token): ?TokenInterface return $token->getOriginalToken(); } - foreach ($token->getRoles(false) as $role) { - if ($role instanceof SwitchUserRole) { - return $role->getSource(); - } - } - return null; } } diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php index 9c980186d4a91..d343cf732858e 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php @@ -18,7 +18,6 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken; use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; -use Symfony\Component\Security\Core\Role\SwitchUserRole; use Symfony\Component\Security\Core\User\User; use Symfony\Component\Security\Http\Event\SwitchUserEvent; use Symfony\Component\Security\Http\Firewall\SwitchUserListener; @@ -95,7 +94,7 @@ public function testExitUserThrowsAuthenticationExceptionIfOriginalTokenCannotBe public function testExitUserUpdatesToken() { $originalToken = new UsernamePasswordToken('username', '', 'key', []); - $this->tokenStorage->setToken(new SwitchUserToken('username', '', 'key', [new SwitchUserRole('ROLE_PREVIOUS', $originalToken, false)], $originalToken)); + $this->tokenStorage->setToken(new SwitchUserToken('username', '', 'key', ['ROLE_USER'], $originalToken)); $this->request->query->set('_switch_user', SwitchUserListener::EXIT_VALUE); @@ -109,22 +108,6 @@ public function testExitUserUpdatesToken() $this->assertSame($originalToken, $this->tokenStorage->getToken()); } - /** - * @group legacy - */ - public function testExitUserBasedOnSwitchUserRoleUpdatesToken() - { - $originalToken = new UsernamePasswordToken('username', '', 'key', []); - $this->tokenStorage->setToken(new UsernamePasswordToken('username', '', 'key', [new SwitchUserRole('ROLE_PREVIOUS', $originalToken, false)], $originalToken)); - - $this->request->query->set('_switch_user', SwitchUserListener::EXIT_VALUE); - - $listener = new SwitchUserListener($this->tokenStorage, $this->userProvider, $this->userChecker, 'provider123', $this->accessDecisionManager); - $listener($this->event); - - $this->assertSame($originalToken, $this->tokenStorage->getToken()); - } - public function testExitUserDispatchesEventWithRefreshedUser() { $originalUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); @@ -136,7 +119,7 @@ public function testExitUserDispatchesEventWithRefreshedUser() ->with($originalUser) ->willReturn($refreshedUser); $originalToken = new UsernamePasswordToken($originalUser, '', 'key'); - $this->tokenStorage->setToken(new SwitchUserToken('username', '', 'key', [new SwitchUserRole('ROLE_PREVIOUS', $originalToken, false)], $originalToken)); + $this->tokenStorage->setToken(new SwitchUserToken('username', '', 'key', ['ROLE_USER'], $originalToken)); $this->request->query->set('_switch_user', SwitchUserListener::EXIT_VALUE); $dispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMock(); @@ -163,7 +146,7 @@ public function testExitUserDoesNotDispatchEventWithStringUser() ->expects($this->never()) ->method('refreshUser'); $originalToken = new UsernamePasswordToken($originalUser, '', 'key'); - $this->tokenStorage->setToken(new SwitchUserToken('username', '', 'key', [new SwitchUserRole('ROLE_PREVIOUS', $originalToken, false)], $originalToken)); + $this->tokenStorage->setToken(new SwitchUserToken('username', '', 'key', ['ROLE_USER'], $originalToken)); $this->request->query->set('_switch_user', SwitchUserListener::EXIT_VALUE); $dispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMock(); diff --git a/src/Symfony/Component/Workflow/EventListener/GuardListener.php b/src/Symfony/Component/Workflow/EventListener/GuardListener.php index 669d394a43f9d..cb322554adcb0 100644 --- a/src/Symfony/Component/Workflow/EventListener/GuardListener.php +++ b/src/Symfony/Component/Workflow/EventListener/GuardListener.php @@ -13,9 +13,7 @@ use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; -use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\RoleHierarchyInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Workflow\Event\GuardEvent; @@ -37,10 +35,6 @@ class GuardListener public function __construct(array $configuration, ExpressionLanguage $expressionLanguage, TokenStorageInterface $tokenStorage, AuthorizationCheckerInterface $authorizationChecker, AuthenticationTrustResolverInterface $trustResolver, RoleHierarchyInterface $roleHierarchy = null, ValidatorInterface $validator = null) { - if (null !== $roleHierarchy && !method_exists($roleHierarchy, 'getReachableRoleNames')) { - @trigger_error(sprintf('Not implementing the getReachableRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($roleHierarchy), RoleHierarchyInterface::class), E_USER_DEPRECATED); - } - $this->configuration = $configuration; $this->expressionLanguage = $expressionLanguage; $this->tokenStorage = $tokenStorage; @@ -86,29 +80,16 @@ private function getVariables(GuardEvent $event): array throw new InvalidTokenConfigurationException(sprintf('There are no tokens available for workflow %s.', $event->getWorkflowName())); } - if (method_exists($token, 'getRoleNames')) { - $roleNames = $token->getRoleNames(); - $roles = array_map(function (string $role) { return new Role($role, false); }, $roleNames); - } else { - @trigger_error(sprintf('Not implementing the getRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($token), TokenInterface::class), E_USER_DEPRECATED); - - $roles = $token->getRoles(false); - $roleNames = array_map(function (Role $role) { return $role->getRole(); }, $roles); - } + $roleNames = $token->getRoleNames(); - if (null !== $this->roleHierarchy && method_exists($this->roleHierarchy, 'getReachableRoleNames')) { + if (null !== $this->roleHierarchy) { $roleNames = $this->roleHierarchy->getReachableRoleNames($roleNames); - $roles = array_map(function (string $role) { return new Role($role, false); }, $roleNames); - } elseif (null !== $this->roleHierarchy) { - $roles = $this->roleHierarchy->getReachableRoles($roles); - $roleNames = array_map(function (Role $role) { return $role->getRole(); }, $roles); } $variables = [ 'token' => $token, 'user' => $token->getUser(), 'subject' => $event->getSubject(), - 'roles' => $roles, 'role_names' => $roleNames, // needed for the is_granted expression function 'auth_checker' => $this->authorizationChecker, From 75179d311487948e09b5adc50f1b03f30dc6240b Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Sat, 1 Jun 2019 00:15:03 +0200 Subject: [PATCH 041/588] [Form] do not iterate twice on the extended types --- src/Symfony/Component/Form/AbstractExtension.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Symfony/Component/Form/AbstractExtension.php b/src/Symfony/Component/Form/AbstractExtension.php index 3af81e29e9112..86a26a54009c2 100644 --- a/src/Symfony/Component/Form/AbstractExtension.php +++ b/src/Symfony/Component/Form/AbstractExtension.php @@ -175,12 +175,7 @@ private function initTypeExtensions() throw new UnexpectedTypeException($extension, 'Symfony\Component\Form\FormTypeExtensionInterface'); } - $extendedTypes = []; foreach ($extension::getExtendedTypes() as $extendedType) { - $extendedTypes[] = $extendedType; - } - - foreach ($extendedTypes as $extendedType) { $this->typeExtensions[$extendedType][] = $extension; } } From 12ed0df2239916ab4654230ddd148a4922766814 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 31 May 2019 13:24:23 +0200 Subject: [PATCH 042/588] remove deprecated date types options handling --- .../AbstractBootstrap3LayoutTest.php | 5 +++ src/Symfony/Component/Form/CHANGELOG.md | 3 ++ .../Form/Extension/Core/Type/DateTimeType.php | 33 ++++++++----------- .../Form/Extension/Core/Type/DateType.php | 8 ++--- .../Form/Tests/AbstractLayoutTest.php | 23 ------------- .../Form/Tests/Command/DebugCommandTest.php | 2 +- .../Extension/Core/Type/DateTimeTypeTest.php | 16 ++------- 7 files changed, 28 insertions(+), 62 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php index b332ff018d742..540d23c8a6e73 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php @@ -13,6 +13,7 @@ use Symfony\Component\Form\Extension\Core\Type\PercentType; use Symfony\Component\Form\FormError; +use Symfony\Component\Form\FormTypeExtensionInterface; use Symfony\Component\Form\Tests\AbstractLayoutTest; abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest @@ -1693,6 +1694,10 @@ public function testDateTimeWithWidgetSingleText() */ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() { + if (method_exists(FormTypeExtensionInterface::class, 'getExtendedTypes')) { + $this->markTestSkipped('The test requires symfony/form 4.x.'); + } + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', [ 'input' => 'string', 'date_widget' => 'choice', diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index 34d3d196d439d..264396a0de7ee 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -4,6 +4,9 @@ CHANGELOG 5.0.0 ----- + * Using the `date_format`, `date_widget`, and `time_widget` options of the `DateTimeType` when the `widget` option is + set to `single_text` is not supported anymore. + * The `format` option of `DateType` and `DateTimeType` cannot be used when the `html5` option is enabled. * Using names for buttons that do not start with a letter, a digit, or an underscore throw an exception * Using names for buttons that do not contain only letters, digits, underscores, hyphens, and colons throw an exception. * removed the `ChoiceLoaderInterface` implementation in `CountryType`, `LanguageType`, `LocaleType` and `CurrencyType` diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php index 4e84b71a7c8e4..3bd61df513690 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Form\Extension\Core\Type; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Exception\LogicException; use Symfony\Component\Form\Extension\Core\DataTransformer\ArrayToPartsTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DataTransformerChain; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeImmutableToDateTimeTransformer; @@ -159,10 +160,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) $dateOptions['input'] = $timeOptions['input'] = 'array'; $dateOptions['error_bubbling'] = $timeOptions['error_bubbling'] = true; - if (isset($dateOptions['format']) && DateType::HTML5_FORMAT !== $dateOptions['format']) { - $dateOptions['html5'] = false; - } - $builder ->addViewTransformer(new DataTransformerChain([ new DateTimeToArrayTransformer($options['model_timezone'], $options['view_timezone'], $parts), @@ -300,37 +297,33 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setAllowedTypes('input_format', 'string'); - $resolver->setDeprecated('date_format', function (Options $options, $dateFormat) { + $resolver->setNormalizer('date_format', function (Options $options, $dateFormat) { if (null !== $dateFormat && 'single_text' === $options['widget'] && self::HTML5_FORMAT === $options['format']) { - return sprintf('Using the "date_format" option of %s with an HTML5 date widget is deprecated since Symfony 4.3 and will lead to an exception in 5.0.', self::class); - //throw new LogicException(sprintf('Cannot use the "date_format" option of the %s with an HTML5 date.', self::class)); + throw new LogicException(sprintf('Cannot use the "date_format" option of the %s with an HTML5 date.', self::class)); } - return ''; + return $dateFormat; }); - $resolver->setDeprecated('date_widget', function (Options $options, $dateWidget) { + $resolver->setNormalizer('date_widget', function (Options $options, $dateWidget) { if (null !== $dateWidget && 'single_text' === $options['widget']) { - return sprintf('Using the "date_widget" option of %s when the "widget" option is set to "single_text" is deprecated since Symfony 4.3 and will lead to an exception in 5.0.', self::class); - //throw new LogicException(sprintf('Cannot use the "date_widget" option of the %s when the "widget" option is set to "single_text".', self::class)); + throw new LogicException(sprintf('Cannot use the "date_widget" option of the %s when the "widget" option is set to "single_text".', self::class)); } - return ''; + return $dateWidget; }); - $resolver->setDeprecated('time_widget', function (Options $options, $timeWidget) { + $resolver->setNormalizer('time_widget', function (Options $options, $timeWidget) { if (null !== $timeWidget && 'single_text' === $options['widget']) { - return sprintf('Using the "time_widget" option of %s when the "widget" option is set to "single_text" is deprecated since Symfony 4.3 and will lead to an exception in 5.0.', self::class); - //throw new LogicException(sprintf('Cannot use the "time_widget" option of the %s when the "widget" option is set to "single_text".', self::class)); + throw new LogicException(sprintf('Cannot use the "time_widget" option of the %s when the "widget" option is set to "single_text".', self::class)); } - return ''; + return $timeWidget; }); - $resolver->setDeprecated('html5', function (Options $options, $html5) { + $resolver->setNormalizer('html5', function (Options $options, $html5) { if ($html5 && self::HTML5_FORMAT !== $options['format']) { - return sprintf('Using a custom format when the "html5" option of %s is enabled is deprecated since Symfony 4.3 and will lead to an exception in 5.0.', self::class); - //throw new LogicException(sprintf('Cannot use the "format" option of %s when the "html5" option is disabled.', self::class)); + throw new LogicException(sprintf('Cannot use the "format" option of %s when the "html5" option is disabled.', self::class)); } - return ''; + return $html5; }); } diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index 39002df2b6d24..03e55ce13d266 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Form\Extension\Core\Type; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Exception\LogicException; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeImmutableToDateTimeTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer; use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer; @@ -308,13 +309,12 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setAllowedTypes('days', 'array'); $resolver->setAllowedTypes('input_format', 'string'); - $resolver->setDeprecated('html5', function (Options $options, $html5) { + $resolver->setNormalizer('html5', function (Options $options, $html5) { if ($html5 && 'single_text' === $options['widget'] && self::HTML5_FORMAT !== $options['format']) { - return sprintf('Using a custom format when the "html5" option of %s is enabled is deprecated since Symfony 4.3 and will lead to an exception in 5.0.', self::class); - //throw new LogicException(sprintf('Cannot use the "format" option of %s when the "html5" option is disabled.', self::class)); + throw new LogicException(sprintf('Cannot use the "format" option of %s when the "html5" option is disabled.', self::class)); } - return ''; + return $html5; }); } diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index b03ac0f9fc4d9..16344f9149d4e 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -1509,29 +1509,6 @@ public function testDateTimeWithWidgetSingleText() ); } - /** - * @group legacy - */ - public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() - { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateTimeType', '2011-02-03 04:05:06', [ - 'input' => 'string', - 'date_widget' => 'choice', - 'time_widget' => 'choice', - 'widget' => 'single_text', - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - ]); - - $this->assertWidgetMatchesXpath($form->createView(), [], -'/input - [@type="datetime-local"] - [@name="name"] - [@value="2011-02-03T04:05:06"] -' - ); - } - public function testDateChoice() { $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\DateType', date('Y').'-02-03', [ diff --git a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php index f2a1b89f0e103..a2d105d2236f7 100644 --- a/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Form/Tests/Command/DebugCommandTest.php @@ -45,7 +45,7 @@ public function testDebugDeprecatedDefaults() Built-in form types (Symfony\Component\Form\Extension\Core\Type) ---------------------------------------------------------------- - BirthdayType, DateTimeType, DateType, IntegerType + IntegerType Service form types ------------------ diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php index 93935157fe9c2..f898212b3bc92 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php @@ -301,6 +301,7 @@ public function testSubmitStringSingleTextWithSeconds() public function testSubmitDifferentPattern() { $form = $this->factory->create(static::TESTED_TYPE, null, [ + 'html5' => false, 'date_format' => 'MM*yyyy*dd', 'date_widget' => 'single_text', 'time_widget' => 'single_text', @@ -470,20 +471,6 @@ public function testDontPassHtml5TypeIfHtml5NotAllowed() $this->assertArrayNotHasKey('type', $view->vars); } - /** - * @group legacy - */ - public function testDontPassHtml5TypeIfNotHtml5Format() - { - $view = $this->factory->create(static::TESTED_TYPE, null, [ - 'widget' => 'single_text', - 'format' => 'yyyy-MM-dd HH:mm', - ]) - ->createView(); - - $this->assertArrayNotHasKey('type', $view->vars); - } - public function testDontPassHtml5TypeIfNotSingleText() { $view = $this->factory->create(static::TESTED_TYPE, null, [ @@ -497,6 +484,7 @@ public function testDontPassHtml5TypeIfNotSingleText() public function testSingleTextWidgetWithCustomNonHtml5Format() { $form = $this->factory->create(static::TESTED_TYPE, new \DateTime('2019-02-13 19:12:13'), [ + 'html5' => false, 'widget' => 'single_text', 'date_format' => \IntlDateFormatter::SHORT, 'format' => null, From d5be373cacc51c3bd5cdc7633d66c5505d3f43f3 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Sun, 2 Jun 2019 22:41:00 -0400 Subject: [PATCH 043/588] Removed support for PHP templating everywhere --- src/Symfony/Bridge/Twig/CHANGELOG.md | 5 + .../Fixtures/StubFilesystemLoader.php | 25 -- ...xtensionBootstrap3HorizontalLayoutTest.php | 4 +- .../FormExtensionBootstrap3LayoutTest.php | 6 +- ...xtensionBootstrap4HorizontalLayoutTest.php | 4 +- .../FormExtensionBootstrap4LayoutTest.php | 6 +- .../Extension/FormExtensionDivLayoutTest.php | 6 +- .../FormExtensionTableLayoutTest.php | 4 +- .../Bridge/Twig/Tests/TwigEngineTest.php | 84 ------ src/Symfony/Bridge/Twig/TwigEngine.php | 134 --------- src/Symfony/Bridge/Twig/composer.json | 2 - .../Bundle/FrameworkBundle/CHANGELOG.md | 1 + .../CacheWarmer/TemplateFinder.php | 115 -------- .../CacheWarmer/TemplateFinderInterface.php | 31 -- .../CacheWarmer/TemplatePathsCacheWarmer.php | 66 ----- .../Controller/AbstractController.php | 2 - .../Controller/ControllerTrait.php | 42 +-- .../Controller/TemplateController.php | 19 +- .../Compiler/TemplatingPass.php | 62 ---- .../Compiler/UnusedTagsPass.php | 1 - .../DependencyInjection/Configuration.php | 62 ---- .../FrameworkExtension.php | 123 +------- .../FrameworkBundle/FrameworkBundle.php | 2 - .../Resources/config/fragment_renderer.xml | 2 +- .../Resources/config/routing.xml | 1 - .../Resources/config/schema/symfony-1.0.xsd | 13 - .../Resources/config/templating.xml | 67 ----- .../Resources/config/templating_debug.xml | 21 -- .../Resources/config/templating_php.xml | 116 -------- .../Templating/DelegatingEngine.php | 78 ----- .../Templating/EngineInterface.php | 40 --- .../Templating/GlobalVariables.php | 98 ------- .../Templating/Helper/ActionsHelper.php | 66 ----- .../Templating/Helper/AssetsHelper.php | 71 ----- .../Templating/Helper/CodeHelper.php | 231 --------------- .../Templating/Helper/FormHelper.php | 271 ------------------ .../Templating/Helper/RequestHelper.php | 76 ----- .../Templating/Helper/RouterHelper.php | 74 ----- .../Templating/Helper/SessionHelper.php | 84 ------ .../Templating/Helper/StopwatchHelper.php | 50 ---- .../Templating/Helper/TranslatorHelper.php | 84 ------ .../Templating/Loader/FilesystemLoader.php | 66 ----- .../Templating/Loader/TemplateLocator.php | 89 ------ .../FrameworkBundle/Templating/PhpEngine.php | 82 ------ .../Templating/TemplateFilenameParser.php | 49 ---- .../Templating/TemplateNameParser.php | 73 ----- .../Templating/TemplateReference.php | 61 ---- .../Templating/TimedPhpEngine.php | 52 ---- .../Tests/CacheWarmer/TemplateFinderTest.php | 60 ---- .../TemplatePathsCacheWarmerTest.php | 105 ------- .../Controller/AbstractControllerTest.php | 1 - .../Tests/Controller/ControllerTraitTest.php | 50 ---- .../Controller/TemplateControllerTest.php | 19 +- .../DependencyInjection/ConfigurationTest.php | 22 -- .../Fixtures/php/template_and_fragments.php | 18 -- .../Fixtures/php/templating.php | 14 - .../Fixtures/php/templating_disabled.php | 5 - .../Fixtures/php/templating_no_assets.php | 7 - .../php/templating_php_assets_disabled.php | 8 - .../Fixtures/xml/template_and_fragments.xml | 24 -- .../Fixtures/xml/templating.xml | 22 -- .../Fixtures/xml/templating_disabled.xml | 11 - .../Fixtures/xml/templating_no_assets.xml | 14 - .../templating_php_translator_disabled.xml | 14 - .../xml/templating_php_translator_enabled.xml | 14 - .../Fixtures/yml/template_and_fragments.yml | 12 - .../Fixtures/yml/templating.yml | 9 - .../Fixtures/yml/templating_disabled.yml | 2 - .../Fixtures/yml/templating_no_assets.yml | 3 - .../yml/templating_php_assets_disabled.yml | 4 - .../templating_php_translator_disabled.yml | 4 - .../yml/templating_php_translator_enabled.yml | 4 - .../FrameworkExtensionTest.php | 96 ------- .../Tests/Functional/AutowiringTypesTest.php | 14 - .../AutowiringTypes/TemplatingServices.php | 31 -- .../app/AutowiringTypes/templating.yml | 12 - .../Tests/Templating/DelegatingEngineTest.php | 128 --------- .../Tests/Templating/GlobalVariablesTest.php | 109 ------- .../Templating/Helper/AssetsHelperTest.php | 48 ---- .../Fixtures/StubTemplateNameParser.php | 43 --- .../Helper/Fixtures/StubTranslator.php | 22 -- .../Helper/FormHelperDivLayoutTest.php | 264 ----------------- .../Helper/FormHelperTableLayoutTest.php | 159 ---------- .../Templating/Helper/RequestHelperTest.php | 57 ---- .../Resources/Child/form_label.html.php | 1 - .../Custom/_name_c_entry_label.html.php | 2 - .../Custom/_names_entry_label.html.php | 4 - .../Resources/Custom/_text_id_widget.html.php | 3 - .../Resources/Parent/form_label.html.php | 1 - .../Parent/form_widget_simple.html.php | 2 - .../Templating/Helper/SessionHelperTest.php | 78 ----- .../Templating/Helper/StopwatchHelperTest.php | 42 --- .../Templating/Loader/TemplateLocatorTest.php | 101 ------- .../Tests/Templating/PhpEngineTest.php | 79 ----- .../Templating/TemplateFilenameParserTest.php | 59 ---- .../Templating/TemplateNameParserTest.php | 87 ------ .../Templating/TemplateReferenceTest.php | 31 -- .../Tests/Templating/TemplateTest.php | 39 --- .../Tests/Templating/TimedPhpEngineTest.php | 119 -------- .../Bundle/FrameworkBundle/composer.json | 4 +- .../Bundle/SecurityBundle/CHANGELOG.md | 11 +- .../DependencyInjection/SecurityExtension.php | 4 - .../Resources/config/templating_php.xml | 24 -- .../Templating/Helper/LogoutUrlHelper.php | 66 ----- .../Templating/Helper/SecurityHelper.php | 56 ---- src/Symfony/Bundle/TwigBundle/CHANGELOG.md | 2 + .../CacheWarmer/TemplateCacheCacheWarmer.php | 127 -------- .../Compiler/ExceptionListenerPass.php | 9 +- .../Compiler/ExtensionPass.php | 23 +- .../DependencyInjection/TwigExtension.php | 10 - .../TwigBundle/Loader/FilesystemLoader.php | 102 ------- .../Loader/NativeFilesystemLoader.php | 50 ---- .../Resources/config/templating.xml | 24 -- .../TwigBundle/Resources/config/twig.xml | 10 - .../Compiler/ExtensionPassTest.php | 8 +- .../DependencyInjection/TwigExtensionTest.php | 5 - .../Tests/Functional/CacheWarmingTest.php | 129 --------- .../Tests/Loader/FilesystemLoaderTest.php | 131 --------- .../Loader/NativeFilesystemLoaderTest.php | 41 --- src/Symfony/Bundle/TwigBundle/TwigEngine.php | 80 ------ src/Symfony/Bundle/TwigBundle/composer.json | 5 +- src/Symfony/Component/Form/CHANGELOG.md | 1 + .../Templating/TemplatingExtension.php | 37 --- .../Templating/TemplatingRendererEngine.php | 128 --------- src/Symfony/Component/HttpKernel/CHANGELOG.md | 1 + .../Fragment/HIncludeFragmentRenderer.php | 50 +--- .../Fragment/HIncludeFragmentRendererTest.php | 16 -- .../Component/HttpKernel/composer.json | 1 - 128 files changed, 80 insertions(+), 5873 deletions(-) delete mode 100644 src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubFilesystemLoader.php delete mode 100644 src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php delete mode 100644 src/Symfony/Bridge/Twig/TwigEngine.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinderInterface.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/EngineInterface.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/Helper/AssetsHelper.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/Helper/TranslatorHelper.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/Loader/FilesystemLoader.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/TemplateFilenameParser.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/template_and_fragments.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_disabled.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/template_and_fragments.xml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating.xml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_disabled.xml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_no_assets.xml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_php_translator_disabled.xml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_php_translator_enabled.xml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/template_and_fragments.yml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating.yml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_disabled.yml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_no_assets.yml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_assets_disabled.yml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_translator_disabled.yml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_translator_enabled.yml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/TemplatingServices.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/templating.yml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelperTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTemplateNameParser.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTranslator.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/RequestHelperTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Child/form_label.html.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_c_entry_label.html.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_names_entry_label.html.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_text_id_widget.html.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Parent/form_label.html.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Parent/form_widget_simple.html.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateReferenceTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php delete mode 100644 src/Symfony/Bundle/SecurityBundle/Resources/config/templating_php.xml delete mode 100644 src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php delete mode 100644 src/Symfony/Bundle/SecurityBundle/Templating/Helper/SecurityHelper.php delete mode 100644 src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php delete mode 100644 src/Symfony/Bundle/TwigBundle/Loader/NativeFilesystemLoader.php delete mode 100644 src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml delete mode 100644 src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php delete mode 100644 src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php delete mode 100644 src/Symfony/Bundle/TwigBundle/Tests/Loader/NativeFilesystemLoaderTest.php delete mode 100644 src/Symfony/Bundle/TwigBundle/TwigEngine.php delete mode 100644 src/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php delete mode 100644 src/Symfony/Component/Form/Extension/Templating/TemplatingRendererEngine.php diff --git a/src/Symfony/Bridge/Twig/CHANGELOG.md b/src/Symfony/Bridge/Twig/CHANGELOG.md index 2fbfe125b5aaf..3aa0183fabc4f 100644 --- a/src/Symfony/Bridge/Twig/CHANGELOG.md +++ b/src/Symfony/Bridge/Twig/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.0.0 +----- + + * removed `TwigEngine` class, use `\Twig\Environment` instead. + 4.4.0 ----- diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubFilesystemLoader.php b/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubFilesystemLoader.php deleted file mode 100644 index 4cbc55b46a66c..0000000000000 --- a/src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubFilesystemLoader.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\Twig\Tests\Extension\Fixtures; - -use Twig\Loader\FilesystemLoader; - -class StubFilesystemLoader extends FilesystemLoader -{ - protected function findTemplate($name, $throw = true) - { - // strip away bundle name - $parts = explode(':', $name); - - return parent::findTemplate(end($parts), $throw); - } -} diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php index 384b9391cc4d6..43946ab828559 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php @@ -14,11 +14,11 @@ use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Bridge\Twig\Form\TwigRendererEngine; -use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; use Twig\Environment; +use Twig\Loader\FilesystemLoader; class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3HorizontalLayoutTest { @@ -37,7 +37,7 @@ protected function setUp() { parent::setUp(); - $loader = new StubFilesystemLoader([ + $loader = new FilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', ]); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php index 2e75e3f7a852b..ae42b16b0b036 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php @@ -14,11 +14,11 @@ use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Bridge\Twig\Form\TwigRendererEngine; -use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; use Twig\Environment; +use Twig\Loader\FilesystemLoader; class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest { @@ -33,7 +33,7 @@ protected function setUp() { parent::setUp(); - $loader = new StubFilesystemLoader([ + $loader = new FilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', ]); @@ -76,7 +76,7 @@ public function testStartTagHasActionAttributeWhenActionIsZero() public function testMoneyWidgetInIso() { - $environment = new Environment(new StubFilesystemLoader([ + $environment = new Environment(new FilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', ]), ['strict_variables' => true]); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php index 243658764cc08..2f6dd333c889f 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php @@ -14,11 +14,11 @@ use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Bridge\Twig\Form\TwigRendererEngine; -use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; use Twig\Environment; +use Twig\Loader\FilesystemLoader; /** * Class providing test cases for the Bootstrap 4 Twig form theme. @@ -39,7 +39,7 @@ protected function setUp() { parent::setUp(); - $loader = new StubFilesystemLoader([ + $loader = new FilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', ]); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php index a0290a2049da6..4331a3d945bb6 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap4LayoutTest.php @@ -14,11 +14,11 @@ use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Bridge\Twig\Form\TwigRendererEngine; -use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; use Twig\Environment; +use Twig\Loader\FilesystemLoader; /** * Class providing test cases for the Bootstrap 4 horizontal Twig form theme. @@ -37,7 +37,7 @@ protected function setUp() { parent::setUp(); - $loader = new StubFilesystemLoader([ + $loader = new FilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', ]); @@ -80,7 +80,7 @@ public function testStartTagHasActionAttributeWhenActionIsZero() public function testMoneyWidgetInIso() { - $environment = new Environment(new StubFilesystemLoader([ + $environment = new Environment(new FilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', ]), ['strict_variables' => true]); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index e40e57505a0a5..807f58c384387 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -14,13 +14,13 @@ use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Bridge\Twig\Form\TwigRendererEngine; -use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator; use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; use Symfony\Component\Form\Tests\AbstractDivLayoutTest; use Twig\Environment; +use Twig\Loader\FilesystemLoader; class FormExtensionDivLayoutTest extends AbstractDivLayoutTest { @@ -37,7 +37,7 @@ protected function setUp() { parent::setUp(); - $loader = new StubFilesystemLoader([ + $loader = new FilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', ]); @@ -169,7 +169,7 @@ public function testIsRootForm($expected, FormView $formView) public function testMoneyWidgetInIso() { - $environment = new Environment(new StubFilesystemLoader([ + $environment = new Environment(new FilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', ]), ['strict_variables' => true]); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php index 9570e03e523c7..ecafc8b8de87f 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php @@ -14,12 +14,12 @@ use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Bridge\Twig\Form\TwigRendererEngine; -use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubFilesystemLoader; use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; use Symfony\Component\Form\Tests\AbstractTableLayoutTest; use Twig\Environment; +use Twig\Loader\FilesystemLoader; class FormExtensionTableLayoutTest extends AbstractTableLayoutTest { @@ -36,7 +36,7 @@ protected function setUp() { parent::setUp(); - $loader = new StubFilesystemLoader([ + $loader = new FilesystemLoader([ __DIR__.'/../../Resources/views/Form', __DIR__.'/Fixtures/templates/form', ]); diff --git a/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php b/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php deleted file mode 100644 index 89eba52167945..0000000000000 --- a/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\Twig\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Bridge\Twig\TwigEngine; -use Symfony\Component\Templating\TemplateReference; -use Twig\Environment; -use Twig\Loader\ArrayLoader; - -/** - * @group legacy - */ -class TwigEngineTest extends TestCase -{ - public function testExistsWithTemplateInstances() - { - $engine = $this->getTwig(); - - $this->assertTrue($engine->exists($this->getMockForAbstractClass('Twig\Template', [], '', false))); - } - - public function testExistsWithNonExistentTemplates() - { - $engine = $this->getTwig(); - - $this->assertFalse($engine->exists('foobar')); - $this->assertFalse($engine->exists(new TemplateReference('foorbar'))); - } - - public function testExistsWithTemplateWithSyntaxErrors() - { - $engine = $this->getTwig(); - - $this->assertTrue($engine->exists('error')); - $this->assertTrue($engine->exists(new TemplateReference('error'))); - } - - public function testExists() - { - $engine = $this->getTwig(); - - $this->assertTrue($engine->exists('index')); - $this->assertTrue($engine->exists(new TemplateReference('index'))); - } - - public function testRender() - { - $engine = $this->getTwig(); - - $this->assertSame('foo', $engine->render('index')); - $this->assertSame('foo', $engine->render(new TemplateReference('index'))); - } - - /** - * @expectedException \Twig\Error\SyntaxError - */ - public function testRenderWithError() - { - $engine = $this->getTwig(); - - $engine->render(new TemplateReference('error')); - } - - protected function getTwig() - { - $twig = new Environment(new ArrayLoader([ - 'index' => 'foo', - 'error' => '{{ foo }', - ])); - $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); - - return new TwigEngine($twig, $parser); - } -} diff --git a/src/Symfony/Bridge/Twig/TwigEngine.php b/src/Symfony/Bridge/Twig/TwigEngine.php deleted file mode 100644 index 266d824bb4e6f..0000000000000 --- a/src/Symfony/Bridge/Twig/TwigEngine.php +++ /dev/null @@ -1,134 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\Twig; - -@trigger_error('The '.TwigEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use \Twig\Environment instead.', E_USER_DEPRECATED); - -use Symfony\Component\Templating\EngineInterface; -use Symfony\Component\Templating\StreamingEngineInterface; -use Symfony\Component\Templating\TemplateNameParserInterface; -use Symfony\Component\Templating\TemplateReferenceInterface; -use Twig\Environment; -use Twig\Error\Error; -use Twig\Error\LoaderError; -use Twig\Loader\ExistsLoaderInterface; -use Twig\Template; - -/** - * This engine knows how to render Twig templates. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class TwigEngine implements EngineInterface, StreamingEngineInterface -{ - protected $environment; - protected $parser; - - public function __construct(Environment $environment, TemplateNameParserInterface $parser) - { - $this->environment = $environment; - $this->parser = $parser; - } - - /** - * {@inheritdoc} - * - * It also supports Template as name parameter. - * - * @throws Error if something went wrong like a thrown exception while rendering the template - */ - public function render($name, array $parameters = []) - { - return $this->load($name)->render($parameters); - } - - /** - * {@inheritdoc} - * - * It also supports Template as name parameter. - * - * @throws Error if something went wrong like a thrown exception while rendering the template - */ - public function stream($name, array $parameters = []) - { - $this->load($name)->display($parameters); - } - - /** - * {@inheritdoc} - * - * It also supports Template as name parameter. - */ - public function exists($name) - { - if ($name instanceof Template) { - return true; - } - - $loader = $this->environment->getLoader(); - - if ($loader instanceof ExistsLoaderInterface || method_exists($loader, 'exists')) { - return $loader->exists((string) $name); - } - - try { - // cast possible TemplateReferenceInterface to string because the - // EngineInterface supports them but LoaderInterface does not - $loader->getSourceContext((string) $name)->getCode(); - } catch (LoaderError $e) { - return false; - } - - return true; - } - - /** - * {@inheritdoc} - * - * It also supports Template as name parameter. - */ - public function supports($name) - { - if ($name instanceof Template) { - return true; - } - - $template = $this->parser->parse($name); - - return 'twig' === $template->get('engine'); - } - - /** - * Loads the given template. - * - * @param string|TemplateReferenceInterface|Template $name A template name or an instance of - * TemplateReferenceInterface or Template - * - * @return Template - * - * @throws \InvalidArgumentException if the template does not exist - */ - protected function load($name) - { - if ($name instanceof Template) { - return $name; - } - - try { - return $this->environment->loadTemplate((string) $name); - } catch (LoaderError $e) { - throw new \InvalidArgumentException($e->getMessage(), $e->getCode(), $e); - } - } -} diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index e0532d88ffc84..3a0a3ddd9e5aa 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -30,7 +30,6 @@ "symfony/mime": "^4.4|^5.0", "symfony/polyfill-intl-icu": "~1.0", "symfony/routing": "^4.4|^5.0", - "symfony/templating": "^4.4|^5.0", "symfony/translation": "^4.4|^5.0", "symfony/yaml": "^4.4|^5.0", "symfony/security-acl": "^2.8|^3.0", @@ -56,7 +55,6 @@ "symfony/form": "For using the FormExtension", "symfony/http-kernel": "For using the HttpKernelExtension", "symfony/routing": "For using the RoutingExtension", - "symfony/templating": "For using the TwigEngine", "symfony/translation": "For using the TranslationExtension", "symfony/yaml": "For using the YamlExtension", "symfony/security-core": "For using the SecurityExtension", diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index a829d2670b4f9..801acb35aa00a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -5,6 +5,7 @@ CHANGELOG ----- * Removed support to load translation resources from the legacy directories `src/Resources/translations/` and `src/Resources//translations/` + * Removed support for PHP templating, use Twig instead 4.4.0 ----- diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php deleted file mode 100644 index 6e5a11cade4a7..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php +++ /dev/null @@ -1,115 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; - -@trigger_error('The '.TemplateFinder::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\Finder\Finder; -use Symfony\Component\HttpKernel\Bundle\BundleInterface; -use Symfony\Component\HttpKernel\KernelInterface; -use Symfony\Component\Templating\TemplateNameParserInterface; -use Symfony\Component\Templating\TemplateReferenceInterface; - -/** - * Finds all the templates. - * - * @author Victor Berchet - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class TemplateFinder implements TemplateFinderInterface -{ - private $kernel; - private $parser; - private $rootDir; - private $templates; - - /** - * @param KernelInterface $kernel A KernelInterface instance - * @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance - * @param string $rootDir The directory where global templates can be stored - */ - public function __construct(KernelInterface $kernel, TemplateNameParserInterface $parser, string $rootDir) - { - $this->kernel = $kernel; - $this->parser = $parser; - $this->rootDir = $rootDir; - } - - /** - * Find all the templates in the bundle and in the kernel Resources folder. - * - * @return TemplateReferenceInterface[] - */ - public function findAllTemplates() - { - if (null !== $this->templates) { - return $this->templates; - } - - $templates = []; - - foreach ($this->kernel->getBundles() as $bundle) { - $templates = array_merge($templates, $this->findTemplatesInBundle($bundle)); - } - - $templates = array_merge($templates, $this->findTemplatesInFolder($this->rootDir.'/views')); - - return $this->templates = $templates; - } - - /** - * Find templates in the given directory. - * - * @param string $dir The folder where to look for templates - * - * @return TemplateReferenceInterface[] - */ - private function findTemplatesInFolder($dir) - { - $templates = []; - - if (is_dir($dir)) { - $finder = new Finder(); - foreach ($finder->files()->followLinks()->in($dir) as $file) { - $template = $this->parser->parse($file->getRelativePathname()); - if (false !== $template) { - $templates[] = $template; - } - } - } - - return $templates; - } - - /** - * Find templates in the given bundle. - * - * @param BundleInterface $bundle The bundle where to look for templates - * - * @return TemplateReferenceInterface[] - */ - private function findTemplatesInBundle(BundleInterface $bundle) - { - $name = $bundle->getName(); - $templates = array_unique(array_merge( - $this->findTemplatesInFolder($bundle->getPath().'/Resources/views'), - $this->findTemplatesInFolder($this->rootDir.'/'.$name.'/views') - )); - - foreach ($templates as $i => $template) { - $templates[$i] = $template->set('bundle', $name); - } - - return $templates; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinderInterface.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinderInterface.php deleted file mode 100644 index f5ed025facfdb..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinderInterface.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; - -@trigger_error('The '.TemplateFinderInterface::class.' interface is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -/** - * Interface for finding all the templates. - * - * @author Victor Berchet - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -interface TemplateFinderInterface -{ - /** - * Find all the templates. - * - * @return array An array of templates of type TemplateReferenceInterface - */ - public function findAllTemplates(); -} diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php deleted file mode 100644 index 9db00d828b64e..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; - -@trigger_error('The '.TemplatePathsCacheWarmer::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmer; - -/** - * Computes the association between template names and their paths on the disk. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class TemplatePathsCacheWarmer extends CacheWarmer -{ - protected $finder; - protected $locator; - - public function __construct(TemplateFinderInterface $finder, TemplateLocator $locator) - { - $this->finder = $finder; - $this->locator = $locator; - } - - /** - * Warms up the cache. - * - * @param string $cacheDir The cache directory - */ - public function warmUp($cacheDir) - { - $filesystem = new Filesystem(); - $templates = []; - - foreach ($this->finder->findAllTemplates() as $template) { - $templates[$template->getLogicalName()] = rtrim($filesystem->makePathRelative($this->locator->locate($template), $cacheDir), '/'); - } - - $templates = str_replace("' => '", "' => __DIR__.'/", var_export($templates, true)); - - $this->writeCacheFile($cacheDir.'/templates.php', sprintf(" '?'.SerializerInterface::class, 'session' => '?'.SessionInterface::class, 'security.authorization_checker' => '?'.AuthorizationCheckerInterface::class, - 'templating' => '?'.EngineInterface::class, 'twig' => '?'.Environment::class, 'doctrine' => '?'.ManagerRegistry::class, 'form.factory' => '?'.FormFactoryInterface::class, diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php index 2f20678e318e3..3499d7cb65a71 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php @@ -205,14 +205,8 @@ protected function denyAccessUnlessGranted($attributes, $subject = null, string */ protected function renderView(string $view, array $parameters = []): string { - if ($this->container->has('templating')) { - @trigger_error('Using the "templating" service is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - - return $this->container->get('templating')->render($view, $parameters); - } - if (!$this->container->has('twig')) { - throw new \LogicException('You can not use the "renderView" method if the Templating Component or the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".'); + throw new \LogicException('You can not use the "renderView" method if the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".'); } return $this->container->get('twig')->render($view, $parameters); @@ -225,15 +219,7 @@ protected function renderView(string $view, array $parameters = []): string */ protected function render(string $view, array $parameters = [], Response $response = null): Response { - if ($this->container->has('templating')) { - @trigger_error('Using the "templating" service is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - - $content = $this->container->get('templating')->render($view, $parameters); - } elseif ($this->container->has('twig')) { - $content = $this->container->get('twig')->render($view, $parameters); - } else { - throw new \LogicException('You can not use the "render" method if the Templating Component or the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".'); - } + $content = $this->renderView($view, $parameters); if (null === $response) { $response = new Response(); @@ -251,24 +237,16 @@ protected function render(string $view, array $parameters = [], Response $respon */ protected function stream(string $view, array $parameters = [], StreamedResponse $response = null): StreamedResponse { - if ($this->container->has('templating')) { - @trigger_error('Using the "templating" service is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - - $templating = $this->container->get('templating'); - - $callback = function () use ($templating, $view, $parameters) { - $templating->stream($view, $parameters); - }; - } elseif ($this->container->has('twig')) { - $twig = $this->container->get('twig'); - - $callback = function () use ($twig, $view, $parameters) { - $twig->display($view, $parameters); - }; - } else { - throw new \LogicException('You can not use the "stream" method if the Templating Component or the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".'); + if (!$this->container->has('twig')) { + throw new \LogicException('You can not use the "stream" method if the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".'); } + $twig = $this->container->get('twig'); + + $callback = function () use ($twig, $view, $parameters) { + $twig->display($view, $parameters); + }; + if (null === $response) { return new StreamedResponse($callback); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php index 8e359569f8ced..0fff40bac58ea 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php @@ -12,7 +12,6 @@ namespace Symfony\Bundle\FrameworkBundle\Controller; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Templating\EngineInterface; use Twig\Environment; /** @@ -25,16 +24,10 @@ class TemplateController { private $twig; - private $templating; - public function __construct(Environment $twig = null, EngineInterface $templating = null) + public function __construct(Environment $twig = null) { - if (null !== $templating) { - @trigger_error(sprintf('Using a "%s" instance for "%s" is deprecated since version 4.4; use a \Twig\Environment instance instead.', EngineInterface::class, __CLASS__), E_USER_DEPRECATED); - } - $this->twig = $twig; - $this->templating = $templating; } /** @@ -47,14 +40,12 @@ public function __construct(Environment $twig = null, EngineInterface $templatin */ public function templateAction(string $template, int $maxAge = null, int $sharedAge = null, bool $private = null): Response { - if ($this->templating) { - $response = new Response($this->templating->render($template)); - } elseif ($this->twig) { - $response = new Response($this->twig->render($template)); - } else { - throw new \LogicException('You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.'); + if (null === $this->twig) { + throw new \LogicException('You can not use the TemplateController if the Twig Bundle is not available.'); } + $response = new Response($this->twig->render($template)); + if ($maxAge) { $response->setMaxAge($maxAge); } diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php deleted file mode 100644 index be7418d909726..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; - -use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface; -use Symfony\Component\DependencyInjection\Alias; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface; - -/** - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class TemplatingPass implements CompilerPassInterface -{ - public function process(ContainerBuilder $container) - { - if ($container->hasDefinition('templating')) { - return; - } - - if ($container->hasAlias('templating')) { - $container->setAlias(ComponentEngineInterface::class, new Alias('templating', false)); - $container->setAlias(FrameworkBundleEngineInterface::class, new Alias('templating', false)); - } - - if ($container->hasDefinition('templating.engine.php')) { - $refs = []; - $helpers = []; - - foreach ($container->findTaggedServiceIds('templating.helper', true) as $id => $attributes) { - if (!$container->getDefinition($id)->isDeprecated()) { - @trigger_error('The "templating.helper" tag is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - } - - if (isset($attributes[0]['alias'])) { - $helpers[$attributes[0]['alias']] = $id; - $refs[$id] = new Reference($id); - } - } - - if (\count($helpers) > 0) { - $definition = $container->getDefinition('templating.engine.php'); - $definition->addMethodCall('setHelpers', [$helpers]); - - if ($container->hasDefinition('templating.engine.php.helpers_locator')) { - $container->getDefinition('templating.engine.php.helpers_locator')->replaceArgument(0, $refs); - } - } - } - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php index efeafad5f06e0..ec92d2addd105 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php @@ -54,7 +54,6 @@ class UnusedTagsPass implements CompilerPassInterface 'security.voter', 'serializer.encoder', 'serializer.normalizer', - 'templating.helper', 'translation.dumper', 'translation.extractor', 'translation.loader', diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index ea64157fde9bc..7436e4d27702b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -28,7 +28,6 @@ use Symfony\Component\Mailer\Mailer; use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface; -use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Symfony\Component\Serializer\Serializer; use Symfony\Component\Translation\Translator; use Symfony\Component\Validator\Validation; @@ -97,7 +96,6 @@ public function getConfigTreeBuilder() $this->addRouterSection($rootNode); $this->addSessionSection($rootNode); $this->addRequestSection($rootNode); - $this->addTemplatingSection($rootNode); $this->addAssetsSection($rootNode); $this->addTranslatorSection($rootNode); $this->addValidationSection($rootNode); @@ -598,66 +596,6 @@ private function addRequestSection(ArrayNodeDefinition $rootNode) ; } - private function addTemplatingSection(ArrayNodeDefinition $rootNode) - { - $rootNode - ->children() - ->arrayNode('templating') - ->info('templating configuration') - ->canBeEnabled() - ->beforeNormalization() - ->ifTrue(function ($v) { return false === $v || \is_array($v) && false === $v['enabled']; }) - ->then(function () { return ['enabled' => false, 'engines' => false]; }) - ->end() - ->children() - ->scalarNode('hinclude_default_template')->setDeprecated('Setting "templating.hinclude_default_template" is deprecated since Symfony 4.3, use "fragments.hinclude_default_template" instead.')->defaultNull()->end() - ->scalarNode('cache')->end() - ->arrayNode('form') - ->addDefaultsIfNotSet() - ->fixXmlConfig('resource') - ->children() - ->arrayNode('resources') - ->addDefaultChildrenIfNoneSet() - ->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end() - ->validate() - ->ifTrue(function ($v) {return !\in_array('FrameworkBundle:Form', $v); }) - ->then(function ($v) { - return array_merge(['FrameworkBundle:Form'], $v); - }) - ->end() - ->end() - ->end() - ->end() - ->end() - ->fixXmlConfig('engine') - ->children() - ->arrayNode('engines') - ->example(['twig']) - ->isRequired() - ->requiresAtLeastOneElement() - ->canBeUnset() - ->beforeNormalization() - ->ifTrue(function ($v) { return !\is_array($v) && false !== $v; }) - ->then(function ($v) { return [$v]; }) - ->end() - ->prototype('scalar')->end() - ->end() - ->end() - ->fixXmlConfig('loader') - ->children() - ->arrayNode('loaders') - ->beforeNormalization() - ->ifTrue(function ($v) { return !\is_array($v); }) - ->then(function ($v) { return [$v]; }) - ->end() - ->prototype('scalar')->end() - ->end() - ->end() - ->end() - ->end() - ; - } - private function addAssetsSection(ArrayNodeDefinition $rootNode) { $rootNode diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 4598ed9532fef..bbe5fced1523d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -197,23 +197,20 @@ public function load(array $configs, ContainerBuilder $container) $container->setParameter('kernel.default_locale', $config['default_locale']); if (!$container->hasParameter('debug.file_link_format')) { - if (!$container->hasParameter('templating.helper.code.file_link_format')) { - $links = [ - 'textmate' => 'txmt://open?url=file://%%f&line=%%l', - 'macvim' => 'mvim://open?url=file://%%f&line=%%l', - 'emacs' => 'emacs://open?url=file://%%f&line=%%l', - 'sublime' => 'subl://open?url=file://%%f&line=%%l', - 'phpstorm' => 'phpstorm://open?file=%%f&line=%%l', - 'atom' => 'atom://core/open/file?filename=%%f&line=%%l', - 'vscode' => 'vscode://file/%%f:%%l', - ]; - $ide = $config['ide']; - // mark any env vars found in the ide setting as used - $container->resolveEnvPlaceholders($ide); - - $container->setParameter('templating.helper.code.file_link_format', str_replace('%', '%%', ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: (isset($links[$ide]) ? $links[$ide] : $ide)); - } - $container->setParameter('debug.file_link_format', '%templating.helper.code.file_link_format%'); + $links = [ + 'textmate' => 'txmt://open?url=file://%%f&line=%%l', + 'macvim' => 'mvim://open?url=file://%%f&line=%%l', + 'emacs' => 'emacs://open?url=file://%%f&line=%%l', + 'sublime' => 'subl://open?url=file://%%f&line=%%l', + 'phpstorm' => 'phpstorm://open?file=%%f&line=%%l', + 'atom' => 'atom://core/open/file?filename=%%f&line=%%l', + 'vscode' => 'vscode://file/%%f:%%l', + ]; + $ide = $config['ide']; + // mark any env vars found in the ide setting as used + $container->resolveEnvPlaceholders($ide); + + $container->setParameter('debug.file_link_format', str_replace('%', '%%', ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: (isset($links[$ide]) ? $links[$ide] : $ide)); } if (!empty($config['test'])) { @@ -269,16 +266,6 @@ public function load(array $configs, ContainerBuilder $container) $this->registerAssetsConfiguration($config['assets'], $container, $loader); } - if ($this->isConfigEnabled($container, $config['templating'])) { - @trigger_error('Enabling the Templating component is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - - if (!class_exists('Symfony\Component\Templating\PhpEngine')) { - throw new LogicException('Templating support cannot be enabled as the Templating component is not installed. Try running "composer require symfony/templating".'); - } - - $this->registerTemplatingConfiguration($config['templating'], $container, $loader); - } - if ($this->messengerConfigEnabled = $this->isConfigEnabled($container, $config['messenger'])) { $this->registerMessengerConfiguration($config['messenger'], $container, $loader, $config['serializer'], $config['validation']); } else { @@ -494,9 +481,6 @@ private function registerFragmentsConfiguration(array $config, ContainerBuilder return; } - if ($container->hasParameter('fragment.renderer.hinclude.global_template') && null !== $container->getParameter('fragment.renderer.hinclude.global_template') && null !== $config['hinclude_default_template']) { - throw new \LogicException('You cannot set both "templating.hinclude_default_template" and "fragments.hinclude_default_template", please only use "fragments.hinclude_default_template".'); - } $container->setParameter('fragment.renderer.hinclude.global_template', $config['hinclude_default_template']); @@ -913,85 +897,6 @@ private function registerRequestConfiguration(array $config, ContainerBuilder $c } } - private function registerTemplatingConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) - { - $loader->load('templating.xml'); - - $container->setParameter('fragment.renderer.hinclude.global_template', $config['hinclude_default_template']); - - if ($container->getParameter('kernel.debug')) { - $logger = new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE); - - $container->getDefinition('templating.loader.cache') - ->addTag('monolog.logger', ['channel' => 'templating']) - ->addMethodCall('setLogger', [$logger]); - $container->getDefinition('templating.loader.chain') - ->addTag('monolog.logger', ['channel' => 'templating']) - ->addMethodCall('setLogger', [$logger]); - } - - if (!empty($config['loaders'])) { - $loaders = array_map(function ($loader) { return new Reference($loader); }, $config['loaders']); - - // Use a delegation unless only a single loader was registered - if (1 === \count($loaders)) { - $container->setAlias('templating.loader', (string) reset($loaders))->setPrivate(true); - } else { - $container->getDefinition('templating.loader.chain')->addArgument($loaders); - $container->setAlias('templating.loader', 'templating.loader.chain')->setPrivate(true); - } - } - - $container->setParameter('templating.loader.cache.path', null); - if (isset($config['cache'])) { - // Wrap the existing loader with cache (must happen after loaders are registered) - $container->setDefinition('templating.loader.wrapped', $container->findDefinition('templating.loader')); - $loaderCache = $container->getDefinition('templating.loader.cache'); - $container->setParameter('templating.loader.cache.path', $config['cache']); - - $container->setDefinition('templating.loader', $loaderCache); - } - - $container->setParameter('templating.engines', $config['engines']); - $engines = array_map(function ($engine) { return new Reference('templating.engine.'.$engine); }, $config['engines']); - - // Use a delegation unless only a single engine was registered - if (1 === \count($engines)) { - $container->setAlias('templating', (string) reset($engines))->setPublic(true); - } else { - $templateEngineDefinition = $container->getDefinition('templating.engine.delegating'); - foreach ($engines as $engine) { - $templateEngineDefinition->addMethodCall('addEngine', [$engine]); - } - $container->setAlias('templating', 'templating.engine.delegating')->setPublic(true); - } - - $container->getDefinition('fragment.renderer.hinclude') - ->addTag('kernel.fragment_renderer', ['alias' => 'hinclude']) - ->replaceArgument(0, new Reference('templating')) - ; - - // configure the PHP engine if needed - if (\in_array('php', $config['engines'], true)) { - $loader->load('templating_php.xml'); - - $container->setParameter('templating.helper.form.resources', $config['form']['resources']); - - if ($container->getParameter('kernel.debug') && class_exists(Stopwatch::class)) { - $loader->load('templating_debug.xml'); - - $container->setDefinition('templating.engine.php', $container->findDefinition('debug.templating.engine.php')); - $container->setAlias('debug.templating.engine.php', 'templating.engine.php')->setPrivate(true); - } - - if ($container->has('assets.packages')) { - $container->getDefinition('templating.helper.assets')->replaceArgument(0, new Reference('assets.packages')); - } else { - $container->removeDefinition('templating.helper.assets'); - } - } - } - private function registerAssetsConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { $loader->load('assets.xml'); diff --git a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php index e5c714965c2b0..74320d08e02d5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php @@ -18,7 +18,6 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass; -use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerRealRefPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TestServiceContainerWeakRefPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass; @@ -98,7 +97,6 @@ public function build(ContainerBuilder $container) // must be registered before removing private services as some might be listeners/subscribers // but as late as possible to get resolved parameters $container->addCompilerPass((new RegisterListenersPass())->setHotPathEvents($hotPathEvents), PassConfig::TYPE_BEFORE_REMOVING); - $container->addCompilerPass(new TemplatingPass()); $this->addCompilerPassIfExists($container, AddConstraintValidatorsPass::class); $container->addCompilerPass(new AddAnnotationsCachedReaderPass(), PassConfig::TYPE_AFTER_REMOVING, -255); $this->addCompilerPassIfExists($container, AddValidatorInitializersPass::class); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_renderer.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_renderer.xml index 394033734d2d4..827a22f9a4668 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_renderer.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_renderer.xml @@ -26,7 +26,7 @@ - + %fragment.renderer.hinclude.global_template% %fragment.path% diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml index 8c293ebefc390..55634218d13a4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml @@ -114,7 +114,6 @@ - diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index 04157511dc1a4..89b219d7f432f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -20,7 +20,6 @@ - @@ -158,18 +157,6 @@ - - - - - - - - - - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml deleted file mode 100644 index b6b70be999de8..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - - %kernel.cache_dir% - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - %kernel.root_dir%/Resources - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - %templating.loader.cache.path% - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml deleted file mode 100644 index 3dd7b84c123ba..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - %kernel.charset% - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml deleted file mode 100644 index 440b9a5d23298..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - - - %kernel.charset% - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - %kernel.project_dir% - %kernel.charset% - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - %templating.helper.form.resources% - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php b/src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php deleted file mode 100644 index bd292e468160b..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating; - -@trigger_error('The '.DelegatingEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Psr\Container\ContainerInterface; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Templating\DelegatingEngine as BaseDelegatingEngine; - -/** - * DelegatingEngine selects an engine for a given template. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class DelegatingEngine extends BaseDelegatingEngine implements EngineInterface -{ - protected $container; - - public function __construct(ContainerInterface $container, array $engineIds) - { - $this->container = $container; - $this->engines = $engineIds; - } - - /** - * {@inheritdoc} - */ - public function getEngine($name) - { - $this->resolveEngines(); - - return parent::getEngine($name); - } - - /** - * {@inheritdoc} - */ - public function renderResponse($view, array $parameters = [], Response $response = null) - { - $engine = $this->getEngine($view); - - if ($engine instanceof EngineInterface) { - return $engine->renderResponse($view, $parameters, $response); - } - - if (null === $response) { - $response = new Response(); - } - - $response->setContent($engine->render($view, $parameters)); - - return $response; - } - - /** - * Resolved engine ids to their real engine instances from the container. - */ - private function resolveEngines() - { - foreach ($this->engines as $i => $engine) { - if (\is_string($engine)) { - $this->engines[$i] = $this->container->get($engine); - } - } - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/EngineInterface.php b/src/Symfony/Bundle/FrameworkBundle/Templating/EngineInterface.php deleted file mode 100644 index 2539980b9d960..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/EngineInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating; - -@trigger_error('The '.EngineInterface::class.' interface is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Templating\EngineInterface as BaseEngineInterface; - -/** - * EngineInterface is the interface each engine must implement. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -interface EngineInterface extends BaseEngineInterface -{ - /** - * Renders a view and returns a Response. - * - * @param string $view The view name - * @param array $parameters An array of parameters to pass to the view - * @param Response $response A Response instance - * - * @return Response A Response instance - * - * @throws \RuntimeException if the template cannot be rendered - */ - public function renderResponse($view, array $parameters = [], Response $response = null); -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php b/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php deleted file mode 100644 index 2981eb66422d1..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php +++ /dev/null @@ -1,98 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating; - -@trigger_error('The '.GlobalVariables::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; - -/** - * GlobalVariables is the entry point for Symfony global variables in PHP templates. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class GlobalVariables -{ - protected $container; - - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - /** - * @return TokenInterface|null - */ - public function getToken() - { - if (!$this->container->has('security.token_storage')) { - return; - } - - return $this->container->get('security.token_storage')->getToken(); - } - - public function getUser() - { - if (!$token = $this->getToken()) { - return; - } - - $user = $token->getUser(); - if (!\is_object($user)) { - return; - } - - return $user; - } - - /** - * @return Request|null The HTTP request object - */ - public function getRequest() - { - if ($this->container->has('request_stack')) { - return $this->container->get('request_stack')->getCurrentRequest(); - } - } - - /** - * @return Session|null The session - */ - public function getSession() - { - if ($request = $this->getRequest()) { - return $request->getSession(); - } - } - - /** - * @return string The current environment string (e.g 'dev') - */ - public function getEnvironment() - { - return $this->container->getParameter('kernel.environment'); - } - - /** - * @return bool The current debug mode - */ - public function getDebug() - { - return (bool) $this->container->getParameter('kernel.debug'); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php deleted file mode 100644 index 8a054162fb81a..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; - -@trigger_error('The '.ActionsHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\HttpKernel\Controller\ControllerReference; -use Symfony\Component\HttpKernel\Fragment\FragmentHandler; -use Symfony\Component\Templating\Helper\Helper; - -/** - * ActionsHelper manages action inclusions. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class ActionsHelper extends Helper -{ - private $handler; - - public function __construct(FragmentHandler $handler) - { - $this->handler = $handler; - } - - /** - * Returns the fragment content for a given URI. - * - * @param string $uri A URI - * @param array $options An array of options - * - * @return string The fragment content - * - * @see FragmentHandler::render() - */ - public function render($uri, array $options = []) - { - $strategy = isset($options['strategy']) ? $options['strategy'] : 'inline'; - unset($options['strategy']); - - return $this->handler->render($uri, $strategy, $options); - } - - public function controller($controller, $attributes = [], $query = []) - { - return new ControllerReference($controller, $attributes, $query); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'actions'; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/AssetsHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/AssetsHelper.php deleted file mode 100644 index ff237d6a9728a..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/AssetsHelper.php +++ /dev/null @@ -1,71 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; - -@trigger_error('The '.AssetsHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\Asset\Packages; -use Symfony\Component\Templating\Helper\Helper; - -/** - * AssetsHelper helps manage asset URLs. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class AssetsHelper extends Helper -{ - private $packages; - - public function __construct(Packages $packages) - { - $this->packages = $packages; - } - - /** - * Returns the public url/path of an asset. - * - * If the package used to generate the path is an instance of - * UrlPackage, you will always get a URL and not a path. - * - * @param string $path A public path - * @param string $packageName The name of the asset package to use - * - * @return string The public path of the asset - */ - public function getUrl($path, $packageName = null) - { - return $this->packages->getUrl($path, $packageName); - } - - /** - * Returns the version of an asset. - * - * @param string $path A public path - * @param string $packageName The name of the asset package to use - * - * @return string The asset version - */ - public function getVersion($path, $packageName = null) - { - return $this->packages->getVersion($path, $packageName); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'assets'; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php deleted file mode 100644 index 1d8885ba40b54..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php +++ /dev/null @@ -1,231 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; - -@trigger_error('The '.CodeHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; -use Symfony\Component\Templating\Helper\Helper; - -/** - * @author Fabien Potencier - * - * @internal since Symfony 4.2 - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class CodeHelper extends Helper -{ - protected $fileLinkFormat; - protected $rootDir; // to be renamed $projectDir in 5.0 - protected $charset; - - /** - * @param string|FileLinkFormatter $fileLinkFormat The format for links to source files - * @param string $projectDir The project root directory - * @param string $charset The charset - */ - public function __construct($fileLinkFormat, string $projectDir, string $charset) - { - $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); - $this->rootDir = str_replace('\\', '/', $projectDir).'/'; - $this->charset = $charset; - } - - /** - * Formats an array as a string. - * - * @param array $args The argument array - * - * @return string - */ - public function formatArgsAsText(array $args) - { - return strip_tags($this->formatArgs($args)); - } - - public function abbrClass($class) - { - $parts = explode('\\', $class); - $short = array_pop($parts); - - return sprintf('%s', $class, $short); - } - - public function abbrMethod($method) - { - if (false !== strpos($method, '::')) { - list($class, $method) = explode('::', $method, 2); - $result = sprintf('%s::%s()', $this->abbrClass($class), $method); - } elseif ('Closure' === $method) { - $result = sprintf('%1$s', $method); - } else { - $result = sprintf('%1$s()', $method); - } - - return $result; - } - - /** - * Formats an array as a string. - * - * @param array $args The argument array - * - * @return string - */ - public function formatArgs(array $args) - { - $result = []; - foreach ($args as $key => $item) { - if ('object' === $item[0]) { - $parts = explode('\\', $item[1]); - $short = array_pop($parts); - $formattedValue = sprintf('object(%s)', $item[1], $short); - } elseif ('array' === $item[0]) { - $formattedValue = sprintf('array(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]); - } elseif ('string' === $item[0]) { - $formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->getCharset())); - } elseif ('null' === $item[0]) { - $formattedValue = 'null'; - } elseif ('boolean' === $item[0]) { - $formattedValue = ''.strtolower(var_export($item[1], true)).''; - } elseif ('resource' === $item[0]) { - $formattedValue = 'resource'; - } else { - $formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES, $this->getCharset()), true)); - } - - $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); - } - - return implode(', ', $result); - } - - /** - * Returns an excerpt of a code file around the given line number. - * - * @param string $file A file path - * @param int $line The selected line number - * - * @return string An HTML string - */ - public function fileExcerpt($file, $line) - { - if (is_readable($file)) { - if (\extension_loaded('fileinfo')) { - $finfo = new \finfo(); - - // Check if the file is an application/octet-stream (eg. Phar file) because highlight_file cannot parse these files - if ('application/octet-stream' === $finfo->file($file, FILEINFO_MIME_TYPE)) { - return; - } - } - - // highlight_file could throw warnings - // see https://bugs.php.net/bug.php?id=25725 - $code = @highlight_file($file, true); - // remove main code/span tags - $code = preg_replace('#^\s*(.*)\s*#s', '\\1', $code); - $content = explode('
', $code); - - $lines = []; - for ($i = max($line - 3, 1), $max = min($line + 3, \count($content)); $i <= $max; ++$i) { - $lines[] = ''.self::fixCodeMarkup($content[$i - 1]).''; - } - - return '
    '.implode("\n", $lines).'
'; - } - } - - /** - * Formats a file path. - * - * @param string $file An absolute file path - * @param int $line The line number - * @param string $text Use this text for the link rather than the file path - * - * @return string - */ - public function formatFile($file, $line, $text = null) - { - $flags = ENT_QUOTES | ENT_SUBSTITUTE; - - if (null === $text) { - $file = trim($file); - $fileStr = $file; - if (0 === strpos($fileStr, $this->rootDir)) { - $fileStr = str_replace(['\\', $this->rootDir], ['/', ''], $fileStr); - $fileStr = htmlspecialchars($fileStr, $flags, $this->charset); - $fileStr = sprintf('kernel.project_dir/%s', htmlspecialchars($this->rootDir, $flags, $this->charset), $fileStr); - } - - $text = sprintf('%s at line %d', $fileStr, $line); - } - - if (false !== $link = $this->getFileLink($file, $line)) { - return sprintf('%s', htmlspecialchars($link, $flags, $this->charset), $text); - } - - return $text; - } - - /** - * Returns the link for a given file/line pair. - * - * @param string $file An absolute file path - * @param int $line The line number - * - * @return string A link of false - */ - public function getFileLink($file, $line) - { - if ($fmt = $this->fileLinkFormat) { - return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line); - } - - return false; - } - - public function formatFileFromText($text) - { - return preg_replace_callback('/in ("|")?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', function ($match) { - return 'in '.$this->formatFile($match[2], $match[3]); - }, $text); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'code'; - } - - protected static function fixCodeMarkup($line) - { - // ending tag from previous line - $opening = strpos($line, ''); - if (false !== $closing && (false === $opening || $closing < $opening)) { - $line = substr_replace($line, '', $closing, 7); - } - - // missing tag at the end of line - $opening = strpos($line, ''); - if (false !== $opening && (false === $closing || $closing > $opening)) { - $line .= ''; - } - - return $line; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php deleted file mode 100644 index 0956d31adaf13..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php +++ /dev/null @@ -1,271 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; - -@trigger_error('The '.FormHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\Form\FormRendererInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\Templating\Helper\Helper; - -/** - * FormHelper provides helpers to help display forms. - * - * @author Fabien Potencier - * @author Bernhard Schussek - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class FormHelper extends Helper -{ - private $renderer; - - public function __construct(FormRendererInterface $renderer) - { - $this->renderer = $renderer; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'form'; - } - - /** - * Sets a theme for a given view. - * - * The theme format is ":". - * - * @param FormView $view A FormView instance - * @param string|array $themes A theme or an array of theme - * @param bool $useDefaultThemes If true, will use default themes defined in the renderer - */ - public function setTheme(FormView $view, $themes, $useDefaultThemes = true) - { - $this->renderer->setTheme($view, $themes, $useDefaultThemes); - } - - /** - * Renders the HTML for a form. - * - * Example usage: - * - * form($form) ?> - * - * You can pass options during the call: - * - * form($form, ['attr' => ['class' => 'foo']]) ?> - * - * form($form, ['separator' => '+++++']) ?> - * - * This method is mainly intended for prototyping purposes. If you want to - * control the layout of a form in a more fine-grained manner, you are - * advised to use the other helper methods for rendering the parts of the - * form individually. You can also create a custom form theme to adapt - * the look of the form. - * - * @param FormView $view The view for which to render the form - * @param array $variables Additional variables passed to the template - * - * @return string The HTML markup - */ - public function form(FormView $view, array $variables = []) - { - return $this->renderer->renderBlock($view, 'form', $variables); - } - - /** - * Renders the form start tag. - * - * Example usage templates: - * - * start($form) ?>> - * - * @param FormView $view The view for which to render the start tag - * @param array $variables Additional variables passed to the template - * - * @return string The HTML markup - */ - public function start(FormView $view, array $variables = []) - { - return $this->renderer->renderBlock($view, 'form_start', $variables); - } - - /** - * Renders the form end tag. - * - * Example usage templates: - * - * end($form) ?>> - * - * @param FormView $view The view for which to render the end tag - * @param array $variables Additional variables passed to the template - * - * @return string The HTML markup - */ - public function end(FormView $view, array $variables = []) - { - return $this->renderer->renderBlock($view, 'form_end', $variables); - } - - /** - * Renders the HTML for a given view. - * - * Example usage: - * - * widget($form) ?> - * - * You can pass options during the call: - * - * widget($form, ['attr' => ['class' => 'foo']]) ?> - * - * widget($form, ['separator' => '+++++']) ?> - * - * @param FormView $view The view for which to render the widget - * @param array $variables Additional variables passed to the template - * - * @return string The HTML markup - */ - public function widget(FormView $view, array $variables = []) - { - return $this->renderer->searchAndRenderBlock($view, 'widget', $variables); - } - - /** - * Renders the entire form field "row". - * - * @param FormView $view The view for which to render the row - * @param array $variables Additional variables passed to the template - * - * @return string The HTML markup - */ - public function row(FormView $view, array $variables = []) - { - return $this->renderer->searchAndRenderBlock($view, 'row', $variables); - } - - /** - * Renders the label of the given view. - * - * @param FormView $view The view for which to render the label - * @param string $label The label - * @param array $variables Additional variables passed to the template - * - * @return string The HTML markup - */ - public function label(FormView $view, $label = null, array $variables = []) - { - if (null !== $label) { - $variables += ['label' => $label]; - } - - return $this->renderer->searchAndRenderBlock($view, 'label', $variables); - } - - /** - * Renders the help of the given view. - * - * @param FormView $view The parent view - * - * @return string The HTML markup - */ - public function help(FormView $view): string - { - return $this->renderer->searchAndRenderBlock($view, 'help'); - } - - /** - * Renders the errors of the given view. - * - * @return string The HTML markup - */ - public function errors(FormView $view) - { - return $this->renderer->searchAndRenderBlock($view, 'errors'); - } - - /** - * Renders views which have not already been rendered. - * - * @param FormView $view The parent view - * @param array $variables An array of variables - * - * @return string The HTML markup - */ - public function rest(FormView $view, array $variables = []) - { - return $this->renderer->searchAndRenderBlock($view, 'rest', $variables); - } - - /** - * Renders a block of the template. - * - * @param FormView $view The view for determining the used themes - * @param string $blockName The name of the block to render - * @param array $variables The variable to pass to the template - * - * @return string The HTML markup - */ - public function block(FormView $view, $blockName, array $variables = []) - { - return $this->renderer->renderBlock($view, $blockName, $variables); - } - - /** - * Returns a CSRF token. - * - * Use this helper for CSRF protection without the overhead of creating a - * form. - * - * echo $view['form']->csrfToken('rm_user_'.$user->getId()); - * - * Check the token in your action using the same CSRF token id. - * - * // $csrfProvider being an instance of Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface - * if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) { - * throw new \RuntimeException('CSRF attack detected.'); - * } - * - * @param string $tokenId The CSRF token id of the protected action - * - * @return string A CSRF token - * - * @throws \BadMethodCallException when no CSRF provider was injected in the constructor - */ - public function csrfToken($tokenId) - { - return $this->renderer->renderCsrfToken($tokenId); - } - - public function humanize($text) - { - return $this->renderer->humanize($text); - } - - /** - * @internal - */ - public function formEncodeCurrency($text, $widget = '') - { - if ('UTF-8' === $charset = $this->getCharset()) { - $text = htmlspecialchars($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8'); - } else { - $text = htmlentities($text, ENT_QUOTES | (\defined('ENT_SUBSTITUTE') ? ENT_SUBSTITUTE : 0), 'UTF-8'); - $text = iconv('UTF-8', $charset, $text); - $widget = iconv('UTF-8', $charset, $widget); - } - - return str_replace('{{ widget }}', $widget, $text); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php deleted file mode 100644 index 351ed712c4a54..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; - -@trigger_error('The '.RequestHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Templating\Helper\Helper; - -/** - * RequestHelper provides access to the current request parameters. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class RequestHelper extends Helper -{ - protected $requestStack; - - public function __construct(RequestStack $requestStack) - { - $this->requestStack = $requestStack; - } - - /** - * Returns a parameter from the current request object. - * - * @param string $key The name of the parameter - * @param string $default A default value - * - * @return mixed - * - * @see Request::get() - */ - public function getParameter($key, $default = null) - { - return $this->getRequest()->get($key, $default); - } - - /** - * Returns the locale. - * - * @return string - */ - public function getLocale() - { - return $this->getRequest()->getLocale(); - } - - private function getRequest() - { - if (!$this->requestStack->getCurrentRequest()) { - throw new \LogicException('A Request must be available.'); - } - - return $this->requestStack->getCurrentRequest(); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'request'; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php deleted file mode 100644 index 0854fe3f048bd..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; - -@trigger_error('The '.RouterHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Templating\Helper\Helper; - -/** - * RouterHelper manages links between pages in a template context. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class RouterHelper extends Helper -{ - protected $generator; - - public function __construct(UrlGeneratorInterface $router) - { - $this->generator = $router; - } - - /** - * Generates a URL reference (as an absolute or relative path) to the route with the given parameters. - * - * @param string $name The name of the route - * @param mixed $parameters An array of parameters - * @param bool $relative Whether to generate a relative or absolute path - * - * @return string The generated URL reference - * - * @see UrlGeneratorInterface - */ - public function path($name, $parameters = [], $relative = false) - { - return $this->generator->generate($name, $parameters, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH); - } - - /** - * Generates a URL reference (as an absolute URL or network path) to the route with the given parameters. - * - * @param string $name The name of the route - * @param mixed $parameters An array of parameters - * @param bool $schemeRelative Whether to omit the scheme in the generated URL reference - * - * @return string The generated URL reference - * - * @see UrlGeneratorInterface - */ - public function url($name, $parameters = [], $schemeRelative = false) - { - return $this->generator->generate($name, $parameters, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'router'; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php deleted file mode 100644 index 86c0fcda1b936..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; - -@trigger_error('The '.SessionHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Templating\Helper\Helper; - -/** - * SessionHelper provides read-only access to the session attributes. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class SessionHelper extends Helper -{ - protected $session; - protected $requestStack; - - public function __construct(RequestStack $requestStack) - { - $this->requestStack = $requestStack; - } - - /** - * Returns an attribute. - * - * @param string $name The attribute name - * @param mixed $default The default value - * - * @return mixed - */ - public function get($name, $default = null) - { - return $this->getSession()->get($name, $default); - } - - public function getFlash($name, array $default = []) - { - return $this->getSession()->getFlashBag()->get($name, $default); - } - - public function getFlashes() - { - return $this->getSession()->getFlashBag()->all(); - } - - public function hasFlash($name) - { - return $this->getSession()->getFlashBag()->has($name); - } - - private function getSession() - { - if (null === $this->session) { - if (!$this->requestStack->getMasterRequest()) { - throw new \LogicException('A Request must be available.'); - } - - $this->session = $this->requestStack->getMasterRequest()->getSession(); - } - - return $this->session; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'session'; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php deleted file mode 100644 index 9ec4df47a1323..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; - -@trigger_error('The '.StopwatchHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\Stopwatch\Stopwatch; -use Symfony\Component\Templating\Helper\Helper; - -/** - * StopwatchHelper provides methods time your PHP templates. - * - * @author Wouter J - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class StopwatchHelper extends Helper -{ - private $stopwatch; - - public function __construct(Stopwatch $stopwatch = null) - { - $this->stopwatch = $stopwatch; - } - - public function getName() - { - return 'stopwatch'; - } - - public function __call($method, $arguments = []) - { - if (null !== $this->stopwatch) { - if (method_exists($this->stopwatch, $method)) { - return $this->stopwatch->{$method}(...$arguments); - } - - throw new \BadMethodCallException(sprintf('Method "%s" of Stopwatch does not exist', $method)); - } - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/TranslatorHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/TranslatorHelper.php deleted file mode 100644 index b86c0da666aa2..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/TranslatorHelper.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; - -@trigger_error('The '.TranslatorHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\Templating\Helper\Helper; -use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterface; -use Symfony\Contracts\Translation\TranslatorInterface; -use Symfony\Contracts\Translation\TranslatorTrait; - -/** - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class TranslatorHelper extends Helper -{ - use TranslatorTrait { - getLocale as private; - setLocale as private; - trans as private doTrans; - } - - protected $translator; - - /** - * @param TranslatorInterface|null $translator - */ - public function __construct($translator = null) - { - if (null !== $translator && !$translator instanceof LegacyTranslatorInterface && !$translator instanceof TranslatorInterface) { - throw new \TypeError(sprintf('Argument 1 passed to %s() must be an instance of %s, %s given.', __METHOD__, TranslatorInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator))); - } - $this->translator = $translator; - } - - /** - * @see TranslatorInterface::trans() - */ - public function trans($id, array $parameters = [], $domain = 'messages', $locale = null) - { - if (null === $this->translator) { - return $this->doTrans($id, $parameters, $domain, $locale); - } - - return $this->translator->trans($id, $parameters, $domain, $locale); - } - - /** - * @see TranslatorInterface::transChoice() - * @deprecated since Symfony 4.2, use the trans() method instead with a %count% parameter - */ - public function transChoice($id, $number, array $parameters = [], $domain = 'messages', $locale = null) - { - @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%%count%%" parameter.', __METHOD__), E_USER_DEPRECATED); - - if (null === $this->translator) { - return $this->doTrans($id, ['%count%' => $number] + $parameters, $domain, $locale); - } - if ($this->translator instanceof TranslatorInterface) { - return $this->translator->trans($id, ['%count%' => $number] + $parameters, $domain, $locale); - } - - return $this->translator->transChoice($id, $number, $parameters, $domain, $locale); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'translator'; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/FilesystemLoader.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/FilesystemLoader.php deleted file mode 100644 index 52edeb86199fe..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/FilesystemLoader.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating\Loader; - -@trigger_error('The '.FilesystemLoader::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\Config\FileLocatorInterface; -use Symfony\Component\Templating\Loader\LoaderInterface; -use Symfony\Component\Templating\Storage\FileStorage; -use Symfony\Component\Templating\TemplateReferenceInterface; - -/** - * FilesystemLoader is a loader that read templates from the filesystem. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class FilesystemLoader implements LoaderInterface -{ - protected $locator; - - public function __construct(FileLocatorInterface $locator) - { - $this->locator = $locator; - } - - /** - * {@inheritdoc} - */ - public function load(TemplateReferenceInterface $template) - { - try { - $file = $this->locator->locate($template); - } catch (\InvalidArgumentException $e) { - return false; - } - - return new FileStorage($file); - } - - /** - * {@inheritdoc} - */ - public function isFresh(TemplateReferenceInterface $template, $time) - { - if (false === $storage = $this->load($template)) { - return false; - } - - if (!is_readable((string) $storage)) { - return false; - } - - return filemtime((string) $storage) < $time; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php deleted file mode 100644 index 39ebe0e1d3d45..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating\Loader; - -@trigger_error('The '.TemplateLocator::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\Config\FileLocatorInterface; -use Symfony\Component\Templating\TemplateReferenceInterface; - -/** - * TemplateLocator locates templates in bundles. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class TemplateLocator implements FileLocatorInterface -{ - protected $locator; - protected $cache; - - private $cacheHits = []; - - /** - * @param FileLocatorInterface $locator A FileLocatorInterface instance - * @param string $cacheDir The cache path - */ - public function __construct(FileLocatorInterface $locator, string $cacheDir = null) - { - if (null !== $cacheDir && file_exists($cache = $cacheDir.'/templates.php')) { - $this->cache = require $cache; - } - - $this->locator = $locator; - } - - /** - * Returns a full path for a given file. - * - * @return string The full path for the file - */ - protected function getCacheKey($template) - { - return $template->getLogicalName(); - } - - /** - * Returns a full path for a given file. - * - * @param TemplateReferenceInterface $template A template - * @param string $currentPath Unused - * @param bool $first Unused - * - * @return string The full path for the file - * - * @throws \InvalidArgumentException When the template is not an instance of TemplateReferenceInterface - * @throws \InvalidArgumentException When the template file can not be found - */ - public function locate($template, $currentPath = null, $first = true) - { - if (!$template instanceof TemplateReferenceInterface) { - throw new \InvalidArgumentException('The template must be an instance of TemplateReferenceInterface.'); - } - - $key = $this->getCacheKey($template); - - if (isset($this->cacheHits[$key])) { - return $this->cacheHits[$key]; - } - if (isset($this->cache[$key])) { - return $this->cacheHits[$key] = realpath($this->cache[$key]) ?: $this->cache[$key]; - } - - try { - return $this->cacheHits[$key] = $this->locator->locate($template->getPath(), $currentPath); - } catch (\InvalidArgumentException $e) { - throw new \InvalidArgumentException(sprintf('Unable to find template "%s" : "%s".', $template, $e->getMessage()), 0, $e); - } - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php b/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php deleted file mode 100644 index 080d0b7815210..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating; - -@trigger_error('The '.PhpEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Psr\Container\ContainerInterface; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Templating\Loader\LoaderInterface; -use Symfony\Component\Templating\PhpEngine as BasePhpEngine; -use Symfony\Component\Templating\TemplateNameParserInterface; - -/** - * This engine knows how to render Symfony templates. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class PhpEngine extends BasePhpEngine implements EngineInterface -{ - protected $container; - - public function __construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, GlobalVariables $globals = null) - { - $this->container = $container; - - parent::__construct($parser, $loader); - - if (null !== $globals) { - $this->addGlobal('app', $globals); - } - } - - /** - * {@inheritdoc} - */ - public function get($name) - { - if (!isset($this->helpers[$name])) { - throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name)); - } - - if (\is_string($this->helpers[$name])) { - $this->helpers[$name] = $this->container->get($this->helpers[$name]); - $this->helpers[$name]->setCharset($this->charset); - } - - return $this->helpers[$name]; - } - - /** - * {@inheritdoc} - */ - public function setHelpers(array $helpers) - { - $this->helpers = $helpers; - } - - /** - * {@inheritdoc} - */ - public function renderResponse($view, array $parameters = [], Response $response = null) - { - if (null === $response) { - $response = new Response(); - } - - $response->setContent($this->render($view, $parameters)); - - return $response; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateFilenameParser.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateFilenameParser.php deleted file mode 100644 index de383461d7f8a..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateFilenameParser.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating; - -@trigger_error('The '.TemplateFilenameParser::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\Templating\TemplateNameParserInterface; -use Symfony\Component\Templating\TemplateReferenceInterface; - -/** - * TemplateFilenameParser converts template filenames to - * TemplateReferenceInterface instances. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class TemplateFilenameParser implements TemplateNameParserInterface -{ - /** - * {@inheritdoc} - */ - public function parse($name) - { - if ($name instanceof TemplateReferenceInterface) { - return $name; - } - - $parts = explode('/', str_replace('\\', '/', $name)); - - $elements = explode('.', array_pop($parts)); - if (3 > \count($elements)) { - return false; - } - $engine = array_pop($elements); - $format = array_pop($elements); - - return new TemplateReference('', implode('/', $parts), implode('.', $elements), $format, $engine); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php deleted file mode 100644 index ffa9a923f1f9d..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating; - -@trigger_error('The '.TemplateNameParser::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\HttpKernel\KernelInterface; -use Symfony\Component\Templating\TemplateNameParser as BaseTemplateNameParser; -use Symfony\Component\Templating\TemplateReferenceInterface; - -/** - * TemplateNameParser converts template names from the short notation - * "bundle:section:template.format.engine" to TemplateReferenceInterface - * instances. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class TemplateNameParser extends BaseTemplateNameParser -{ - protected $kernel; - protected $cache = []; - - public function __construct(KernelInterface $kernel) - { - $this->kernel = $kernel; - } - - /** - * {@inheritdoc} - */ - public function parse($name) - { - if ($name instanceof TemplateReferenceInterface) { - return $name; - } elseif (isset($this->cache[$name])) { - return $this->cache[$name]; - } - - // normalize name - $name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', str_replace('\\', '/', $name))); - - if (false !== strpos($name, '..')) { - throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name)); - } - - if (!preg_match('/^(?:([^:]*):([^:]*):)?(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches) || 0 === strpos($name, '@')) { - return parent::parse($name); - } - - $template = new TemplateReference($matches[1], $matches[2], $matches[3], $matches[4], $matches[5]); - - if ($template->get('bundle')) { - try { - $this->kernel->getBundle($template->get('bundle')); - } catch (\Exception $e) { - throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid.', $name), 0, $e); - } - } - - return $this->cache[$name] = $template; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php deleted file mode 100644 index 3bc461ebb66e8..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php +++ /dev/null @@ -1,61 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating; - -@trigger_error('The '.TemplateReference::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\Templating\TemplateReference as BaseTemplateReference; - -/** - * Internal representation of a template. - * - * @author Victor Berchet - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class TemplateReference extends BaseTemplateReference -{ - public function __construct(string $bundle = null, string $controller = null, string $name = null, string $format = null, string $engine = null) - { - $this->parameters = [ - 'bundle' => $bundle, - 'controller' => $controller, - 'name' => $name, - 'format' => $format, - 'engine' => $engine, - ]; - } - - /** - * Returns the path to the template - * - as a path when the template is not part of a bundle - * - as a resource when the template is part of a bundle. - * - * @return string A path to the template or a resource - */ - public function getPath() - { - $controller = str_replace('\\', '/', $this->get('controller')); - - $path = (empty($controller) ? '' : $controller.'/').$this->get('name').'.'.$this->get('format').'.'.$this->get('engine'); - - return empty($this->parameters['bundle']) ? 'views/'.$path : '@'.$this->get('bundle').'/Resources/views/'.$path; - } - - /** - * {@inheritdoc} - */ - public function getLogicalName() - { - return sprintf('%s:%s:%s.%s.%s', $this->parameters['bundle'], $this->parameters['controller'], $this->parameters['name'], $this->parameters['format'], $this->parameters['engine']); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php deleted file mode 100644 index faa7c55fae63b..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Templating; - -@trigger_error('The '.TimedPhpEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Psr\Container\ContainerInterface; -use Symfony\Component\Stopwatch\Stopwatch; -use Symfony\Component\Templating\Loader\LoaderInterface; -use Symfony\Component\Templating\TemplateNameParserInterface; - -/** - * Times the time spent to render a template. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class TimedPhpEngine extends PhpEngine -{ - protected $stopwatch; - - public function __construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, Stopwatch $stopwatch, GlobalVariables $globals = null) - { - parent::__construct($parser, $container, $loader, $globals); - - $this->stopwatch = $stopwatch; - } - - /** - * {@inheritdoc} - */ - public function render($name, array $parameters = []) - { - $e = $this->stopwatch->start(sprintf('template.php (%s)', $name), 'template'); - - $ret = parent::render($name, $parameters); - - $e->stop(); - - return $ret; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php deleted file mode 100644 index 52b8dfad9dfbd..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer; - -use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinder; -use Symfony\Bundle\FrameworkBundle\Templating\TemplateFilenameParser; -use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\BaseBundle\BaseBundle; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; - -/** - * @group legacy - */ -class TemplateFinderTest extends TestCase -{ - public function testFindAllTemplates() - { - $kernel = $this - ->getMockBuilder('Symfony\Component\HttpKernel\Kernel') - ->disableOriginalConstructor() - ->getMock() - ; - - $kernel - ->expects($this->any()) - ->method('getBundle') - ; - - $kernel - ->expects($this->once()) - ->method('getBundles') - ->willReturn(['BaseBundle' => new BaseBundle()]) - ; - - $parser = new TemplateFilenameParser(); - - $finder = new TemplateFinder($kernel, $parser, __DIR__.'/../Fixtures/Resources'); - - $templates = array_map( - function ($template) { return $template->getLogicalName(); }, - $finder->findAllTemplates() - ); - - $this->assertCount(7, $templates, '->findAllTemplates() find all templates in the bundles and global folders'); - $this->assertContains('BaseBundle::base.format.engine', $templates); - $this->assertContains('BaseBundle::this.is.a.template.format.engine', $templates); - $this->assertContains('BaseBundle:controller:base.format.engine', $templates); - $this->assertContains('BaseBundle:controller:custom.format.engine', $templates); - $this->assertContains('::this.is.a.template.format.engine', $templates); - $this->assertContains('::resource.format.engine', $templates); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php deleted file mode 100644 index ea05f965f64c4..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php +++ /dev/null @@ -1,105 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\CacheWarmer; - -use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface; -use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplatePathsCacheWarmer; -use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator; -use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; -use Symfony\Component\Config\FileLocator; -use Symfony\Component\Filesystem\Filesystem; - -/** - * @group legacy - */ -class TemplatePathsCacheWarmerTest extends TestCase -{ - /** @var Filesystem */ - private $filesystem; - - /** @var TemplateFinderInterface */ - private $templateFinder; - - /** @var FileLocator */ - private $fileLocator; - - /** @var TemplateLocator */ - private $templateLocator; - - private $tmpDir; - - protected function setUp() - { - $this->templateFinder = $this - ->getMockBuilder(TemplateFinderInterface::class) - ->setMethods(['findAllTemplates']) - ->getMock(); - - $this->fileLocator = $this - ->getMockBuilder(FileLocator::class) - ->setMethods(['locate']) - ->setConstructorArgs(['/path/to/fallback']) - ->getMock(); - - $this->templateLocator = new TemplateLocator($this->fileLocator); - - $this->tmpDir = sys_get_temp_dir().\DIRECTORY_SEPARATOR.uniqid('cache_template_paths_', true); - - $this->filesystem = new Filesystem(); - $this->filesystem->mkdir($this->tmpDir); - } - - protected function tearDown() - { - $this->filesystem->remove($this->tmpDir); - } - - public function testWarmUp() - { - $template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine'); - - $this->templateFinder - ->expects($this->once()) - ->method('findAllTemplates') - ->willReturn([$template]); - - $this->fileLocator - ->expects($this->once()) - ->method('locate') - ->with($template->getPath()) - ->willReturn(\dirname($this->tmpDir).'/path/to/template.html.twig'); - - $warmer = new TemplatePathsCacheWarmer($this->templateFinder, $this->templateLocator); - $warmer->warmUp($this->tmpDir); - - $this->assertFileEquals(__DIR__.'/../Fixtures/TemplatePathsCache/templates.php', $this->tmpDir.'/templates.php'); - } - - public function testWarmUpEmpty() - { - $this->templateFinder - ->expects($this->once()) - ->method('findAllTemplates') - ->willReturn([]); - - $this->fileLocator - ->expects($this->never()) - ->method('locate'); - - $warmer = new TemplatePathsCacheWarmer($this->templateFinder, $this->templateLocator); - $warmer->warmUp($this->tmpDir); - - $this->assertFileExists($this->tmpDir.'/templates.php'); - $this->assertSame(file_get_contents(__DIR__.'/../Fixtures/TemplatePathsCache/templates-empty.php'), file_get_contents($this->tmpDir.'/templates.php')); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php index 9c1e0b8d9a51d..cd86432e783d7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php @@ -37,7 +37,6 @@ public function testSubscribedServices() 'serializer' => '?Symfony\\Component\\Serializer\\SerializerInterface', 'session' => '?Symfony\\Component\\HttpFoundation\\Session\\SessionInterface', 'security.authorization_checker' => '?Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface', - 'templating' => '?Symfony\\Component\\Templating\\EngineInterface', 'twig' => '?Twig\\Environment', 'doctrine' => '?Doctrine\\Common\\Persistence\\ManagerRegistry', 'form.factory' => '?Symfony\\Component\\Form\\FormFactoryInterface', diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php index ca78fdd54d126..d4f0c24440fe5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php @@ -439,56 +439,6 @@ public function testRedirect() $this->assertSame(301, $response->getStatusCode()); } - /** - * @group legacy - */ - public function testRenderViewTemplating() - { - $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); - $templating->expects($this->once())->method('render')->willReturn('bar'); - - $container = new Container(); - $container->set('templating', $templating); - - $controller = $this->createController(); - $controller->setContainer($container); - - $this->assertEquals('bar', $controller->renderView('foo')); - } - - /** - * @group legacy - */ - public function testRenderTemplating() - { - $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); - $templating->expects($this->once())->method('render')->willReturn('bar'); - - $container = new Container(); - $container->set('templating', $templating); - - $controller = $this->createController(); - $controller->setContainer($container); - - $this->assertEquals('bar', $controller->render('foo')->getContent()); - } - - /** - * @group legacy - */ - public function testStreamTemplating() - { - $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); - - $container = new Container(); - $container->set('templating', $templating); - - $controller = $this->createController(); - $controller->setContainer($container); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $controller->stream('foo')); - } - public function testCreateNotFoundException() { $controller = $this->createController(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php index a19d0651bb126..f35b9bc5d6606 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php @@ -12,7 +12,6 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Controller\TemplateController; -use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; /** @@ -31,25 +30,11 @@ public function testTwig() $this->assertEquals('bar', $controller('mytemplate')->getContent()); } - /** - * @group legacy - */ - public function testTemplating() - { - $templating = $this->getMockBuilder(EngineInterface::class)->getMock(); - $templating->expects($this->exactly(2))->method('render')->willReturn('bar'); - - $controller = new TemplateController(null, $templating); - - $this->assertEquals('bar', $controller->templateAction('mytemplate')->getContent()); - $this->assertEquals('bar', $controller('mytemplate')->getContent()); - } - /** * @expectedException \LogicException - * @expectedExceptionMessage You can not use the TemplateController if the Templating Component or the Twig Bundle are not available. + * @expectedExceptionMessage You can not use the TemplateController if the Twig Bundle is not available. */ - public function testNoTwigNorTemplating() + public function testNoTwig() { $controller = new TemplateController(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index 3980036006b11..e576e01fe8cce 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -35,19 +35,6 @@ public function testDefaultConfig() ); } - public function testDoNoDuplicateDefaultFormResources() - { - $input = ['templating' => [ - 'form' => ['resources' => ['FrameworkBundle:Form']], - 'engines' => ['php'], - ]]; - - $processor = new Processor(); - $config = $processor->processConfiguration(new Configuration(true), [$input]); - - $this->assertEquals(['FrameworkBundle:Form'], $config['templating']['form']['resources']); - } - public function getTestValidSessionName() { return [ @@ -305,15 +292,6 @@ protected static function getBundleDefaultConfig() 'enabled' => false, 'formats' => [], ], - 'templating' => [ - 'enabled' => false, - 'hinclude_default_template' => null, - 'form' => [ - 'resources' => ['FrameworkBundle:Form'], - ], - 'engines' => [], - 'loaders' => [], - ], 'assets' => [ 'enabled' => !class_exists(FullStack::class), 'version_strategy' => null, diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/template_and_fragments.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/template_and_fragments.php deleted file mode 100644 index 6fd941d9f46c0..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/template_and_fragments.php +++ /dev/null @@ -1,18 +0,0 @@ -loadFromExtension('framework', [ - 'templating' => [ - 'cache' => '/path/to/cache', - 'engines' => ['php', 'twig'], - 'loader' => ['loader.foo', 'loader.bar'], - 'form' => [ - 'resources' => ['theme1', 'theme2'], - ], - 'hinclude_default_template' => 'global_hinclude_template', - ], - 'assets' => null, - 'fragments' => [ - 'enabled' => true, - 'hinclude_default_template' => 'global_hinclude_template', - ], -]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating.php deleted file mode 100644 index a7edabf763afd..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating.php +++ /dev/null @@ -1,14 +0,0 @@ -loadFromExtension('framework', [ - 'templating' => [ - 'cache' => '/path/to/cache', - 'engines' => ['php', 'twig'], - 'loader' => ['loader.foo', 'loader.bar'], - 'form' => [ - 'resources' => ['theme1', 'theme2'], - ], - 'hinclude_default_template' => 'global_hinclude_template', - ], - 'assets' => null, -]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_disabled.php deleted file mode 100644 index 2d5e6d779f79c..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_disabled.php +++ /dev/null @@ -1,5 +0,0 @@ -loadFromExtension('framework', [ - 'templating' => false, -]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php deleted file mode 100644 index f4d5a28aafc67..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_no_assets.php +++ /dev/null @@ -1,7 +0,0 @@ -loadFromExtension('framework', [ - 'templating' => [ - 'engines' => ['php', 'twig'], - ], -]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php deleted file mode 100644 index 851a7e140c747..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating_php_assets_disabled.php +++ /dev/null @@ -1,8 +0,0 @@ -loadFromExtension('framework', [ - 'assets' => false, - 'templating' => [ - 'engines' => ['php'], - ], -]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/template_and_fragments.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/template_and_fragments.xml deleted file mode 100644 index d253e9f5deeed..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/template_and_fragments.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - loader.foo - loader.bar - php - twig - - theme1 - theme2 - - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating.xml deleted file mode 100644 index 192533dbf617a..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - loader.foo - loader.bar - php - twig - - theme1 - theme2 - - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_disabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_disabled.xml deleted file mode 100644 index 8fda04d92a591..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_disabled.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_no_assets.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_no_assets.xml deleted file mode 100644 index 7bba936c5a58e..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_no_assets.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - php - twig - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_php_translator_disabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_php_translator_disabled.xml deleted file mode 100644 index 8e0a8cc039cb5..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_php_translator_disabled.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - php - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_php_translator_enabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_php_translator_enabled.xml deleted file mode 100644 index d1cb1fad83367..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating_php_translator_enabled.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - php - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/template_and_fragments.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/template_and_fragments.yml deleted file mode 100644 index dbf7b697541e0..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/template_and_fragments.yml +++ /dev/null @@ -1,12 +0,0 @@ -framework: - fragments: - enabled: true - hinclude_default_template: global_hinclude_template - templating: - engines: [php, twig] - loader: [loader.foo, loader.bar] - cache: /path/to/cache - form: - resources: [theme1, theme2] - hinclude_default_template: global_hinclude_template - assets: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating.yml deleted file mode 100644 index d307e1609b090..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating.yml +++ /dev/null @@ -1,9 +0,0 @@ -framework: - templating: - engines: [php, twig] - loader: [loader.foo, loader.bar] - cache: /path/to/cache - form: - resources: [theme1, theme2] - hinclude_default_template: global_hinclude_template - assets: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_disabled.yml deleted file mode 100644 index 1e548b859473c..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_disabled.yml +++ /dev/null @@ -1,2 +0,0 @@ -framework: - templating: false diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_no_assets.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_no_assets.yml deleted file mode 100644 index 393477aeb49ac..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_no_assets.yml +++ /dev/null @@ -1,3 +0,0 @@ -framework: - templating: - engines: [php, twig] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_assets_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_assets_disabled.yml deleted file mode 100644 index 7ef6b3e57c292..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_assets_disabled.yml +++ /dev/null @@ -1,4 +0,0 @@ -framework: - assets: false - templating: - engines: [php] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_translator_disabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_translator_disabled.yml deleted file mode 100644 index fe0f3e83b5683..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_translator_disabled.yml +++ /dev/null @@ -1,4 +0,0 @@ -framework: - translator: false - templating: - engines: [php] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_translator_enabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_translator_enabled.yml deleted file mode 100644 index 0991a2007d77f..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating_php_translator_enabled.yml +++ /dev/null @@ -1,4 +0,0 @@ -framework: - translator: true - templating: - engines: [php] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 322bcd1305c6c..afffc07aab0ee 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -160,15 +160,6 @@ public function testEsiDisabled() $this->assertFalse($container->hasDefinition('esi')); } - /** - * @group legacy - * @expectedException \LogicException - */ - public function testAmbiguousWhenBothTemplatingAndFragments() - { - $this->createContainerFromFile('template_and_fragments'); - } - public function testSsi() { $container = $this->createContainerFromFile('full'); @@ -575,37 +566,6 @@ public function testEmptyRequestFormats() $this->assertFalse($container->hasDefinition('request.add_request_formats_listener'), '->registerRequestConfiguration() does not load request.xml when no request formats are defined'); } - /** - * @group legacy - */ - public function testTemplating() - { - $container = $this->createContainerFromFile('templating'); - - $this->assertTrue($container->hasDefinition('templating.name_parser'), '->registerTemplatingConfiguration() loads templating.xml'); - - $this->assertEquals('templating.engine.delegating', (string) $container->getAlias('templating'), '->registerTemplatingConfiguration() configures delegating loader if multiple engines are provided'); - - $this->assertEquals($container->getDefinition('templating.loader.chain'), $container->getDefinition('templating.loader.wrapped'), '->registerTemplatingConfiguration() configures loader chain if multiple loaders are provided'); - - $this->assertEquals($container->getDefinition('templating.loader'), $container->getDefinition('templating.loader.cache'), '->registerTemplatingConfiguration() configures the loader to use cache'); - - $this->assertEquals('%templating.loader.cache.path%', $container->getDefinition('templating.loader.cache')->getArgument(1)); - $this->assertEquals('/path/to/cache', $container->getParameter('templating.loader.cache.path')); - - $this->assertEquals(['php', 'twig'], $container->getParameter('templating.engines'), '->registerTemplatingConfiguration() sets a templating.engines parameter'); - - $this->assertEquals(['FrameworkBundle:Form', 'theme1', 'theme2'], $container->getParameter('templating.helper.form.resources'), '->registerTemplatingConfiguration() registers the theme and adds the base theme'); - $this->assertEquals('global_hinclude_template', $container->getParameter('fragment.renderer.hinclude.global_template'), '->registerTemplatingConfiguration() registers the global hinclude.js template'); - } - - public function testTemplatingCanBeDisabled() - { - $container = $this->createContainerFromFile('templating_disabled'); - - $this->assertFalse($container->hasParameter('templating.engines'), '"templating.engines" container parameter is not registered when templating is disabled.'); - } - public function testAssets() { $container = $this->createContainerFromFile('assets'); @@ -650,13 +610,6 @@ public function testAssetsDefaultVersionStrategyAsService() $this->assertEquals('assets.custom_version_strategy', (string) $defaultPackage->getArgument(1)); } - public function testAssetsCanBeDisabled() - { - $container = $this->createContainerFromFile('assets_disabled'); - - $this->assertFalse($container->has('templating.helper.assets'), 'The templating.helper.assets helper service is removed when assets are disabled.'); - } - public function testWebLink() { $container = $this->createContainerFromFile('web_link'); @@ -849,16 +802,6 @@ public function testTranslatorMultipleFallbacks() $this->assertEquals(['en', 'fr'], $calls[1][1][0]); } - /** - * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException - */ - public function testTemplatingRequiresAtLeastOneEngine() - { - $container = $this->createContainer(); - $loader = new FrameworkExtension(); - $loader->load([['templating' => null]], $container); - } - public function testValidation() { $container = $this->createContainerFromFile('full'); @@ -1283,45 +1226,6 @@ public function testSerializerMapping() $this->assertEquals($expectedLoaders, $loaders); } - /** - * @group legacy - */ - public function testAssetHelperWhenAssetsAreEnabled() - { - $container = $this->createContainerFromFile('templating'); - $packages = $container->getDefinition('templating.helper.assets')->getArgument(0); - - $this->assertSame('assets.packages', (string) $packages); - } - - /** - * @group legacy - */ - public function testAssetHelperWhenTemplatesAreEnabledAndNoAssetsConfiguration() - { - $container = $this->createContainerFromFile('templating_no_assets'); - $packages = $container->getDefinition('templating.helper.assets')->getArgument(0); - - $this->assertSame('assets.packages', (string) $packages); - } - - /** - * @group legacy - */ - public function testAssetsHelperIsRemovedWhenPhpTemplatingEngineIsEnabledAndAssetsAreDisabled() - { - $container = $this->createContainerFromFile('templating_php_assets_disabled'); - - $this->assertTrue(!$container->has('templating.helper.assets'), 'The templating.helper.assets helper service is removed when assets are disabled.'); - } - - public function testAssetHelperWhenAssetsAndTemplatesAreDisabled() - { - $container = $this->createContainerFromFile('default_config'); - - $this->assertFalse($container->hasDefinition('templating.helper.assets')); - } - public function testSerializerServiceIsRegisteredWhenEnabled() { $container = $this->createContainerFromFile('serializer_enabled'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php index e4338e3746c11..f6aeb61e7c2b5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php @@ -13,11 +13,9 @@ use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\CachedReader; -use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher; -use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface; class AutowiringTypesTest extends WebTestCase { @@ -37,18 +35,6 @@ public function testCachedAnnotationReaderAutowiring() $this->assertInstanceOf(CachedReader::class, $annotationReader); } - /** - * @group legacy - */ - public function testTemplatingAutowiring() - { - static::bootKernel(['root_config' => 'templating.yml', 'environment' => 'templating']); - - $autowiredServices = static::$container->get('test.autowiring_types.autowired_services'); - $this->assertInstanceOf(FrameworkBundleEngineInterface::class, $autowiredServices->getFrameworkBundleEngine()); - $this->assertInstanceOf(ComponentEngineInterface::class, $autowiredServices->getEngine()); - } - public function testEventDispatcherAutowiring() { static::bootKernel(['debug' => false]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/TemplatingServices.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/TemplatingServices.php deleted file mode 100644 index 7fc0cdd7b55af..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/TemplatingServices.php +++ /dev/null @@ -1,31 +0,0 @@ - - */ -class TemplatingServices -{ - private $frameworkBundleEngine; - private $engine; - - public function __construct(FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine) - { - $this->frameworkBundleEngine = $frameworkBundleEngine; - $this->engine = $engine; - } - - public function getFrameworkBundleEngine() - { - return $this->frameworkBundleEngine; - } - - public function getEngine() - { - return $this->engine; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/templating.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/templating.yml deleted file mode 100644 index 765bfa9d70d48..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/templating.yml +++ /dev/null @@ -1,12 +0,0 @@ -imports: - - { resource: ../config/default.yml } - -services: - _defaults: { public: true } - test.autowiring_types.autowired_services: - class: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes\TemplatingServices - autowire: true - -framework: - templating: - engines: ['php'] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php deleted file mode 100644 index b7558544eca97..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php +++ /dev/null @@ -1,128 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; - -use PHPUnit\Framework\TestCase; -use Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine; -use Symfony\Component\HttpFoundation\Response; - -/** - * @group legacy - */ -class DelegatingEngineTest extends TestCase -{ - public function testSupportsRetrievesEngineFromTheContainer() - { - $container = $this->getContainerMock([ - 'engine.first' => $this->getEngineMock('template.php', false), - 'engine.second' => $this->getEngineMock('template.php', true), - ]); - - $delegatingEngine = new DelegatingEngine($container, ['engine.first', 'engine.second']); - - $this->assertTrue($delegatingEngine->supports('template.php')); - } - - public function testGetExistingEngine() - { - $firstEngine = $this->getEngineMock('template.php', false); - $secondEngine = $this->getEngineMock('template.php', true); - $container = $this->getContainerMock([ - 'engine.first' => $firstEngine, - 'engine.second' => $secondEngine, - ]); - - $delegatingEngine = new DelegatingEngine($container, ['engine.first', 'engine.second']); - - $this->assertSame($secondEngine, $delegatingEngine->getEngine('template.php')); - } - - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage No engine is able to work with the template "template.php" - */ - public function testGetInvalidEngine() - { - $firstEngine = $this->getEngineMock('template.php', false); - $secondEngine = $this->getEngineMock('template.php', false); - $container = $this->getContainerMock([ - 'engine.first' => $firstEngine, - 'engine.second' => $secondEngine, - ]); - - $delegatingEngine = new DelegatingEngine($container, ['engine.first', 'engine.second']); - $delegatingEngine->getEngine('template.php'); - } - - public function testRenderResponseWithFrameworkEngine() - { - $response = new Response(); - $engine = $this->getFrameworkEngineMock('template.php', true); - $engine->expects($this->once()) - ->method('renderResponse') - ->with('template.php', ['foo' => 'bar']) - ->willReturn($response); - $container = $this->getContainerMock(['engine' => $engine]); - - $delegatingEngine = new DelegatingEngine($container, ['engine']); - - $this->assertSame($response, $delegatingEngine->renderResponse('template.php', ['foo' => 'bar'])); - } - - public function testRenderResponseWithTemplatingEngine() - { - $engine = $this->getEngineMock('template.php', true); - $container = $this->getContainerMock(['engine' => $engine]); - $delegatingEngine = new DelegatingEngine($container, ['engine']); - - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $delegatingEngine->renderResponse('template.php', ['foo' => 'bar'])); - } - - private function getEngineMock($template, $supports) - { - $engine = $this->getMockBuilder('Symfony\Component\Templating\EngineInterface')->getMock(); - - $engine->expects($this->once()) - ->method('supports') - ->with($template) - ->willReturn($supports); - - return $engine; - } - - private function getFrameworkEngineMock($template, $supports) - { - $engine = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); - - $engine->expects($this->once()) - ->method('supports') - ->with($template) - ->willReturn($supports); - - return $engine; - } - - private function getContainerMock($services) - { - $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); - - $i = 0; - foreach ($services as $id => $service) { - $container->expects($this->at($i++)) - ->method('get') - ->with($id) - ->willReturn($service); - } - - return $container; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php deleted file mode 100644 index 4c3e57d88f200..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php +++ /dev/null @@ -1,109 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; - -use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; -use Symfony\Component\DependencyInjection\Container; - -/** - * @group legacy - */ -class GlobalVariablesTest extends TestCase -{ - private $container; - private $globals; - - protected function setUp() - { - $this->container = new Container(); - $this->globals = new GlobalVariables($this->container); - } - - public function testGetTokenNoTokenStorage() - { - $this->assertNull($this->globals->getToken()); - } - - public function testGetTokenNoToken() - { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $this->container->set('security.token_storage', $tokenStorage); - $this->assertNull($this->globals->getToken()); - } - - public function testGetToken() - { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - - $this->container->set('security.token_storage', $tokenStorage); - - $tokenStorage - ->expects($this->once()) - ->method('getToken') - ->willReturn('token'); - - $this->assertSame('token', $this->globals->getToken()); - } - - public function testGetUserNoTokenStorage() - { - $this->assertNull($this->globals->getUser()); - } - - public function testGetUserNoToken() - { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $this->container->set('security.token_storage', $tokenStorage); - $this->assertNull($this->globals->getUser()); - } - - /** - * @dataProvider getUserProvider - */ - public function testGetUser($user, $expectedUser) - { - $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - - $this->container->set('security.token_storage', $tokenStorage); - - $token - ->expects($this->once()) - ->method('getUser') - ->willReturn($user); - - $tokenStorage - ->expects($this->once()) - ->method('getToken') - ->willReturn($token); - - $this->assertSame($expectedUser, $this->globals->getUser()); - } - - public function getUserProvider() - { - $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); - $std = new \stdClass(); - $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - - return [ - [$user, $user], - [$std, $std], - [$token, $token], - ['Anon.', null], - [null, null], - [10, null], - [true, null], - ]; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelperTest.php deleted file mode 100644 index 06e87f43f72ff..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelperTest.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper; - -use PHPUnit\Framework\TestCase; -use Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper; -use Symfony\Component\Asset\Package; -use Symfony\Component\Asset\Packages; -use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy; - -/** - * @group legacy - */ -class AssetsHelperTest extends TestCase -{ - private $helper; - - protected function setUp() - { - $fooPackage = new Package(new StaticVersionStrategy('42', '%s?v=%s')); - $barPackage = new Package(new StaticVersionStrategy('22', '%s?%s')); - - $packages = new Packages($fooPackage, ['bar' => $barPackage]); - - $this->helper = new AssetsHelper($packages); - } - - public function testGetUrl() - { - $this->assertEquals('me.png?v=42', $this->helper->getUrl('me.png')); - $this->assertEquals('me.png?22', $this->helper->getUrl('me.png', 'bar')); - } - - public function testGetVersion() - { - $this->assertEquals('42', $this->helper->getVersion('/')); - $this->assertEquals('22', $this->helper->getVersion('/', 'bar')); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTemplateNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTemplateNameParser.php deleted file mode 100644 index 9835bc2a228ea..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTemplateNameParser.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures; - -use Symfony\Component\Templating\TemplateNameParserInterface; -use Symfony\Component\Templating\TemplateReference; - -class StubTemplateNameParser implements TemplateNameParserInterface -{ - private $root; - - private $rootTheme; - - public function __construct($root, $rootTheme) - { - $this->root = $root; - $this->rootTheme = $rootTheme; - } - - public function parse($name) - { - list($bundle, $controller, $template) = explode(':', $name, 3); - - if ('_' == $template[0]) { - $path = $this->rootTheme.'/Custom/'.$template; - } elseif ('TestBundle' === $bundle) { - $path = $this->rootTheme.'/'.$controller.'/'.$template; - } else { - $path = $this->root.'/'.$controller.'/'.$template; - } - - return new TemplateReference($path, 'php'); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTranslator.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTranslator.php deleted file mode 100644 index 402b3a886c74b..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Fixtures/StubTranslator.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures; - -use Symfony\Contracts\Translation\TranslatorInterface; - -class StubTranslator implements TranslatorInterface -{ - public function trans($id, array $parameters = [], $domain = null, $locale = null) - { - return '[trans]'.strtr($id, $parameters).'[/trans]'; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php deleted file mode 100644 index 729b01920f7d6..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php +++ /dev/null @@ -1,264 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper; - -use Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper; -use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTemplateNameParser; -use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTranslator; -use Symfony\Component\Form\Extension\Templating\TemplatingExtension; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\Tests\AbstractDivLayoutTest; -use Symfony\Component\Templating\Loader\FilesystemLoader; -use Symfony\Component\Templating\PhpEngine; - -/** - * @group legacy - */ -class FormHelperDivLayoutTest extends AbstractDivLayoutTest -{ - /** - * @var PhpEngine - */ - protected $engine; - - protected static $supportedFeatureSetVersion = 403; - - protected function getExtensions() - { - // should be moved to the Form component once absolute file paths are supported - // by the default name parser in the Templating component - $reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle'); - $root = realpath(\dirname($reflClass->getFileName()).'/Resources/views'); - $rootTheme = realpath(__DIR__.'/Resources'); - $templateNameParser = new StubTemplateNameParser($root, $rootTheme); - $loader = new FilesystemLoader([]); - - $this->engine = new PhpEngine($templateNameParser, $loader); - $this->engine->addGlobal('global', ''); - $this->engine->setHelpers([ - new TranslatorHelper(new StubTranslator()), - ]); - - return array_merge(parent::getExtensions(), [ - new TemplatingExtension($this->engine, $this->csrfTokenManager, [ - 'FrameworkBundle:Form', - ]), - ]); - } - - protected function tearDown() - { - $this->engine = null; - - parent::tearDown(); - } - - public function testStartTagHasNoActionAttributeWhenActionIsEmpty() - { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ - 'method' => 'get', - 'action' => '', - ]); - - $html = $this->renderStart($form->createView()); - - $this->assertSame('
', $html); - } - - public function testStartTagHasActionAttributeWhenActionIsZero() - { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ - 'method' => 'get', - 'action' => '0', - ]); - - $html = $this->renderStart($form->createView()); - - $this->assertSame('', $html); - } - - public function testMoneyWidgetInIso() - { - $this->engine->setCharset('ISO-8859-1'); - - $view = $this->factory - ->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType') - ->createView() - ; - - $this->assertSame('€ ', $this->renderWidget($view)); - } - - public function testHelpAttr() - { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [ - 'help' => 'Help text test!', - 'help_attr' => [ - 'class' => 'class-test', - ], - ]); - $view = $form->createView(); - $html = $this->renderHelp($view); - - $this->assertMatchesXpath($html, - '/p - [@id="name_help"] - [@class="class-test help-text"] - [.="[trans]Help text test![/trans]"] -' - ); - } - - public function testHelpHtmlDefaultIsFalse() - { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [ - 'help' => 'Help text test!', - ]); - $view = $form->createView(); - $html = $this->renderHelp($view); - - $this->assertMatchesXpath($html, - '/p - [@id="name_help"] - [@class="help-text"] - [.="[trans]Help text test![/trans]"] -' - ); - - $this->assertMatchesXpath($html, - '/p - [@id="name_help"] - [@class="help-text"] - /b - [.="text"] -', 0 - ); - } - - public function testHelpHtmlIsFalse() - { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [ - 'help' => 'Help text test!', - 'help_html' => false, - ]); - $view = $form->createView(); - $html = $this->renderHelp($view); - - $this->assertMatchesXpath($html, - '/p - [@id="name_help"] - [@class="help-text"] - [.="[trans]Help text test![/trans]"] -' - ); - - $this->assertMatchesXpath($html, - '/p - [@id="name_help"] - [@class="help-text"] - /b - [.="text"] -', 0 - ); - } - - public function testHelpHtmlIsTrue() - { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [ - 'help' => 'Help text test!', - 'help_html' => true, - ]); - $view = $form->createView(); - $html = $this->renderHelp($view); - - $this->assertMatchesXpath($html, - '/p - [@id="name_help"] - [@class="help-text"] - [.="[trans]Help text test![/trans]"] -', 0 - ); - - $this->assertMatchesXpath($html, - '/p - [@id="name_help"] - [@class="help-text"] - /b - [.="text"] -' - ); - } - - protected function renderForm(FormView $view, array $vars = []) - { - return (string) $this->engine->get('form')->form($view, $vars); - } - - protected function renderLabel(FormView $view, $label = null, array $vars = []) - { - return (string) $this->engine->get('form')->label($view, $label, $vars); - } - - protected function renderHelp(FormView $view) - { - return (string) $this->engine->get('form')->help($view); - } - - protected function renderErrors(FormView $view) - { - return (string) $this->engine->get('form')->errors($view); - } - - protected function renderWidget(FormView $view, array $vars = []) - { - return (string) $this->engine->get('form')->widget($view, $vars); - } - - protected function renderRow(FormView $view, array $vars = []) - { - return (string) $this->engine->get('form')->row($view, $vars); - } - - protected function renderRest(FormView $view, array $vars = []) - { - return (string) $this->engine->get('form')->rest($view, $vars); - } - - protected function renderStart(FormView $view, array $vars = []) - { - return (string) $this->engine->get('form')->start($view, $vars); - } - - protected function renderEnd(FormView $view, array $vars = []) - { - return (string) $this->engine->get('form')->end($view, $vars); - } - - protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) - { - $this->engine->get('form')->setTheme($view, $themes, $useDefaultThemes); - } - - public static function themeBlockInheritanceProvider() - { - return [ - [['TestBundle:Parent']], - ]; - } - - public static function themeInheritanceProvider() - { - return [ - [['TestBundle:Parent'], ['TestBundle:Child']], - ]; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php deleted file mode 100644 index 8e335788ea335..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php +++ /dev/null @@ -1,159 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper; - -use Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper; -use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTemplateNameParser; -use Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper\Fixtures\StubTranslator; -use Symfony\Component\Form\Extension\Templating\TemplatingExtension; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\Tests\AbstractTableLayoutTest; -use Symfony\Component\Templating\Loader\FilesystemLoader; -use Symfony\Component\Templating\PhpEngine; - -/** - * @group legacy - */ -class FormHelperTableLayoutTest extends AbstractTableLayoutTest -{ - /** - * @var PhpEngine - */ - protected $engine; - - protected static $supportedFeatureSetVersion = 403; - - public function testStartTagHasNoActionAttributeWhenActionIsEmpty() - { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ - 'method' => 'get', - 'action' => '', - ]); - - $html = $this->renderStart($form->createView()); - - $this->assertSame('', $html); - } - - public function testStartTagHasActionAttributeWhenActionIsZero() - { - $form = $this->factory->create('Symfony\Component\Form\Extension\Core\Type\FormType', null, [ - 'method' => 'get', - 'action' => '0', - ]); - - $html = $this->renderStart($form->createView()); - - $this->assertSame('', $html); - } - - public function testHelpAttr() - { - $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [ - 'help' => 'Help text test!', - 'help_attr' => [ - 'class' => 'class-test', - ], - ]); - $view = $form->createView(); - $html = $this->renderHelp($view); - - $this->assertMatchesXpath($html, - '/p - [@id="name_help"] - [@class="class-test help-text"] - [.="[trans]Help text test![/trans]"] -' - ); - } - - protected function getExtensions() - { - // should be moved to the Form component once absolute file paths are supported - // by the default name parser in the Templating component - $reflClass = new \ReflectionClass('Symfony\Bundle\FrameworkBundle\FrameworkBundle'); - $root = realpath(\dirname($reflClass->getFileName()).'/Resources/views'); - $rootTheme = realpath(__DIR__.'/Resources'); - $templateNameParser = new StubTemplateNameParser($root, $rootTheme); - $loader = new FilesystemLoader([]); - - $this->engine = new PhpEngine($templateNameParser, $loader); - $this->engine->addGlobal('global', ''); - $this->engine->setHelpers([ - new TranslatorHelper(new StubTranslator()), - ]); - - return array_merge(parent::getExtensions(), [ - new TemplatingExtension($this->engine, $this->csrfTokenManager, [ - 'FrameworkBundle:Form', - 'FrameworkBundle:FormTable', - ]), - ]); - } - - protected function tearDown() - { - $this->engine = null; - - parent::tearDown(); - } - - protected function renderForm(FormView $view, array $vars = []) - { - return (string) $this->engine->get('form')->form($view, $vars); - } - - protected function renderLabel(FormView $view, $label = null, array $vars = []) - { - return (string) $this->engine->get('form')->label($view, $label, $vars); - } - - protected function renderHelp(FormView $view) - { - return (string) $this->engine->get('form')->help($view); - } - - protected function renderErrors(FormView $view) - { - return (string) $this->engine->get('form')->errors($view); - } - - protected function renderWidget(FormView $view, array $vars = []) - { - return (string) $this->engine->get('form')->widget($view, $vars); - } - - protected function renderRow(FormView $view, array $vars = []) - { - return (string) $this->engine->get('form')->row($view, $vars); - } - - protected function renderRest(FormView $view, array $vars = []) - { - return (string) $this->engine->get('form')->rest($view, $vars); - } - - protected function renderStart(FormView $view, array $vars = []) - { - return (string) $this->engine->get('form')->start($view, $vars); - } - - protected function renderEnd(FormView $view, array $vars = []) - { - return (string) $this->engine->get('form')->end($view, $vars); - } - - protected function setTheme(FormView $view, array $themes, $useDefaultThemes = true) - { - $this->engine->get('form')->setTheme($view, $themes, $useDefaultThemes); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/RequestHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/RequestHelperTest.php deleted file mode 100644 index d29b5c0ff47b6..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/RequestHelperTest.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper; - -use PHPUnit\Framework\TestCase; -use Symfony\Bundle\FrameworkBundle\Templating\Helper\RequestHelper; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; - -/** - * @group legacy - */ -class RequestHelperTest extends TestCase -{ - protected $requestStack; - - protected function setUp() - { - $this->requestStack = new RequestStack(); - $request = new Request(); - $request->initialize(['foobar' => 'bar']); - $this->requestStack->push($request); - } - - public function testGetParameter() - { - $helper = new RequestHelper($this->requestStack); - - $this->assertEquals('bar', $helper->getParameter('foobar')); - $this->assertEquals('foo', $helper->getParameter('bar', 'foo')); - - $this->assertNull($helper->getParameter('foo')); - } - - public function testGetLocale() - { - $helper = new RequestHelper($this->requestStack); - - $this->assertEquals('en', $helper->getLocale()); - } - - public function testGetName() - { - $helper = new RequestHelper($this->requestStack); - - $this->assertEquals('request', $helper->getName()); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Child/form_label.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Child/form_label.html.php deleted file mode 100644 index aebb53d3e7221..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Child/form_label.html.php +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_c_entry_label.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_c_entry_label.html.php deleted file mode 100644 index 4ad7e75ddcc12..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_c_entry_label.html.php +++ /dev/null @@ -1,2 +0,0 @@ -humanize($name); } ?> - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_names_entry_label.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_names_entry_label.html.php deleted file mode 100644 index 71de9d4631de7..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_names_entry_label.html.php +++ /dev/null @@ -1,4 +0,0 @@ -humanize($name); -} ?> - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_text_id_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_text_id_widget.html.php deleted file mode 100644 index 078fe57583f1c..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_text_id_widget.html.php +++ /dev/null @@ -1,3 +0,0 @@ -
- widget($form) ?> -
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Parent/form_label.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Parent/form_label.html.php deleted file mode 100644 index 068c5dec3ff48..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Parent/form_label.html.php +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Parent/form_widget_simple.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Parent/form_widget_simple.html.php deleted file mode 100644 index 1b53a7213f025..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Parent/form_widget_simple.html.php +++ /dev/null @@ -1,2 +0,0 @@ - -block($form, 'widget_attributes'); ?> value="" rel="theme" /> diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php deleted file mode 100644 index c9521e8e54074..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper; - -use PHPUnit\Framework\TestCase; -use Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; - -/** - * @group legacy - */ -class SessionHelperTest extends TestCase -{ - protected $requestStack; - - protected function setUp() - { - $request = new Request(); - - $session = new Session(new MockArraySessionStorage()); - $session->set('foobar', 'bar'); - $session->getFlashBag()->set('notice', 'bar'); - - $request->setSession($session); - - $this->requestStack = new RequestStack(); - $this->requestStack->push($request); - } - - protected function tearDown() - { - $this->requestStack = null; - } - - public function testFlash() - { - $helper = new SessionHelper($this->requestStack); - - $this->assertTrue($helper->hasFlash('notice')); - - $this->assertEquals(['bar'], $helper->getFlash('notice')); - } - - public function testGetFlashes() - { - $helper = new SessionHelper($this->requestStack); - $this->assertEquals(['notice' => ['bar']], $helper->getFlashes()); - } - - public function testGet() - { - $helper = new SessionHelper($this->requestStack); - - $this->assertEquals('bar', $helper->get('foobar')); - $this->assertEquals('foo', $helper->get('bar', 'foo')); - - $this->assertNull($helper->get('foo')); - } - - public function testGetName() - { - $helper = new SessionHelper($this->requestStack); - - $this->assertEquals('session', $helper->getName()); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php deleted file mode 100644 index f5030b4e79fc1..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper; - -use PHPUnit\Framework\TestCase; -use Symfony\Bundle\FrameworkBundle\Templating\Helper\StopwatchHelper; - -/** - * @group legacy - */ -class StopwatchHelperTest extends TestCase -{ - public function testDevEnvironment() - { - $stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock(); - $stopwatch->expects($this->once()) - ->method('start') - ->with('foo'); - - $helper = new StopwatchHelper($stopwatch); - $helper->start('foo'); - } - - public function testProdEnvironment() - { - $helper = new StopwatchHelper(null); - $helper->start('foo'); - - // add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above - // can be executed without throwing any exceptions - $this->addToAssertionCount(1); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php deleted file mode 100644 index 393539952d1b2..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php +++ /dev/null @@ -1,101 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Loader; - -use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator; -use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; - -/** - * @group legacy - */ -class TemplateLocatorTest extends TestCase -{ - public function testLocateATemplate() - { - $template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine'); - - $fileLocator = $this->getFileLocator(); - - $fileLocator - ->expects($this->once()) - ->method('locate') - ->with($template->getPath()) - ->willReturn('/path/to/template') - ; - - $locator = new TemplateLocator($fileLocator); - - $this->assertEquals('/path/to/template', $locator->locate($template)); - - // Assert cache is used as $fileLocator->locate should be called only once - $this->assertEquals('/path/to/template', $locator->locate($template)); - } - - public function testLocateATemplateFromCacheDir() - { - $template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine'); - - $fileLocator = $this->getFileLocator(); - - $locator = new TemplateLocator($fileLocator, __DIR__.'/../../Fixtures'); - - $this->assertEquals(realpath(__DIR__.'/../../Fixtures/Resources/views/this.is.a.template.format.engine'), $locator->locate($template)); - } - - public function testThrowsExceptionWhenTemplateNotFound() - { - $template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine'); - - $fileLocator = $this->getFileLocator(); - - $errorMessage = 'FileLocator exception message'; - - $fileLocator - ->expects($this->once()) - ->method('locate') - ->willThrowException(new \InvalidArgumentException($errorMessage)) - ; - - $locator = new TemplateLocator($fileLocator); - - try { - $locator->locate($template); - $this->fail('->locate() should throw an exception when the file is not found.'); - } catch (\InvalidArgumentException $e) { - $this->assertContains( - $errorMessage, - $e->getMessage(), - 'TemplateLocator exception should propagate the FileLocator exception message' - ); - } - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testThrowsAnExceptionWhenTemplateIsNotATemplateReferenceInterface() - { - $locator = new TemplateLocator($this->getFileLocator()); - $locator->locate('template'); - } - - protected function getFileLocator() - { - return $this - ->getMockBuilder('Symfony\Component\Config\FileLocator') - ->setMethods(['locate']) - ->setConstructorArgs(['/path/to/fallback']) - ->getMock() - ; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php deleted file mode 100644 index 47f3f360aa747..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php +++ /dev/null @@ -1,79 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; - -use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables; -use Symfony\Bundle\FrameworkBundle\Templating\PhpEngine; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; -use Symfony\Component\Templating\TemplateNameParser; - -/** - * @group legacy - */ -class PhpEngineTest extends TestCase -{ - public function testEvaluateAddsAppGlobal() - { - $container = $this->getContainer(); - $loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); - $engine = new PhpEngine(new TemplateNameParser(), $container, $loader, $app = new GlobalVariables($container)); - $globals = $engine->getGlobals(); - $this->assertSame($app, $globals['app']); - } - - public function testEvaluateWithoutAvailableRequest() - { - $container = new Container(); - $loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); - $engine = new PhpEngine(new TemplateNameParser(), $container, $loader, new GlobalVariables($container)); - - $this->assertFalse($container->has('request_stack')); - $globals = $engine->getGlobals(); - $this->assertEmpty($globals['app']->getRequest()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testGetInvalidHelper() - { - $container = $this->getContainer(); - $loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); - $engine = new PhpEngine(new TemplateNameParser(), $container, $loader); - - $engine->get('non-existing-helper'); - } - - /** - * Creates a Container with a Session-containing Request service. - * - * @return Container - */ - protected function getContainer() - { - $container = new Container(); - $session = new Session(new MockArraySessionStorage()); - $request = new Request(); - $stack = new RequestStack(); - $stack->push($request); - - $request->setSession($session); - $container->set('request_stack', $stack); - - return $container; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php deleted file mode 100644 index 305be175910b8..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; - -use Symfony\Bundle\FrameworkBundle\Templating\TemplateFilenameParser; -use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; - -/** - * @group legacy - */ -class TemplateFilenameParserTest extends TestCase -{ - protected $parser; - - protected function setUp() - { - $this->parser = new TemplateFilenameParser(); - } - - protected function tearDown() - { - $this->parser = null; - } - - /** - * @dataProvider getFilenameToTemplateProvider - */ - public function testParseFromFilename($file, $ref) - { - $template = $this->parser->parse($file); - - if (false === $ref) { - $this->assertFalse($template); - } else { - $this->assertEquals($template->getLogicalName(), $ref->getLogicalName()); - } - } - - public function getFilenameToTemplateProvider() - { - return [ - ['/path/to/section/name.format.engine', new TemplateReference('', '/path/to/section', 'name', 'format', 'engine')], - ['\\path\\to\\section\\name.format.engine', new TemplateReference('', '/path/to/section', 'name', 'format', 'engine')], - ['name.format.engine', new TemplateReference('', '', 'name', 'format', 'engine')], - ['name.format', false], - ['name', false], - ]; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php deleted file mode 100644 index 49136769f2da4..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; - -use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser; -use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; -use Symfony\Component\Templating\TemplateReference as BaseTemplateReference; - -/** - * @group legacy - */ -class TemplateNameParserTest extends TestCase -{ - protected $parser; - - protected function setUp() - { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock(); - $kernel - ->expects($this->any()) - ->method('getBundle') - ->willReturnCallback(function ($bundle) { - if (\in_array($bundle, ['SensioFooBundle', 'SensioCmsFooBundle', 'FooBundle'])) { - return true; - } - - throw new \InvalidArgumentException(); - }) - ; - $this->parser = new TemplateNameParser($kernel); - } - - protected function tearDown() - { - $this->parser = null; - } - - /** - * @dataProvider parseProvider - */ - public function testParse($name, $logicalName, $path, $ref) - { - $template = $this->parser->parse($name); - - $this->assertSame($ref->getLogicalName(), $template->getLogicalName()); - $this->assertSame($logicalName, $template->getLogicalName()); - $this->assertSame($path, $template->getPath()); - } - - public function parseProvider() - { - return [ - ['FooBundle:Post:index.html.php', 'FooBundle:Post:index.html.php', '@FooBundle/Resources/views/Post/index.html.php', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php')], - ['FooBundle:Post:index.html.twig', 'FooBundle:Post:index.html.twig', '@FooBundle/Resources/views/Post/index.html.twig', new TemplateReference('FooBundle', 'Post', 'index', 'html', 'twig')], - ['FooBundle:Post:index.xml.php', 'FooBundle:Post:index.xml.php', '@FooBundle/Resources/views/Post/index.xml.php', new TemplateReference('FooBundle', 'Post', 'index', 'xml', 'php')], - ['SensioFooBundle:Post:index.html.php', 'SensioFooBundle:Post:index.html.php', '@SensioFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioFooBundle', 'Post', 'index', 'html', 'php')], - ['SensioCmsFooBundle:Post:index.html.php', 'SensioCmsFooBundle:Post:index.html.php', '@SensioCmsFooBundle/Resources/views/Post/index.html.php', new TemplateReference('SensioCmsFooBundle', 'Post', 'index', 'html', 'php')], - [':Post:index.html.php', ':Post:index.html.php', 'views/Post/index.html.php', new TemplateReference('', 'Post', 'index', 'html', 'php')], - ['::index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')], - ['index.html.php', '::index.html.php', 'views/index.html.php', new TemplateReference('', '', 'index', 'html', 'php')], - ['FooBundle:Post:foo.bar.index.html.php', 'FooBundle:Post:foo.bar.index.html.php', '@FooBundle/Resources/views/Post/foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')], - ['@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', new BaseTemplateReference('@FooBundle/Resources/views/layout.html.twig', 'twig')], - ['@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', new BaseTemplateReference('@FooBundle/Foo/layout.html.twig', 'twig')], - ['name.twig', 'name.twig', 'name.twig', new BaseTemplateReference('name.twig', 'twig')], - ['name', 'name', 'name', new BaseTemplateReference('name')], - ['default/index.html.php', '::default/index.html.php', 'views/default/index.html.php', new TemplateReference(null, null, 'default/index', 'html', 'php')], - ]; - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testParseValidNameWithNotFoundBundle() - { - $this->parser->parse('BarBundle:Post:index.html.php'); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateReferenceTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateReferenceTest.php deleted file mode 100644 index 179c3b6da0dbd..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateReferenceTest.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; - -use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; - -/** - * @group legacy - */ -class TemplateReferenceTest extends TestCase -{ - public function testGetPathWorksWithNamespacedControllers() - { - $reference = new TemplateReference('AcmeBlogBundle', 'Admin\Post', 'index', 'html', 'twig'); - - $this->assertSame( - '@AcmeBlogBundle/Resources/views/Admin/Post/index.html.twig', - $reference->getPath() - ); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php deleted file mode 100644 index 899740169f207..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; - -use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; - -/** - * @group legacy - */ -class TemplateTest extends TestCase -{ - /** - * @dataProvider getTemplateToPathProvider - */ - public function testGetPathForTemplate($template, $path) - { - $this->assertSame($template->getPath(), $path); - } - - public function getTemplateToPathProvider() - { - return [ - [new TemplateReference('FooBundle', 'Post', 'index', 'html', 'php'), '@FooBundle/Resources/views/Post/index.html.php'], - [new TemplateReference('FooBundle', '', 'index', 'html', 'twig'), '@FooBundle/Resources/views/index.html.twig'], - [new TemplateReference('', 'Post', 'index', 'html', 'php'), 'views/Post/index.html.php'], - [new TemplateReference('', '', 'index', 'html', 'php'), 'views/index.html.php'], - ]; - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php deleted file mode 100644 index 4bdb0ccda565f..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; - -use Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables; -use Symfony\Bundle\FrameworkBundle\Templating\TimedPhpEngine; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; -use Symfony\Component\DependencyInjection\Container; - -/** - * @group legacy - */ -class TimedPhpEngineTest extends TestCase -{ - public function testThatRenderLogsTime() - { - $container = $this->getContainer(); - $templateNameParser = $this->getTemplateNameParser(); - $globalVariables = $this->getGlobalVariables(); - $loader = $this->getLoader($this->getStorage()); - - $stopwatch = $this->getStopwatch(); - $stopwatchEvent = $this->getStopwatchEvent(); - - $stopwatch->expects($this->once()) - ->method('start') - ->with('template.php (index.php)', 'template') - ->willReturn($stopwatchEvent); - - $stopwatchEvent->expects($this->once())->method('stop'); - - $engine = new TimedPhpEngine($templateNameParser, $container, $loader, $stopwatch, $globalVariables); - $engine->render('index.php'); - } - - /** - * @return Container - */ - private function getContainer() - { - return $this->getMockBuilder('Symfony\Component\DependencyInjection\Container')->getMock(); - } - - /** - * @return \Symfony\Component\Templating\TemplateNameParserInterface - */ - private function getTemplateNameParser() - { - $templateReference = $this->getMockBuilder('Symfony\Component\Templating\TemplateReferenceInterface')->getMock(); - $templateNameParser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); - $templateNameParser->expects($this->any()) - ->method('parse') - ->willReturn($templateReference); - - return $templateNameParser; - } - - /** - * @return GlobalVariables - */ - private function getGlobalVariables() - { - return $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables') - ->disableOriginalConstructor() - ->getMock(); - } - - /** - * @return \Symfony\Component\Templating\Storage\StringStorage - */ - private function getStorage() - { - return $this->getMockBuilder('Symfony\Component\Templating\Storage\StringStorage') - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - } - - /** - * @param \Symfony\Component\Templating\Storage\StringStorage $storage - * - * @return \Symfony\Component\Templating\Loader\Loader - */ - private function getLoader($storage) - { - $loader = $this->getMockForAbstractClass('Symfony\Component\Templating\Loader\Loader'); - $loader->expects($this->once()) - ->method('load') - ->willReturn($storage); - - return $loader; - } - - /** - * @return \Symfony\Component\Stopwatch\StopwatchEvent - */ - private function getStopwatchEvent() - { - return $this->getMockBuilder('Symfony\Component\Stopwatch\StopwatchEvent') - ->disableOriginalConstructor() - ->getMock(); - } - - /** - * @return \Symfony\Component\Stopwatch\Stopwatch - */ - private function getStopwatch() - { - return $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock(); - } -} diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index f3fc1262a9c5b..efe19217ff3d6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -49,8 +49,7 @@ "symfony/serializer": "^4.4|^5.0", "symfony/stopwatch": "^4.4|^5.0", "symfony/translation": "^4.4|^5.0", - "symfony/templating": "^4.4|^5.0", - "symfony/twig-bundle": "^4.4|^5.0", + "symfony/twig-bundle": "^5.0", "symfony/validator": "^4.4|^5.0", "symfony/var-dumper": "^4.4|^5.0", "symfony/workflow": "^4.4|^5.0", @@ -77,6 +76,7 @@ "symfony/serializer": "<4.4", "symfony/stopwatch": "<4.4", "symfony/translation": "<4.4", + "symfony/twig-bundle": "<5.0", "symfony/twig-bridge": "<4.4", "symfony/validator": "<4.4", "symfony/workflow": "<4.4" diff --git a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md index d0cef610d9ced..b6706cd09a3f1 100644 --- a/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/SecurityBundle/CHANGELOG.md @@ -4,11 +4,12 @@ CHANGELOG 5.0.0 ----- -* Removed the ability to configure encoders using `argon2i` or `bcrypt` as algorithm, use `auto` instead -* The `simple_form` and `simple_preauth` authentication listeners have been removed, - use Guard instead. -* The `SimpleFormFactory` and `SimplePreAuthenticationFactory` classes have been removed, - use Guard instead. + * Removed the ability to configure encoders using `argon2i` or `bcrypt` as algorithm, use `auto` instead + * The `simple_form` and `simple_preauth` authentication listeners have been removed, + use Guard instead. + * The `SimpleFormFactory` and `SimplePreAuthenticationFactory` classes have been removed, + use Guard instead. + * Removed `LogoutUrlHelper` and `SecurityHelper` templating helpers, use Twig instead 4.3.0 ----- diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index 8cb11887429bd..a05e2f636769d 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -33,7 +33,6 @@ use Symfony\Component\Security\Core\Encoder\SodiumPasswordEncoder; use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Http\Controller\UserValueResolver; -use Symfony\Component\Templating\PhpEngine; /** * SecurityExtension. @@ -99,9 +98,6 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('security.xml'); $loader->load('security_listeners.xml'); $loader->load('security_rememberme.xml'); - if (class_exists(PhpEngine::class)) { - $loader->load('templating_php.xml'); - } $loader->load('templating_twig.xml'); $loader->load('collectors.xml'); $loader->load('guard.xml'); diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_php.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_php.xml deleted file mode 100644 index b2bafbc60546f..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_php.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - - - - - The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. - - - diff --git a/src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php b/src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php deleted file mode 100644 index 30ef9c2829028..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\SecurityBundle\Templating\Helper; - -@trigger_error('The '.LogoutUrlHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator; -use Symfony\Component\Templating\Helper\Helper; - -/** - * LogoutUrlHelper provides generator functions for the logout URL. - * - * @author Jeremy Mikola - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class LogoutUrlHelper extends Helper -{ - private $generator; - - public function __construct(LogoutUrlGenerator $generator) - { - $this->generator = $generator; - } - - /** - * Generates the absolute logout path for the firewall. - * - * @param string|null $key The firewall key or null to use the current firewall key - * - * @return string The logout path - */ - public function getLogoutPath($key) - { - return $this->generator->getLogoutPath($key); - } - - /** - * Generates the absolute logout URL for the firewall. - * - * @param string|null $key The firewall key or null to use the current firewall key - * - * @return string The logout URL - */ - public function getLogoutUrl($key) - { - return $this->generator->getLogoutUrl($key); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'logout_url'; - } -} diff --git a/src/Symfony/Bundle/SecurityBundle/Templating/Helper/SecurityHelper.php b/src/Symfony/Bundle/SecurityBundle/Templating/Helper/SecurityHelper.php deleted file mode 100644 index f6738bd3690df..0000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Templating/Helper/SecurityHelper.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\SecurityBundle\Templating\Helper; - -@trigger_error('The '.SecurityHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Symfony\Component\Security\Acl\Voter\FieldVote; -use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; -use Symfony\Component\Templating\Helper\Helper; - -/** - * SecurityHelper provides read-only access to the security checker. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. - */ -class SecurityHelper extends Helper -{ - private $securityChecker; - - public function __construct(AuthorizationCheckerInterface $securityChecker = null) - { - $this->securityChecker = $securityChecker; - } - - public function isGranted($role, $object = null, $field = null) - { - if (null === $this->securityChecker) { - return false; - } - - if (null !== $field) { - $object = new FieldVote($object, $field); - } - - return $this->securityChecker->isGranted($role, $object); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'security'; - } -} diff --git a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md index 9f7ddd9fbe2a6..2e032c1c6c817 100644 --- a/src/Symfony/Bundle/TwigBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/TwigBundle/CHANGELOG.md @@ -6,6 +6,8 @@ CHANGELOG * updated default value for the `strict_variables` option to `%kernel.debug%` parameter * removed support to load templates from the legacy directories `src/Resources/views/` and `src/Resources//views/` + * removed `TwigEngine` class, use `Twig\Environment` instead + * removed `FilesystemLoader` and `NativeFilesystemLoader`, use Twig notation for templates instead 4.2.0 ----- diff --git a/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php b/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php index 4905bd3b1e1f5..e69de29bb2d1d 100644 --- a/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php +++ b/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php @@ -1,127 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\CacheWarmer; - -@trigger_error('The '.TemplateCacheCacheWarmer::class.' class is deprecated since version 4.4 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); - -use Psr\Container\ContainerInterface; -use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface; -use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; -use Symfony\Component\Finder\Finder; -use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; -use Twig\Environment; -use Twig\Error\Error; - -/** - * Generates the Twig cache for all templates. - * - * This warmer must be registered after TemplatePathsCacheWarmer, - * as the Twig loader will need the cache generated by it. - * - * @author Fabien Potencier - * - * @deprecated since version 4.4, to be removed in 5.0; use Twig instead. - */ -class TemplateCacheCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface -{ - protected $container; - protected $finder; - private $paths; - - /** - * @param array $paths Additional twig paths to warm - */ - public function __construct(ContainerInterface $container, TemplateFinderInterface $finder = null, array $paths = []) - { - // We don't inject the Twig environment directly as it depends on the - // template locator (via the loader) which might be a cached one. - // The cached template locator is available once the TemplatePathsCacheWarmer - // has been warmed up. - // But it can also be null if templating has been disabled. - $this->container = $container; - $this->finder = $finder; - $this->paths = $paths; - } - - /** - * Warms up the cache. - * - * @param string $cacheDir The cache directory - */ - public function warmUp($cacheDir) - { - if (null === $this->finder) { - return; - } - - $twig = $this->container->get('twig'); - - $templates = $this->finder->findAllTemplates(); - - foreach ($this->paths as $path => $namespace) { - $templates = array_merge($templates, $this->findTemplatesInFolder($namespace, $path)); - } - - foreach ($templates as $template) { - try { - $twig->loadTemplate($template); - } catch (Error $e) { - // problem during compilation, give up - } - } - } - - /** - * Checks whether this warmer is optional or not. - * - * @return bool always true - */ - public function isOptional() - { - return true; - } - - /** - * {@inheritdoc} - */ - public static function getSubscribedServices() - { - return [ - 'twig' => Environment::class, - ]; - } - - /** - * Find templates in the given directory. - * - * @param string $namespace The namespace for these templates - * @param string $dir The folder where to look for templates - * - * @return array An array of templates - */ - private function findTemplatesInFolder($namespace, $dir) - { - if (!is_dir($dir)) { - return []; - } - - $templates = []; - $finder = new Finder(); - - foreach ($finder->files()->followLinks()->in($dir) as $file) { - $name = $file->getRelativePathname(); - $templates[] = $namespace ? sprintf('@%s/%s', $namespace, $name) : $name; - } - - return $templates; - } -} diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php index 6b6149ad57c57..8746eca30ebfb 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php @@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; /** - * Registers the Twig exception listener if Twig is registered as a templating engine. + * Registers the Twig exception listener if required dependencies do exist. * * @author Fabien Potencier */ @@ -27,14 +27,9 @@ public function process(ContainerBuilder $container) return; } - // register the exception controller only if Twig is enabled and required dependencies do exist + // register the exception controller only if required dependencies do exist if (!class_exists('Symfony\Component\Debug\Exception\FlattenException') || !interface_exists('Symfony\Component\EventDispatcher\EventSubscriberInterface')) { $container->removeDefinition('twig.exception_listener'); - } elseif ($container->hasParameter('templating.engines')) { - $engines = $container->getParameter('templating.engines'); - if (!\in_array('twig', $engines)) { - $container->removeDefinition('twig.exception_listener'); - } } } } diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php index ba7e782378c84..14156b4f3f61e 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php @@ -14,7 +14,6 @@ use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Workflow\Workflow; /** @@ -50,12 +49,6 @@ public function process(ContainerBuilder $container) $paths = $container->getDefinition('twig.template_iterator')->getArgument(2); $paths[$coreThemePath] = null; $container->getDefinition('twig.template_iterator')->replaceArgument(2, $paths); - - if ($container->hasDefinition('twig.cache_warmer')) { - $paths = $container->getDefinition('twig.cache_warmer')->getArgument(2); - $paths[$coreThemePath] = null; - $container->getDefinition('twig.cache_warmer')->replaceArgument(2, $paths); - } } if ($container->has('router')) { @@ -66,11 +59,9 @@ public function process(ContainerBuilder $container) $container->getDefinition('twig.extension.httpkernel')->addTag('twig.extension'); $container->getDefinition('twig.runtime.httpkernel')->addTag('twig.runtime'); - // inject Twig in the hinclude service if Twig is the only registered templating engine - if ((!$container->hasParameter('templating.engines') || ['twig'] == $container->getParameter('templating.engines')) && $container->hasDefinition('fragment.renderer.hinclude')) { + if ($container->hasDefinition('fragment.renderer.hinclude')) { $container->getDefinition('fragment.renderer.hinclude') ->addTag('kernel.fragment_renderer', ['alias' => 'hinclude']) - ->replaceArgument(0, new Reference('twig')) ; } } @@ -96,17 +87,7 @@ public function process(ContainerBuilder $container) $container->getDefinition('twig.extension.weblink')->addTag('twig.extension'); } - $twigLoader = $container->getDefinition('twig.loader.native_filesystem'); - if ($container->has('templating')) { - $loader = $container->getDefinition('twig.loader.filesystem'); - $loader->setMethodCalls(array_merge($twigLoader->getMethodCalls(), $loader->getMethodCalls())); - - $twigLoader->clearTag('twig.loader'); - } else { - $container->setAlias('twig.loader.filesystem', new Alias('twig.loader.native_filesystem', false)); - $container->removeDefinition('templating.engine.twig'); - $container->removeDefinition('twig.cache_warmer'); - } + $container->setAlias('twig.loader.filesystem', new Alias('twig.loader.native_filesystem', false)); if ($container->has('assets.packages')) { $container->getDefinition('twig.extension.assets')->addTag('twig.extension'); diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index d56dc154c7f43..073d77b45acba 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -42,10 +42,6 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('form.xml'); } - if (interface_exists('Symfony\Component\Templating\EngineInterface')) { - $loader->load('templating.xml'); - } - if (class_exists(Application::class)) { $loader->load('console.xml'); } @@ -91,10 +87,6 @@ public function load(array $configs, ContainerBuilder $container) $twigFilesystemLoaderDefinition = $container->getDefinition('twig.loader.native_filesystem'); - if ($container->getParameter('kernel.debug')) { - $twigFilesystemLoaderDefinition->setClass(NativeFilesystemLoader::class); - } - // register user-configured paths foreach ($config['paths'] as $path => $namespace) { if (!$namespace) { @@ -105,7 +97,6 @@ public function load(array $configs, ContainerBuilder $container) } // paths are modified in ExtensionPass if forms are enabled - $container->getDefinition('twig.cache_warmer')->replaceArgument(2, $config['paths']); $container->getDefinition('twig.template_iterator')->replaceArgument(2, $config['paths']); foreach ($this->getBundleTemplatePaths($container, $config) as $name => $paths) { @@ -156,7 +147,6 @@ public function load(array $configs, ContainerBuilder $container) $container->registerForAutoconfiguration(RuntimeExtensionInterface::class)->addTag('twig.runtime'); if (false === $config['cache']) { - $container->removeDefinition('twig.cache_warmer'); $container->removeDefinition('twig.template_cache_warmer'); } } diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php deleted file mode 100644 index 1757a5997ced1..0000000000000 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Loader; - -@trigger_error('The '.FilesystemLoader::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig notation for templates instead.', E_USER_DEPRECATED); - -use Symfony\Component\Config\FileLocatorInterface; -use Symfony\Component\Templating\TemplateNameParserInterface; -use Symfony\Component\Templating\TemplateReferenceInterface; -use Twig\Error\LoaderError; -use Twig\Loader\FilesystemLoader as BaseFilesystemLoader; - -/** - * FilesystemLoader extends the default Twig filesystem loader - * to work with the Symfony paths and template references. - * - * @author Fabien Potencier - * - * @deprecated since version 4.3, to be removed in 5.0; use Twig notation for templates instead. - */ -class FilesystemLoader extends BaseFilesystemLoader -{ - protected $locator; - protected $parser; - - /** - * @param string|null $rootPath The root path common to all relative paths (null for getcwd()) - */ - public function __construct(FileLocatorInterface $locator, TemplateNameParserInterface $parser, string $rootPath = null) - { - parent::__construct([], $rootPath); - - $this->locator = $locator; - $this->parser = $parser; - } - - /** - * {@inheritdoc} - * - * The name parameter might also be a TemplateReferenceInterface. - */ - public function exists($name) - { - return parent::exists((string) $name); - } - - /** - * Returns the path to the template file. - * - * The file locator is used to locate the template when the naming convention - * is the symfony one (i.e. the name can be parsed). - * Otherwise the template is located using the locator from the twig library. - * - * @param string|TemplateReferenceInterface $template The template - * @param bool $throw When true, a LoaderError exception will be thrown if a template could not be found - * - * @return string The path to the template file - * - * @throws LoaderError if the template could not be found - */ - protected function findTemplate($template, $throw = true) - { - $logicalName = (string) $template; - - if (isset($this->cache[$logicalName])) { - return $this->cache[$logicalName]; - } - - $file = null; - try { - $file = parent::findTemplate($logicalName); - } catch (LoaderError $e) { - $twigLoaderException = $e; - - // for BC - try { - $template = $this->parser->parse($template); - $file = $this->locator->locate($template); - } catch (\Exception $e) { - } - } - - if (false === $file || null === $file) { - if ($throw) { - throw $twigLoaderException; - } - - return false; - } - - return $this->cache[$logicalName] = $file; - } -} diff --git a/src/Symfony/Bundle/TwigBundle/Loader/NativeFilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/NativeFilesystemLoader.php deleted file mode 100644 index 9ef58d7bdbbe6..0000000000000 --- a/src/Symfony/Bundle/TwigBundle/Loader/NativeFilesystemLoader.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Loader; - -use Twig\Error\LoaderError; -use Twig\Loader\FilesystemLoader; - -/** - * @author Behnoush Norouzali - * - * @internal - */ -class NativeFilesystemLoader extends FilesystemLoader -{ - /** - * {@inheritdoc} - */ - protected function findTemplate($template, $throw = true) - { - try { - return parent::findTemplate($template, $throw); - } catch (LoaderError $e) { - if ('' === $template || '@' === $template[0] || !preg_match('/^(?P[^:]*?)(?:Bundle)?:(?P[^:]*+):(?P