Removed deprecations in Console component
This commit is contained in:
parent
5f42822f3b
commit
1a8f87d9ff
@ -11,8 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Console;
|
||||
|
||||
use Symfony\Component\Console\Descriptor\TextDescriptor;
|
||||
use Symfony\Component\Console\Descriptor\XmlDescriptor;
|
||||
use Symfony\Component\Console\Helper\DebugFormatterHelper;
|
||||
use Symfony\Component\Console\Helper\ProcessHelper;
|
||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||
@ -23,7 +21,6 @@ use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputAwareInterface;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
@ -613,53 +610,6 @@ class Application
|
||||
return $abbrevs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a text representation of the Application.
|
||||
*
|
||||
* @param string $namespace An optional namespace name
|
||||
* @param bool $raw Whether to return raw command list
|
||||
*
|
||||
* @return string A string representing the Application
|
||||
*
|
||||
* @deprecated since version 2.3, to be removed in 3.0.
|
||||
*/
|
||||
public function asText($namespace = null, $raw = false)
|
||||
{
|
||||
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, !$raw);
|
||||
$descriptor->describe($output, $this, array('namespace' => $namespace, 'raw_output' => true));
|
||||
|
||||
return $output->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an XML representation of the Application.
|
||||
*
|
||||
* @param string $namespace An optional namespace name
|
||||
* @param bool $asDom Whether to return a DOM or an XML string
|
||||
*
|
||||
* @return string|\DOMDocument An XML string representing the Application
|
||||
*
|
||||
* @deprecated since version 2.3, to be removed in 3.0.
|
||||
*/
|
||||
public function asXml($namespace = null, $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->getApplicationDocument($this, $namespace);
|
||||
}
|
||||
|
||||
$output = new BufferedOutput();
|
||||
$descriptor->describe($output, $this, array('namespace' => $namespace));
|
||||
|
||||
return $output->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a caught exception.
|
||||
*
|
||||
|
@ -168,20 +168,6 @@ class ProgressBar
|
||||
return $this->max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the progress bar step.
|
||||
*
|
||||
* @deprecated since version 2.6, to be removed in 3.0. Use {@link getProgress()} instead.
|
||||
*
|
||||
* @return int The progress bar step
|
||||
*/
|
||||
public function getStep()
|
||||
{
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the getProgress() method instead.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->getProgress();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current step position.
|
||||
*
|
||||
@ -355,22 +341,6 @@ class ProgressBar
|
||||
$this->setProgress($this->step + $step);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current progress.
|
||||
*
|
||||
* @deprecated since version 2.6, to be removed in 3.0. Use {@link setProgress()} instead.
|
||||
*
|
||||
* @param int $step The current progress
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function setCurrent($step)
|
||||
{
|
||||
trigger_error('The '.__METHOD__.' method is deprecated since version 2.6 and will be removed in 3.0. Use the setProgress() method instead.', E_USER_DEPRECATED);
|
||||
|
||||
$this->setProgress($step);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to overwrite the progressbar, false for new line
|
||||
*
|
||||
|
@ -11,10 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Console\Input;
|
||||
|
||||
use Symfony\Component\Console\Descriptor\TextDescriptor;
|
||||
use Symfony\Component\Console\Descriptor\XmlDescriptor;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
/**
|
||||
* A InputDefinition represents a set of valid command line arguments and options.
|
||||
*
|
||||
@ -411,47 +407,4 @@ class InputDefinition
|
||||
|
||||
return implode(' ', $elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a textual representation of the InputDefinition.
|
||||
*
|
||||
* @return string A string representing the InputDefinition
|
||||
*
|
||||
* @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 InputDefinition.
|
||||
*
|
||||
* @param bool $asDom Whether to return a DOM or an XML string
|
||||
*
|
||||
* @return string|\DOMDocument An XML string representing the InputDefinition
|
||||
*
|
||||
* @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->getInputDefinitionDocument($this);
|
||||
}
|
||||
|
||||
$output = new BufferedOutput();
|
||||
$descriptor->describe($output, $this);
|
||||
|
||||
return $output->fetch();
|
||||
}
|
||||
}
|
||||
|
@ -31,25 +31,14 @@ class StringInput extends ArgvInput
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $input An array of parameters from the CLI (in the argv format)
|
||||
* @param InputDefinition $definition A InputDefinition instance
|
||||
*
|
||||
* @deprecated The second argument is deprecated as it does not work (will be removed in 3.0), use 'bind' method instead
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function __construct($input, InputDefinition $definition = null)
|
||||
public function __construct($input)
|
||||
{
|
||||
if ($definition) {
|
||||
trigger_error('The $definition argument of the '.__METHOD__.' method is deprecated and will be removed in 3.0. Set this parameter with the bind() method instead.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
parent::__construct(array(), null);
|
||||
parent::__construct(array());
|
||||
|
||||
$this->setTokens($this->tokenize($input));
|
||||
|
||||
if (null !== $definition) {
|
||||
$this->bind($definition);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -490,34 +490,6 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAsText()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$application = new Application();
|
||||
$application->add(new \FooCommand());
|
||||
$this->ensureStaticCommandHelp($application);
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_astext1.txt', $this->normalizeLineBreaks($application->asText()), '->asText() returns a text representation of the application');
|
||||
$this->assertStringEqualsFile(self::$fixturesPath.'/application_astext2.txt', $this->normalizeLineBreaks($application->asText('foo')), '->asText() returns a text representation of the application');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAsXml()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$application = new Application();
|
||||
$application->add(new \FooCommand());
|
||||
$this->ensureStaticCommandHelp($application);
|
||||
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml1.txt', $application->asXml(), '->asXml() returns an XML representation of the application');
|
||||
$this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml2.txt', $application->asXml('foo'), '->asXml() returns an XML representation of the application');
|
||||
}
|
||||
|
||||
public function testRenderException()
|
||||
{
|
||||
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
|
||||
|
@ -373,44 +373,6 @@ class InputDefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('foo1 ... [fooN]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAsText()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$definition = new InputDefinition(array(
|
||||
new InputArgument('foo', InputArgument::OPTIONAL, 'The foo argument'),
|
||||
new InputArgument('baz', InputArgument::OPTIONAL, 'The baz argument', true),
|
||||
new InputArgument('bar', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'The bar argument', array('http://foo.com/')),
|
||||
new InputOption('foo', 'f', InputOption::VALUE_REQUIRED, 'The foo option'),
|
||||
new InputOption('baz', null, InputOption::VALUE_OPTIONAL, 'The baz option', false),
|
||||
new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL, 'The bar option', 'bar'),
|
||||
new InputOption('qux', '', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The qux option', array('http://foo.com/', 'bar')),
|
||||
new InputOption('qux2', '', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The qux2 option', array('foo' => 'bar')),
|
||||
));
|
||||
$this->assertStringEqualsFile(self::$fixtures.'/definition_astext.txt', $definition->asText(), '->asText() returns a textual representation of the InputDefinition');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyAsXml()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$definition = new InputDefinition(array(
|
||||
new InputArgument('foo', InputArgument::OPTIONAL, 'The foo argument'),
|
||||
new InputArgument('baz', InputArgument::OPTIONAL, 'The baz argument', true),
|
||||
new InputArgument('bar', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'The bar argument', array('bar')),
|
||||
new InputOption('foo', 'f', InputOption::VALUE_REQUIRED, 'The foo option'),
|
||||
new InputOption('baz', null, InputOption::VALUE_OPTIONAL, 'The baz option', false),
|
||||
new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL, 'The bar option', 'bar'),
|
||||
));
|
||||
$this->assertXmlStringEqualsXmlFile(self::$fixtures.'/definition_asxml.txt', $definition->asXml(), '->asXml() returns an XML representation of the InputDefinition');
|
||||
}
|
||||
|
||||
protected function initializeArguments()
|
||||
{
|
||||
$this->foo = new InputArgument('foo');
|
||||
|
@ -41,21 +41,6 @@ class StringInputTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('bar', $input->getOption('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyInputOptionDefinitionInConstructor()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$definition = new InputDefinition(
|
||||
array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))
|
||||
);
|
||||
|
||||
$input = new StringInput('--foo=bar', $definition);
|
||||
$this->assertEquals('bar', $input->getOption('foo'));
|
||||
}
|
||||
|
||||
public function getTokenizeData()
|
||||
{
|
||||
return array(
|
||||
|
Reference in New Issue
Block a user