Fix Cache error while using anonymous class
This commit is contained in:
parent
357fe5d6c3
commit
036e72210d
@ -70,6 +70,11 @@ class Psr6Cache implements CacheInterface
|
||||
*/
|
||||
private function escapeClassName($class)
|
||||
{
|
||||
if (false !== strpos($class, '@')) {
|
||||
// anonymous class: replace all PSR6-reserved characters
|
||||
return str_replace(["\0", '\\', '/', '@', ':', '{', '}', '(', ')'], '.', $class);
|
||||
}
|
||||
|
||||
return str_replace('\\', '.', $class);
|
||||
}
|
||||
}
|
||||
|
@ -23,4 +23,12 @@ class Psr6CacheTest extends AbstractCacheTest
|
||||
$this->cache->write($metadata);
|
||||
$this->assertFalse($this->cache->has('Foo_Bar'));
|
||||
}
|
||||
|
||||
public function testNameWithInvalidChars()
|
||||
{
|
||||
$metadata = new ClassMetadata('class@anonymous/path/file');
|
||||
|
||||
$this->cache->write($metadata);
|
||||
$this->assertTrue($this->cache->has('class@anonymous/path/file'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user