From 270147b04fbf54a688f4532c4d552d4d2041ee22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 19 Feb 2018 17:05:09 +0100 Subject: [PATCH] [PropertyInfo] ReflectionExtractor: give a chance to other extractors if no properties --- .../Extractor/ReflectionExtractor.php | 2 +- .../Extractors/ReflectionExtractorTest.php | 2 ++ .../Tests/Fixtures/NoProperties.php | 21 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/PropertyInfo/Tests/Fixtures/NoProperties.php diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php index 3ec1d8d6ea..b29d78d070 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php @@ -76,7 +76,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp $properties[$propertyName] = $propertyName; } - return array_values($properties); + return $properties ? array_values($properties) : null; } /** diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php index cc2ecbe6f5..2828878ce6 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php @@ -57,6 +57,8 @@ class ReflectionExtractorTest extends TestCase ), $this->extractor->getProperties('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy') ); + + $this->assertNull($this->extractor->getProperties('Symfony\Component\PropertyInfo\Tests\Fixtures\NoProperties')); } /** diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/NoProperties.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/NoProperties.php new file mode 100644 index 0000000000..177bbe4df0 --- /dev/null +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/NoProperties.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\PropertyInfo\Tests\Fixtures; + +/** + * @author Kévin Dunglas + */ +class NoProperties +{ +}