feature #23815 [FrameworkBundle][SecurityBundle][TwigBundle][Yaml] remove deprecated code (xabbuh)

This PR was merged into the 4.0-dev branch.

Discussion
----------

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

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

c9ff029 remove deprecated code
This commit is contained in:
Nicolas Grekas 2017-08-16 18:10:21 +02:00
commit befad6315b
26 changed files with 67 additions and 556 deletions

View File

@ -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;
@ -26,7 +27,7 @@ use Symfony\Component\HttpKernel\KernelInterface;
*
* @final since version 3.4
*/
class AboutCommand extends ContainerAwareCommand
class AboutCommand extends Command
{
/**
* {@inheritdoc}

View File

@ -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;
@ -29,7 +30,7 @@ use Symfony\Component\HttpKernel\Bundle\BundleInterface;
*
* @final since version 3.4
*/
class AssetsInstallCommand extends ContainerAwareCommand
class AssetsInstallCommand extends Command
{
const METHOD_COPY = 'copy';
const METHOD_ABSOLUTE_SYMLINK = 'absolute symlink';
@ -37,19 +38,8 @@ class AssetsInstallCommand extends ContainerAwareCommand
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;
@ -96,17 +86,11 @@ EOT
*/
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');
}
$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;
if (!is_dir($targetArg)) {
throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));

View File

@ -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;
@ -27,7 +28,7 @@ use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
*
* @final since version 3.4
*/
class CacheClearCommand extends ContainerAwareCommand
class CacheClearCommand extends Command
{
private $cacheClearer;
private $filesystem;

View File

@ -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;
@ -23,23 +24,12 @@ use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
*
* @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;
@ -70,12 +60,6 @@ EOF
*/
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');
}
$io = new SymfonyStyle($input, $output);
$kernel = $this->getApplication()->getKernel();
$pools = array();
@ -99,7 +83,7 @@ EOF
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) {

View File

@ -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;
@ -24,23 +25,12 @@ use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate;
*
* @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;
@ -77,12 +67,6 @@ EOF
*/
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');
}
$io = new SymfonyStyle($input, $output);
$kernel = $this->getApplication()->getKernel();
@ -92,7 +76,7 @@ EOF
$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)));
}

View File

@ -13,6 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Command;
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;
@ -30,7 +31,7 @@ use Symfony\Component\Config\FileLocator;
*
* @internal since version 3.4
*/
class ContainerDebugCommand extends ContainerAwareCommand
class ContainerDebugCommand extends Command
{
/**
* @var ContainerBuilder|null

View File

@ -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;
@ -26,23 +27,12 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
*
* @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;
@ -81,11 +71,6 @@ EOF
*/
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();
@ -105,16 +90,4 @@ EOF
$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');
}
}

View File

@ -13,6 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Command;
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;
@ -30,49 +31,17 @@ use Symfony\Component\Routing\Route;
*
* @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}
*/
@ -104,11 +73,6 @@ EOF
*/
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();

View File

@ -11,6 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@ -27,49 +28,17 @@ use Symfony\Component\Routing\Matcher\TraceableUrlMatcher;
*
* @final since version 3.4
*/
class RouterMatchCommand extends ContainerAwareCommand
class RouterMatchCommand 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}
*/
@ -103,11 +72,6 @@ EOF
*/
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);
$context = $this->router->getContext();

View File

