Skip to content

Commit

Permalink
Merge branch '4.4' into 5.1
Browse files Browse the repository at this point in the history
* 4.4:
  [Cache] Psr16Cache does not handle Proxy cache items
  [Serializer] fixed fix encoding of cache keys with anonymous classes
  Bump Symfony version to 4.4.13
  Update VERSION for 4.4.12
  Update CHANGELOG for 4.4.12
  Bump Symfony version to 3.4.45
  Update VERSION for 3.4.44
  Update CONTRIBUTORS for 3.4.44
  Update CHANGELOG for 3.4.44
  • Loading branch information
fabpot committed Sep 1, 2020
2 parents a2c913f + f8e1211 commit bcda9e5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Mapping/Factory/CacheClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public function getMetadataFor($value)
return $this->loadedClasses[$class];
}

// Key cannot contain backslashes according to PSR-6
$key = strtr($class, '\\', '_');
$key = rawurlencode(strtr($class, '\\', '_'));

$item = $this->cacheItemPool->getItem($key);
if ($item->isHit()) {
Expand Down
16 changes: 16 additions & 0 deletions Tests/Mapping/Factory/CacheMetadataFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,20 @@ public function testInvalidClassThrowsException()

$factory->getMetadataFor('Not\Exist');
}

public function testAnonymousClass()
{
$anonymousObject = new class() {
};

$metadata = new ClassMetadata(\get_class($anonymousObject));
$decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock();
$decorated
->expects($this->once())
->method('getMetadataFor')
->willReturn($metadata);

$factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter());
$this->assertEquals($metadata, $factory->getMetadataFor($anonymousObject));
}
}

0 comments on commit bcda9e5

Please sign in to comment.