Skip to content

[FrameworkBundle][SecurityBundle][TwigBundle][Yaml] remove deprecated code #23815

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
Aug 16, 2017
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
3 changes: 2 additions & 1 deletion src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bundle\FrameworkBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Helper;
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -26,7 +27,7 @@
*
* @final since version 3.4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it become final for real too ?

Copy link
Member

@chalasr chalasr Aug 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

letting it @final is valid and I think the use case of adding extra info to the about output is too in fact

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is a use case for extending it and we want to support this use case, we must remove @final, to allow extending.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@final is telling the intention to external users - extending internally is not an issue to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#23624 (comment) it's done for allowing proxiex/mocks solely.

extending internally is not an issue to me

For most commands i dont see it happen, yet we made containerdebug internal because of this :) and commands in components/bridges are also not marked final.

Last, some commands were already final for real.

*/
class AboutCommand extends ContainerAwareCommand
class AboutCommand extends Command
{
/**
* {@inheritdoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bundle\FrameworkBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -29,27 +30,16 @@
*
* @final since version 3.4
*/
class AssetsInstallCommand extends ContainerAwareCommand
class AssetsInstallCommand extends Command
{
const METHOD_COPY = 'copy';
const METHOD_ABSOLUTE_SYMLINK = 'absolute symlink';
const METHOD_RELATIVE_SYMLINK = 'relative symlink';

private $filesystem;

/**
* @param Filesystem $filesystem
*/
public function __construct($filesystem = null)
public function __construct(Filesystem $filesystem)
{
if (!$filesystem instanceof Filesystem) {
@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);

parent::__construct($filesystem);

return;
}

parent::__construct();

$this->filesystem = $filesystem;
Expand Down Expand Up @@ -96,17 +86,11 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// BC to be removed in 4.0
if (null === $this->filesystem) {
$this->filesystem = $this->getContainer()->get('filesystem');
$baseDir = $this->getContainer()->getParameter('kernel.project_dir');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isset($baseDir) below can be removed

}

$kernel = $this->getApplication()->getKernel();
$targetArg = rtrim($input->getArgument('target'), '/');

if (!is_dir($targetArg)) {
$targetArg = (isset($baseDir) ? $baseDir : $kernel->getContainer()->getParameter('kernel.project_dir')).'/'.$targetArg;
$targetArg = $kernel->getContainer()->getParameter('kernel.project_dir').'/'.$targetArg;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could also inject the project_dir in the command instead

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we reached consensus to use getParameter from the kernel container for cache_dir, project_dir etc. It can be an optional constructor arg.. thats a new feature to me.

#23624 (comment)


if (!is_dir($targetArg)) {
throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bundle\FrameworkBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -26,7 +27,7 @@
*
* @final since version 3.4
*/
class CacheClearCommand extends ContainerAwareCommand
class CacheClearCommand extends Command
{
private $cacheClearer;
private $filesystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Command;

use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -23,23 +24,12 @@
*
* @author Nicolas Grekas <p@tchwork.com>
*/
final class CachePoolClearCommand extends ContainerAwareCommand
final class CachePoolClearCommand extends Command
{
private $poolClearer;

/**
* @param Psr6CacheClearer $poolClearer
*/
public function __construct($poolClearer = null)
public function __construct(Psr6CacheClearer $poolClearer)
{
if (!$poolClearer instanceof Psr6CacheClearer) {
@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);

parent::__construct($poolClearer);

return;
}

parent::__construct();

$this->poolClearer = $poolClearer;
Expand Down Expand Up @@ -70,12 +60,6 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// BC to be removed in 4.0
if (null === $this->poolClearer) {
$this->poolClearer = $this->getContainer()->get('cache.global_clearer');
$cacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, isset($cacheDir) below can be removed

}

$io = new SymfonyStyle($input, $output);
$kernel = $this->getApplication()->getKernel();
$pools = array();
Expand All @@ -99,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

foreach ($clearers as $id => $clearer) {
$io->comment(sprintf('Calling cache clearer: <info>%s</info>', $id));
$clearer->clear(isset($cacheDir) ? $cacheDir : $kernel->getContainer()->getParameter('kernel.cache_dir'));
$clearer->clear($kernel->getContainer()->getParameter('kernel.cache_dir'));
}

foreach ($pools as $id => $pool) {
Expand Down
24 changes: 4 additions & 20 deletions src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bundle\FrameworkBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -24,23 +25,12 @@
*
* @final since version 3.4
*/
class CacheWarmupCommand extends ContainerAwareCommand
class CacheWarmupCommand extends Command
{
private $cacheWarmer;

/**
* @param CacheWarmerAggregate $cacheWarmer
*/
public function __construct($cacheWarmer = null)
public function __construct(CacheWarmerAggregate $cacheWarmer)
{
if (!$cacheWarmer instanceof CacheWarmerAggregate) {
@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);

parent::__construct($cacheWarmer);

return;
}

parent::__construct();

$this->cacheWarmer = $cacheWarmer;
Expand Down Expand Up @@ -77,12 +67,6 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// BC to be removed in 4.0
if (null === $this->cacheWarmer) {
$this->cacheWarmer = $this->getContainer()->get('cache_warmer');
$cacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same :)

}

$io = new SymfonyStyle($input, $output);

$kernel = $this->getApplication()->getKernel();
Expand All @@ -92,7 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->cacheWarmer->enableOptionalWarmers();
}

$this->cacheWarmer->warmUp(isset($cacheDir) ? $cacheDir : $kernel->getContainer()->getParameter('kernel.cache_dir'));
$this->cacheWarmer->warmUp($kernel->getContainer()->getParameter('kernel.cache_dir'));

$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Bundle\FrameworkBundle\Console\Helper\DescriptorHelper;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -30,7 +31,7 @@
*
* @internal since version 3.4
*/
class ContainerDebugCommand extends ContainerAwareCommand
class ContainerDebugCommand extends Command
{
/**
* @var ContainerBuilder|null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Command;

use Symfony\Bundle\FrameworkBundle\Console\Helper\DescriptorHelper;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -26,23 +27,12 @@
*
* @final since version 3.4
*/
class EventDispatcherDebugCommand extends ContainerAwareCommand
class EventDispatcherDebugCommand extends Command
{
private $dispatcher;

/**
* @param EventDispatcherInterface $dispatcher
*/
public function __construct($dispatcher = null)
public function __construct(EventDispatcherInterface $dispatcher)
{
if (!$dispatcher instanceof EventDispatcherInterface) {
@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);

parent::__construct($dispatcher);

return;
}

parent::__construct();

$this->dispatcher = $dispatcher;
Expand Down Expand Up @@ -81,11 +71,6 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// BC to be removed in 4.0
if (null === $this->dispatcher) {
$this->dispatcher = $this->getEventDispatcher();
}

$io = new SymfonyStyle($input, $output);

$options = array();
Expand All @@ -105,16 +90,4 @@ protected function execute(InputInterface $input, OutputInterface $output)
$options['output'] = $io;
$helper->describe($io, $this->dispatcher, $options);
}

/**
* Loads the Event Dispatcher from the container.
*
* BC to removed in 4.0
*
* @return EventDispatcherInterface
*/
protected function getEventDispatcher()
{
return $this->getContainer()->get('event_dispatcher');
}
}
42 changes: 3 additions & 39 deletions src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Bundle\FrameworkBundle\Console\Helper\DescriptorHelper;
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -30,49 +31,17 @@
*
* @final since version 3.4
*/
class RouterDebugCommand extends ContainerAwareCommand
class RouterDebugCommand extends Command
{
private $router;

/**
* @param RouterInterface $router
*/
public function __construct($router = null)
public function __construct(RouterInterface $router)
{
if (!$router instanceof RouterInterface) {
@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);

parent::__construct($router);

return;
}

parent::__construct();

$this->router = $router;
}

/**
* {@inheritdoc}
*
* BC to be removed in 4.0
*/
public function isEnabled()
{
if (null !== $this->router) {
return parent::isEnabled();
}
if (!$this->getContainer()->has('router')) {
return false;
}
$router = $this->getContainer()->get('router');
if (!$router instanceof RouterInterface) {
return false;
}

return parent::isEnabled();
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -104,11 +73,6 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// BC to be removed in 4.0
if (null === $this->router) {
$this->router = $this->getContainer()->get('router');
}

$io = new SymfonyStyle($input, $output);
$name = $input->getArgument('name');
$helper = new DescriptorHelper();
Expand Down
Loading