Skip to content

Commit 70a8de2

Browse files
committed
[PropertyInfo] Fix an error in PropertyInfoCacheExtractor
1 parent eccbe67 commit 70a8de2

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

src/Symfony/Component/PropertyInfo/PropertyInfoCacheExtractor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function getProperties($class, array $context = array())
8686
*/
8787
public function getTypes($class, $property, array $context = array())
8888
{
89-
return $this->extract('getTypes', array($class, $context));
89+
return $this->extract('getTypes', array($class, $property, $context));
9090
}
9191

9292
/**

src/Symfony/Component/PropertyInfo/Tests/Fixtures/NullExtractor.php

+18
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,58 @@ class NullExtractor implements PropertyListExtractorInterface, PropertyDescripti
2828
*/
2929
public function getShortDescription($class, $property, array $context = array())
3030
{
31+
$this->assertIsString($class);
32+
$this->assertIsString($property);
3133
}
3234

3335
/**
3436
* {@inheritdoc}
3537
*/
3638
public function getLongDescription($class, $property, array $context = array())
3739
{
40+
$this->assertIsString($class);
41+
$this->assertIsString($property);
3842
}
3943

4044
/**
4145
* {@inheritdoc}
4246
*/
4347
public function getTypes($class, $property, array $context = array())
4448
{
49+
$this->assertIsString($class);
50+
$this->assertIsString($property);
4551
}
4652

4753
/**
4854
* {@inheritdoc}
4955
*/
5056
public function isReadable($class, $property, array $context = array())
5157
{
58+
$this->assertIsString($class);
59+
$this->assertIsString($property);
5260
}
5361

5462
/**
5563
* {@inheritdoc}
5664
*/
5765
public function isWritable($class, $property, array $context = array())
5866
{
67+
$this->assertIsString($class);
68+
$this->assertIsString($property);
5969
}
6070

6171
/**
6272
* {@inheritdoc}
6373
*/
6474
public function getProperties($class, array $context = array())
6575
{
76+
$this->assertIsString($class);
77+
}
78+
79+
private function assertIsString($string)
80+
{
81+
if (!is_string($string)) {
82+
throw new \Exception(sprintf('"%s" expects strings, given "%s".', __CLASS__, gettype($string)));
83+
}
6684
}
6785
}

src/Symfony/Component/PropertyInfo/Tests/PropertyInfoCacheExtractorTest.php

+30-5
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,40 @@ protected function setUp()
2626
$this->propertyInfo = new PropertyInfoCacheExtractor($this->propertyInfo, new ArrayAdapter());
2727
}
2828

29-
public function testCache()
29+
public function testGetShortDescription()
3030
{
31-
$this->assertSame('short', $this->propertyInfo->getShortDescription('Foo', 'bar', array()));
32-
$this->assertSame('short', $this->propertyInfo->getShortDescription('Foo', 'bar', array()));
31+
parent::testGetShortDescription();
32+
parent::testGetShortDescription();
3333
}
3434

35-
public function testNotSerializableContext()
35+
public function testGetLongDescription()
3636
{
37-
$this->assertSame('short', $this->propertyInfo->getShortDescription('Foo', 'bar', array('foo' => function () {})));
37+
parent::testGetLongDescription();
38+
parent::testGetLongDescription();
39+
}
40+
41+
public function testGetTypes()
42+
{
43+
parent::testGetTypes();
44+
parent::testGetTypes();
45+
}
46+
47+
public function testIsReadable()
48+
{
49+
parent::testIsReadable();
50+
parent::testIsReadable();
51+
}
52+
53+
public function testIsWritable()
54+
{
55+
parent::testIsWritable();
56+
parent::testIsWritable();
57+
}
58+
59+
public function testGetProperties()
60+
{
61+
parent::testGetProperties();
62+
parent::testGetProperties();
3863
}
3964

4065
/**

0 commit comments

Comments
 (0)