@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Command;
use Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
@ -34,7 +35,7 @@ use Symfony\Component\Translation\TranslatorInterface;
*
* @final since version 3.4
*/
class TranslationDebugCommand extends ContainerAwareCommand
class TranslationDebugCommand extends Command
{
const MESSAGE_MISSING = 0;
const MESSAGE_UNUSED = 1;
@ -44,21 +45,8 @@ class TranslationDebugCommand extends ContainerAwareCommand
private $loader;
private $extractor;
/**
* @param TranslatorInterface $translator
* @param TranslationLoader $loader
* @param ExtractorInterface $extractor
*/
public function __construct($translator = null, TranslationLoader $loader = null, ExtractorInterface $extractor = null)
public function __construct(TranslatorInterface $translator, TranslationLoader $loader, ExtractorInterface $extractor)
{
if (!$translator instanceof TranslatorInterface) {
@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($translator);
return;
}
parent::__construct();
$this->translator = $translator;
@ -116,35 +104,11 @@ EOF
;
}
/**
* {@inheritdoc}
*
* BC to be removed in 4.0
*/
public function isEnabled()
{
if (null !== $this->translator) {
return parent::isEnabled();
}
if (!class_exists('Symfony\Component\Translation\Translator')) {
return false;
}
return parent::isEnabled();
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// BC to be removed in 4.0
if (null === $this->translator) {
$this->translator = $this->getContainer()->get('translator');
$this->loader = $this->getContainer()->get('translation.loader');
$this->extractor = $this->getContainer()->get('translation.extractor');
}
$io = new SymfonyStyle($input, $output);
$locale = $input->getArgument('locale');

View File

@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Command;
use Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Translation\Catalogue\TargetOperation;
use Symfony\Component\Translation\Catalogue\MergeOperation;
@ -31,7 +32,7 @@ use Symfony\Component\Translation\Writer\TranslationWriter;
*
* @final since version 3.4
*/
class TranslationUpdateCommand extends ContainerAwareCommand
class TranslationUpdateCommand extends Command
{
private $writer;
private $loader;
@ -44,16 +45,8 @@ class TranslationUpdateCommand extends ContainerAwareCommand
* @param ExtractorInterface $extractor
* @param string $defaultLocale
*/
public function __construct($writer = null, TranslationLoader $loader = null, ExtractorInterface $extractor = null, $defaultLocale = null)
public function __construct(TranslationWriter $writer, TranslationLoader $loader, ExtractorInterface $extractor, $defaultLocale)
{
if (!$writer instanceof TranslationWriter) {
@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($writer);
return;
}
parent::__construct();
$this->writer = $writer;
@ -100,36 +93,11 @@ EOF
;
}
/**
* {@inheritdoc}
*
* BC to be removed in 4.0
*/
public function isEnabled()
{
if (null !== $this->writer) {
return parent::isEnabled();
}
if (!class_exists('Symfony\Component\Translation\Translator')) {
return false;
}
return parent::isEnabled();
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// BC to be removed in 4.0
if (null === $this->writer) {
$this->writer = $this->getContainer()->get('translation.writer');
$this->loader = $this->getContainer()->get('translation.loader');
$this->extractor = $this->getContainer()->get('translation.extractor');
$this->defaultLocale = $this->getContainer()->getParameter('kernel.default_locale');
}
$io = new SymfonyStyle($input, $output);
$errorIo = $io->getErrorStyle();

View File

@ -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\Output\OutputInterface;
@ -23,18 +24,8 @@ use Symfony\Component\Workflow\Marking;
*
* @final since version 3.4
*/
class WorkflowDumpCommand extends ContainerAwareCommand
class WorkflowDumpCommand extends Command
{
/**
* {@inheritdoc}
*
* BC to be removed in 4.0
*/
public function isEnabled()
{
return $this->getContainer()->has('workflow.registry');
}
/**
* {@inheritdoc}
*/

View File

@ -24,29 +24,21 @@ use Symfony\Component\Translation\Command\XliffLintCommand as BaseLintCommand;
*/
class XliffLintCommand extends BaseLintCommand
{
public function __construct($name = null, $directoryIteratorProvider = null, $isReadableProvider = null)
public function __construct()
{
if (func_num_args()) {
@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);
}
$directoryIteratorProvider = function ($directory, $default) {
if (!is_dir($directory)) {
$directory = $this->getApplication()->getKernel()->locateResource($directory);
}
if (null === $directoryIteratorProvider) {
$directoryIteratorProvider = function ($directory, $default) {
if (!is_dir($directory)) {
$directory = $this->getApplication()->getKernel()->locateResource($directory);
}
return $default($directory);
};
return $default($directory);
};
}
$isReadableProvider = function ($fileOrDirectory, $default) {
return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory);
};
if (null === $isReadableProvider) {
$isReadableProvider = function ($fileOrDirectory, $default) {
return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory);
};
}
parent::__construct($name, $directoryIteratorProvider, $isReadableProvider);
parent::__construct(null, $directoryIteratorProvider, $isReadableProvider);
}
/**

View File

@ -23,29 +23,21 @@ use Symfony\Component\Yaml\Command\LintCommand as BaseLintCommand;
*/
class YamlLintCommand extends BaseLintCommand
{
public function __construct($name = null, $directoryIteratorProvider = null, $isReadableProvider = null)
public function __construct()
{
if (func_num_args()) {
@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);
}
$directoryIteratorProvider = function ($directory, $default) {
if (!is_dir($directory)) {
$directory = $this->getApplication()->getKernel()->locateResource($directory);
}
if (null === $directoryIteratorProvider) {
$directoryIteratorProvider = function ($directory, $default) {
if (!is_dir($directory)) {
$directory = $this->getApplication()->getKernel()->locateResource($directory);
}
return $default($directory);
};
return $default($directory);
};
}
$isReadableProvider = function ($fileOrDirectory, $default) {
return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory);
};
if (null === $isReadableProvider) {
$isReadableProvider = function ($fileOrDirectory, $default) {
return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory);
};
}
parent::__construct($name, $directoryIteratorProvider, $isReadableProvider);
parent::__construct(null, $directoryIteratorProvider, $isReadableProvider);
}
/**

View File

@ -47,22 +47,6 @@ class RouterDebugCommandTest extends TestCase
$this->createCommandTester()->execute(array('name' => 'test'));
}
/**
* @group legacy
* @expectedDeprecation Passing a command name as the first argument of "Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand::__construct" 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.
*/
public function testLegacyDebugCommand()
{
$application = new Application($this->getKernel());
$application->add(new RouterDebugCommand());
$tester = new CommandTester($application->find('debug:router'));
$tester->execute(array());
$this->assertRegExp('/foo\s+ANY\s+ANY\s+ANY\s+\\/foo/', $tester->getDisplay());
}
/**
* @return CommandTester
*/

View File

@ -41,24 +41,6 @@ class RouterMatchCommandTest extends TestCase
$this->assertContains('None of the routes match the path "/test"', $tester->getDisplay());
}
/**
* @group legacy
* @expectedDeprecation Passing a command name as the first argument of "Symfony\Bundle\FrameworkBundle\Command\RouterMatchCommand::__construct" 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.
* @expectedDeprecation Passing a command name as the first argument of "Symfony\Bundle\FrameworkBundle\Command\RouterDebugCommand::__construct" 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.
*/
public function testLegacyMatchCommand()
{
$application = new Application($this->getKernel());
$application->add(new RouterMatchCommand());
$application->add(new RouterDebugCommand());
$tester = new CommandTester($application->find('router:match'));
$tester->execute(array('path_info' => '/'));
$this->assertContains('None of the routes match the path "/"', $tester->getDisplay());
}
/**
* @return CommandTester
*/

