Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 12852c2

Browse files
committed
[Validator] PSR-6 cache: Avoid name collision
1 parent f1cdc6f commit 12852c2

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 <[email protected]>
@@ -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)