Skip to content

Commit

Permalink
Fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Chalas committed Jul 23, 2017
1 parent f55595f commit e7abc61
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 104 deletions.
44 changes: 1 addition & 43 deletions Command/DebugCommand.php
Expand Up @@ -28,41 +28,13 @@ class DebugCommand extends Command
{
private $twig;

/**
* @param Environment $twig
*/
public function __construct($twig = null)
public function __construct(Environment $twig)
{
parent::__construct();

if (!$twig instanceof Environment) {
@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);

$this->setName(null === $twig ? 'debug:twig' : $twig);

return;
}

$this->twig = $twig;
}

public function setTwigEnvironment(Environment $twig)
{
@trigger_error(sprintf('Method "%s" is deprecated since version 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);

$this->twig = $twig;
}

/**
* @return Environment $twig
*/
protected function getTwigEnvironment()
{
@trigger_error(sprintf('Method "%s" is deprecated since version 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);

return $this->twig;
}

protected function configure()
{
$this
Expand Down Expand Up @@ -95,20 +67,6 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);

// BC to be removed in 4.0
if (__CLASS__ !== get_class($this)) {
$r = new \ReflectionMethod($this, 'getTwigEnvironment');
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
@trigger_error(sprintf('Usage of method "%s" is deprecated since version 3.4 and will no longer be supported in 4.0.', get_class($this).'::getTwigEnvironment'), E_USER_DEPRECATED);

$this->twig = $this->getTwigEnvironment();
}
}
if (null === $this->twig) {
throw new \RuntimeException('The Twig environment needs to be set.');
}

$types = array('functions', 'filters', 'tests', 'globals');

if ($input->getOption('format') === 'json') {
Expand Down
44 changes: 1 addition & 43 deletions Command/LintCommand.php
Expand Up @@ -33,41 +33,13 @@ class LintCommand extends Command
{
private $twig;

/**
* @param Environment $twig
*/
public function __construct($twig = null)
public function __construct(Environment $twig)
{
parent::__construct();

if (!$twig instanceof Environment) {
@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);

$this->setName(null === $twig ? 'lint:twig' : $twig);

return;
}

$this->twig = $twig;
}

public function setTwigEnvironment(Environment $twig)
{
@trigger_error(sprintf('Method "%s" is deprecated since version 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);

$this->twig = $twig;
}

/**
* @return Environment $twig
*/
protected function getTwigEnvironment()
{
@trigger_error(sprintf('Method "%s" is deprecated since version 3.4 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED);

return $this->twig;
}

protected function configure()
{
$this
Expand Down Expand Up @@ -100,20 +72,6 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);

// BC to be removed in 4.0
if (__CLASS__ !== get_class($this)) {
$r = new \ReflectionMethod($this, 'getTwigEnvironment');
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
@trigger_error(sprintf('Usage of method "%s" is deprecated since version 3.4 and will no longer be supported in 4.0.', get_class($this).'::getTwigEnvironment'), E_USER_DEPRECATED);

$this->twig = $this->getTwigEnvironment();
}
}
if (null === $this->twig) {
throw new \RuntimeException('The Twig environment needs to be set.');
}

$filenames = $input->getArgument('filename');

if (0 === count($filenames)) {
Expand Down
18 changes: 0 additions & 18 deletions Tests/Command/LintCommandTest.php
Expand Up @@ -68,24 +68,6 @@ public function testLintFileCompileTimeException()
$this->assertRegExp('/ERROR in \S+ \(line /', trim($tester->getDisplay()));
}

/**
* @group legacy
* @expectedDeprecation Passing a command name as the first argument of "Symfony\Bridge\Twig\Command\LintCommand::__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.
* @expectedException \RuntimeException
* @expectedExceptionMessage The Twig environment needs to be set.
*/
public function testLegacyLintCommand()
{
$command = new LintCommand();

$application = new Application();
$application->add($command);
$command = $application->find('lint:twig');

$tester = new CommandTester($command);
$tester->execute(array());
}

/**
* @return CommandTester
*/
Expand Down

0 comments on commit e7abc61

Please sign in to comment.