From b190ec241e3a95a824487fee72617e01021e5cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 13 Apr 2017 21:00:55 +0200 Subject: [PATCH] [PropertyInfo] Prevent returning int values in some cases. --- .../PropertyInfo/Extractor/ReflectionExtractor.php | 6 +++--- .../Tests/Extractors/ReflectionExtractorTest.php | 3 ++- src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php index 8ba5db00d3..ecf0b287e2 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php @@ -64,7 +64,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp $properties = array(); foreach ($reflectionClass->getProperties(\ReflectionProperty::IS_PUBLIC) as $reflectionProperty) { - $properties[$reflectionProperty->name] = true; + $properties[$reflectionProperty->name] = $reflectionProperty->name; } foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflectionMethod) { @@ -79,10 +79,10 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp if (!$reflectionClass->hasProperty($propertyName) && !preg_match('/^[A-Z]{2,}/', $propertyName)) { $propertyName = lcfirst($propertyName); } - $properties[$propertyName] = true; + $properties[$propertyName] = $propertyName; } - return array_keys($properties); + return array_values($properties); } /** diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php index 55f75b9016..cc2ecbe6f5 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php @@ -32,7 +32,7 @@ class ReflectionExtractorTest extends TestCase public function testGetProperties() { - $this->assertEquals( + $this->assertSame( array( 'bal', 'parent', @@ -49,6 +49,7 @@ class ReflectionExtractorTest extends TestCase 'a', 'DOB', 'Id', + '123', 'c', 'd', 'e', diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php index 2f6fc11b0d..d358bae13a 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php @@ -116,4 +116,8 @@ class Dummy extends ParentDummy public function getId() { } + + public function get123() + { + } }