From 2030f62bb53a4d54838e40445dcc8bfe8372a4f7 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 4 Nov 2015 19:12:53 +0100 Subject: [PATCH 1/2] [DI] Clean a phpdoc --- src/Symfony/Component/DependencyInjection/ContainerAware.php | 4 ++-- .../Component/DependencyInjection/ContainerAwareInterface.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/ContainerAware.php b/src/Symfony/Component/DependencyInjection/ContainerAware.php index af977fea03..8937c669a6 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerAware.php +++ b/src/Symfony/Component/DependencyInjection/ContainerAware.php @@ -24,9 +24,9 @@ abstract class ContainerAware implements ContainerAwareInterface protected $container; /** - * Sets the Container associated with this Controller. + * Sets the container. * - * @param ContainerInterface $container A ContainerInterface instance + * @param ContainerInterface|null $container A ContainerInterface instance or null */ public function setContainer(ContainerInterface $container = null) { diff --git a/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php b/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php index 7007265ac8..fe301b6270 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php +++ b/src/Symfony/Component/DependencyInjection/ContainerAwareInterface.php @@ -19,7 +19,7 @@ namespace Symfony\Component\DependencyInjection; interface ContainerAwareInterface { /** - * Sets the Container. + * Sets the container. * * @param ContainerInterface|null $container A ContainerInterface instance or null */ From 8ff449d86c6e29fdc7e884f56354d52af8c40a3f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 5 Nov 2015 08:34:00 +0100 Subject: [PATCH 2/2] [VarDumper] Fix casting for ReflectionParameter --- .../VarDumper/Caster/ReflectionCaster.php | 9 ++++++++ .../Tests/Caster/ReflectionCasterTest.php | 23 ++++++++++++++++++- ...54.php => VarDumperTestTraitRequire54.php} | 0 ...aitTest.php => VarDumperTestTraitTest.php} | 4 ++-- 4 files changed, 33 insertions(+), 3 deletions(-) rename src/Symfony/Component/VarDumper/Tests/Test/{VarDumpTestTraitRequire54.php => VarDumperTestTraitRequire54.php} (100%) rename src/Symfony/Component/VarDumper/Tests/Test/{VarDumpTestTraitTest.php => VarDumperTestTraitTest.php} (73%) diff --git a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php index 04cf7b0552..a302835f08 100644 --- a/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/ReflectionCaster.php @@ -157,6 +157,9 @@ class ReflectionCaster { $prefix = Caster::PREFIX_VIRTUAL; + // Added by HHVM + unset($a['info']); + self::addMap($a, $c, array( 'position' => 'getPosition', 'isVariadic' => 'isVariadic', @@ -172,6 +175,9 @@ class ReflectionCaster $a[$prefix.'typeHint'] = $v->name; } } catch (\ReflectionException $e) { + if (preg_match('/^Class ([^ ]++) does not exist$/', $e->getMessage(), $m)) { + $a[$prefix.'typeHint'] = $m[1]; + } } try { @@ -180,6 +186,9 @@ class ReflectionCaster $a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v); } } catch (\ReflectionException $e) { + if (isset($a[$prefix.'typeHint']) && $c->allowsNull()) { + $a[$prefix.'default'] = null; + } } return $a; diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php index edb6b1f4aa..4120d341da 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php @@ -61,6 +61,23 @@ EOTXT ); } + public function testReflectionParameter() + { + $var = new \ReflectionParameter(__NAMESPACE__.'\reflectionParameterFixture', 0); + + $this->assertDumpMatchesFormat( + <<<'EOTXT' +ReflectionParameter { + +name: "arg1" + position: 0 + typeHint: "Symfony\Component\VarDumper\Tests\Caster\NotExistingClass" + default: null +} +EOTXT + , $var + ); + } + /** * @requires PHP 7.0 */ @@ -74,7 +91,7 @@ Closure { returnType: "int" class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest" this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …} - file: "%sReflectionCasterTest.php(69) : eval()'d code" + file: "%sReflectionCasterTest.php(86) : eval()'d code" line: "1 to 1" } EOTXT @@ -82,3 +99,7 @@ EOTXT ); } } + +function reflectionParameterFixture(NotExistingClass $arg1 = null, $arg2) +{ +} diff --git a/src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitRequire54.php b/src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitRequire54.php similarity index 100% rename from src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitRequire54.php rename to src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitRequire54.php diff --git a/src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitTest.php b/src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitTest.php similarity index 73% rename from src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitTest.php rename to src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitTest.php index 21ef14d9ff..2be2f8c2a4 100644 --- a/src/Symfony/Component/VarDumper/Tests/Test/VarDumpTestTraitTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitTest.php @@ -10,7 +10,7 @@ */ // Skipping trait tests for PHP < 5.4 -if (version_compare(PHP_VERSION, '5.4.0-dev', '>=')) { - require 'VarDumpTestTraitRequire54.php'; +if (PHP_VERSION_ID >= 50400) { + require __DIR__.'/VarDumperTestTraitRequire54.php'; }