Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ffb7573

Browse filesBrowse files
Merge branch '2.8' into 3.0
* 2.8: [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 [Routing] add query param if value is different from default Conflicts: src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php
2 parents 2a47edc + 68415ab commit ffb7573
Copy full SHA for ffb7573

File tree

Expand file treeCollapse file tree

12 files changed

+95
-27
lines changed
Filter options
Expand file treeCollapse file tree

12 files changed

+95
-27
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Style/SymfonyStyle.php
+11-1Lines 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);
+26Lines 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+
};
+9Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyAccess/PropertyAccessor.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,11 @@ private function readPropertiesUntil($zval, PropertyPathInterface $propertyPath,
373373
}
374374

375375
if ($i + 1 < $propertyPath->getLength()) {
376-
$zval[self::VALUE][$property] = array();
377-
378376
if (isset($zval[self::REF])) {
377+
$zval[self::VALUE][$property] = array();
379378
$zval[self::REF] = $zval[self::VALUE];
379+
} else {
380+
$zval[self::VALUE] = array($property => array());
380381
}
381382
}
382383
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php
+9Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Generator/UrlGenerator.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,10 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
267267
}
268268

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

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Generator/UrlGeneratorTest.php
+15-3Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Serializer.php
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,6 @@ private function denormalizeObject($data, $class, $format, array $context = arra
250250
return $normalizer->denormalize($data, $class, $format, $context);
251251
}
252252

253-
foreach ($this->normalizers as $normalizer) {
254-
if (
255-
$normalizer instanceof DenormalizerInterface &&
256-
$normalizer->supportsDenormalization($data, $class, $format)
257-
) {
258-
return $normalizer->denormalize($data, $class, $format, $context);
259-
}
260-
}
261-
262253
throw new UnexpectedValueException(sprintf('Could not denormalize object of type %s, no supporting normalizer found.', $class));
263254
}
264255

‎src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,11 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st
220220
if ($c->hasType()) {
221221
$a[$prefix.'typeHint'] = $c->getType()->__toString();
222222
}
223-
} elseif ($c->isArray()) {
224-
$a[$prefix.'typeHint'] = 'array';
225-
} elseif (method_exists($c, 'isCallable') && $c->isCallable()) {
226-
$a[$prefix.'typeHint'] = 'callable';
227-
} elseif ($v = $c->getClass()) {
228-
$a[$prefix.'typeHint'] = $v->name;
223+
} else {
224+
$v = explode(' ', $c->__toString(), 6);
225+
if (isset($v[5]) && 0 === strspn($v[4], '.&$')) {
226+
$a[$prefix.'typeHint'] = $v[4];
227+
}
229228
}
230229
} catch (\ReflectionException $e) {
231230
if (preg_match('/^Class ([^ ]++) does not exist$/', $e->getMessage(), $m)) {

‎src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
1515
use Symfony\Component\VarDumper\Tests\Fixtures\GeneratorDemo;
16+
use Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass;
1617

1718
/**
1819
* @author Nicolas Grekas <p@tchwork.com>
@@ -49,7 +50,7 @@ public function testReflectionCaster()
4950
"export" => ReflectionMethod {
5051
+name: "export"
5152
+class: "ReflectionClass"
52-
parameters: {
53+
%A parameters: {
5354
$%s: ReflectionParameter {
5455
%A position: 0
5556
%A
@@ -75,7 +76,7 @@ public function testClosureCaster()
7576
\$b: & 123
7677
}
7778
file: "%sReflectionCasterTest.php"
78-
line: "65 to 65"
79+
line: "66 to 66"
7980
}
8081
EOTXT
8182
, $var
@@ -91,7 +92,7 @@ public function testReflectionParameter()
9192
ReflectionParameter {
9293
+name: "arg1"
9394
position: 0
94-
typeHint: "Symfony\Component\VarDumper\Tests\Caster\NotExistingClass"
95+
typeHint: "Symfony\Component\VarDumper\Tests\Fixtures\NotLoadableClass"
9596
default: null
9697
}
9798
EOTXT
@@ -223,6 +224,6 @@ public function testGenerator()
223224
}
224225
}
225226

226-
function reflectionParameterFixture(NotExistingClass $arg1 = null, $arg2)
227+
function reflectionParameterFixture(NotLoadableClass $arg1 = null, $arg2)
227228
{
228229
}
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\VarDumper\Tests\Fixtures;
4+
5+
class NotLoadableClass extends NotLoadableClass
6+
{
7+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.