Skip to content

Commit db208e3

Browse files
Merge branch '3.0'
* 3.0: [PropertyAccess] ->getValue() should be read-only [VarDumper] Fix dumping type hints for non-existing parent classes [Config] Fix XmlUtilsTest namespace [Console] [TableHelper] make it work with SymfonyStyle. Remove dead code [FrameworkBundle] Better output for user in ContainerDebugCommand [Routing] add query param if value is different from default
2 parents c4acbb4 + ffb7573 commit db208e3

File tree

13 files changed

+103
-29
lines changed

13 files changed

+103
-29
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
121121
$options['output'] = $io;
122122
$helper->describe($output, $object, $options);
123123

124-
if (!$input->getArgument('name') && $input->isInteractive()) {
125-
$io->comment('To search for a specific service, re-run this command with a search term. (e.g. <comment>debug:container log</comment>)');
124+
if (!$input->getArgument('name') && !$input->getOption('tag') && !$input->getOption('parameter') && $input->isInteractive()) {
125+
if ($input->getOption('tags')) {
126+
$io->comment('To search for a specific tag, re-run this command with a search term. (e.g. <comment>debug:container --tag=form.type</comment>)');
127+
} elseif ($input->getOption('parameters')) {
128+
$io->comment('To search for a specific parameter, re-run this command with a search term. (e.g. <comment>debug:container --parameter=kernel.debug</comment>)');
129+
} else {
130+
$io->comment('To search for a specific service, re-run this command with a search term. (e.g. <comment>debug:container log</comment>)');
131+
}
126132
}
127133
}
128134

src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Config\Tests\Loader;
12+
namespace Symfony\Component\Config\Tests\Util;
1313

1414
use Symfony\Component\Config\Util\XmlUtils;
1515

src/Symfony/Component/Console/Style/SymfonyStyle.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Console\Helper\ProgressBar;
1919
use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
2020
use Symfony\Component\Console\Helper\Table;
21+
use Symfony\Component\Console\Helper\TableCell;
2122
use Symfony\Component\Console\Input\InputInterface;
2223
use Symfony\Component\Console\Output\BufferedOutput;
2324
use Symfony\Component\Console\Output\OutputInterface;
@@ -213,7 +214,16 @@ public function caution($message)
213214
*/
214215
public function table(array $headers, array $rows)
215216
{
216-
$headers = array_map(function ($value) { return sprintf('<info>%s</>', $value); }, $headers);
217+
array_walk_recursive($headers, function (&$value) {
218+
if ($value instanceof TableCell) {
219+
$value = new TableCell(sprintf('<info>%s</>', $value), array(
220+
'colspan' => $value->getColspan(),
221+
'rowspan' => $value->getRowspan(),
222+
));
223+
} else {
224+
$value = sprintf('<info>%s</>', $value);
225+
}
226+
});
217227

218228
$table = new Table($this);
219229
$table->setHeaders($headers);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
use Symfony\Component\Console\Input\InputInterface;
4+
use Symfony\Component\Console\Output\OutputInterface;
5+
use Symfony\Component\Console\Tests\Style\SymfonyStyleWithForcedLineLength;
6+
use Symfony\Component\Console\Helper\TableCell;
7+
8+
//Ensure formatting tables when using multiple headers with TableCell
9+
return function (InputInterface $input, OutputInterface $output) {
10+
$headers = array(
11+
array(new TableCell('Main table title', array('colspan' => 3))),
12+
array('ISBN', 'Title', 'Author'),
13+
);
14+
15+
$rows = array(
16+
array(
17+
'978-0521567817',
18+
'De Monarchia',
19+
new TableCell("Dante Alighieri\nspans multiple rows", array('rowspan' => 2)),
20+
),
21+
array('978-0804169127', 'Divine Comedy'),
22+
);
23+
24+
$output = new SymfonyStyleWithForcedLineLength($input, $output);
25+
$output->table($headers, $rows);
26+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---------------- --------------- ---------------------
2+
Main table title
3+
---------------- --------------- ---------------------
4+
ISBN Title Author
5+
---------------- --------------- ---------------------
6+
978-0521567817 De Monarchia Dante Alighieri
7+
978-0804169127 Divine Comedy spans multiple rows
8+
---------------- --------------- ---------------------
9+

src/Symfony/Component/PropertyAccess/PropertyAccessor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,11 @@ private function readPropertiesUntil($zval, PropertyPathInterface $propertyPath,
374374
}
375375

376376
if ($i + 1 < $propertyPath->getLength()) {
377-
$zval[self::VALUE][$property] = array();
378-
379377
if (isset($zval[self::REF])) {
378+
$zval[self::VALUE][$property] = array();
380379
$zval[self::REF] = $zval[self::VALUE];
380+
} else {
381+
$zval[self::VALUE] = array($property => array());
381382
}
382383
}
383384
}

src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ public function testGetValueReadsMagicGet()
126126
$this->assertSame('Bernhard', $this->propertyAccessor->getValue(new TestClassMagicGet('Bernhard'), 'magicProperty'));
127127
}
128128

