Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22bb403

Browse files
Merge branch '3.2'
* 3.2: [DI] Autowiring and factories are incompatible with each others [DI] Don't use auto-registered services to populate type-candidates Lighten tests output by removing composer suggestions support nullable array or collection Complete the injection of the expression in all syntax errors CS: Remove invisible chars Disable resource tracking if the config component is missing [EventDispatcher] Remove unneded count() Fix tests expecting a valid date Avoid forcing to define the choices_as_values option when using choice_loader add expression text to SyntaxError [Console] Fix table cell styling [Console] Revised exception rendering Fix @param in PHPDoc [WebProfilerBundle] Normalize whitespace in exceptions passed in headers Disable color support detection for tests [Form] Improve the exceptions when trying to get the data in a PRE_SET_DATA listener and the data has not already been set
2 parents 83fc742 + ccbbff2 commit 22bb403

36 files changed

+307
-141
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ install:
8787
- export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
8888
- if [[ ! $skip && $deps ]]; then export SYMFONY_DEPRECATIONS_HELPER=weak; fi
8989
- if [[ ! $skip && $deps ]]; then mv composer.json.phpunit composer.json; fi
90-
- if [[ ! $skip ]]; then composer update; fi
90+
- if [[ ! $skip ]]; then composer update --no-suggest; fi
9191
- if [[ ! $skip ]]; then ./phpunit install; fi
9292
- if [[ ! $skip && ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi
9393

@@ -98,8 +98,8 @@ script:
9898
- if [[ ! $deps && ! $PHP = hhvm* ]]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi
9999
- if [[ ! $deps && $PHP = hhvm* ]]; then $PHPUNIT --exclude-group benchmark,intl-data; fi
100100
- if [[ ! $deps && $PHP = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | xargs -I{} sh -c 'echo "\\nPHP --enable-sigchild enhanced={}" && SYMFONY_DEPRECATIONS_HELPER=weak ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/'; fi
101-
- if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY"$REPORT"; fi
102-
- if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'"$REPORT"; fi
101+
- if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --no-suggest --ansi; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY"$REPORT"; fi
102+
- if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --no-suggest --ansi --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'"$REPORT"; fi
103103
# Test the PhpUnit bridge using the original phpunit script
104104
- if [[ $deps = low ]]; then (cd src/Symfony/Bridge/PhpUnit && wget https://phar.phpunit.de/phpunit-4.8.phar); fi
105105
- if [[ $deps = low ]]; then (cd src/Symfony/Bridge/PhpUnit && phpenv global 5.3 && php --version && composer update && php phpunit-4.8.phar); fi

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ install:
5151
- copy /Y .composer\* %APPDATA%\Composer\
5252
- php .github/build-packages.php "HEAD^" src\Symfony\Bridge\PhpUnit
5353
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
54-
- php composer.phar update --no-progress --ansi
54+
- php composer.phar update --no-progress --no-suggest --ansi
5555
- php phpunit install
5656

5757
test_script:

src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ class DoctrineChoiceLoader implements ChoiceLoaderInterface
6161
* loaded objects
6262
* @param IdReader $idReader The reader for the object
6363
* IDs.
64+
* @param null|EntityLoaderInterface $objectLoader The objects loader
6465
* @param ChoiceListFactoryInterface $factory The factory for creating
6566
* the loaded choice list
66-
* @param null|EntityLoaderInterface $objectLoader The objects loader
6767
*/
6868
public function __construct($manager, $class, $idReader = null, $objectLoader = null, $factory = null)
6969
{

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ class ProfilerController
4040
/**
4141
* Constructor.
4242
*
43-
* @param UrlGeneratorInterface $generator The URL Generator
44-
* @param Profiler $profiler The profiler
45-
* @param \Twig_Environment $twig The twig environment
46-
* @param array $templates The templates
47-
* @param string $toolbarPosition The toolbar position (top, bottom, normal, or null -- use the configuration)
48-
* @param string $baseDir The project root directory
43+
* @param UrlGeneratorInterface $generator The URL Generator
44+
* @param Profiler $profiler The profiler
45+
* @param \Twig_Environment $twig The twig environment
46+
* @param array $templates The templates
47+
* @param string $toolbarPosition The toolbar position (top, bottom, normal, or null -- use the configuration)
48+
* @param ContentSecurityPolicyHandler $cspHandler The Content-Security-Policy handler
49+
* @param string $baseDir The project root directory
4950
*/
5051
public function __construct(UrlGeneratorInterface $generator, Profiler $profiler = null, \Twig_Environment $twig, array $templates, $toolbarPosition = 'bottom', ContentSecurityPolicyHandler $cspHandler = null, $baseDir = null)
5152
{

src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function onKernelResponse(FilterResponseEvent $event)
7171
$this->urlGenerator->generate('_profiler', array('token' => $response->headers->get('X-Debug-Token')), UrlGeneratorInterface::ABSOLUTE_URL)
7272
);
7373
} catch (\Exception $e) {
74-
$response->headers->set('X-Debug-Error', get_class($e).': '.$e->getMessage());
74+
$response->headers->set('X-Debug-Error', get_class($e).': '.preg_replace('/\s+/', ' ', $e->getMessage()));
7575
}
7676
}
7777

src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,27 @@ public function testThrowingUrlGenerator()
246246
$this->assertEquals('Exception: foo', $response->headers->get('X-Debug-Error'));
247247
}
248248

249+
public function testThrowingErrorCleanup()
250+
{
251+
$response = new Response();
252+
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
253+
254+
$urlGenerator = $this->getUrlGeneratorMock();
255+
$urlGenerator
256+
->expects($this->once())
257+
->method('generate')
258+
->with('_profiler', array('token' => 'xxxxxxxx'))
259+
->will($this->throwException(new \Exception("This\nmultiline\r\ntabbed text should\tcome out\r on\n \ta single plain\r\nline")))
260+
;
261+
262+
$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);
263+
264+
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, 'bottom', $urlGenerator);
265+
$listener->onKernelResponse($event);
266+
267+
$this->assertEquals('Exception: This multiline tabbed text should come out on a single plain line', $response->headers->get('X-Debug-Error'));
268+
}
269+
249270
protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'html', $hasSession = true)
250271
{
251272
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->setMethods(array('getSession', 'isXmlHttpRequest', 'getRequestFormat'))->disableOriginalConstructor()->getMock();

src/Symfony/Component/Asset/PathPackage.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class PathPackage extends Package
3131
/**
3232
* @param string $basePath The base path to be prepended to relative paths
3333
* @param VersionStrategyInterface $versionStrategy The version strategy
34+
* @param ContextInterface|null $context The context
3435
*/
3536
public function __construct($basePath, VersionStrategyInterface $versionStrategy, ContextInterface $context = null)
3637
{

src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ function ($key, $value, $isHit) {
5757
* stores arrays in its latest versions. This factory method decorates the given
5858
* fallback pool with this adapter only if the current PHP version is supported.
5959
*
60-
* @param string $file The PHP file were values are cached
60+
* @param string $file The PHP file were values are cached
61+
* @param CacheItemPoolInterface $fallbackPool Fallback for old PHP versions or opcache disabled
6162
*
6263
* @return CacheItemPoolInterface
6364
*/

src/Symfony/Component/Cache/Adapter/RedisAdapter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ class RedisAdapter extends AbstractAdapter
1818
use RedisTrait;
1919

2020
/**
21-
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient
21+
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client $redisClient The redis client
22+
* @param string $namespace The default namespace
23+
* @param integer $defaultLifetime The default lifetime
2224
*/
2325
public function __construct($redisClient, $namespace = '', $defaultLifetime = 0)
2426
{

src/Symfony/Component/Console/Application.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -672,28 +672,27 @@ public function renderException(\Exception $e, OutputInterface $output)
672672
if (defined('HHVM_VERSION') && $width > 1 << 31) {
673673
$width = 1 << 31;
674674
}
675-
$formatter = $output->getFormatter();
676675
$lines = array();
677-
foreach (preg_split('/\r?\n/', OutputFormatter::escape($e->getMessage())) as $line) {
676+
foreach (preg_split('/\r?\n/', $e->getMessage()) as $line) {
678677
foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
679678
// pre-format lines to get the right string length
680-
$lineLength = $this->stringWidth(preg_replace('/\[[^m]*m/', '', $formatter->format($line))) + 4;
679+
$lineLength = $this->stringWidth($line) + 4;
681680
$lines[] = array($line, $lineLength);
682681

683682
$len = max($lineLength, $len);
684683
}
685684
}
686685

687686
$messages = array();
688-
$messages[] = $emptyLine = $formatter->format(sprintf('<error>%s</error>', str_repeat(' ', $len)));
689-
$messages[] = $formatter->format(sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - $this->stringWidth($title)))));
687+
$messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len));
688+
$messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - $this->stringWidth($title))));
690689
foreach ($lines as $line) {
691-
$messages[] = $formatter->format(sprintf('<error> %s %s</error>', $line[0], str_repeat(' ', $len - $line[1])));
690+
$messages[] = sprintf('<error> %s %s</error>', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
692691
}
693692
$messages[] = $emptyLine;
694693
$messages[] = '';
695694

696-
$output->writeln($messages, OutputInterface::OUTPUT_RAW | OutputInterface::VERBOSITY_QUIET);
695+
$output->writeln($messages, OutputInterface::VERBOSITY_QUIET);
697696

698697
if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
699698
$output->writeln('<comment>Exception trace:</comment>', OutputInterface::VERBOSITY_QUIET);

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ public static function formatMemory($memory)
123123
}
124124

