diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php
index 7a345938bd02d..df8f1162dee54 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php
@@ -12,7 +12,6 @@
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;
use Symfony\Component\Console\Descriptor\DescriptorInterface;
-use Symfony\Component\Console\Helper\TableHelper;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -30,7 +29,7 @@ abstract class Descriptor implements DescriptorInterface
/**
* @var OutputInterface
*/
- private $output;
+ protected $output;
/**
* {@inheritdoc}
@@ -89,22 +88,6 @@ protected function write($content, $decorated = false)
$this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
}
- /**
- * Writes content to output.
- *
- * @param TableHelper $table
- * @param bool $decorated
- */
- protected function renderTable(TableHelper $table, $decorated = false)
- {
- if (!$decorated) {
- $table->setCellRowFormat('%s');
- $table->setCellHeaderFormat('%s');
- }
-
- $table->render($this->output);
- }
-
/**
* Describes an InputArgument instance.
*
diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
index 4a391b4333477..88ad0ea3bc96f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
@@ -11,7 +11,7 @@
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;
-use Symfony\Component\Console\Helper\TableHelper;
+use Symfony\Component\Console\Helper\Table;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
@@ -30,10 +30,10 @@ class TextDescriptor extends Descriptor
*/
protected function describeRouteCollection(RouteCollection $routes, array $options = array())
{
+ $table = new Table($this->output);
+
$showControllers = isset($options['show_controllers']) && $options['show_controllers'];
$headers = array('Name', 'Method', 'Scheme', 'Host', 'Path');
- $table = new TableHelper();
- $table->setLayout(TableHelper::LAYOUT_COMPACT);
$table->setHeaders($showControllers ? array_merge($headers, array('Controller')) : $headers);
foreach ($routes->all() as $name => $route) {
@@ -59,7 +59,7 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio
}
$this->writeText($this->formatSection('router', 'Current routes')."\n", $options);
- $this->renderTable($table, !(isset($options['raw_output']) && $options['raw_output']));
+ $table->render();
}
/**
@@ -100,8 +100,7 @@ protected function describeRoute(Route $route, array $options = array())
*/
protected function describeContainerParameters(ParameterBag $parameters, array $options = array())
{
- $table = new TableHelper();
- $table->setLayout(TableHelper::LAYOUT_COMPACT);
+ $table = new Table($this->output);
$table->setHeaders(array('Parameter', 'Value'));
foreach ($this->sortParameters($parameters) as $parameter => $value) {
@@ -109,7 +108,7 @@ protected function describeContainerParameters(ParameterBag $parameters, array $
}
$this->writeText($this->formatSection('container', 'List of parameters')."\n", $options);
- $this->renderTable($table, !(isset($options['raw_output']) && $options['raw_output']));
+ $table->render();
}
/**
@@ -201,8 +200,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
$tagsCount = count($maxTags);
$tagsNames = array_keys($maxTags);
- $table = new TableHelper();
- $table->setLayout(TableHelper::LAYOUT_COMPACT);
+ $table = new Table($this->output);
$table->setHeaders(array_merge(array('Service ID'), $tagsNames, array('Class name')));
foreach ($this->sortServiceIds($serviceIds) as $serviceId) {
@@ -232,7 +230,7 @@ protected function describeContainerServices(ContainerBuilder $builder, array $o
}
}
- $this->renderTable($table);
+ $table->render();
}
/**
@@ -302,31 +300,30 @@ protected function describeEventDispatcherListeners(EventDispatcherInterface $ev
$this->writeText($this->formatSection('event_dispatcher', $label)."\n", $options);
$registeredListeners = $eventDispatcher->getListeners($event);
+ $table = new Table($this->output);
+
if (null !== $event) {
$this->writeText("\n");
- $table = new TableHelper();
+
$table->setHeaders(array('Order', 'Callable'));
foreach ($registeredListeners as $order => $listener) {
$table->addRow(array(sprintf('#%d', $order + 1), $this->formatCallable($listener)));
}
-
- $this->renderTable($table);
} else {
ksort($registeredListeners);
foreach ($registeredListeners as $eventListened => $eventListeners) {
$this->writeText(sprintf("\n[Event] %s\n", $eventListened), $options);
- $table = new TableHelper();
$table->setHeaders(array('Order', 'Callable'));
foreach ($eventListeners as $order => $eventListener) {
$table->addRow(array(sprintf('#%d', $order + 1), $this->formatCallable($eventListener)));
}
-
- $this->renderTable($table);
}
}
+
+ $table->render();
}
/**
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php
index 481744aac0a91..b0edee046b727 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php
@@ -137,7 +137,7 @@ private function assertDescription($expectedDescription, $describedObject, array
if ('json' === $this->getFormat()) {
$this->assertEquals(json_decode($expectedDescription), json_decode($output->fetch()));
} else {
- $this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch())));
+ $this->assertEquals($expectedDescription, $output->fetch());
}
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_1.md
index ec63107b93b0f..3220d5f1393f0 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_1.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_1.md
@@ -1,2 +1,2 @@
- Service: `service_1`
-- Public: yes
+- Public: yes
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_2.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_2.md
index f2a46087c162e..73a4101d8bce3 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_2.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/alias_2.md
@@ -1,2 +1,2 @@
- Service: `service_2`
-- Public: no
+- Public: no
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md
index 196757b13b7a2..044eade656f9d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.md
@@ -32,4 +32,4 @@ alias_2
Services
--------
-- `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder`
+- `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder`
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.txt
index b6debca225fea..a8243a4009f24 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.txt
@@ -1,6 +1,9 @@
[container] Public services
- Service ID Class name
- alias_1 alias for "service_1"
- alias_2 alias for "service_2"
- definition_1 Full\Qualified\Class1
- service_container Symfony\Component\DependencyInjection\ContainerBuilder
++-------------------+--------------------------------------------------------+
+|[32m Service ID [39m|[32m Class name [39m|
++-------------------+--------------------------------------------------------+
+| alias_1 | alias for "service_1" |
+| alias_2 | alias for "service_2" |
+| definition_1 | Full\Qualified\Class1 |
+| service_container | Symfony\Component\DependencyInjection\ContainerBuilder |
++-------------------+--------------------------------------------------------+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md
index 33cb0a93a74c9..b4d2025acd17a 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.md
@@ -47,4 +47,4 @@ alias_2
Services
--------
-- `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder`
+- `service_container`: `Symfony\Component\DependencyInjection\ContainerBuilder`
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.txt
index e203d5a90fad7..58307ff202119 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.txt
@@ -1,8 +1,10 @@
[container] Public and private services
- Service ID Class name
- alias_1 alias for "service_1"
- alias_2 alias for "service_2"
- definition_1 Full\Qualified\Class1
- definition_2 Full\Qualified\Class2
- service_container Symfony\Component\DependencyInjection\ContainerBuilder
-
++-------------------+--------------------------------------------------------+
+|[32m Service ID [39m|[32m Class name [39m|
++-------------------+--------------------------------------------------------+
+| alias_1 | alias for "service_1" |
+| alias_2 | alias for "service_2" |
+| definition_1 | Full\Qualified\Class1 |
+| definition_2 | Full\Qualified\Class2 |
+| service_container | Symfony\Component\DependencyInjection\ContainerBuilder |
++-------------------+--------------------------------------------------------+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.txt
index da12899f94083..b84e5450e0d0e 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.txt
@@ -1,4 +1,7 @@
[container] Public and private services with tag tag1
- Service ID attr1 attr2 attr3 Class name
- definition_2 val1 val2 Full\Qualified\Class2
- " val3
++--------------+-------+-------+-------+-----------------------+
+|[32m Service ID [39m|[32m attr1 [39m|[32m attr2 [39m|[32m attr3 [39m|[32m Class name [39m|
++--------------+-------+-------+-------+-----------------------+
+| definition_2 | val1 | val2 | | Full\Qualified\Class2 |
+| " | | | val3 | |
++--------------+-------+-------+-------+-----------------------+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.md
index 0c3e1dd6f26dd..9cf31352e3cfd 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.md
@@ -1,2 +1,3 @@
+
- Type: `function`
- Name: `array_key_exists`
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.txt
index 92ac06e2f64d5..09901c3c403c1 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_1.txt
@@ -1 +1 @@
-array_key_exists()
+array_key_exists()
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.md
index cef6d81ed1fd6..c041ee8ea6fc4 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.md
@@ -1,3 +1,4 @@
+
- Type: `function`
- Name: `staticMethod`
- Class: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass`
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.txt
index e58a2ba59a515..5e3101e1bc2c2 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_2.txt
@@ -1 +1 @@
-Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::staticMethod()
+Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::staticMethod()
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.md
index 8b260e7074410..3b61c0da2ee77 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.md
@@ -1,3 +1,4 @@
+
- Type: `function`
- Name: `method`
- Class: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass`
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.txt
index e2f79511ee2c9..dde0dbba2e3d8 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_3.txt
@@ -1 +1 @@
-Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::method()
+Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::method()
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.md
index cef6d81ed1fd6..c041ee8ea6fc4 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.md
@@ -1,3 +1,4 @@
+
- Type: `function`
- Name: `staticMethod`
- Class: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass`
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.txt
index e58a2ba59a515..5e3101e1bc2c2 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_4.txt
@@ -1 +1 @@
-Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::staticMethod()
+Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::staticMethod()
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.md
index 9fd61c39ac2e2..fc69e9bafc01f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.md
@@ -1,3 +1,4 @@
+
- Type: `function`
- Name: `staticMethod`
- Class: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\ExtendedCallableClass`
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.txt
index 1c48ebc471cc6..1c06a7e9a5cfd 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_5.txt
@@ -1 +1 @@
-Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\ExtendedCallableClass::parent::staticMethod()
+Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\ExtendedCallableClass::parent::staticMethod()
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.md
index 0fb5bdb107b37..474a9ddc24cc2 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.md
@@ -1 +1,2 @@
+
- Type: `closure`
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.txt
index 56996feb78930..9b030ab7913a9 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_6.txt
@@ -1 +1 @@
-\Closure()
+\Closure()
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.md
index b6a236ce7bac6..c9ad7af95d8c7 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.md
@@ -1,3 +1,3 @@
+
- Type: `object`
- Name: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass`
-
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.txt
index 66274dc2cd4d7..78ef6a6527cae 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/callable_7.txt
@@ -1 +1 @@
-Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::__invoke()
+Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::__invoke()
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md
index 49005b12a4a47..3f85a7c305daa 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.md
@@ -1,4 +1,4 @@
- Class: `Full\Qualified\Class1`
- Scope: `container`
- Public: yes
-- Synthetic: no
+- Synthetic: no
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.md
index 521b496e07609..dad1c7f470c57 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.md
@@ -8,4 +8,4 @@
- Attr2: val2
- Tag: `tag1`
- Attr3: val3
-- Tag: `tag2`
+- Tag: `tag2`
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_event1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_event1.txt
index 22b17a19cfb91..9cd9ca96592cb 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_event1.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_event1.txt
@@ -1,7 +1,7 @@
[event_dispatcher] Registered listeners for event event1
+-------+-------------------+
-| Order | Callable |
+|[32m Order [39m|[32m Callable [39m|
+-------+-------------------+
| #1 | global_function() |
| #2 | \Closure() |
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt
index 95a5b4648e939..4cd880b0ef9f4 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt
@@ -1,16 +1,12 @@
[event_dispatcher] Registered listeners by event
[Event] event1
-+-------+-------------------+
-| Order | Callable |
-+-------+-------------------+
-| #1 | global_function() |
-| #2 | \Closure() |
-+-------+-------------------+
[Event] event2
+-------+-----------------------------------------------------------------------------------+
-| Order | Callable |
+|[32m Order [39m|[32m Callable [39m|
+-------+-----------------------------------------------------------------------------------+
+| #1 | global_function() |
+| #2 | \Closure() |
| #1 | Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::__invoke() |
+-------+-----------------------------------------------------------------------------------+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.md
index 4c67978f68347..239e98d6aac72 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.md
@@ -1,4 +1,4 @@
database_name
=============
-symfony
+symfony
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.txt
index a1435083911ce..6bc5995f62e34 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.txt
@@ -1 +1 @@
-symfony
+symfony
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.md
index 2dfe5d640b858..c1eb4dc90fc4f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.md
@@ -4,4 +4,4 @@ Container parameters
- `array`: `[12,"Hello world!",true]`
- `boolean`: `true`
- `integer`: `12`
-- `string`: `Hello world!`
+- `string`: `Hello world!`
\ No newline at end of file
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.txt
index 1c9a2739ca63c..0d418dd07b68a 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.txt
@@ -1,7 +1,9 @@
[container] List of parameters
- Parameter Value
- array [12,"Hello world!",true]
- boolean true
- integer 12
- string Hello world!
-
\ No newline at end of file
++-----------+--------------------------+
+|[32m Parameter [39m|[32m Value [39m|
++-----------+--------------------------+
+| array | [12,"Hello world!",true] |
+| boolean | true |
+| integer | 12 |
+| string | Hello world! |
++-----------+--------------------------+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.md
index 4ac00a8929755..269bd11a6612f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.md
@@ -6,4 +6,4 @@
- Defaults:
- `name`: Joseph
- Requirements:
- - `name`: [a-z]+
\ No newline at end of file
+ - `name`: [a-z]+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.txt
index 2552c1ed88993..54bf11b4eb239 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_1.txt
@@ -9,4 +9,4 @@
opt1: val1
opt2: val2
Path-Regex #^/hello(?:/(?P[a-z]+))?$#s
-Host-Regex #^localhost$#s
\ No newline at end of file
+Host-Regex #^localhost$#s
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md
index c19d75f4f3b13..494f3223a28b4 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.md
@@ -4,4 +4,4 @@
- Method: PUT|POST
- Class: Symfony\Component\Routing\Route
- Defaults: NONE
-- Requirements: NONE
\ No newline at end of file
+- Requirements: NONE
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt
index 99119b6cc4e90..70eca6c7e4885 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_2.txt
@@ -9,4 +9,4 @@
opt1: val1
opt2: val2
Path-Regex #^/name/add$#s
-Host-Regex #^localhost$#s
\ No newline at end of file
+Host-Regex #^localhost$#s
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md
index a148c23210bad..981adc208c7bc 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.md
@@ -22,3 +22,4 @@ route_2
- Class: Symfony\Component\Routing\Route
- Defaults: NONE
- Requirements: NONE
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.txt b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.txt
index e0ade43e2afd3..ce7f760d02fd6 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.txt
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.txt
@@ -1,5 +1,7 @@
[router] Current routes
- Name Method Scheme Host Path
- route_1 GET|HEAD http|https localhost /hello/{name}
- route_2 PUT|POST http|https localhost /name/add
-
\ No newline at end of file
++---------+----------+------------+-----------+---------------+
+|[32m Name [39m|[32m Method [39m|[32m Scheme [39m|[32m Host [39m|[32m Path [39m|
++---------+----------+------------+-----------+---------------+
+| route_1 | GET|HEAD | http|https | localhost | /hello/{name} |
+| route_2 | PUT|POST | http|https | localhost | /name/add |
++---------+----------+------------+-----------+---------------+
diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php
index 3f1b6604c9647..8249fad47daa0 100644
--- a/src/Symfony/Component/Console/Application.php
+++ b/src/Symfony/Component/Console/Application.php
@@ -32,9 +32,6 @@
use Symfony\Component\Console\Command\ListCommand;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Helper\FormatterHelper;
-use Symfony\Component\Console\Helper\DialogHelper;
-use Symfony\Component\Console\Helper\ProgressHelper;
-use Symfony\Component\Console\Helper\TableHelper;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
@@ -950,9 +947,6 @@ protected function getDefaultHelperSet()
{
return new HelperSet(array(
new FormatterHelper(),
- new DialogHelper(false),
- new ProgressHelper(false),
- new TableHelper(false),
new DebugFormatterHelper(),
new ProcessHelper(),
new QuestionHelper(),
diff --git a/src/Symfony/Component/Console/Descriptor/Descriptor.php b/src/Symfony/Component/Console/Descriptor/Descriptor.php
index 952341579a847..7536838f71880 100644
--- a/src/Symfony/Component/Console/Descriptor/Descriptor.php
+++ b/src/Symfony/Component/Console/Descriptor/Descriptor.php
@@ -26,7 +26,7 @@ abstract class Descriptor implements DescriptorInterface
/**
* @var OutputInterface
*/
- private $output;
+ protected $output;
/**
* {@inheritdoc}
diff --git a/src/Symfony/Component/Console/Helper/DialogHelper.php b/src/Symfony/Component/Console/Helper/DialogHelper.php
deleted file mode 100644
index 4d6eccd95fde6..0000000000000
--- a/src/Symfony/Component/Console/Helper/DialogHelper.php
+++ /dev/null
@@ -1,479 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Console\Helper;
-
-use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Formatter\OutputFormatterStyle;
-
-/**
- * The Dialog class provides helpers to interact with the user.
- *
- * @author Fabien Potencier
- *
- * @deprecated Deprecated since version 2.5, to be removed in 3.0.
- * Use {@link \Symfony\Component\Console\Helper\QuestionHelper} instead.
- */
-class DialogHelper extends InputAwareHelper
-{
- private $inputStream;
- private static $shell;
- private static $stty;
-
- public function __construct($triggerDeprecationError = true)
- {
- if ($triggerDeprecationError) {
- trigger_error('"Symfony\Component\Console\Helper\DialogHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\QuestionHelper" instead.', E_USER_DEPRECATED);
- }
- }
-
- /**
- * Asks the user to select a value.
- *
- * @param OutputInterface $output An Output instance
- * @param string|array $question The question to ask
- * @param array $choices List of choices to pick from
- * @param bool|string $default The default answer if the user enters nothing
- * @param bool|int $attempts Max number of times to ask before giving up (false by default, which means infinite)
- * @param string $errorMessage Message which will be shown if invalid value from choice list would be picked
- * @param bool $multiselect Select more than one value separated by comma
- *
- * @return int|string|array The selected value or values (the key of the choices array)
- *
- * @throws \InvalidArgumentException
- */
- public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
- {
- $width = max(array_map('strlen', array_keys($choices)));
-
- $messages = (array) $question;
- foreach ($choices as $key => $value) {
- $messages[] = sprintf(" [%-${width}s] %s", $key, $value);
- }
-
- $output->writeln($messages);
-
- $result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) {
- // Collapse all spaces.
- $selectedChoices = str_replace(" ", "", $picked);
-
- if ($multiselect) {
- // Check for a separated comma values
- if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) {
- throw new \InvalidArgumentException(sprintf($errorMessage, $picked));
- }
- $selectedChoices = explode(",", $selectedChoices);
- } else {
- $selectedChoices = array($picked);
- }
-
- $multiselectChoices = array();
-
- foreach ($selectedChoices as $value) {
- if (empty($choices[$value])) {
- throw new \InvalidArgumentException(sprintf($errorMessage, $value));
- }
- array_push($multiselectChoices, $value);
- }
-
- if ($multiselect) {
- return $multiselectChoices;
- }
-
- return $picked;
- }, $attempts, $default);
-
- return $result;
- }
-
- /**
- * Asks a question to the user.
- *
- * @param OutputInterface $output An Output instance
- * @param string|array $question The question to ask
- * @param string $default The default answer if none is given by the user
- * @param array $autocomplete List of values to autocomplete
- *
- * @return string The user answer
- *
- * @throws \RuntimeException If there is no data to read in the input stream
- */
- public function ask(OutputInterface $output, $question, $default = null, array $autocomplete = null)
- {
- if ($this->input && !$this->input->isInteractive()) {
- return $default;
- }
-
- $output->write($question);
-
- $inputStream = $this->inputStream ?: STDIN;
-
- if (null === $autocomplete || !$this->hasSttyAvailable()) {
- $ret = fgets($inputStream, 4096);
- if (false === $ret) {
- throw new \RuntimeException('Aborted');
- }
- $ret = trim($ret);
- } else {
- $ret = '';
-
- $i = 0;
- $ofs = -1;
- $matches = $autocomplete;
- $numMatches = count($matches);
-
- $sttyMode = shell_exec('stty -g');
-
- // Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead)
- shell_exec('stty -icanon -echo');
-
- // Add highlighted text style
- $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
-
- // Read a keypress
- while (!feof($inputStream)) {
- $c = fread($inputStream, 1);
-
- // Backspace Character
- if ("\177" === $c) {
- if (0 === $numMatches && 0 !== $i) {
- $i--;
- // Move cursor backwards
- $output->write("\033[1D");
- }
-
- if ($i === 0) {
- $ofs = -1;
- $matches = $autocomplete;
- $numMatches = count($matches);
- } else {
- $numMatches = 0;
- }
-
- // Pop the last character off the end of our string
- $ret = substr($ret, 0, $i);
- } elseif ("\033" === $c) {
- // Did we read an escape sequence?
- $c .= fread($inputStream, 2);
-
- // A = Up Arrow. B = Down Arrow
- if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
- if ('A' === $c[2] && -1 === $ofs) {
- $ofs = 0;
- }
-
- if (0 === $numMatches) {
- continue;
- }
-
- $ofs += ('A' === $c[2]) ? -1 : 1;
- $ofs = ($numMatches + $ofs) % $numMatches;
- }
- } elseif (ord($c) < 32) {
- if ("\t" === $c || "\n" === $c) {
- if ($numMatches > 0 && -1 !== $ofs) {
- $ret = $matches[$ofs];
- // Echo out remaining chars for current match
- $output->write(substr($ret, $i));
- $i = strlen($ret);
- }
-
- if ("\n" === $c) {
- $output->write($c);
- break;
- }
-
- $numMatches = 0;
- }
-
- continue;
- } else {
- $output->write($c);
- $ret .= $c;
- $i++;
-
- $numMatches = 0;
- $ofs = 0;
-
- foreach ($autocomplete as $value) {
- // If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle)
- if (0 === strpos($value, $ret) && $i !== strlen($value)) {
- $matches[$numMatches++] = $value;
- }
- }
- }
-
- // Erase characters from cursor to end of line
- $output->write("\033[K");
-
- if ($numMatches > 0 && -1 !== $ofs) {
- // Save cursor position
- $output->write("\0337");
- // Write highlighted text
- $output->write(''.substr($matches[$ofs], $i).'');
- // Restore cursor position
- $output->write("\0338");
- }
- }
-
- // Reset stty so it behaves normally again
- shell_exec(sprintf('stty %s', $sttyMode));
- }
-
- return strlen($ret) > 0 ? $ret : $default;
- }
-
- /**
- * Asks a confirmation to the user.
- *
- * The question will be asked until the user answers by nothing, yes, or no.
- *
- * @param OutputInterface $output An Output instance
- * @param string|array $question The question to ask
- * @param bool $default The default answer if the user enters nothing
- *
- * @return bool true if the user has confirmed, false otherwise
- */
- public function askConfirmation(OutputInterface $output, $question, $default = true)
- {
- $answer = 'z';
- while ($answer && !in_array(strtolower($answer[0]), array('y', 'n'))) {
- $answer = $this->ask($output, $question);
- }
-
- if (false === $default) {
- return $answer && 'y' == strtolower($answer[0]);
- }
-
- return !$answer || 'y' == strtolower($answer[0]);
- }
-
- /**
- * Asks a question to the user, the response is hidden.
- *
- * @param OutputInterface $output An Output instance
- * @param string|array $question The question
- * @param bool $fallback In case the response can not be hidden, whether to fallback on non-hidden question or not
- *
- * @return string The answer
- *
- * @throws \RuntimeException In case the fallback is deactivated and the response can not be hidden
- */
- public function askHiddenResponse(OutputInterface $output, $question, $fallback = true)
- {
- if (defined('PHP_WINDOWS_VERSION_BUILD')) {
- $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
-
- // handle code running from a phar
- if ('phar:' === substr(__FILE__, 0, 5)) {
- $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
- copy($exe, $tmpExe);
- $exe = $tmpExe;
- }
-
- $output->write($question);
- $value = rtrim(shell_exec($exe));
- $output->writeln('');
-
- if (isset($tmpExe)) {
- unlink($tmpExe);
- }
-
- return $value;
- }
-
- if ($this->hasSttyAvailable()) {
- $output->write($question);
-
- $sttyMode = shell_exec('stty -g');
-
- shell_exec('stty -echo');
- $value = fgets($this->inputStream ?: STDIN, 4096);
- shell_exec(sprintf('stty %s', $sttyMode));
-
- if (false === $value) {
- throw new \RuntimeException('Aborted');
- }
-
- $value = trim($value);
- $output->writeln('');
-
- return $value;
- }
-
- if (false !== $shell = $this->getShell()) {
- $output->write($question);
- $readCmd = $shell === 'csh' ? 'set mypassword = $<' : 'read -r mypassword';
- $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
- $value = rtrim(shell_exec($command));
- $output->writeln('');
-
- return $value;
- }
-
- if ($fallback) {
- return $this->ask($output, $question);
- }
-
- throw new \RuntimeException('Unable to hide the response');
- }
-
- /**
- * Asks for a value and validates the response.
- *
- * The validator receives the data to validate. It must return the
- * validated data when the data is valid and throw an exception
- * otherwise.
- *
- * @param OutputInterface $output An Output instance
- * @param string|array $question The question to ask
- * @param callable $validator A PHP callback
- * @param int|false $attempts Max number of times to ask before giving up (false by default, which means infinite)
- * @param string $default The default answer if none is given by the user
- * @param array $autocomplete List of values to autocomplete
- *
- * @return mixed
- *
- * @throws \Exception When any of the validators return an error
- */
- public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null, array $autocomplete = null)
- {
- $interviewer = function () use ($output, $question, $default, $autocomplete) {
- return $this->ask($output, $question, $default, $autocomplete);
- };
-
- return $this->validateAttempts($interviewer, $output, $validator, $attempts);
- }
-
- /**
- * Asks for a value, hide and validates the response.
- *
- * The validator receives the data to validate. It must return the
- * validated data when the data is valid and throw an exception
- * otherwise.
- *
- * @param OutputInterface $output An Output instance
- * @param string|array $question The question to ask
- * @param callable $validator A PHP callback
- * @param int|false $attempts Max number of times to ask before giving up (false by default, which means infinite)
- * @param bool $fallback In case the response can not be hidden, whether to fallback on non-hidden question or not
- *
- * @return string The response
- *
- * @throws \Exception When any of the validators return an error
- * @throws \RuntimeException In case the fallback is deactivated and the response can not be hidden
- */
- public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true)
- {
- $interviewer = function () use ($output, $question, $fallback) {
- return $this->askHiddenResponse($output, $question, $fallback);
- };
-
- return $this->validateAttempts($interviewer, $output, $validator, $attempts);
- }
-
- /**
- * Sets the input stream to read from when interacting with the user.
- *
- * This is mainly useful for testing purpose.
- *
- * @param resource $stream The input stream
- */
- public function setInputStream($stream)
- {
- $this->inputStream = $stream;
- }
-
- /**
- * Returns the helper's input stream.
- *
- * @return string
- */
- public function getInputStream()
- {
- return $this->inputStream;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'dialog';
- }
-
- /**
- * Return a valid Unix shell.
- *
- * @return string|bool The valid shell name, false in case no valid shell is found
- */
- private function getShell()
- {
- if (null !== self::$shell) {
- return self::$shell;
- }
-
- self::$shell = false;
-
- if (file_exists('/usr/bin/env')) {
- // handle other OSs with bash/zsh/ksh/csh if available to hide the answer
- $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
- foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
- if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
- self::$shell = $sh;
- break;
- }
- }
- }
-
- return self::$shell;
- }
-
- private function hasSttyAvailable()
- {
- if (null !== self::$stty) {
- return self::$stty;
- }
-
- exec('stty 2>&1', $output, $exitcode);
-
- return self::$stty = $exitcode === 0;
- }
-
- /**
- * Validate an attempt.
- *
- * @param callable $interviewer A callable that will ask for a question and return the result
- * @param OutputInterface $output An Output instance
- * @param callable $validator A PHP callback
- * @param int|false $attempts Max number of times to ask before giving up ; false will ask infinitely
- *
- * @return string The validated response
- *
- * @throws \Exception In case the max number of attempts has been reached and no valid response has been given
- */
- private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts)
- {
- $error = null;
- while (false === $attempts || $attempts--) {
- if (null !== $error) {
- $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
- }
-
- try {
- return call_user_func($validator, $interviewer());
- } catch (\Exception $error) {
- }
- }
-
- throw $error;
- }
-}
diff --git a/src/Symfony/Component/Console/Helper/HelperSet.php b/src/Symfony/Component/Console/Helper/HelperSet.php
index 52a669d48542b..467be86a85d75 100644
--- a/src/Symfony/Component/Console/Helper/HelperSet.php
+++ b/src/Symfony/Component/Console/Helper/HelperSet.php
@@ -78,14 +78,6 @@ public function get($name)
throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
}
- if ('dialog' === $name && $this->helpers[$name] instanceof DialogHelper) {
- trigger_error('"Symfony\Component\Console\Helper\DialogHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\QuestionHelper" instead.', E_USER_DEPRECATED);
- } elseif ('progress' === $name && $this->helpers[$name] instanceof ProgressHelper) {
- trigger_error('"Symfony\Component\Console\Helper\ProgressHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\ProgressBar" instead.', E_USER_DEPRECATED);
- } elseif ('table' === $name && $this->helpers[$name] instanceof TableHelper) {
- trigger_error('"Symfony\Component\Console\Helper\TableHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\Table" instead.', E_USER_DEPRECATED);
- }
-
return $this->helpers[$name];
}
diff --git a/src/Symfony/Component/Console/Helper/ProgressHelper.php b/src/Symfony/Component/Console/Helper/ProgressHelper.php
deleted file mode 100644
index d1ab241ac0027..0000000000000
--- a/src/Symfony/Component/Console/Helper/ProgressHelper.php
+++ /dev/null
@@ -1,464 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Console\Helper;
-
-use Symfony\Component\Console\Output\NullOutput;
-use Symfony\Component\Console\Output\OutputInterface;
-
-/**
- * The Progress class provides helpers to display progress output.
- *
- * @author Chris Jones
- * @author Fabien Potencier
- *
- * @deprecated Deprecated since 2.5, to be removed in 3.0; use ProgressBar instead.
- */
-class ProgressHelper extends Helper
-{
- const FORMAT_QUIET = ' %percent%%';
- const FORMAT_NORMAL = ' %current%/%max% [%bar%] %percent%%';
- const FORMAT_VERBOSE = ' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%';
- const FORMAT_QUIET_NOMAX = ' %current%';
- const FORMAT_NORMAL_NOMAX = ' %current% [%bar%]';
- const FORMAT_VERBOSE_NOMAX = ' %current% [%bar%] Elapsed: %elapsed%';
-
- // options
- private $barWidth = 28;
- private $barChar = '=';
- private $emptyBarChar = '-';
- private $progressChar = '>';
- private $format = null;
- private $redrawFreq = 1;
-
- private $lastMessagesLength;
- private $barCharOriginal;
-
- /**
- * @var OutputInterface
- */
- private $output;
-
- /**
- * Current step.
- *
- * @var int
- */
- private $current;
-
- /**
- * Maximum number of steps.
- *
- * @var int
- */
- private $max;
-
- /**
- * Start time of the progress bar.
- *
- * @var int
- */
- private $startTime;
-
- /**
- * List of formatting variables.
- *
- * @var array
- */
- private $defaultFormatVars = array(
- 'current',
- 'max',
- 'bar',
- 'percent',
- 'elapsed',
- );
-
- /**
- * Available formatting variables.
- *
- * @var array
- */
- private $formatVars;
-
- /**
- * Stored format part widths (used for padding).
- *
- * @var array
- */
- private $widths = array(
- 'current' => 4,
- 'max' => 4,
- 'percent' => 3,
- 'elapsed' => 6,
- );
-
- /**
- * Various time formats.
- *
- * @var array
- */
- private $timeFormats = array(
- array(0, '???'),
- array(2, '1 sec'),
- array(59, 'secs', 1),
- array(60, '1 min'),
- array(3600, 'mins', 60),
- array(5400, '1 hr'),
- array(86400, 'hrs', 3600),
- array(129600, '1 day'),
- array(604800, 'days', 86400),
- );
-
- public function __construct($triggerDeprecationError = true)
- {
- if ($triggerDeprecationError) {
- trigger_error('"Symfony\Component\Console\Helper\ProgressHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\ProgressBar" instead.', E_USER_DEPRECATED);
- }
- }
-
- /**
- * Sets the progress bar width.
- *
- * @param int $size The progress bar size
- */
- public function setBarWidth($size)
- {
- $this->barWidth = (int) $size;
- }
-
- /**
- * Sets the bar character.
- *
- * @param string $char A character
- */
- public function setBarCharacter($char)
- {
- $this->barChar = $char;
- }
-
- /**
- * Sets the empty bar character.
- *
- * @param string $char A character
- */
- public function setEmptyBarCharacter($char)
- {
- $this->emptyBarChar = $char;
- }
-
- /**
- * Sets the progress bar character.
- *
- * @param string $char A character
- */
- public function setProgressCharacter($char)
- {
- $this->progressChar = $char;
- }
-
- /**
- * Sets the progress bar format.
- *
- * @param string $format The format
- */
- public function setFormat($format)
- {
- $this->format = $format;
- }
-
- /**
- * Sets the redraw frequency.
- *
- * @param int $freq The frequency in steps
- */
- public function setRedrawFrequency($freq)
- {
- $this->redrawFreq = (int) $freq;
- }
-
- /**
- * Starts the progress output.
- *
- * @param OutputInterface $output An Output instance
- * @param int|null $max Maximum steps
- */
- public function start(OutputInterface $output, $max = null)
- {
- $this->startTime = time();
- $this->current = 0;
- $this->max = (int) $max;
-
- // Disabling output when it does not support ANSI codes as it would result in a broken display anyway.
- $this->output = $output->isDecorated() ? $output : new NullOutput();
- $this->lastMessagesLength = 0;
- $this->barCharOriginal = '';
-
- if (null === $this->format) {
- switch ($output->getVerbosity()) {
- case OutputInterface::VERBOSITY_QUIET:
- $this->format = self::FORMAT_QUIET_NOMAX;
- if ($this->max > 0) {
- $this->format = self::FORMAT_QUIET;
- }
- break;
- case OutputInterface::VERBOSITY_VERBOSE:
- case OutputInterface::VERBOSITY_VERY_VERBOSE:
- case OutputInterface::VERBOSITY_DEBUG:
- $this->format = self::FORMAT_VERBOSE_NOMAX;
- if ($this->max > 0) {
- $this->format = self::FORMAT_VERBOSE;
- }
- break;
- default:
- $this->format = self::FORMAT_NORMAL_NOMAX;
- if ($this->max > 0) {
- $this->format = self::FORMAT_NORMAL;
- }
- break;
- }
- }
-
- $this->initialize();
- }
-
- /**
- * Advances the progress output X steps.
- *
- * @param int $step Number of steps to advance
- * @param bool $redraw Whether to redraw or not
- *
- * @throws \LogicException
- */
- public function advance($step = 1, $redraw = false)
- {
- $this->setCurrent($this->current + $step, $redraw);
- }
-
- /**
- * Sets the current progress.
- *
- * @param int $current The current progress
- * @param bool $redraw Whether to redraw or not
- *
- * @throws \LogicException
- */
- public function setCurrent($current, $redraw = false)
- {
- if (null === $this->startTime) {
- throw new \LogicException('You must start the progress bar before calling setCurrent().');
- }
-
- $current = (int) $current;
-
- if ($current < $this->current) {
- throw new \LogicException('You can\'t regress the progress bar');
- }
-
- if (0 === $this->current) {
- $redraw = true;
- }
-
- $prevPeriod = intval($this->current / $this->redrawFreq);
-
- $this->current = $current;
-
- $currPeriod = intval($this->current / $this->redrawFreq);
- if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
- $this->display();
- }
- }
-
- /**
- * Outputs the current progress string.
- *
- * @param bool $finish Forces the end result
- *
- * @throws \LogicException
- */
- public function display($finish = false)
- {
- if (null === $this->startTime) {
- throw new \LogicException('You must start the progress bar before calling display().');
- }
-
- $message = $this->format;
- foreach ($this->generate($finish) as $name => $value) {
- $message = str_replace("%{$name}%", $value, $message);
- }
- $this->overwrite($this->output, $message);
- }
-
- /**
- * Removes the progress bar from the current line.
- *
- * This is useful if you wish to write some output
- * while a progress bar is running.
- * Call display() to show the progress bar again.
- */
- public function clear()
- {
- $this->overwrite($this->output, '');
- }
-
- /**
- * Finishes the progress output.
- */
- public function finish()
- {
- if (null === $this->startTime) {
- throw new \LogicException('You must start the progress bar before calling finish().');
- }
-
- if (null !== $this->startTime) {
- if (!$this->max) {
- $this->barChar = $this->barCharOriginal;
- $this->display(true);
- }
- $this->startTime = null;
- $this->output->writeln('');
- $this->output = null;
- }
- }
-
- /**
- * Initializes the progress helper.
- */
- private function initialize()
- {
- $this->formatVars = array();
- foreach ($this->defaultFormatVars as $var) {
- if (false !== strpos($this->format, "%{$var}%")) {
- $this->formatVars[$var] = true;
- }
- }
-
- if ($this->max > 0) {
- $this->widths['max'] = $this->strlen($this->max);
- $this->widths['current'] = $this->widths['max'];
- } else {
- $this->barCharOriginal = $this->barChar;
- $this->barChar = $this->emptyBarChar;
- }
- }
-
- /**
- * Generates the array map of format variables to values.
- *
- * @param bool $finish Forces the end result
- *
- * @return array Array of format vars and values
- */
- private function generate($finish = false)
- {
- $vars = array();
- $percent = 0;
- if ($this->max > 0) {
- $percent = (float) $this->current / $this->max;
- }
-
- if (isset($this->formatVars['bar'])) {
- $completeBars = 0;
-
- if ($this->max > 0) {
- $completeBars = floor($percent * $this->barWidth);
- } else {
- if (!$finish) {
- $completeBars = floor($this->current % $this->barWidth);
- } else {
- $completeBars = $this->barWidth;
- }
- }
-
- $emptyBars = $this->barWidth - $completeBars - $this->strlen($this->progressChar);
- $bar = str_repeat($this->barChar, $completeBars);
- if ($completeBars < $this->barWidth) {
- $bar .= $this->progressChar;
- $bar .= str_repeat($this->emptyBarChar, $emptyBars);
- }
-
- $vars['bar'] = $bar;
- }
-
- if (isset($this->formatVars['elapsed'])) {
- $elapsed = time() - $this->startTime;
- $vars['elapsed'] = str_pad($this->humaneTime($elapsed), $this->widths['elapsed'], ' ', STR_PAD_LEFT);
- }
-
- if (isset($this->formatVars['current'])) {
- $vars['current'] = str_pad($this->current, $this->widths['current'], ' ', STR_PAD_LEFT);
- }
-
- if (isset($this->formatVars['max'])) {
- $vars['max'] = $this->max;
- }
-
- if (isset($this->formatVars['percent'])) {
- $vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT);
- }
-
- return $vars;
- }
-
- /**
- * Converts seconds into human-readable format.
- *
- * @param int $secs Number of seconds
- *
- * @return string Time in readable format
- */
- private function humaneTime($secs)
- {
- $text = '';
- foreach ($this->timeFormats as $format) {
- if ($secs < $format[0]) {
- if (count($format) == 2) {
- $text = $format[1];
- break;
- } else {
- $text = ceil($secs / $format[2]).' '.$format[1];
- break;
- }
- }
- }
-
- return $text;
- }
-
- /**
- * Overwrites a previous message to the output.
- *
- * @param OutputInterface $output An Output instance
- * @param string $message The message
- */
- private function overwrite(OutputInterface $output, $message)
- {
- $length = $this->strlen($message);
-
- // append whitespace to match the last line's length
- if (null !== $this->lastMessagesLength && $this->lastMessagesLength > $length) {
- $message = str_pad($message, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
- }
-
- // carriage return
- $output->write("\x0D");
- $output->write($message);
-
- $this->lastMessagesLength = $this->strlen($message);
- }
-
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'progress';
- }
-}
diff --git a/src/Symfony/Component/Console/Helper/TableHelper.php b/src/Symfony/Component/Console/Helper/TableHelper.php
deleted file mode 100644
index eec3f362a3673..0000000000000
--- a/src/Symfony/Component/Console/Helper/TableHelper.php
+++ /dev/null
@@ -1,267 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Console\Helper;
-
-use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Output\NullOutput;
-
-/**
- * Provides helpers to display table output.
- *
- * @author Саша Стаменковић
- * @author Fabien Potencier
- *
- * @deprecated Deprecated since 2.5, to be removed in 3.0; use Table instead.
- */
-class TableHelper extends Helper
-{
- const LAYOUT_DEFAULT = 0;
- const LAYOUT_BORDERLESS = 1;
- const LAYOUT_COMPACT = 2;
-
- /**
- * @var Table
- */
- private $table;
-
- public function __construct($triggerDeprecationError = true)
- {
- if ($triggerDeprecationError) {
- trigger_error('"Symfony\Component\Console\Helper\TableHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\Table" instead.', E_USER_DEPRECATED);
- }
-
- $this->table = new Table(new NullOutput());
- }
-
- /**
- * Sets table layout type.
- *
- * @param int $layout self::LAYOUT_*
- *
- * @return TableHelper
- *
- * @throws \InvalidArgumentException when the table layout is not known
- */
- public function setLayout($layout)
- {
- switch ($layout) {
- case self::LAYOUT_BORDERLESS:
- $this->table->setStyle('borderless');
- break;
-
- case self::LAYOUT_COMPACT:
- $this->table->setStyle('compact');
- break;
-
- case self::LAYOUT_DEFAULT:
- $this->table->setStyle('default');
- break;
-
- default:
- throw new \InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout));
- };
-
- return $this;
- }
-
- public function setHeaders(array $headers)
- {
- $this->table->setHeaders($headers);
-
- return $this;
- }
-
- public function setRows(array $rows)
- {
- $this->table->setRows($rows);
-
- return $this;
- }
-
- public function addRows(array $rows)
- {
- $this->table->addRows($rows);
-
- return $this;
- }
-
- public function addRow(array $row)
- {
- $this->table->addRow($row);
-
- return $this;
- }
-
- public function setRow($column, array $row)
- {
- $this->table->setRow($column, $row);
-
- return $this;
- }
-
- /**
- * Sets padding character, used for cell padding.
- *
- * @param string $paddingChar
- *
- * @return TableHelper
- */
- public function setPaddingChar($paddingChar)
- {
- $this->table->getStyle()->setPaddingChar($paddingChar);
-
- return $this;
- }
-
- /**
- * Sets horizontal border character.
- *
- * @param string $horizontalBorderChar
- *
- * @return TableHelper
- */
- public function setHorizontalBorderChar($horizontalBorderChar)
- {
- $this->table->getStyle()->setHorizontalBorderChar($horizontalBorderChar);
-
- return $this;
- }
-
- /**
- * Sets vertical border character.
- *
- * @param string $verticalBorderChar
- *
- * @return TableHelper
- */
- public function setVerticalBorderChar($verticalBorderChar)
- {
- $this->table->getStyle()->setVerticalBorderChar($verticalBorderChar);
-
- return $this;
- }
-
- /**
- * Sets crossing character.
- *
- * @param string $crossingChar
- *
- * @return TableHelper
- */
- public function setCrossingChar($crossingChar)
- {
- $this->table->getStyle()->setCrossingChar($crossingChar);
-
- return $this;
- }
-
- /**
- * Sets header cell format.
- *
- * @param string $cellHeaderFormat
- *
- * @return TableHelper
- */
- public function setCellHeaderFormat($cellHeaderFormat)
- {
- $this->table->getStyle()->setCellHeaderFormat($cellHeaderFormat);
-
- return $this;
- }
-
- /**
- * Sets row cell format.
- *
- * @param string $cellRowFormat
- *
- * @return TableHelper
- */
- public function setCellRowFormat($cellRowFormat)
- {
- $this->table->getStyle()->setCellHeaderFormat($cellRowFormat);
-
- return $this;
- }
-
- /**
- * Sets row cell content format.
- *
- * @param string $cellRowContentFormat
- *
- * @return TableHelper
- */
- public function setCellRowContentFormat($cellRowContentFormat)
- {
- $this->table->getStyle()->setCellRowContentFormat($cellRowContentFormat);
-
- return $this;
- }
-
- /**
- * Sets table border format.
- *
- * @param string $borderFormat
- *
- * @return TableHelper
- */
- public function setBorderFormat($borderFormat)
- {
- $this->table->getStyle()->setBorderFormat($borderFormat);
-
- return $this;
- }
-
- /**
- * Sets cell padding type.
- *
- * @param int $padType STR_PAD_*
- *
- * @return TableHelper
- */
- public function setPadType($padType)
- {
- $this->table->getStyle()->setPadType($padType);
-
- return $this;
- }
-
- /**
- * Renders table to output.
- *
- * Example:
- * +---------------+-----------------------+------------------+
- * | ISBN | Title | Author |
- * +---------------+-----------------------+------------------+
- * | 99921-58-10-7 | Divine Comedy | Dante Alighieri |
- * | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
- * | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
- * +---------------+-----------------------+------------------+
- *
- * @param OutputInterface $output
- */
- public function render(OutputInterface $output)
- {
- $p = new \ReflectionProperty($this->table, 'output');
- $p->setAccessible(true);
- $p->setValue($this->table, $output);
-
- $this->table->render();
- }
-
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'table';
- }
-}
diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php
index 27cf58775e231..a280845c58bcb 100644
--- a/src/Symfony/Component/Console/Tests/ApplicationTest.php
+++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php
@@ -749,8 +749,6 @@ public function testGetDefaultHelperSetReturnsDefaultValues()
$helperSet = $application->getHelperSet();
$this->assertTrue($helperSet->has('formatter'));
- $this->assertTrue($helperSet->has('dialog'));
- $this->assertTrue($helperSet->has('progress'));
}
public function testAddingSingleHelperSetOverwritesDefaultValues()
diff --git a/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php
deleted file mode 100644
index e8404a4a687d3..0000000000000
--- a/src/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php
+++ /dev/null
@@ -1,192 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Console\Tests\Helper;
-
-use Symfony\Component\Console\Input\ArrayInput;
-use Symfony\Component\Console\Helper\DialogHelper;
-use Symfony\Component\Console\Helper\HelperSet;
-use Symfony\Component\Console\Helper\FormatterHelper;
-use Symfony\Component\Console\Output\StreamOutput;
-
-class DialogHelperTest extends \PHPUnit_Framework_TestCase
-{
- public function testSelect()
- {
- $dialog = new DialogHelper();
-
- $helperSet = new HelperSet(array(new FormatterHelper()));
- $dialog->setHelperSet($helperSet);
-
- $heroes = array('Superman', 'Batman', 'Spiderman');
-
- $dialog->setInputStream($this->getInputStream("\n1\n 1 \nFabien\n1\nFabien\n1\n0,2\n 0 , 2 \n\n\n"));
- $this->assertEquals('2', $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, '2'));
- $this->assertEquals('1', $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes));
- $this->assertEquals('1', $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes));
- $this->assertEquals('1', $dialog->select($output = $this->getOutputStream(), 'What is your favorite superhero?', $heroes, null, false, 'Input "%s" is not a superhero!', false));
-
- rewind($output->getStream());
- $this->assertContains('Input "Fabien" is not a superhero!', stream_get_contents($output->getStream()));
-
- try {
- $this->assertEquals('1', $dialog->select($output = $this->getOutputStream(), 'What is your favorite superhero?', $heroes, null, 1));
- $this->fail();
- } catch (\InvalidArgumentException $e) {
- $this->assertEquals('Value "Fabien" is invalid', $e->getMessage());
- }
-
- $this->assertEquals(array('1'), $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, null, false, 'Input "%s" is not a superhero!', true));
- $this->assertEquals(array('0', '2'), $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, null, false, 'Input "%s" is not a superhero!', true));
- $this->assertEquals(array('0', '2'), $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, null, false, 'Input "%s" is not a superhero!', true));
- $this->assertEquals(array('0', '1'), $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, '0,1', false, 'Input "%s" is not a superhero!', true));
- $this->assertEquals(array('0', '1'), $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, ' 0 , 1 ', false, 'Input "%s" is not a superhero!', true));
- }
-
- public function testAsk()
- {
- $dialog = new DialogHelper();
-
- $dialog->setInputStream($this->getInputStream("\n8AM\n"));
-
- $this->assertEquals('2PM', $dialog->ask($this->getOutputStream(), 'What time is it?', '2PM'));
- $this->assertEquals('8AM', $dialog->ask($output = $this->getOutputStream(), 'What time is it?', '2PM'));
-
- rewind($output->getStream());
- $this->assertEquals('What time is it?', stream_get_contents($output->getStream()));
- }
-
- public function testAskWithAutocomplete()
- {
- if (!$this->hasSttyAvailable()) {
- $this->markTestSkipped('`stty` is required to test autocomplete functionality');
- }
-
- // Acm
- // AcsTest
- //
- //
- // Test
- //
- // S
- // F00oo
- $inputStream = $this->getInputStream("Acm\nAc\177\177s\tTest\n\n\033[A\033[A\n\033[A\033[A\033[A\033[A\033[A\tTest\n\033[B\nS\177\177\033[B\033[B\nF00\177\177oo\t\n");
-
- $dialog = new DialogHelper();
- $dialog->setInputStream($inputStream);
-
- $bundles = array('AcmeDemoBundle', 'AsseticBundle', 'SecurityBundle', 'FooBundle');
-
- $this->assertEquals('AcmeDemoBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
- $this->assertEquals('AsseticBundleTest', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
- $this->assertEquals('FrameworkBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
- $this->assertEquals('SecurityBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
- $this->assertEquals('FooBundleTest', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
- $this->assertEquals('AcmeDemoBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
- $this->assertEquals('AsseticBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
- $this->assertEquals('FooBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
- }
-
- /**
- * @group tty
- */
- public function testAskHiddenResponse()
- {
- if (defined('PHP_WINDOWS_VERSION_BUILD')) {
- $this->markTestSkipped('This test is not supported on Windows');
- }
-
- $dialog = new DialogHelper();
-
- $dialog->setInputStream($this->getInputStream("8AM\n"));
-
- $this->assertEquals('8AM', $dialog->askHiddenResponse($this->getOutputStream(), 'What time is it?'));
- }
-
- public function testAskConfirmation()
- {
- $dialog = new DialogHelper();
-
- $dialog->setInputStream($this->getInputStream("\n\n"));
- $this->assertTrue($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?'));
- $this->assertFalse($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', false));
-
- $dialog->setInputStream($this->getInputStream("y\nyes\n"));
- $this->assertTrue($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', false));
- $this->assertTrue($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', false));
-
- $dialog->setInputStream($this->getInputStream("n\nno\n"));
- $this->assertFalse($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', true));
- $this->assertFalse($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', true));
- }
-
- public function testAskAndValidate()
- {
- $dialog = new DialogHelper();
- $helperSet = new HelperSet(array(new FormatterHelper()));
- $dialog->setHelperSet($helperSet);
-
- $question = 'What color was the white horse of Henry IV?';
- $error = 'This is not a color!';
- $validator = function ($color) use ($error) {
- if (!in_array($color, array('white', 'black'))) {
- throw new \InvalidArgumentException($error);
- }
-
- return $color;
- };
-
- $dialog->setInputStream($this->getInputStream("\nblack\n"));
- $this->assertEquals('white', $dialog->askAndValidate($this->getOutputStream(), $question, $validator, 2, 'white'));
- $this->assertEquals('black', $dialog->askAndValidate($this->getOutputStream(), $question, $validator, 2, 'white'));
-
- $dialog->setInputStream($this->getInputStream("green\nyellow\norange\n"));
- try {
- $this->assertEquals('white', $dialog->askAndValidate($this->getOutputStream(), $question, $validator, 2, 'white'));
- $this->fail();
- } catch (\InvalidArgumentException $e) {
- $this->assertEquals($error, $e->getMessage());
- }
- }
-
- public function testNoInteraction()
- {
- $dialog = new DialogHelper();
-
- $input = new ArrayInput(array());
- $input->setInteractive(false);
-
- $dialog->setInput($input);
-
- $this->assertEquals('not yet', $dialog->ask($this->getOutputStream(), 'Do you have a job?', 'not yet'));
- }
-
- protected function getInputStream($input)
- {
- $stream = fopen('php://memory', 'r+', false);
- fputs($stream, $input);
- rewind($stream);
-
- return $stream;
- }
-
- protected function getOutputStream()
- {
- return new StreamOutput(fopen('php://memory', 'r+', false));
- }
-
- private function hasSttyAvailable()
- {
- exec('stty 2>&1', $output, $exitcode);
-
- return $exitcode === 0;
- }
-}
diff --git a/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php
deleted file mode 100644
index 7bc475fce001b..0000000000000
--- a/src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php
+++ /dev/null
@@ -1,224 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Console\Tests\Helper;
-
-use Symfony\Component\Console\Helper\ProgressHelper;
-use Symfony\Component\Console\Output\StreamOutput;
-
-class ProgressHelperTest extends \PHPUnit_Framework_TestCase
-{
- public function testAdvance()
- {
- $progress = new ProgressHelper();
- $progress->start($output = $this->getOutputStream());
- $progress->advance();
-
- rewind($output->getStream());
- $this->assertEquals($this->generateOutput(' 1 [->--------------------------]'), stream_get_contents($output->getStream()));
- }
-
- public function testAdvanceWithStep()
- {
- $progress = new ProgressHelper();
- $progress->start($output = $this->getOutputStream());
- $progress->advance(5);
-
- rewind($output->getStream());
- $this->assertEquals($this->generateOutput(' 5 [----->----------------------]'), stream_get_contents($output->getStream()));
- }
-
- public function testAdvanceMultipleTimes()
- {
- $progress = new ProgressHelper();
- $progress->start($output = $this->getOutputStream());
- $progress->advance(3);
- $progress->advance(2);
-
- rewind($output->getStream());
- $this->assertEquals($this->generateOutput(' 3 [--->------------------------]').$this->generateOutput(' 5 [----->----------------------]'), stream_get_contents($output->getStream()));
- }
-
- public function testCustomizations()
- {
- $progress = new ProgressHelper();
- $progress->setBarWidth(10);
- $progress->setBarCharacter('_');
- $progress->setEmptyBarCharacter(' ');
- $progress->setProgressCharacter('/');
- $progress->setFormat(' %current%/%max% [%bar%] %percent%%');
- $progress->start($output = $this->getOutputStream(), 10);
- $progress->advance();
-
- rewind($output->getStream());
- $this->assertEquals($this->generateOutput(' 1/10 [_/ ] 10%'), stream_get_contents($output->getStream()));
- }
-
- public function testPercent()
- {
- $progress = new ProgressHelper();
- $progress->start($output = $this->getOutputStream(), 50);
- $progress->display();
- $progress->advance();
- $progress->advance();
-
- rewind($output->getStream());
- $this->assertEquals($this->generateOutput(' 0/50 [>---------------------------] 0%').$this->generateOutput(' 1/50 [>---------------------------] 2%').$this->generateOutput(' 2/50 [=>--------------------------] 4%'), stream_get_contents($output->getStream()));
- }
-
- public function testOverwriteWithShorterLine()
- {
- $progress = new ProgressHelper();
- $progress->setFormat(' %current%/%max% [%bar%] %percent%%');
- $progress->start($output = $this->getOutputStream(), 50);
- $progress->display();
- $progress->advance();
-
- // set shorter format
- $progress->setFormat(' %current%/%max% [%bar%]');
- $progress->advance();
-
- rewind($output->getStream());
- $this->assertEquals(
- $this->generateOutput(' 0/50 [>---------------------------] 0%').
- $this->generateOutput(' 1/50 [>---------------------------] 2%').
- $this->generateOutput(' 2/50 [=>--------------------------] '),
- stream_get_contents($output->getStream())
- );
- }
-
- public function testSetCurrentProgress()
- {
- $progress = new ProgressHelper();
- $progress->start($output = $this->getOutputStream(), 50);
- $progress->display();
- $progress->advance();
- $progress->setCurrent(15);
- $progress->setCurrent(25);
-
- rewind($output->getStream());
- $this->assertEquals(
- $this->generateOutput(' 0/50 [>---------------------------] 0%').
- $this->generateOutput(' 1/50 [>---------------------------] 2%').
- $this->generateOutput(' 15/50 [========>-------------------] 30%').
- $this->generateOutput(' 25/50 [==============>-------------] 50%'),
- stream_get_contents($output->getStream())
- );
- }
-
- /**
- * @expectedException \LogicException
- * @expectedExceptionMessage You must start the progress bar
- */
- public function testSetCurrentBeforeStarting()
- {
- $progress = new ProgressHelper();
- $progress->setCurrent(15);
- }
-
- /**
- * @expectedException \LogicException
- * @expectedExceptionMessage You can't regress the progress bar
- */
- public function testRegressProgress()
- {
- $progress = new ProgressHelper();
- $progress->start($output = $this->getOutputStream(), 50);
- $progress->setCurrent(15);
- $progress->setCurrent(10);
- }
-
- public function testRedrawFrequency()
- {
- $progress = $this->getMock('Symfony\Component\Console\Helper\ProgressHelper', array('display'));
- $progress->expects($this->exactly(4))
- ->method('display');
-
- $progress->setRedrawFrequency(2);
-
- $progress->start($output = $this->getOutputStream(), 6);
- $progress->setCurrent(1);
- $progress->advance(2);
- $progress->advance(2);
- $progress->advance(1);
- }
-
- public function testMultiByteSupport()
- {
- if (!function_exists('mb_strlen') || (false === $encoding = mb_detect_encoding('■'))) {
- $this->markTestSkipped('The mbstring extension is needed for multi-byte support');
- }
-
- $progress = new ProgressHelper();
- $progress->start($output = $this->getOutputStream());
- $progress->setBarCharacter('■');
- $progress->advance(3);
-
- rewind($output->getStream());
- $this->assertEquals($this->generateOutput(' 3 [■■■>------------------------]'), stream_get_contents($output->getStream()));
- }
-
- public function testClear()
- {
- $progress = new ProgressHelper();
- $progress->start($output = $this->getOutputStream(), 50);
- $progress->setCurrent(25);
- $progress->clear();
-
- rewind($output->getStream());
- $this->assertEquals(
- $this->generateOutput(' 25/50 [==============>-------------] 50%').$this->generateOutput(''),
- stream_get_contents($output->getStream())
- );
- }
-
- public function testPercentNotHundredBeforeComplete()
- {
- $progress = new ProgressHelper();
- $progress->start($output = $this->getOutputStream(), 200);
- $progress->display();
- $progress->advance(199);
- $progress->advance();
-
- rewind($output->getStream());
- $this->assertEquals($this->generateOutput(' 0/200 [>---------------------------] 0%').$this->generateOutput(' 199/200 [===========================>] 99%').$this->generateOutput(' 200/200 [============================] 100%'), stream_get_contents($output->getStream()));
- }
-
- public function testNonDecoratedOutput()
- {
- $progress = new ProgressHelper();
- $progress->start($output = $this->getOutputStream(false));
- $progress->advance();
-
- rewind($output->getStream());
- $this->assertEquals('', stream_get_contents($output->getStream()));
- }
-
- protected function getOutputStream($decorated = true)
- {
- return new StreamOutput(fopen('php://memory', 'r+', false), StreamOutput::VERBOSITY_NORMAL, $decorated);
- }
-
- protected $lastMessagesLength;
-
- protected function generateOutput($expected)
- {
- $expectedout = $expected;
-
- if ($this->lastMessagesLength !== null) {
- $expectedout = str_pad($expected, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
- }
-
- $this->lastMessagesLength = strlen($expectedout);
-
- return "\x0D".$expectedout;
- }
-}
diff --git a/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php
deleted file mode 100644
index f3cda0dabf9c1..0000000000000
--- a/src/Symfony/Component/Console/Tests/Helper/TableHelperTest.php
+++ /dev/null
@@ -1,294 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Console\Tests\Helper;
-
-use Symfony\Component\Console\Helper\TableHelper;
-use Symfony\Component\Console\Output\StreamOutput;
-
-class TableHelperTest extends \PHPUnit_Framework_TestCase
-{
- protected $stream;
-
- protected function setUp()
- {
- $this->stream = fopen('php://memory', 'r+');
- }
-
- protected function tearDown()
- {
- fclose($this->stream);
- $this->stream = null;
- }
-
- /**
- * @dataProvider testRenderProvider
- */
- public function testRender($headers, $rows, $layout, $expected)
- {
- $table = new TableHelper();
- $table
- ->setHeaders($headers)
- ->setRows($rows)
- ->setLayout($layout)
- ;
- $table->render($output = $this->getOutputStream());
-
- $this->assertEquals($expected, $this->getOutputContent($output));
- }
-
- /**
- * @dataProvider testRenderProvider
- */
- public function testRenderAddRows($headers, $rows, $layout, $expected)
- {
- $table = new TableHelper();
- $table
- ->setHeaders($headers)
- ->addRows($rows)
- ->setLayout($layout)
- ;
- $table->render($output = $this->getOutputStream());
-
- $this->assertEquals($expected, $this->getOutputContent($output));
- }
-
- /**
- * @dataProvider testRenderProvider
- */
- public function testRenderAddRowsOneByOne($headers, $rows, $layout, $expected)
- {
- $table = new TableHelper();
- $table
- ->setHeaders($headers)
- ->setLayout($layout)
- ;
- foreach ($rows as $row) {
- $table->addRow($row);
- }
- $table->render($output = $this->getOutputStream());
-
- $this->assertEquals($expected, $this->getOutputContent($output));
- }
-
- public function testRenderProvider()
- {
- $books = array(
- array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'),
- array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'),
- array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'),
- array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'),
- );
-
- return array(
- array(
- array('ISBN', 'Title', 'Author'),
- $books,
- TableHelper::LAYOUT_DEFAULT,
-<< array(
- array('ISBN', 'Title', 'Author'),
- array(
- array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'),
- array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens>'),
- ),
- TableHelper::LAYOUT_DEFAULT,
-<< array(
- array('ISBN', 'Title', 'Author'),
- array(
- array('99921-58-10-700', 'Divine Com', 'Dante Alighieri'),
- array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'),
- ),
- TableHelper::LAYOUT_DEFAULT,
-<<99921-58-10-700 | Divine Com | Dante Alighieri |
-| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
-+----------------------------------+----------------------+-----------------+
-
-TABLE
- ),
- );
- }
-
- public function testRenderMultiByte()
- {
- if (!function_exists('mb_strlen')) {
- $this->markTestSkipped('The "mbstring" extension is not available');
- }
-
- $table = new TableHelper();
- $table
- ->setHeaders(array('■■'))
- ->setRows(array(array(1234)))
- ->setLayout(TableHelper::LAYOUT_DEFAULT)
- ;
- $table->render($output = $this->getOutputStream());
-
- $expected =
-<<assertEquals($expected, $this->getOutputContent($output));
- }
-
- protected function getOutputStream()
- {
- return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, false);
- }
-
- protected function getOutputContent(StreamOutput $output)
- {
- rewind($output->getStream());
-
- return str_replace(PHP_EOL, "\n", stream_get_contents($output->getStream()));
- }
-}