diff --git a/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php b/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php index b7d5c6d372ca..69ade35dfeee 100644 --- a/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php +++ b/src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php @@ -86,7 +86,7 @@ public function getProperties($class, array $context = array()) */ public function getTypes($class, $property, array $context = array()) { - return $this->extract('getTypes', array($class, $context)); + return $this->extract('getTypes', array($class, $property, $context)); } /** @@ -108,7 +108,7 @@ private function extract($method, array $arguments) $key = $this->escape($method.'.'.$serializedArguments); - if (isset($this->arrayCache[$key])) { + if (array_key_exists($key, $this->arrayCache)) { return $this->arrayCache[$key]; } diff --git a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/NullExtractor.php b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/NullExtractor.php index a1ef78209342..4c2af4112045 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Fixtures/NullExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Fixtures/NullExtractor.php @@ -28,6 +28,8 @@ class NullExtractor implements PropertyListExtractorInterface, PropertyDescripti */ public function getShortDescription($class, $property, array $context = array()) { + $this->assertIsString($class); + $this->assertIsString($property); } /** @@ -35,6 +37,8 @@ public function getShortDescription($class, $property, array $context = array()) */ public function getLongDescription($class, $property, array $context = array()) { + $this->assertIsString($class); + $this->assertIsString($property); } /** @@ -42,6 +46,8 @@ public function getLongDescription($class, $property, array $context = array()) */ public function getTypes($class, $property, array $context = array()) { + $this->assertIsString($class); + $this->assertIsString($property); } /** @@ -49,6 +55,8 @@ public function getTypes($class, $property, array $context = array()) */ public function isReadable($class, $property, array $context = array()) { + $this->assertIsString($class); + $this->assertIsString($property); } /** @@ -56,6 +64,8 @@ public function isReadable($class, $property, array $context = array()) */ public function isWritable($class, $property, array $context = array()) { + $this->assertIsString($class); + $this->assertIsString($property); } /** @@ -63,5 +73,13 @@ public function isWritable($class, $property, array $context = array()) */ public function getProperties($class, array $context = array()) { + $this->assertIsString($class); + } + + private function assertIsString($string) + { + if (!is_string($string)) { + throw new \InvalidArgumentException(sprintf('"%s" expects strings, given "%s".', __CLASS__, gettype($string))); + } } } diff --git a/src/Symfony/Component/PropertyInfo/Tests/PropertyInfoCacheExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/PropertyInfoCacheExtractorTest.php index ce3ade2d94ec..455d39fa96c2 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/PropertyInfoCacheExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/PropertyInfoCacheExtractorTest.php @@ -26,15 +26,40 @@ protected function setUp() $this->propertyInfo = new PropertyInfoCacheExtractor($this->propertyInfo, new ArrayAdapter()); } - public function testCache() + public function testGetShortDescription() { - $this->assertSame('short', $this->propertyInfo->getShortDescription('Foo', 'bar', array())); - $this->assertSame('short', $this->propertyInfo->getShortDescription('Foo', 'bar', array())); + parent::testGetShortDescription(); + parent::testGetShortDescription(); } - public function testNotSerializableContext() + public function testGetLongDescription() { - $this->assertSame('short', $this->propertyInfo->getShortDescription('Foo', 'bar', array('foo' => function () {}))); + parent::testGetLongDescription(); + parent::testGetLongDescription(); + } + + public function testGetTypes() + { + parent::testGetTypes(); + parent::testGetTypes(); + } + + public function testIsReadable() + { + parent::testIsReadable(); + parent::testIsReadable(); + } + + public function testIsWritable() + { + parent::testIsWritable(); + parent::testIsWritable(); + } + + public function testGetProperties() + { + parent::testGetProperties(); + parent::testGetProperties(); } /**