8000 minor #31688 [TwigBridge] Swapped $rootDir and $fileLinkFormatter arg… · symfony/symfony@ea8c054 · GitHub
[go: up one dir, main page]

Skip to content

Commit ea8c054

Browse files
committed
minor #31688 [TwigBridge] Swapped $rootDir and $fileLinkFormatter arguments in DebugCommand (yceruto)
This PR was merged into the 4.4 branch. Discussion ---------- [TwigBridge] Swapped $rootDir and $fileLinkFormatter arguments in DebugCommand | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This is necessary to remove the `$rootDir` in 5.0, see #31667 Commits ------- beca864 exchanged $rootDir and $fileLinkFormatter arguments in DebugCommand
2 parents 5af3e54 + beca864 commit ea8c054

File tree

6 files changed

+30
-5
lines changed

6 files changed

+30
-5
lines changed

UPGRADE-4.4.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ DependencyInjection
1919
my_service:
2020
factory: ['@factory_service', method]
2121
```
22+
23+
TwigBridge
24+
----------
25+
26+
* Deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the
27+
`DebugCommand::__construct()` method, swap the variables position.

UPGRADE-5.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ TwigBundle
404404
TwigBridge
405405
----------
406406

407+
* Removed argument `$rootDir` from the `DebugCommand::__construct()` method and the 5th argument must be an instance of `FileLinkFormatter`
407408
* removed the `$requestStack` and `$requestContext` arguments of the
408409
`HttpFoundationExtension`, pass a `Symfony\Component\HttpFoundation\UrlHelper`
409410
instance as the only argument instead

src/Symfony/Bridge/Twig/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
4.4.0
5+
-----
6+
7+
* deprecated to pass `$rootDir` and `$fileLinkFormatter` as 5th and 6th argument respectively to the
8+
`DebugCommand::__construct()` method, swap the variables position.
9+
410
4.3.0
511
-----
612

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,28 @@ class DebugCommand extends Command
4242
private $filesystemLoaders;
4343
private $fileLinkFormatter;
4444

45-
public function __construct(Environment $twig, string $projectDir = null, array $bundlesMetadata = [], string $twigDefaultPath = null, string $rootDir = null, FileLinkFormatter $fileLinkFormatter = null)
45+
/**
46+
* @param FileLinkFormatter|null $fileLinkFormatter
47+
* @param string|null $rootDir
48+
*/
49+
public function __construct(Environment $twig, string $projectDir = null, array $bundlesMetadata = [], string $twigDefaultPath = null, $fileLinkFormatter = null, $rootDir = null)
4650
{
4751
parent::__construct();
4852

4953
$this->twig = $twig;
5054
$this->projectDir = $projectDir;
5155
$this->bundlesMetadata = $bundlesMetadata;
5256
$this->twigDefaultPath = $twigDefaultPath;
53-
$this->rootDir = $rootDir;
54-
$this->fileLinkFormatter = $fileLinkFormatter;
57+
58+
if (\is_string($fileLinkFormatter) || $rootDir instanceof FileLinkFormatter) {
59+
@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);
60+
61+
$this->rootDir = $fileLinkFormatter;
62+
$this->fileLinkFormatter = $rootDir;
63+
} else {
64+
$this->fileLinkFormatter = $fileLinkFormatter;
65+
$this->rootDir = $rootDir;
66+
}
5567
}
5668

5769
protected function configure()

src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ private function createCommandTester(array $paths = [], array $bundleMetadata =
342342
}
343343

344344
$application = new Application();
345-
$application->add(new DebugCommand($environment, $projectDir, $bundleMetadata, $defaultPath, $rootDir));
345+
$application->add(new DebugCommand($environment, $projectDir, $bundleMetadata, $defaultPath, null, $rootDir));
346346
$command = $application->find('debug:twig');
347347

348348
return new CommandTester($command);

src/Symfony/Bundle/TwigBundle/Resources/config/console.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<argument>%kernel.project_dir%</argument>
1313
<argument>%kernel.bundles_metadata%</argument>
1414
<argument>%twig.default_path%</argument>
15-
<argument>%kernel.root_dir%</argument>
1615
<argument type="service" id="debug.file_link_formatter" on-invalid="null" />
16+
<argument>%kernel.root_dir%</argument>
1717
<tag name="console.command" command="debug:twig" />
1818
</service>
1919

0 commit comments

Comments
 (0)
0