Skip to content

[PropertyInfo] Fix an error in PropertyInfoCacheExtractor #19437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand All @@ -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];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,58 @@ class NullExtractor implements PropertyListExtractorInterface, PropertyDescripti
*/
public function getShortDescription($class, $property, array $context = array())
{
$this->assertIsString($class);
$this->assertIsString($property);
}

/**
* {@inheritdoc}
*/
public function getLongDescription($class, $property, array $context = array())
{
$this->assertIsString($class);
$this->assertIsString($property);
}

/**
* {@inheritdoc}
*/
public function getTypes($class, $property, array $context = array())
{
$this->assertIsString($class);
$this->assertIsString($property);
}

/**
* {@inheritdoc}
*/
public function isReadable($class, $property, array $context = array())
{
$this->assertIsString($class);
$this->assertIsString($property);
}

/**
* {@inheritdoc}
*/
public function isWritable($class, $property, array $context = array())
{
$this->assertIsString($class);
$this->assertIsString($property);
}

/**
* {@inheritdoc}
*/
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)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down