8000 minor #23801 Continuation of #23624 (ro0NL) · symfony/symfony@266d9d3 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 266d9d3

Browse files
minor #23801 Continuation of #23624 (ro0NL)
This PR was squashed before being merged into the 3.4 branch (closes #23801). Discussion ---------- Continuation of #23624 | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> See #23624 (comment) cc @chalasr Also included service injection for init:acl + set:acl and simplification of lint:xliff + lintt:yaml. Btw, i think init:acl needs to be renamed to acl:init :) Commits ------- 5f637c1 Continuation of #23624
2 parents 8be06c4 + 5f637c1 commit 266d9d3

19 files changed

+184
-138
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ class DebugCommand extends Command
3333
*/
3434
public function __construct($twig = null)
3535
{
36-
parent::__construct();
37-
3836
if (!$twig instanceof Environment) {
3937
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
4038

41-
$this->setName(null === $twig ? 'debug:twig' : $twig);
39+
parent::__construct($twig);
4240

4341
return;
4442
}
4543

44+
parent::__construct();
45+
4646
$this->twig = $twig;
4747
}
4848

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ class LintCommand extends Command
3838
*/
3939
public function __construct($twig = null)
4040
{
41-
parent::__construct();
42-
4341
if (!$twig instanceof Environment) {
4442
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
4543

46-
$this->setName(null === $twig ? 'lint:twig' : $twig);
44+
parent::__construct($twig);
4745

4846
return;
4947
}
5048

49+
parent::__construct();
50+
5151
$this->twig = $twig;
5252
}
5353

src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ class AssetsInstallCommand extends ContainerAwareCommand
4242
*/
4343
public function __construct($filesystem = null)
4444
{
45-
parent::__construct();
46-
4745
if (!$filesystem instanceof Filesystem) {
4846
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
4947

50-
$this->setName(null === $filesystem ? 'assets:install' : $filesystem);
48+
parent::__construct($filesystem);
5149

5250
return;
5351
}
5452

53+
parent::__construct();
54+
5555
$this->filesystem = $filesystem;
5656
}
5757

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ class CacheClearCommand extends ContainerAwareCommand
3939
*/
4040
public function __construct($cacheClearer = null, Filesystem $filesystem = null)
4141
{
42-
parent::__construct();
43-
4442
if (!$cacheClearer instanceof CacheClearerInterface) {
4543
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
4644

47-
$this->setName(null === $cacheClearer ? 'cache:clear' : $cacheClearer);
45+
parent::__construct($cacheClearer);
4846

4947
return;
5048
}
5149

50+
parent::__construct();
51+
5252
$this->cacheClearer = $cacheClearer;
5353
$this->filesystem = $filesystem ?: new Filesystem();
5454
}

src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ final class CachePoolClearCommand extends ContainerAwareCommand
3232
*/
3333
public function __construct($poolClearer = null)
3434
{
35-
parent::__construct();
36-
3735
if (!$poolClearer instanceof Psr6CacheClearer) {
3836
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
3937

40-
$this->setName(null === $poolClearer ? 'cache:pool:clear' : $poolClearer);
38+
parent::__construct($poolClearer);
4139

4240
return;
4341
}
4442

43+
parent::__construct();
44+
4545
$this->poolClearer = $poolClearer;
4646
}
4747

src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ class CacheWarmupCommand extends ContainerAwareCommand
3333
*/
3434
public function __construct($cacheWarmer = null)
3535
{
36-
parent::__construct();
37-
3836
if (!$cacheWarmer instanceof CacheWarmerAggregate) {
3937
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
4038

41-
$this->setName(null === $cacheWarmer ? 'cache:warmup' : $cacheWarmer);
39+
parent::__construct($cacheWarmer);
4240

4341
return;
4442
}
4543

44+
parent::__construct();
45+
4646
$this->cacheWarmer = $cacheWarmer;
4747
}
4848

src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ class EventDispatcherDebugCommand extends ContainerAwareCommand
3535
*/
3636
public function __construct($dispatcher = null)
3737
{
38-
parent::__construct();
39-
4038
if (!$dispatcher instanceof EventDispatcherInterface) {
4139
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
4240

43-
$this->setName(null === $dispatcher ? 'debug:event-dispatcher' : $dispatcher);
41+
parent::__construct($dispatcher);
4442

4543
return;
4644
}
4745

46+
parent::__construct();
47+
4848
$this->dispatcher = $dispatcher;
4949
}
5050

src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ class RouterDebugCommand extends ContainerAwareCommand
3939
*/
4040
public function __construct($router = null)
4141
{
42-
parent::__construct();
43-
4442
if (!$router instanceof RouterInterface) {
4543
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
4644

47-
$this->setName(null === $router ? 'debug:router' : $router);
45+
parent::__construct($router);
4846

4947
return;
5048
}
5149

50+
parent::__construct();
51+
5252
$this->router = $router;
5353
}
5454

src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ class RouterMatchCommand extends ContainerAwareCommand
3636
*/
3737
public function __construct($router = null)
3838
{
39-
parent::__construct();
40-
4139
if (!$router instanceof RouterInterface) {
4240
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
4341

44-
$this->setName(null === $router ? 'router:match' : $router);
42+
parent::__construct($router);
4543

4644
return;
4745
}
4846

47+
parent::__construct();
48+
4949
$this->router = $router;
5050
}
5151

src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,31 @@
3636
*/
3737
class TranslationDebugCommand extends ContainerAwareCommand
3838
{
39-
private $translator;
40-
private $loader;
41-
private $extractor;
42-
4339
const MESSAGE_MISSING = 0;
4440
const MESSAGE_UNUSED = 1;
4541
const MESSAGE_EQUALS_FALLBACK = 2;
4642

43+
private $translator;
44+
private $loader;
45+
private $extractor;
46+
4747
/**
4848
* @param TranslatorInterface $translator
4949
* @param TranslationLoader $loader
5050
* @param ExtractorInterface $extractor
5151
*/
5252
public function __construct($translator = null, TranslationLoader $loader = null, ExtractorInterface $extractor = null)
5353
{
54-
parent::__construct();
55-
5654
if (!$translator instanceof TranslatorInterface) {
5755
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
5856

59-
$this->setName(null === $translator ? 'debug:translation' : $translator);
57+
parent::__construct($translator);
6058

6159
return;
6260
}
6361

62+
parent::__construct();
63+
6464
$this->translator = $translator;
6565
$this->loader = $loader;
6666
$this->extractor = $extractor;

src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ class TranslationUpdateCommand extends ContainerAwareCommand
4646
*/
4747
public function __construct($writer = null, TranslationLoader $loader = null, ExtractorInterface $extractor = null, $defaultLocale = null)
4848
{
49-
parent::__construct();
50-
5149
if (!$writer instanceof TranslationWriter) {
5250
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
5351

54-
$this->setName(null === $writer ? 'translation:update' : $writer);
52+
parent::__construct($writer);
5553

5654
return;
5755
}
5856

57+
parent::__construct();
58+
5959
$this->writer = $writer;
6060
$this->loader = $loader;
6161
$this->extractor = $extractor;

src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

14-
use Symfony\Component\Console\Command\Command;
15-
use Symfony\Component\Console\Input\InputInterface;
16-
use Symfony\Component\Console\Output\OutputInterface;
1714
use Symfony\Component\Translation\Command\XliffLintCommand as BaseLintCommand;
1815

1916
/**
@@ -25,39 +22,41 @@
2522
*
2623
* @final since version 3.4
2724
*/
28-
class XliffLintCommand extends Command
25+
class XliffLintCommand extends BaseLintCommand
2926
{
30-
private $command;
31-
32-
/**
33-
* {@inheritdoc}
34-
*/
35-
protected function configure()
27+
public function __construct($name = null, $directoryIteratorProvider = null, $isReadableProvider = null)
3628
{
37-
$this->setName('lint:xliff');
38-
39-
if (!$this->isEnabled()) {
40-
return;
29+
if (func_num_args()) {
30+
@trigger_error(sprintf('Passing a constructor argument in "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
4131
}
4232

43-
$directoryIteratorProvider = function ($directory, $default) {
44-
if (!is_dir($directory)) {
45-
$directory = $this->getApplication()->getKernel()->locateResource($directory);
46-
}
33+
if (null === $directoryIteratorProvider) {
34+
$directoryIteratorProvider = function ($directory, $default) {
35+
if (!is_dir($directory)) {
36+
$directory = $this->getApplication()->getKernel()->locateResource($directory);
37+
}
4738

48-
return $default($directory);
49-
};
39+
return $default($directory);
40+
};
41+
}
42+
43+
if (null === $isReadableProvider) {
44+
$isReadableProvider = function ($fileOrDirectory, $default) {
45+
return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory);
46+
};
47+
}
5048

51-
$isReadableProvider = function ($fileOrDirectory, $default) {
52-
return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory);
53-
};
49+
parent::__construct($name, $directoryIteratorProvider, $isReadableProvider);
50+
}
5451

55-
$this->command = new BaseLintCommand(null, $directoryIteratorProvider, $isReadableProvider);
52+
/**
53+
* {@inheritdoc}
54+
*/
55+
protected function configure()
56+
{
57+
parent::configure();
5658

57-
$this
58-
->setDescription($this->command->getDescription())
59-
->setDefinition($this->command->getDefinition())
60-
->setHelp($this->command->getHelp().<<<'EOF'
59+
$this->setHelp($this->getHelp().<<<'EOF'
6160
6261
Or find all files in a bundle:
6362
@@ -66,17 +65,4 @@ protected function configure()
6665
EOF
6766
);
6867
}
69-
70-
/**
71-
* {@inheritdoc}
72-
*/
73-
public function isEnabled()
74-
{
75-
return class_exists(BaseLintCommand::class);
76-
}
77-
78-
protected function execute(InputInterface $input, OutputInterface $output)
79-
{
80-
return $this->command->execute($input, $output);
81-
}
8268
}

0 commit comments

Comments
 (0)
0