Skip to content

Commit 90fb19f

Browse files
committed
Prepare removing Doctrine Cache from remaining components
Signed-off-by: Alexander M. Turek <[email protected]>
1 parent a8c7c81 commit 90fb19f

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

ValidatorBuilder.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Doctrine\Common\Annotations\CachedReader;
1616
use Doctrine\Common\Annotations\PsrCachedReader;
1717
use Doctrine\Common\Annotations\Reader;
18-
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
18+
use Doctrine\Common\Cache\ArrayCache;
1919
use Psr\Cache\CacheItemPoolInterface;
2020
use Symfony\Component\Cache\Adapter\ArrayAdapter;
2121
use Symfony\Component\Validator\Context\ExecutionContextFactory;
@@ -429,22 +429,16 @@ private function createAnnotationReader(): Reader
429429
throw new LogicException('Enabling annotation based constraint mapping requires the packages doctrine/annotations and symfony/cache to be installed.');
430430
}
431431

432-
// Doctrine Annotation >= 1.13, Symfony Cache
433-
if (class_exists(PsrCachedReader::class) && class_exists(ArrayAdapter::class)) {
432+
if (class_exists(ArrayAdapter::class)) {
434433
return new PsrCachedReader(new AnnotationReader(), new ArrayAdapter());
435434
}
436435

437-
// Doctrine Annotations < 1.13, Doctrine Cache >= 1.11, Symfony Cache
438-
if (class_exists(CachedReader::class) && class_exists(ArrayAdapter::class)) {
439-
return new CachedReader(new AnnotationReader(), DoctrineProvider::wrap(new ArrayAdapter()));
440-
}
436+
if (class_exists(CachedReader::class) && class_exists(ArrayCache::class)) {
437+
trigger_deprecation('symfony/validator', '5.4', 'Enabling annotation based constraint mapping without having symfony/cache installed is deprecated.');
441438

442-
// Doctrine Annotation >= 1.13, Doctrine Cache >= 2, no Symfony Cache
443-
if (class_exists(PsrCachedReader::class)) {
444-
throw new LogicException('Enabling annotation based constraint mapping requires the package symfony/cache to be installed.');
439+
return new CachedReader(new AnnotationReader(), new ArrayCache());
445440
}
446441

447-
// Doctrine Annotation (<1.13 || >2), no Doctrine Cache, no Symfony Cache
448-
throw new LogicException('Enabling annotation based constraint mapping requires the packages doctrine/annotations (>=1.13) and symfony/cache to be installed.');
442+
throw new LogicException('Enabling annotation based constraint mapping requires the packages doctrine/annotations and symfony/cache to be installed.');
449443
}
450444
}

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@
4040
"symfony/property-access": "^4.4|^5.0|^6.0",
4141
"symfony/property-info": "^5.3|^6.0",
4242
"symfony/translation": "^4.4|^5.0|^6.0",
43-
"doctrine/annotations": "^1.10.4",
43+
"doctrine/annotations": "^1.13",
4444
"doctrine/cache": "^1.11|^2.0",
4545
"egulias/email-validator": "^2.1.10|^3"
4646
},
4747
"conflict": {
48+
"doctrine/annotations": "<1.13",
4849
"doctrine/cache": "<1.11",
4950
"doctrine/lexer": "<1.0.2",
5051
"phpunit/phpunit": "<5.4.3",

0 commit comments

Comments
 (0)