8000 Merge branch '2.7' into 2.8 · symfony/symfony@c812b39 · GitHub
[go: up one dir, main page]

Skip to content

Commit c812b39

Browse files
Merge branch '2.7' into 2.8
* 2.7: [VarDumper] Fix casting for ReflectionParameter [DI] Clean a phpdoc Conflicts: src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php
2 parents c0f0ad3 + a3f2f5c commit c812b39

File tree

7 files changed

+38
-8
lines changed

7 files changed

+38
-8
lines changed

src/Symfony/Component/DependencyInjection/ContainerAware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ abstract class ContainerAware implements ContainerAwareInterface
2626
protected $container;
2727

2828
/**
29-
* Sets the Container associated with this Controller.
29+
* Sets the container.
3030
*
31-
* @param ContainerInterface $container A ContainerInterface instance
31+
* @param ContainerInterface|null $container A ContainerInterface instance or null
3232
*/
3333
public function setContainer(ContainerInterface $container = null)
3434
{

src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
interface ContainerAwareInterface
2020
{
2121
/**
22-
* Sets the Container.
22+
* Sets the container.
2323
*
2424
* @param ContainerInterface|null $container A ContainerInterface instance or null
2525
*/

src/Symfony/Component/DependencyInjection/ContainerAwareTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ trait ContainerAwareTrait
2424
protected $container;
2525

2626
/**
27-
* Sets the Container associated with this Controller.
27+
* Sets the container.
2828
*
29-
* @param ContainerInterface $container A ContainerInterface instance
29+
* @param ContainerInterface|null $container A ContainerInterface instance or null
3030
*/
3131
public function setContainer(ContainerInterface $container = null)
3232
{

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st
217217
{
218218
$prefix = Caster::PREFIX_VIRTUAL;
219219

220+
// Added by HHVM
221+
unset($a['info']);
222+
220223
self::addMap($a, $c, array(
221224
'position' => 'getPosition',
222225
'isVariadic' => 'isVariadic',
@@ -232,6 +235,9 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st
232235
$a[$prefix.'typeHint'] = $v->name;
233236
}
234237
} catch (\ReflectionException $e) {
238+
if (preg_match('/^Class ([^ ]++) does not exist$/', $e->getMessage(), $m)) {
239+
$a[$prefix.'typeHint'] = $m[1];
240+
}
235241
}
236242

237243
try {
@@ -240,6 +246,9 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st
240246
$a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v);
241247
}
242248
} catch (\ReflectionException $e) {
249+
if (isset($a[$prefix.'typeHint']) && $c->allowsNull()) {
250+
$a[$prefix.'default'] = null;
251+
}
243252
}
244253

245254
return $a;

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ public function testClosureCaster()
8080
);
8181
}
8282

83+
public function testReflectionParameter()
84+
{
85+
$var = new \ReflectionParameter(__NAMESPACE__.'\reflectionParameterFixture', 0);
86+
87+
$this->assertDumpMatchesFormat(
88+
<<<'EOTXT'
89+
ReflectionParameter {
90+
+name: "arg1"
91+
position: 0
92+
typeHint: "Symfony\Component\VarDumper\Tests\Caster\NotExistingClass"
93+
default: null
94+
}
95+
EOTXT
96+
, $var
97+
);
98+
}
99+
83100
/**
84101
* @requires PHP 7.0
85102
*/
@@ -93,7 +110,7 @@ public function testReturnType()
93110
returnType: "int"
94111
class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
95112
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
96-
file: "%sReflectionCasterT B422 est.php(88) : eval()'d code"
113+
file: "%sReflectionCasterTest.php(105) : eval()'d code"
97114
line: "1 to 1"
98115
}
99116
EOTXT
@@ -182,3 +199,7 @@ public function testGenerator()
182199
$this->assertDumpMatchesFormat($xDump, array($r, $r->getExecutingGenerator()));
183200
}
184201
}
202+
203+
function reflectionParameterFixture(NotExistingClass $arg1 = null, $arg2)
204+
{
205+
}

src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitTest.php renamed to src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111

1212
// Skipping trait tests for PHP < 5.4
13-
if (version_compare(PHP_VERSION, '5.4.0-dev', '>=')) {
14-
require 'VarDumpTestTraitRequire54.php';
13+
if (PHP_VERSION_ID >= 50400) {
14+
require __DIR__.'/VarDumperTestTraitRequire54.php';
1515
}
1616

0 commit comments

Comments
 (0)
0