Skip to content

Commit 38dffe7

Browse files
minor #33460 [Validator] Removed CacheInterface in favor of PSR-6 (derrabus)
This PR was merged into the 5.0-dev branch. Discussion ---------- [Validator] Removed CacheInterface in favor of PSR-6 | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #33414 | License | MIT | Doc PR | symfony/symfony-docs#12276 This PR removes the deprecation layer of #33459. Commits ------- 34b141c [Validator] Removed CacheInterface in favor of PSR-6.
2 parents f1b5d29 + 34b141c commit 38dffe7

File tree

10 files changed

+8
-447
lines changed

10 files changed

+8
-447
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@
3838
<tag name="kernel.cache_warmer" />
3939
</service>
4040

41-
<service id="validator.mapping.cache.symfony" class="Symfony\Component\Validator\Mapping\Cache\Psr6Cache">
42-
<argument type="service" id="validator.mapping.cache.adapter" />
43-
<deprecated>The "%service_id%" service is deprecated since Symfony 4.4. Use validator.mapping.cache.adapter instead.</deprecated>
44-
</service>
45-
4641
<service id="validator.mapping.cache.adapter" class="Symfony\Component\Cache\Adapter\PhpArrayAdapter">
4742
<factory class="Symfony\Component\Cache\Adapter\PhpArrayAdapter" method="create" />
4843
<argument>%validator.mapping.cache.file%</argument>

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

Lines changed: 0 additions & 45 deletions
This file was deleted.

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

Lines changed: 0 additions & 63 deletions
This file was deleted.

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

Lines changed: 0 additions & 80 deletions
This file was deleted.

src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Psr\Cache\CacheItemPoolInterface;
1515
use Symfony\Component\Validator\Exception\NoSuchMetadataException;
16-
use Symfony\Component\Validator\Mapping\Cache\CacheInterface;
1716
use Symfony\Component\Validator\Mapping\ClassMetadata;
1817
use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
1918

@@ -49,20 +48,8 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface
4948
*/
5049
protected $loadedClasses = [];
5150

52-
/**
53-
* Creates a new metadata factory.
54-
*
55-
* @param CacheItemPoolInterface|null $cache The cache for persisting metadata
56-
* between multiple PHP requests
57-
*/
58-
public function __construct(LoaderInterface $loader = null, $cache = null)
51+
public function __construct(LoaderInterface $loader = null, CacheItemPoolInterface $cache = null)
5952
{
60-
if ($cache instanceof CacheInterface) {
61-
@trigger_error(sprintf('Passing a "%s" to "%s" is deprecated in Symfony 4.4 and will trigger a TypeError in 5.0. Please pass an implementation of "%s" instead.', \get_class($cache), __METHOD__, CacheItemPoolInterface::class), E_USER_DEPRECATED);
62-
} elseif (!$cache instanceof CacheItemPoolInterface && null !== $cache) {
63-
throw new \TypeError(sprintf('Expected an instance of %s, got %s.', CacheItemPoolInterface::class, \is_object($cache) ? \get_class($cache) : \gettype($cache)));
64-
}
65-
6653
$this->loader = $loader;
6754
$this->cache = $cache;
6855
}
@@ -98,24 +85,14 @@ public function getMetadataFor($value)
9885
throw new NoSuchMetadataException(sprintf('The class or interface "%s" does not exist.', $class));
9986
}
10087

101-
$cacheItem = null;
102-
if ($this->cache instanceof CacheInterface) {
103-
if ($metadata = $this->cache->read($class)) {
104-
// Include constraints from the parent class
105-
$this->mergeConstraints($metadata);
106-
107-
return $this->loadedClasses[$class] = $metadata;
108-
}
109-
} elseif (null !== $this->cache) {
110-
$cacheItem = $this->cache->getItem($this->escapeClassName($class));
111-
if ($cacheItem->isHit()) {
112-
$metadata = $cacheItem->get();
88+
$cacheItem = null === $this->cache ? null : $this->cache->getItem($this->escapeClassName($class));
89+
if ($cacheItem && $cacheItem->isHit()) {
90+
$metadata = $cacheItem->get();
11391

114-
// Include constraints from the parent class
115-
$this->mergeConstraints($metadata);
92+
// Include constraints from the parent class
93+
$this->mergeConstraints($metadata);
11694

117-
return $this->loadedClasses[$class] = $metadata;
118-
}
95+
return $this->loadedClasses[$class] = $metadata;
11996
}
12097

12198
$metadata = new ClassMetadata($class);
@@ -124,9 +101,7 @@ public function getMetadataFor($value)
124101
$this->loader->loadClassMetadata($metadata);
125102
}
126103

127-
if ($this->cache instanceof CacheInterface) {
128-
$this->cache->write($metadata);
129-
} elseif (null !== $cacheItem) {
104+
if (null !== $cacheItem) {
130105
$this->cache->save($cacheItem->set($metadata));
131106
}
132107

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

Lines changed: 0 additions & 79 deletions
This file was deleted.

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

Lines changed: 0 additions & 26 deletions
This file was deleted.

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