minor #13251 [3.0][Console] - Remove deprecated methods from Command class (mickaelandrieu)
This PR was merged into the 3.0-dev branch.
Discussion
----------
[3.0][Console] - Remove deprecated methods from Command class
| Q | A
| ------------- | ---
| Bug fix? | [no]
| New feature? | [no]
| BC breaks? | [no]
| Deprecations? | [yes]
| Tests pass? | [yes]
| Fixed tickets | no one
| License | MIT
| Doc PR | no documentation is related to text descriptor in official documentation
Comments: I only removed deprecated methods from Command class in Console commands and related tests. I'm wondering if we should'nt split Console component into ``Console-core`` and ``Console-descriptors`` components.
ping @jfsimon : in which case do we need to use console descriptors ?
Commits
-------
8691321
[Console] - Remove deprecated methods from Command class
This commit is contained in:
commit
0d97759084
@ -11,13 +11,10 @@
|
||||
|
||||
namespace Symfony\Component\Console\Command;
|
||||
|
||||
use Symfony\Component\Console\Descriptor\TextDescriptor;
|
||||
use Symfony\Component\Console\Descriptor\XmlDescriptor;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Helper\HelperSet;
|
||||
@ -345,7 +342,7 @@ class Command
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the InputDefinition to be used to create XML and Text representations of this Command.
|
||||
* Gets the InputDefinition to be used to create representations of this Command.
|
||||
*
|
||||
* Can be overridden to provide the original command representation when it would otherwise
|
||||
* be changed by merging with the application InputDefinition.
|
||||
@ -600,49 +597,6 @@ class Command
|
||||
return $this->helperSet->get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a text representation of the command.
|
||||
*
|
||||
* @return string A string representing the command
|
||||
*
|
||||
* @deprecated since version 2.3, to be removed in 3.0.
|
||||
*/
|
||||
public function asText()
|
||||
{
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
$descriptor = new TextDescriptor();
|
||||
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
|
||||
$descriptor->describe($output, $this, array('raw_output' => true));
|
||||
|
||||
return $output->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an XML representation of the command.
|
||||
*
|
||||
* @param bool $asDom Whether to return a DOM or an XML string
|
||||
*
|
||||
* @return string|\DOMDocument An XML string representing the command
|
||||
*
|
||||
* @deprecated since version 2.3, to be removed in 3.0.
|
||||
*/
|
||||
public function asXml($asDom = false)
|
||||
{
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
$descriptor = new XmlDescriptor();
|
||||
|
||||
if ($asDom) {
|
||||
return $descriptor->getCommandDocument($this);
|
||||
}
|
||||
|
||||
$output = new BufferedOutput();
|
||||
$descriptor->describe($output, $this);
|
||||
|
||||
return $output->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a command name.
|
||||
*
|
||||
|
@ -317,26 +317,4 @@ class CommandTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$output->writeln('from the code...');
|
||||
}
|
||||
|
||||
public function testLegacyAsText()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$command = new \TestCommand();
|
||||
$command->setApplication(new Application());
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute(array('command' => $command->getName()));
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/command_astext.txt', $command->asText(), '->asText() returns a text representation of the command');
|
||||
}
|
||||
|
||||
public function testLegacyAsXml()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$command = new \TestCommand();
|
||||
$command->setApplication(new Application());
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute(array('command' => $command->getName()));
|
||||
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/command_asxml.txt', $command->asXml(), '->asXml() returns an XML representation of the command');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user