Skip to content

Commit

Permalink
Removed deprecations in Console component
Browse files Browse the repository at this point in the history
  • Loading branch information
saro0h committed Mar 30, 2015
1 parent 66e05d9 commit abb1308
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 221 deletions.
50 changes: 0 additions & 50 deletions Application.php
Expand Up @@ -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;
Expand All @@ -23,7 +21,6 @@
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;
Expand Down Expand Up @@ -613,53 +610,6 @@ public static function getAbbreviations($names)
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.
*
Expand Down
30 changes: 0 additions & 30 deletions Helper/ProgressBar.php
Expand Up @@ -168,20 +168,6 @@ public function getMaxSteps()
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.
*
Expand Down Expand Up @@ -355,22 +341,6 @@ public function advance($step = 1)
$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
*
Expand Down
47 changes: 0 additions & 47 deletions Input/InputDefinition.php
Expand Up @@ -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.
*
Expand Down Expand Up @@ -411,47 +407,4 @@ public function getSynopsis()

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();
}
}
15 changes: 2 additions & 13 deletions Input/StringInput.php
Expand Up @@ -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);
}
}

/**
Expand Down
28 changes: 0 additions & 28 deletions Tests/ApplicationTest.php
Expand Up @@ -490,34 +490,6 @@ public function testSetCatchExceptions()
}
}

/**
* @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'));
Expand Down
38 changes: 0 additions & 38 deletions Tests/Input/InputDefinitionTest.php
Expand Up @@ -373,44 +373,6 @@ public function testGetSynopsis()
$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');
Expand Down
15 changes: 0 additions & 15 deletions Tests/Input/StringInputTest.php
Expand Up @@ -41,21 +41,6 @@ public function testInputOptionWithGivenString()
$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(
Expand Down

0 comments on commit abb1308

Please sign in to comment.