125125
public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, $string)
126+
{
127+
return self::strlen(self::removeDecoration($formatter, $string));
128+
}
129+
130+
public static function removeDecoration(OutputFormatterInterface $formatter, $string)
126131
{
127132
$isDecorated = $formatter->isDecorated();
128133
$formatter->setDecorated(false);
@@ -132,6 +137,6 @@ public static function strlenWithoutDecoration(OutputFormatterInterface $formatt
132137
$string = preg_replace("/\033\[[^m]*m/", '', $string);
133138
$formatter->setDecorated($isDecorated);
134139

135-
return self::strlen($string);
140+
return $string;
136141
}
137142
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ private function buildTableRows($rows)
426426
if (!strstr($cell, "\n")) {
427427
continue;
428428
}
429-
$lines = explode("\n", $cell);
429+
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
430430
foreach ($lines as $lineKey => $line) {
431431
if ($cell instanceof TableCell) {
432432
$line = new TableCell($line, array('colspan' => $cell->getColspan()));
@@ -467,7 +467,7 @@ private function fillNextRows($rows, $line)
467467
$nbLines = $cell->getRowspan() - 1;
468468
$lines = array($cell);
469469
if (strstr($cell, "\n")) {
470-
$lines = explode("\n", $cell);
470+
$lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
471471
$nbLines = count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
472472

473473
$rows[$line][$column] = new TableCell($lines[0], array('colspan' => $cell->getColspan()));
@@ -602,9 +602,10 @@ private function calculateColumnsWidth($rows)
602602

603603
foreach ($row as $i => $cell) {
604604
if ($cell instanceof TableCell) {
605-
$textLength = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
605+
$textContent = Helper::removeDecoration($this->output->getFormatter(), $cell);
606+
$textLength = Helper::strlen($textContent);
606607
if ($textLength > 0) {
607-
$contentColumns = str_split($cell, ceil($textLength / $cell->getColspan()));
608+
$contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan()));
608609
foreach ($contentColumns as $position => $content) {
609610
$row[$i + $position] = $content;
610611
}

src/Symfony/Component/Console/Tester/CommandTester.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ public function execute(array $input, array $options = array())
7676
}
7777

7878
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
79-
if (isset($options['decorated'])) {
80-
$this->output->setDecorated($options['decorated']);
81-
}
79+
$this->output->setDecorated(isset($options['decorated']) ? $options['decorated'] : false);
8280
if (isset($options['verbosity'])) {
8381
$this->output->setVerbosity($options['verbosity']);
8482
}

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,22 @@ public function testRenderExceptionWithDoubleWidthCharacters()
636636
putenv('COLUMNS=120');
637637
}
638638

639+
public function testRenderExceptionEscapesLines()
640+
{
641+
$application = $this->getMockBuilder('Symfony\Component\Console\Application')->setMethods(array('getTerminalWidth'))->getMock();
642+
$application->setAutoExit(false);
643+
$application->expects($this->any())
644+
->method('getTerminalWidth')
645+
->will($this->returnValue(22));
646+
$application->register('foo')->setCode(function () {
647+
throw new \Exception('dont break here <info>!</info>');
648+
});
649+
$tester = new ApplicationTester($application);
650+
651+
$tester->run(array('command' => 'foo'), array('decorated' => false));
652+
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_escapeslines.txt', $tester->getDisplay(true), '->renderException() escapes lines containing formatting');
653+
}
654+
639655
public function testRun()
640656
{
641657
$application = new Application();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
3+
[Exception]
4+
dont break here <
5+
info>!</info>
6+
7+
8+
foo
9+

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,35 @@ public function renderProvider()
511511
| Dante Alighieri | J. R. R. Tolkien | J. R. R |
512512
+-----------------+------------------+---------+
513513
514+
TABLE
515+
,
516+
true,
517+
),
518+
'Row with formatted cells containing a newline' => array(
519+
array(),
520+
array(
521+
array(
522+
new TableCell('<error>Dont break'."\n".'here</error>', array('colspan' => 2)),
523+
),
524+
new TableSeparator(),
525+
array(
526+
'foo',
527+
new TableCell('<error>Dont break'."\n".'here</error>', array('rowspan' => 2)),
528+
),
529+
array(
530+
'bar',
531+
),
532+
),
533+
'default',
534+
<<<'TABLE'
535+
+-------+------------+
536+
| Dont break |
537+
| here |
538+
+-------+------------+
539+
| foo | Dont break |
540+
| bar | here |
541+
+-------+------------+
542+
514543
TABLE
515544
,
516545
true,

src/Symfony/Component/Debug/ExceptionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function setHandler(callable $handler = null)
8383
/**
8484
* Sets the format for links to source files.
8585
*
86-
* @param string|FileLinkFormatter $format The format for links to source files
86+
* @param string|FileLinkFormatter $fileLinkFormat The format for links to source files
8787
*
8888
* @return string The previous file link format
8989
*/

0 commit comments

Comments
 (0)