Skip to content

Commit 6a07144

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: Fix deprecations from Doctrine Annotations+Cache
2 parents b909dbc + f2b7c03 commit 6a07144

File tree

6 files changed

+42
-29
lines changed

6 files changed

+42
-29
lines changed

CacheWarmer/AnnotationsCacheWarmer.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,10 @@ protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter)
5454
}
5555

5656
$annotatedClasses = include $annotatedClassPatterns;
57-
58-
if (class_exists(PsrCachedReader::class)) {
59-
// doctrine/annotations:1.13 and above
60-
$reader = new PsrCachedReader($this->annotationReader, $arrayAdapter, $this->debug);
61-
} else {
62-
$reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter), $this->debug);
63-
}
57+
$reader = class_exists(PsrCachedReader::class)
58+
? new PsrCachedReader($this->annotationReader, $arrayAdapter, $this->debug)
59+
: new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter), $this->debug)
60+
;
6461

6562
foreach ($annotatedClasses as $class) {
6663
if (null !== $this->excludeRegexp && preg_match($this->excludeRegexp, $class)) {

DependencyInjection/Compiler/UnusedTagsPass.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class UnusedTagsPass implements CompilerPassInterface
9292
'validator.auto_mapper',
9393
'validator.constraint_validator',
9494
'validator.initializer',
95+
'workflow.definition',
9596
];
9697

9798
public function process(ContainerBuilder $container)

Resources/config/annotations.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,16 @@
6262
param('kernel.debug'),
6363
])
6464

65+
->set('annotations.cache_adapter', PhpArrayAdapter::class)
66+
->factory([PhpArrayAdapter::class, 'create'])
67+
->args([
68+
param('kernel.cache_dir').'/annotations.php',
69+
service('cache.annotations'),
70+
])
71+
6572
->set('annotations.cache', DoctrineProvider::class)
6673
->args([
67-
inline_service(PhpArrayAdapter::class)
68-
->factory([PhpArrayAdapter::class, 'create'])
69-
->args([
70-
param('kernel.cache_dir').'/annotations.php',
71-
service('cache.annotations'),
72-
]),
74+
service('annotations.cache_adapter')
7375
])
7476
->tag('container.hot_path')
7577

Tests/CacheWarmer/AnnotationsCacheWarmerTest.php

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,16 @@ public function testAnnotationsCacheWarmerWithDebugDisabled()
4444
$this->assertFileExists($cacheFile);
4545

4646
// Assert cache is valid
47-
$psr6Cache = new PhpArrayAdapter($cacheFile, new NullAdapter());
48-
if (class_exists(PsrCachedReader::class)) {
49-
$reader = new PsrCachedReader($this->getReadOnlyReader(), $psr6Cache);
50-
} else {
51-
$reader = new CachedReader($this->getReadOnlyReader(), new DoctrineProvider($psr6Cache));
52-
}
53-
47+
$reader = class_exists(PsrCachedReader::class)
48+
? new PsrCachedReader(
49+
$this->getReadOnlyReader(),
50+
new PhpArrayAdapter($cacheFile, new NullAdapter())
51+
)
52+
: new CachedReader(
53+
$this->getReadOnlyReader(),
54+
new DoctrineProvider(new PhpArrayAdapter($cacheFile, new NullAdapter()))
55+
)
56+
;
5457
$refClass = new \ReflectionClass($this);
5558
$reader->getClassAnnotations($refClass);
5659
$reader->getMethodAnnotations($refClass->getMethod(__FUNCTION__));
@@ -67,13 +70,19 @@ public function testAnnotationsCacheWarmerWithDebugEnabled()
6770
$this->assertFileExists($cacheFile);
6871

6972
// Assert cache is valid
70-
$psr6Cache = new PhpArrayAdapter($cacheFile, new NullAdapter());
71-
if (class_exists(PsrCachedReader::class)) {
72-
$reader = new PsrCachedReader($this->getReadOnlyReader(), $psr6Cache);
73-
} else {
74-
$reader = new CachedReader($this->getReadOnlyReader(), new DoctrineProvider($psr6Cache));
75-
}
76-
73+
$phpArrayAdapter = new PhpArrayAdapter($cacheFile, new NullAdapter());
74+
$reader = class_exists(PsrCachedReader::class)
75+
? new PsrCachedReader(
76+
$this->getReadOnlyReader(),
77+
$phpArrayAdapter,
78+
true
79+
)
80+
: new CachedReader(
81+
$this->getReadOnlyReader(),
82+
new DoctrineProvider($phpArrayAdapter),
83+
true
84+
)
85+
;
7786
$refClass = new \ReflectionClass($this);
7887
$reader->getClassAnnotations($refClass);
7988
$reader->getMethodAnnotations($refClass->getMethod(__FUNCTION__));

Tests/Functional/AutowiringTypesTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ public function testCachedAnnotationReaderAutowiring()
3434
static::bootKernel();
3535

3636
$annotationReader = self::getContainer()->get('test.autowiring_types.autowired_services')->getAnnotationReader();
37-
$this->assertInstanceOf(class_exists(PsrCachedReader::class) ? PsrCachedReader::class : CachedReader::class, $annotationReader);
37+
if (class_exists(PsrCachedReader::class)) {
38+
$this->assertInstanceOf(PsrCachedReader::class, $annotationReader);
39+
} else {
40+
$this->assertInstanceOf(CachedReader::class, $annotationReader);
41+
}
3842
}
3943

4044
public function testEventDispatcherAutowiring()

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"require-dev": {
3636
"doctrine/annotations": "^1.10.4",
37-
"doctrine/cache": "~1.0",
37+
"doctrine/cache": "^1.0|^2.0",
3838
"doctrine/persistence": "^1.3|^2.0",
3939
"symfony/asset": "^5.3",
4040
"symfony/browser-kit": "^4.4|^5.0",

0 commit comments

Comments
 (0)