View File

@ -174,51 +174,6 @@ class TranslationDebugCommandTest extends TestCase
return new CommandTester($application->find('debug:translation'));
}
/**
* @group legacy
* @expectedDeprecation Passing a command name as the first argument of "Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand::__construct" 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.
*/
public function testLegacyDebugCommand()
{
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
->disableOriginalConstructor()
->getMock();
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
$loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader')->getMock();
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->any())
->method('getBundles')
->will($this->returnValue(array()));
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->any())
->method('get')
->will($this->returnValueMap(array(
array('translation.extractor', 1, $extractor),
array('translation.loader', 1, $loader),
array('translator', 1, $translator),
array('kernel', 1, $kernel),
)));
$kernel
->expects($this->any())
->method('getContainer')
->will($this->returnValue($container));
$command = new TranslationDebugCommand();
$command->setContainer($container);
$application = new Application($kernel);
$application->add($command);
$tester = new CommandTester($application->find('debug:translation'));
$tester->execute(array('locale' => 'en'));
$this->assertContains('No defined or extracted', $tester->getDisplay());
}
private function getBundle($path)
{
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();

View File

@ -153,53 +153,6 @@ class TranslationUpdateCommandTest extends TestCase
return new CommandTester($application->find('translation:update'));
}
/**
* @group legacy
* @expectedDeprecation Passing a command name as the first argument of "Symfony\Bundle\FrameworkBundle\Command\TranslationUpdateCommand::__construct" 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.
*/
public function testLegacyUpdateCommand()
{
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
->disableOriginalConstructor()
->getMock();
$extractor = $this->getMockBuilder('Symfony\Component\Translation\Extractor\ExtractorInterface')->getMock();
$loader = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader')->getMock();
$writer = $this->getMockBuilder('Symfony\Component\Translation\Writer\TranslationWriter')->getMock();
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->any())
->method('getBundles')
->will($this->returnValue(array()));
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container
->expects($this->any())
->method('get')
->will($this->returnValueMap(array(
array('translation.extractor', 1, $extractor),
array('translation.loader', 1, $loader),
array('translation.writer', 1, $writer),
array('translator', 1, $translator),
array('kernel', 1, $kernel),
)));
$kernel
->expects($this->any())
->method('getContainer')
->will($this->returnValue($container));
$command = new TranslationUpdateCommand();
$command->setContainer($container);
$application = new Application($kernel);
$application->add($command);
$tester = new CommandTester($application->find('translation:update'));
$tester->execute(array('locale' => 'en'));
$this->assertContains('You must choose one of --force or --dump-messages', $tester->getDisplay());
}
private function getBundle($path)
{
$bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock();

View File

@ -75,22 +75,6 @@ class CachePoolClearCommandTest extends WebTestCase
->execute(array('pools' => array('unknown_pool')), array('decorated' => false));
}
/**
* @group legacy
* @expectedDeprecation Passing a command name as the first argument of "Symfony\Bundle\FrameworkBundle\Command\CachePoolClearCommand::__construct" 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.
*/
public function testLegacyClearCommand()
{
$application = new Application(static::$kernel);
$application->add(new CachePoolClearCommand());
$tester = new CommandTester($application->find('cache:pool:clear'));
$tester->execute(array('pools' => array()));
$this->assertContains('Cache was successfully cleared', $tester->getDisplay());
}
private function createCommandTester()
{
$container = static::$kernel->getContainer();

View File

@ -11,7 +11,7 @@
namespace Symfony\Bundle\SecurityBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Security\Acl\Dbal\Schema;
@ -25,45 +25,19 @@ use Doctrine\DBAL\Schema\SchemaException;
*
* @final since version 3.4
*/
class InitAclCommand extends ContainerAwareCommand
class InitAclCommand extends Command
{
private $connection;
private $schema;
/**
* @param Connection $connection
* @param Schema $schema
*/
public function __construct($connection = null, Schema $schema = null)
public function __construct(Connection $connection, Schema $schema)
{
if (!$connection instanceof Connection) {
@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($connection);
return;
}
parent::__construct();
$this->connection = $connection;
$this->schema = $schema;
}
/**
* {@inheritdoc}
*
* BC to be removed in 4.0
*/
public function isEnabled()
{
if (!$this->connection && !$this->getContainer()->has('security.acl.dbal.connection')) {
return false;
}
return parent::isEnabled();
}
/**
* {@inheritdoc}
*/
@ -92,12 +66,6 @@ EOF
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// BC to be removed in 4.0
if (null === $this->connection) {
$this->connection = $this->getContainer()->get('security.acl.dbal.connection');
$this->schema = $this->getContainer()->get('security.acl.dbal.schema');
}
try {
$this->schema->addToSchema($this->connection->getSchemaManager()->createSchema());
} catch (SchemaException $e) {

View File

@ -11,7 +11,7 @@
namespace Symfony\Bundle\SecurityBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@ -30,50 +30,17 @@ use Symfony\Component\Security\Acl\Model\MutableAclProviderInterface;
*
* @final since version 3.4
*/
class SetAclCommand extends ContainerAwareCommand
class SetAclCommand extends Command
{
private $provider;
/**
* @param MutableAclProviderInterface $provider
*/
public function __construct($provider = null)
public function __construct(MutableAclProviderInterface $provider)
{
if (!$provider instanceof MutableAclProviderInterface) {
@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($provider);
return;
}
parent::__construct();
$this->provider = $provider;
}
/**
* {@inheritdoc}
*
* BC to be removed in 4.0
*/
public function isEnabled()
{
if (null !== $this->provider) {
return parent::isEnabled();
}
if (!$this->getContainer()->has('security.acl.provider')) {
return false;
}
$provider = $this->getContainer()->get('security.acl.provider');
if (!$provider instanceof MutableAclProviderInterface) {
return false;
}
return parent::isEnabled();
}
/**
* {@inheritdoc}
*/
@ -116,14 +83,9 @@ EOF
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// BC to be removed in 4.0
if (null === $this->provider) {
$this->provider = $this->getContainer()->get('security.acl.provider');
}
// Parse arguments
$objectIdentities = array();
$maskBuilder = $this->getMaskBuilder();
$maskBuilder = new MaskBuilder();
foreach ($input->getArgument('arguments') as $argument) {
$data = explode(':', $argument, 2);
@ -187,16 +149,4 @@ EOF
$this->provider->updateAcl($acl);
}
}
/**
* Gets the mask builder.
*
* BC to be removed in 4.0
*
* @return MaskBuilder
*/
protected function getMaskBuilder()
{
return new MaskBuilder();
}
}

View File

@ -52,7 +52,7 @@ class SetAclCommandTest extends WebTestCase
$grantedPermission2 = 'EDIT';
$application = $this->getApplication();
$application->add(new SetAclCommand());
$application->add(new SetAclCommand($application->getKernel()->getContainer()->get('security.acl.provider')));
$setAclCommand = $application->find('acl:set');
$setAclCommandTester = new CommandTester($setAclCommand);

View File

@ -12,8 +12,6 @@
namespace Symfony\Bundle\TwigBundle\Command;
use Symfony\Bridge\Twig\Command\LintCommand as BaseLintCommand;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\Finder\Finder;
/**
@ -22,11 +20,8 @@ use Symfony\Component\Finder\Finder;
* @author Marc Weistroff <marc.weistroff@sensiolabs.com>
* @author Jérôme Tamarelle <jerome@tamarelle.net>
*/
final class LintCommand extends BaseLintCommand implements ContainerAwareInterface
final class LintCommand extends BaseLintCommand
{
// BC to be removed in 4.0
use ContainerAwareTrait;
/**
* {@inheritdoc}
*/

View File

@ -181,15 +181,7 @@ class Parser
Inline::parse(null, $flags, $this->refs);
try {
Inline::$parsedLineNumber = $this->getRealCurrentLineNb();
$i = 0;
$evaluateKey = !(Yaml::PARSE_KEYS_AS_STRINGS & $flags);
// constants in key will be evaluated anyway
if (isset($values['key'][0]) && '!' === $values['key'][0] && Yaml::PARSE_CONSTANT & $flags) {
$evaluateKey = true;
}
$key = Inline::parseScalar($values['key'], 0, null, $i, $evaluateKey);
$key = Inline::parseScalar($values['key']);
} catch (ParseException $e) {
$e->setParsedLine($this->getRealCurrentLineNb() + 1);
$e->setSnippet($this->currentLine);

View File

@ -45,16 +45,6 @@ class ParserTest extends TestCase
return $this->loadTestsFromFixtureFiles('index.yml');
}
/**
* @group legacy
* @expectedDeprecationMessage Using the Yaml::PARSE_KEYS_AS_STRINGS flag is deprecated since version 3.4 as it will be removed in 4.0. Quote your keys when they are evaluable
* @dataProvider getNonStringMappingKeysData
*/
public function testNonStringMappingKeys($expected, $yaml, $comment)
{
$this->assertSame($expected, var_export($this->parser->parse($yaml, Yaml::PARSE_KEYS_AS_STRINGS), true), $comment);
}
public function getNonStringMappingKeysData()
{
return $this->loadTestsFromFixtureFiles('nonStringKeys.yml');

View File

@ -32,11 +32,6 @@ class Yaml
const PARSE_CUSTOM_TAGS = 512;
const DUMP_EMPTY_ARRAY_AS_SEQUENCE = 1024;
/**
* @deprecated since version 3.4, to be removed in 4.0. Quote your evaluable keys instead.
*/
const PARSE_KEYS_AS_STRINGS = 2048;
/**
* Parses YAML into a PHP value.
*