129+
public function testGetValueReadsArrayWithMissingIndexForCustomPropertyPath()
130+
{
131+
$object = new \ArrayObject();
132+
$array = array('child' => array('index' => $object));
133+
134+
$this->assertNull($this->propertyAccessor->getValue($array, '[child][index][foo][bar]'));
135+
$this->assertSame(array(), $object->getArrayCopy());
136+
}
137+
129138
// https://github.com/symfony/symfony/pull/4450
130139
public function testGetValueReadsMagicGetThatReturnsConstant()
131140
{

src/Symfony/Component/Routing/Generator/UrlGenerator.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
265265
}
266266

267267
// add a query string if needed
268-
$extra = array_diff_key($parameters, $variables, $defaults);
268+
$extra = array_udiff_assoc(array_diff_key($parameters, $variables), $defaults, function ($a, $b) {
269+
return $a == $b ? 0 : 1;
270+
});
271+
269272
if ($extra && $query = http_build_query($extra, '', '&')) {
270273
// "/" and "?" can be left decoded for better user experience, see
271274
// http://tools.ietf.org/html/rfc3986#section-3.4

src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,22 @@ public function testNullForOptionalParameterIsIgnored()
297297

298298
public function testQueryParamSameAsDefault()
299299
{
300-
$routes = $this->getRoutes('test', new Route('/test', array('default' => 'value')));
300+
$routes = $this->getRoutes('test', new Route('/test', array('page' => 1)));
301301

302-
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('default' => 'foo')));
303-
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('default' => 'value')));
302+
$this->assertSame('/app.php/test?page=2', $this->getGenerator($routes)->generate('test', array('page' => 2)));
303+
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('page' => 1)));
304+
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('page' => '1')));
305+
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test'));
306+
}
307+
308+
public function testArrayQueryParamSameAsDefault()
309+
{
310+
$routes = $this->getRoutes('test', new Route('/test', array('array' => array('foo', 'bar'))));
311+
312+
$this->assertSame('/app.php/test?array%5B0%5D=bar&array%5B1%5D=foo', $this->getGenerator($routes)->generate('test', array('array' => array('bar', 'foo'))));
313+
$this->assertSame('/app.php/test?array%5Ba%5D=foo&array%5Bb%5D=bar', $this->getGenerator($routes)->generate('test', array('array' => array('a' => 'foo', 'b' => 'bar'))));
314+
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('array' => array('foo', 'bar'))));
315+
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', array('array' => array(1 => 'bar', 0 => 'foo'))));
304316
$this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test'));
305317
}
306318

src/Symfony/Component/Serializer/Serializer.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,6 @@ private function denormalizeObject($data, $class, $format, array $context = arra
264264
return $normalizer->denormalize($data, $class, $format, $context);
265265
}
266266

267-
foreach ($this->normalizers as $normalizer) {
268-
if (
269-
$normalizer instanceof DenormalizerInterface &&
270-
$normalizer->supportsDenormalization($data, $class, $format)
271-
) {
272-
return $normalizer->denormalize($data, $class, $format, $context);
273-
}
274-
}
275-
276267
throw new UnexpectedValueException(sprintf('Could not denormalize object of type %s, no supporting normalizer found.', $class));
277268
}
278269

0 commit comments

Comments
 (0)