8000 [TwigBridge] Swapped $rootDir and $fileLinkFormatter arguments in DebugCommand by yceruto · Pull Request #31688 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[TwigBridge] Swapped $rootDir and $fileLinkFormatter arguments in DebugCommand #31688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions UPGRADE-4.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Bridge/Twig/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
-----

Expand Down
18 changes: 15 additions & 3 deletions src/Symfony/Bridge/Twig/Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,28 @@ 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();

$this->twig = $twig;
$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()
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ private function createCommandTester(array $paths = [], array $bundleMetadata =
}

$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);
Expand Down
54C3
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<argument>%kernel.project_dir%</argument>
<argument>%kernel.bundles_metadata%</argument>
<argument>%twig.default_path%</argument>
<argument>%kernel.root_dir%</argument>
<argument type="service" id="debug.file_link_formatter" on-invalid="null" />
<argument>%kernel.root_dir%</argument>
<tag name="console.command" command="debug:twig" />
</service>

Expand Down
0