Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aa4b8bd

Browse filesBrowse files
committed
Fix deprecations from Doctrine Annotations+Cache
1 parent 907f103 commit aa4b8bd
Copy full SHA for aa4b8bd

File tree

Expand file treeCollapse file tree

15 files changed

+114
-48
lines changed
Filter options
Expand file treeCollapse file tree

15 files changed

+114
-48
lines changed

‎composer.json

Copy file name to clipboardExpand all lines: composer.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
"cache/integration-tests": "dev-master",
120120
"composer/package-versions-deprecated": "^1.8",
121121
"doctrine/annotations": "^1.10.4",
122-
"doctrine/cache": "~1.6",
122+
"doctrine/cache": "^1.6|^2.0",
123123
"doctrine/collections": "~1.0",
124124
"doctrine/data-fixtures": "^1.1",
125125
"doctrine/dbal": "^2.6|^3.0",
@@ -143,6 +143,7 @@
143143
"twig/markdown-extra": "^2.12|^3"
144144
},
145145
"conflict": {
146+
"doctrine/annotations": "1.13.0",
146147
"egulias/email-validator": "~3.0.0",
147148
"masterminds/html5": "<2.6",
148149
"monolog/monolog": ">=2",

‎src/Symfony/Bridge/Doctrine/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/composer.json
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"symfony/var-dumper": "^3.4|^4.0|^5.0",
4141
"symfony/translation": "^3.4|^4.0|^5.0",
4242
"doctrine/annotations": "^1.10.4",
43-
"doctrine/cache": "~1.6",
4443
"doctrine/collections": "~1.0",
4544
"doctrine/data-fixtures": "^1.1",
4645
"doctrine/dbal": "^2.6|^3.0",

‎src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\Common\Annotations\AnnotationException;
1515
use Doctrine\Common\Annotations\CachedReader;
16+
use Doctrine\Common\Annotations\PsrCachedReader;
1617
use Doctrine\Common\Annotations\Reader;
1718
use Psr\Cache\CacheItemPoolInterface;
1819
use Symfony\Component\Cache\Adapter\ArrayAdapter;
@@ -61,7 +62,10 @@ protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter)
6162
}
6263

6364
$annotatedClasses = include $annotatedClassPatterns;
64-
$reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter), $this->debug);
65+
$reader = class_exists(PsrCachedReader::class)
66+
? new PsrCachedReader($this->annotationReader, $arrayAdapter, $this->debug)
67+
: new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter), $this->debug)
68+
;
6569

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

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
1313

1414
use Doctrine\Common\Annotations\AnnotationRegistry;
15+
use Doctrine\Common\Annotations\PsrCachedReader;
1516
use Doctrine\Common\Annotations\Reader;
1617
use Http\Client\HttpClient;
1718
use Psr\Cache\CacheItemPoolInterface;
@@ -1423,14 +1424,20 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
14231424
}
14241425

