diff --git a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php index 07e192fdc7..74d867c31e 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php @@ -34,7 +34,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp /** * @internal */ - public static $defaultAccessorPrefixes = array('is', 'can', 'get'); + public static $defaultAccessorPrefixes = array('is', 'can', 'get', 'has'); /** * @internal @@ -178,7 +178,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp return array($this->extractFromReflectionType($reflectionType)); } - if (in_array($prefix, array('is', 'can'))) { + if (in_array($prefix, array('is', 'can', 'has'))) { return array(new Type(Type::BUILTIN_TYPE_BOOL)); } diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php index 9cc0a8d6e1..10e7fbcf9e 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php @@ -88,7 +88,8 @@ class PhpDocExtractorTest extends TestCase array('d', array(new Type(Type::BUILTIN_TYPE_BOOL)), null, null), array('e', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_RESOURCE))), null, null), array('f', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))), null, null), - array('g', array(new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)), 'Nullable array.', null), + array('g', array(new Type(Type::BUILTIN_TYPE_BOOL, true)), null, null), + array('array', array(new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)), 'Nullable array.', null), array('donotexist', null, null, null), array('staticGetter', null, null, null), array('staticSetter', null, null, null), diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php index 513504b68d..db78dd7a4e 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php @@ -40,7 +40,7 @@ class ReflectionExtractorTest extends TestCase 'collection', 'B', 'Guid', - 'g', + 'array', 'emptyVar', 'foo', 'foo2', @@ -56,6 +56,7 @@ class ReflectionExtractorTest extends TestCase 'd', 'e', 'f', + 'g', ), $this->extractor->getProperties('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy') ); @@ -196,10 +197,12 @@ class ReflectionExtractorTest extends TestCase array('d', true), array('e', false), array('f', false), + array('g', true), array('Id', true), array('id', true), array('Guid', true), array('guid', false), + array('guid', false), ); } @@ -226,6 +229,7 @@ class ReflectionExtractorTest extends TestCase array('d', false), array('e', true), array('f', true), + array('g', false), array('Id', false), array('Guid', true), array('guid', false), diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php index 4e558eca01..0916217020 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php @@ -66,7 +66,7 @@ class Dummy extends ParentDummy * * @var array|null */ - public $g; + public $array; /** * This should not be removed. diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/ParentDummy.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/ParentDummy.php index 330496827c..dc9109d7d1 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/ParentDummy.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/ParentDummy.php @@ -75,4 +75,11 @@ class ParentDummy public function removeF(\DateTime $f) { } + + /** + * @return bool|null + */ + public function hasG() + { + } }