Skip to content

Commit cb5e791

Browse files
Merge branch '3.3' into 3.4
* 3.3: [2.8] Fix some docblocks Escape trailing \ in QuestionHelper autocompletion [FrameworkBundle][Serializer] Remove outdated condition Add "doctrine/annotations" to top-level composer.json Fix phpdoc inconsistencies, simplify no-op sprintf. Remove inapplicable phpdoc comment nit: Fix phpdoc inconsistency and unreachable statement Prefer line formatter on missing cli dumper [DI] Enhance service locator error message
2 parents 2a5759d + c73ee30 commit cb5e791

File tree

15 files changed

+62
-23
lines changed

15 files changed

+62
-23
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
},
8989
"require-dev": {
9090
"cache/integration-tests": "dev-master",
91+
"doctrine/annotations": "~1.0",
9192
"doctrine/cache": "~1.6",
9293
"doctrine/data-fixtures": "1.0.*",
9394
"doctrine/dbal": "~2.4",

src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\Monolog\Handler;
1313

14+
use Monolog\Formatter\LineFormatter;
1415
use Monolog\Handler\AbstractProcessingHandler;
1516
use Monolog\Logger;
1617
use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter;
@@ -20,6 +21,7 @@
2021
use Symfony\Component\Console\Output\ConsoleOutputInterface;
2122
use Symfony\Component\Console\Output\OutputInterface;
2223
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
24+
use Symfony\Component\VarDumper\Dumper\CliDumper;
2325

2426
/**
2527
* Writes logs to the console output depending on its verbosity setting.
@@ -162,6 +164,9 @@ protected function write(array $record)
162164
*/
163165
protected function getDefaultFormatter()
164166
{
167+
if (!class_exists(CliDumper::class)) {
168+
return new LineFormatter();
169+
}
165170
if (!$this->output) {
166171
return new ConsoleFormatter();
167172
}

src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function hasMarkedPlace($subject, $placeName, $name = null)
8585
* Returns marked places.
8686
*
8787
* @param object $subject A subject
88-
* @param string $placesNameOnly If true, returns only places name. If false returns the raw representation
88+
* @param bool $placesNameOnly If true, returns only places name. If false returns the raw representation
8989
* @param string $name A workflow name
9090
*
9191
* @return string[]|int[]

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,6 @@ protected function describeCallable($callable, array $options = array())
418418
$this->writeText($this->formatCallable($callable), $options);
419419
}
420420

421-
/**
422-
* @param array $array
423-
*/
424421
private function renderEventListenerTable(EventDispatcherInterface $eventDispatcher, $event, array $eventListeners, SymfonyStyle $io)
425422
{
426423
$tableHeaders = array('Order', 'Callable', 'Priority');

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SerializerTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,13 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
1313

14-
use Symfony\Component\Serializer\Normalizer\DataUriNormalizer;
15-
1614
/**
1715
* @author Kévin Dunglas <[email protected]>
1816
*/
1917
class SerializerTest extends WebTestCase
2018
{
2119
public function testDeserializeArrayOfObject()
2220
{
23-
if (!class_exists(DataUriNormalizer::class)) {
24-
$this->markTestSkipped('This test is only applicable when using the Symfony Serializer Component version 3.1 or superior.');
25-
}
26-
2721
static::bootKernel(array('test_case' => 'Serializer'));
2822
$container = static::$kernel->getContainer();
2923

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313

1414
use Symfony\Component\Console\Exception\InvalidArgumentException;
1515
use Symfony\Component\Console\Exception\RuntimeException;
16+
use Symfony\Component\Console\Formatter\OutputFormatter;
17+
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
1618
use Symfony\Component\Console\Input\InputInterface;
1719
use Symfony\Component\Console\Input\StreamableInputInterface;
1820
use Symfony\Component\Console\Output\ConsoleOutputInterface;
1921
use Symfony\Component\Console\Output\OutputInterface;
20-
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
2122
use Symfony\Component\Console\Question\Question;
2223
use Symfony\Component\Console\Question\ChoiceQuestion;
2324

@@ -324,7 +325,7 @@ private function autocomplete(OutputInterface $output, Question $question, $inpu
324325
// Save cursor position
325326
$output->write("\0337");
326327
// Write highlighted text
327-
$output->write('<hl>'.substr($matches[$ofs], $i).'</hl>');
328+
$output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $i)).'</hl>');
328329
// Restore cursor position
329330
$output->write("\0338");
330331
}

src/Symfony/Component/Console/Helper/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Table
4848
/**
4949
* Number of columns cache.
5050
*
51-
* @var array
51+
* @var int
5252
*/
5353
private $numberOfColumns;
5454

src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,46 @@ public function testAskWithAutocompleteWithNonSequentialKeys()
153153
$this->assertEquals('AsseticBundle', $dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question));
154154
}
155155

156+
public function testAutocompleteWithTrailingBackslash()
157+
{
158+
if (!$this->hasSttyAvailable()) {
159+
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
160+
}
161+
162+
$inputStream = $this->getInputStream('E');
163+
164+
$dialog = new QuestionHelper();
165+
$dialog->setInputStream($inputStream);
166+
$helperSet = new HelperSet(array(new FormatterHelper()));
167+
$dialog->setHelperSet($helperSet);
168+
169+
$question = new Question('');
170+
$expectedCompletion = 'ExampleNamespace\\';
171+
$question->setAutocompleterValues(array($expectedCompletion));
172+
173+
$output = $this->createOutputInterface();
174+
$dialog->ask($this->createInputInterfaceMock(), $output, $question);
175+
176+
$outputStream = $output->getStream();
177+
rewind($outputStream);
178+
$actualOutput = stream_get_contents($outputStream);
179+
180+
// Shell control (esc) sequences are not so important: we only care that
181+
// <hl> tag is interpreted correctly and replaced
182+
$irrelevantEscSequences = array(
183+
"\0337" => '', // Save cursor position
184+
"\0338" => '', // Restore cursor position
185+
"\033[K" => '', // Clear line from cursor till the end
186+
);
187+
188+
$importantActualOutput = strtr($actualOutput, $irrelevantEscSequences);
189+
190+
// Remove colors (e.g. "\033[30m", "\033[31;41m")
191+
$importantActualOutput = preg_replace('/\033\[\d+(;\d+)?m/', '', $importantActualOutput);
192+
193+
$this->assertEquals($expectedCompletion, $importantActualOutput);
194+
}
195+
156196
public function testAskHiddenResponse()
157197
{
158198
if ('\\' === DIRECTORY_SEPARATOR) {

src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ protected function processValue($value, $isRoot = false)
7878
public static function register(ContainerBuilder $container, array $refMap)
7979
{
8080
foreach ($refMap as $id => $ref) {
81+
if (!$ref instanceof Reference) {
82+
throw new InvalidArgumentException(sprintf('Invalid service locator definition: only services can be referenced, "%s" found for key "%s". Inject parameter values using constructors instead.', is_object($ref) ? get_class($ref) : gettype($ref), $id));
83+
}
8184
$refMap[$id] = new ServiceClosureArgument($ref);
8285
}
8386
ksort($refMap);

src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private function getControllerError($callable)
219219
}
220220

221221
if (2 !== count($callable)) {
222-
return sprintf('Invalid format for controller, expected array(controller, method) or controller::method.');
222+
return 'Invalid format for controller, expected array(controller, method) or controller::method.';
223223
}
224224

225225
list($controller, $method) = $callable;

0 commit comments

Comments
 (0)