14251426
if ('none' !== $config['cache']) {
1426-
if (!class_exists(\Doctrine\Common\Cache\CacheProvider::class)) {
1427+
if (class_exists(PsrCachedReader::class)) {
1428+
$container
1429+
->getDefinition('annotations.cached_reader')
1430+
->setClass(PsrCachedReader::class)
1431+
->replaceArgument(1, new Definition(ArrayAdapter::class))
1432+
;
1433+
} elseif (!class_exists(\Doctrine\Common\Cache\CacheProvider::class)) {
14271434
throw new LogicException('Annotations cannot be enabled as the Doctrine Cache library is not installed.');
14281435
}
14291436

14301437
$cacheService = $config['cache'];
14311438

14321439
if ('php_array' === $config['cache']) {
1433-
$cacheService = 'annotations.cache';
1440+
$cacheService = class_exists(PsrCachedReader::class) ? 'annotations.cache_adapter' : 'annotations.cache';
14341441

14351442
// Enable warmer only if PHP array is used for cache
14361443
$definition = $container->findDefinition('annotations.cache_warmer');
@@ -1447,7 +1454,7 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
14471454
->replaceArgument(2, $cacheDir)
14481455
;
14491456

1450-
$cacheService = 'annotations.filesystem_cache';
1457+
$cacheService = class_exists(PsrCachedReader::class) ? 'annotations.filesystem_cache_adapter' : 'annotations.filesystem_cache';
14511458
}
14521459

14531460
$container

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@
5050
<argument>%kernel.debug%</argument>
5151
</service>
5252

53+
<service id="annotations.cache_adapter" class="Symfony\Component\Cache\Adapter\PhpArrayAdapter">
54+
<factory class="Symfony\Component\Cache\Adapter\PhpArrayAdapter" method="create" />
55+
<argument>%kernel.cache_dir%/annotations.php</argument>
56+
<argument type="service" id="cache.annotations" />
57+
<tag name="container.hot_path" />
58+
</service>
59+
5360
<service id="annotations.cache" class="Symfony\Component\Cache\DoctrineProvider">
54-
<argument type="service">
55-
<service class="Symfony\Component\Cache\Adapter\PhpArrayAdapter">
56-
<factory class="Symfony\Component\Cache\Adapter\PhpArrayAdapter" method="create" />
57-
<argument>%kernel.cache_dir%/annotations.php</argument>
58-
<argument type="service" id="cache.annotations" />
59-
</service>
60-
</argument>
61+
<argument type="service" id="annotations.cache_adapter" />
6162
<tag name="container.hot_path" />
6263
</service>
6364

‎src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/AnnotationsCacheWarmerTest.php
+25-9Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Doctrine\Common\Annotations\AnnotationReader;
66
use Doctrine\Common\Annotations\CachedReader;
7+
use Doctrine\Common\Annotations\PsrCachedReader;
78
use Doctrine\Common\Annotations\Reader;
89
use PHPUnit\Framework\MockObject\MockObject;
910
use Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer;
@@ -43,10 +44,16 @@ public function testAnnotationsCacheWarmerWithDebugDisabled()
4344
$this->assertFileExists($cacheFile);
4445

4546
// Assert cache is valid
46-
$reader = new CachedReader(
47-
$this->getReadOnlyReader(),
48-
new DoctrineProvider(new PhpArrayAdapter($cacheFile, new NullAdapter()))
49-
);
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+
;
5057
$refClass = new \ReflectionClass($this);
5158
$reader->getClassAnnotations($refClass);
5259
$reader->getMethodAnnotations($refClass->getMethod(__FUNCTION__));
@@ -61,12 +68,21 @@ public function testAnnotationsCacheWarmerWithDebugEnabled()
6168
$warmer = new AnnotationsCacheWarmer($reader, $cacheFile, null, true);
6269
$warmer->warmUp($this->cacheDir);
6370
$this->assertFileExists($cacheFile);
71+
6472
// Assert cache is valid
65-
$reader = new CachedReader(
66-
$this->getReadOnlyReader(),
67-
new DoctrineProvider(new PhpArrayAdapter($cacheFile, new NullAdapter())),
68-
true
69-
);
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+
;
7086
$refClass = new \ReflectionClass($this);
7187
$reader->getClassAnnotations($refClass);
7288
$reader->getMethodAnnotations($refClass->getMethod(__FUNCTION__));

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
1313

1414
use Doctrine\Common\Annotations\Annotation;
15+
use Doctrine\Common\Annotations\PsrCachedReader;
1516
use Psr\Log\LoggerAwareInterface;
1617
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass;
1718
use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
@@ -999,7 +1000,11 @@ public function testAnnotations()
9991000
$container->compile();
10001001

10011002
$this->assertEquals($container->getParameter('kernel.cache_dir').'/annotations', $container->getDefinition('annotations.filesystem_cache_adapter')->getArgument(2));
1002-
$this->assertSame('annotations.filesystem_cache', (string) $container->getDefinition('annotation_reader')->getArgument(1));
1003+
if (class_exists(PsrCachedReader::class)) {
1004+
$this->assertSame('annotations.filesystem_cache_adapter', (string) $container->getDefinition('annotation_reader')->getArgument(1));
1005+
} else {
1006+
$this->assertSame('annotations.filesystem_cache', (string) $container->getDefinition('annotation_reader')->getArgument(1));
1007+
}
10031008
}
10041009

10051010
public function testFileLinkFormat()

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\Common\Annotations\AnnotationReader;
1515
use Doctrine\Common\Annotations\CachedReader;
16+
use Doctrine\Common\Annotations\PsrCachedReader;
1617
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
1718
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
1819
use Symfony\Component\EventDispatcher\EventDispatcher;
@@ -35,7 +36,11 @@ public function testCachedAnnotationReaderAutowiring()
3536
static::bootKernel();
3637

3738
$annotationReader = static::$container->get('test.autowiring_types.autowired_services')->getAnnotationReader();
38-
$this->assertInstanceOf(CachedReader::class, $annotationReader);
39+
if (class_exists(PsrCachedReader::class)) {
40+
$this->assertInstanceOf(PsrCachedReader::class, $annotationReader);
41+
} else {
42+
$this->assertInstanceOf(CachedReader::class, $annotationReader);
43+
}
3944
}
4045

4146
/**

‎src/Symfony/Bundle/FrameworkBundle/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/composer.json
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php": ">=7.1.3",
2020
"ext-xml": "*",
2121
"symfony/cache": "^4.4|^5.0",
22-
"symfony/config": "^4.3.4|^5.0",
22+
"symfony/config": "^4.4.11|~5.0.11|^5.1.3",
2323
"symfony/dependency-injection": "^4.4.1|^5.0.1",
2424
"symfony/error-handler": "^4.4.1|^5.0.1",
2525
"symfony/http-foundation": "^4.4|^5.0",
@@ -31,7 +31,7 @@
3131
},
3232
"require-dev": {
3333
"doctrine/annotations": "^1.10.4",
34-
"doctrine/cache": "~1.0",
34+
"doctrine/cache": "^1.0|^2.0",
3535
"doctrine/persistence": "^1.3|^2.0",
3636
"paragonie/sodium_compat": "^1.8",
3737
"symfony/asset": "^3.4|^4.0|^5.0",
@@ -66,6 +66,7 @@
6666
"twig/twig": "^1.43|^2.13|^3.0.4"
6767
},
6868
"conflict": {
69+
"doctrine/annotations": "1.13.0",
6970
"doctrine/persistence": "<1.3",
7071
"phpdocumentor/reflection-docblock": "<3.0|>=3.2.0,<3.2.2",
7172
"phpdocumentor/type-resolver": "<0.3.0|1.3.*",

‎src/Symfony/Bundle/TwigBundle/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"symfony/framework-bundle": "^4.4|^5.0",
3838
"symfony/web-link": "^3.4|^4.0|^5.0",
3939
"doctrine/annotations": "^1.10.4",
40-
"doctrine/cache": "~1.0"
40+
"doctrine/cache": "^1.0|^2.0"
4141
},
4242
"conflict": {
4343
"symfony/dependency-injection": "<4.1",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.