Skip to content

Commit 52384fb

Browse files
committed
minor #17550 [Validator] PSR-6 cache: Avoid name collision (dunglas)
This PR was merged into the 3.1-dev branch. Discussion ---------- [Validator] PSR-6 cache: Avoid name collision | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a See tests. Commits ------- 12852c2 [Validator] PSR-6 cache: Avoid name collision
2 parents f1cdc6f + 12852c2 commit 52384fb

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Symfony/Component/Validator/Mapping/Cache/Psr6Cache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ public function write(ClassMetadata $metadata)
6767
}
6868

6969
/**
70-
* Replaces backslashes by underscores in a class name.
70+
* Replaces backslashes by dots in a class name.
7171
*
7272
* @param string $class
7373
*
7474
* @return string
7575
*/
7676
private function escapeClassName($class)
7777
{
78-
return strtr($class, '\\', '_');
78+
return strtr($class, '\\', '.');
7979
}
8080
}

src/Symfony/Component/Validator/Tests/Mapping/Cache/Psr6CacheTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Symfony\Component\Cache\Adapter\ArrayAdapter;
66
use Symfony\Component\Validator\Mapping\Cache\Psr6Cache;
7+
use Symfony\Component\Validator\Mapping\ClassMetadata;
78

89
/**
910
* @author Kévin Dunglas <dunglas@gmail.com>
@@ -14,4 +15,12 @@ protected function setUp()
1415
{
1516
$this->cache = new Psr6Cache(new ArrayAdapter());
1617
}
18+
19+
public function testNameCollision()
20+
{
21+
$metadata = new ClassMetadata('Foo\\Bar');
22+
23+
$this->cache->write($metadata);
24+
$this->assertFalse($this->cache->has('Foo_Bar'));
25+
}
1726
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy