From beca8642ca0f1f13b7884d5fe5a4e00c3445cd5f Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Wed, 29 May 2019 08:39:34 -0400 Subject: [PATCH] exchanged $rootDir and $fileLinkFormatter arguments in DebugCommand --- UPGRADE-4.4.md | 6 ++++++ UPGRADE-5.0.md | 1 + src/Symfony/Bridge/Twig/CHANGELOG.md | 6 ++++++ .../Bridge/Twig/Command/DebugCommand.php | 18 +++++++++++++++--- .../Twig/Tests/Command/DebugCommandTest.php | 2 +- .../TwigBundle/Resources/config/console.xml | 2 +- 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/UPGRADE-4.4.md b/UPGRADE-4.4.md index ec1852e3e4..916e089c7b 100644 --- a/UPGRADE-4.4.md +++ b/UPGRADE-4.4.md @@ -19,3 +19,9 @@ DependencyInjection my_service: factory: ['@factory_service', method] ``` + +TwigBridge +---------- + + * Deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the + `DebugCommand::__construct()` method, swap the variables position. diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 74c8bd4580..edb458aeb4 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -404,6 +404,7 @@ TwigBundle TwigBridge ---------- + * Removed argument `$rootDir` from the `DebugCommand::__construct()` method and the 5th argument must be an instance of `FileLinkFormatter` * removed the `$requestStack` and `$requestContext` arguments of the `HttpFoundationExtension`, pass a `Symfony\Component\HttpFoundation\UrlHelper` instance as the only argument instead diff --git a/src/Symfony/Bridge/Twig/CHANGELOG.md b/src/Symfony/Bridge/Twig/CHANGELOG.md index 905d242217..2fbfe125b5 100644 --- a/src/Symfony/Bridge/Twig/CHANGELOG.md +++ b/src/Symfony/Bridge/Twig/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +4.4.0 +----- + + * deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the + `DebugCommand::__construct()` method, swap the variables position. + 4.3.0 ----- diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index 5533a2d98f..e12fd9c04d 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -42,7 +42,11 @@ class DebugCommand extends Command private $filesystemLoaders; private $fileLinkFormatter; - public function __construct(Environment $twig, string $projectDir = null, array $bundlesMetadata = [], string $twigDefaultPath = null, string $rootDir = null, FileLinkFormatter $fileLinkFormatter = null) + /** + * @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) { parent::__construct(); @@ -50,8 +54,16 @@ class DebugCommand extends Command $this->projectDir = $projectDir; $this->bundlesMetadata = $bundlesMetadata; $this->twigDefaultPath = $twigDefaultPath; - $this->rootDir = $rootDir; - $this->fileLinkFormatter = $fileLinkFormatter; + + 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; + } } protected function configure() diff --git a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php index cf46c8e620..516dd75387 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php @@ -342,7 +342,7 @@ TXT } $application = new Application(); - $application->add(new DebugCommand($environment, $projectDir, $bundleMetadata, $defaultPath, $rootDir)); + $application->add(new DebugCommand($environment, $projectDir, $bundleMetadata, $defaultPath, null, $rootDir)); $command = $application->find('debug:twig'); return new CommandTester($command); diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/console.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/console.xml index 03e75a405f..28306e19c5 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/console.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/console.xml @@ -12,8 +12,8 @@ %kernel.project_dir% %kernel.bundles_metadata% %twig.default_path% - %kernel.root_dir% + %kernel.root_dir%