From 31b5615b51a338bf73c93b148f46c7a5f8fe3b0f Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Wed, 3 Oct 2018 11:38:29 +0200 Subject: [PATCH] [WebServerBundle] Deprecate relying on --env in server:start and server:run --- UPGRADE-4.2.md | 6 ++++++ UPGRADE-5.0.md | 6 ++++++ src/Symfony/Bundle/WebServerBundle/CHANGELOG.md | 6 ++++++ .../Bundle/WebServerBundle/Command/ServerRunCommand.php | 5 +++++ .../Bundle/WebServerBundle/Command/ServerStartCommand.php | 5 +++++ 5 files changed, 28 insertions(+) diff --git a/UPGRADE-4.2.md b/UPGRADE-4.2.md index 18b88f2fa231..d0fbb857c43d 100644 --- a/UPGRADE-4.2.md +++ b/UPGRADE-4.2.md @@ -231,3 +231,9 @@ Validator * Using the `Bic`, `Country`, `Currency`, `Language` and `Locale` constraints without `symfony/intl` is deprecated * Using the `Email` constraint without `egulias/email-validator` is deprecated * Using the `Expression` constraint without `symfony/expression-language` is deprecated + +WebServerBundle +--------------- + +* Omitting the `$environment` argument of the `ServerRunCommand` and + `ServerStartCommand` constructors is deprecated. diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index e7470a2467db..91e199a43f9d 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -222,3 +222,9 @@ Workflow * `add` method has been removed use `addWorkflow` method in `Workflow\Registry` instead. * `SupportStrategyInterface` has been removed, use `WorkflowSupportStrategyInterface` instead. * `ClassInstanceSupportStrategy` has been removed, use `InstanceOfSupportStrategy` instead. + +WebServerBundle +--------------- + +* Omitting the `$environment` argument of the `ServerRunCommand` and + `ServerStartCommand` constructors now throws a `\TypeError. diff --git a/src/Symfony/Bundle/WebServerBundle/CHANGELOG.md b/src/Symfony/Bundle/WebServerBundle/CHANGELOG.md index af709a0ee45e..45eff9240afe 100644 --- a/src/Symfony/Bundle/WebServerBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/WebServerBundle/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +4.2.0 +----- + +* Deprecated omitting the `$environment` argument of the `ServerRunCommand` and + `ServerStartCommand` constructors + 3.4.0 ----- diff --git a/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php index 64bc45b0265e..10b2de7fa384 100644 --- a/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/WebServerBundle/Command/ServerRunCommand.php @@ -36,6 +36,10 @@ class ServerRunCommand extends Command public function __construct(string $documentRoot = null, string $environment = null) { + if (!$environment) { + @trigger_error(sprintf('Omitting the $environment argument of the "%s" constructor is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + } + $this->documentRoot = $documentRoot; $this->environment = $environment; @@ -99,6 +103,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $documentRoot = $this->documentRoot; } + // @deprecated since Symfony 4.2 if (!$env = $this->environment) { if ($input->hasOption('env') && !$env = $input->getOption('env')) { $io->error('The environment must be either passed as second argument of the constructor or through the "--env" input option.'); diff --git a/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php b/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php index 6c0fb781ceb1..ac10072ab4ba 100644 --- a/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php +++ b/src/Symfony/Bundle/WebServerBundle/Command/ServerStartCommand.php @@ -36,6 +36,10 @@ class ServerStartCommand extends Command public function __construct(string $documentRoot = null, string $environment = null) { + if (!$environment) { + @trigger_error(sprintf('Omitting the $environment argument of the "%s" constructor is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED); + } + $this->documentRoot = $documentRoot; $this->environment = $environment; @@ -112,6 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $documentRoot = $this->documentRoot; } + // @deprecated since Symfony 4.2 if (!$env = $this->environment) { if ($input->hasOption('env') && !$env = $input->getOption('env')) { $io->error('The environment must be either passed as second argument of the constructor or through the "--env" input option.');