1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Tebru\Gson\Internal; |
6
|
|
|
|
7
|
|
|
use Psr\SimpleCache\CacheInterface; |
8
|
|
|
use Symfony\Component\Cache\Adapter\ArrayAdapter; |
9
|
|
|
use Symfony\Component\Cache\Adapter\ChainAdapter; |
10
|
|
|
use Symfony\Component\Cache\Adapter\NullAdapter; |
11
|
|
|
use Symfony\Component\Cache\Adapter\PhpFilesAdapter; |
12
|
|
|
use Symfony\Component\Cache\Adapter\Psr16Adapter; |
13
|
|
|
use Symfony\Component\Cache\Psr16Cache; |
14
|
|
|
use Symfony\Component\Cache\Simple\ArrayCache; |
|
|
|
|
15
|
|
|
use Symfony\Component\Cache\Simple\ChainCache; |
|
|
|
|
16
|
|
|
use Symfony\Component\Cache\Simple\NullCache; |
|
|
|
|
17
|
|
|
use Symfony\Component\Cache\Simple\PhpFilesCache; |
|
|
|
|
18
|
|
|
|
19
|
|
|
final class CacheProvider |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Create a "file cache", chained to a "memory cache" depending on symfony/cache version |
23
|
|
|
* |
24
|
|
|
* @param string $cacheDir |
25
|
|
|
* @return CacheInterface |
26
|
|
|
* @throws \Symfony\Component\Cache\Exception\CacheException |
27
|
|
|
*/ |
28
|
|
|
public static function createFileCache(string $cacheDir): CacheInterface |
29
|
|
|
{ |
30
|
|
|
// >= Symfony 4.3 |
31
|
|
|
if (class_exists('Symfony\Component\Cache\Psr16Cache')) { |
32
|
|
|
return new Psr16Cache(new ChainAdapter([ |
33
|
|
|
new Psr16Adapter(self::createMemoryCache()), |
34
|
|
|
new PhpFilesAdapter('', 0, $cacheDir), |
35
|
|
|
])); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
return new ChainCache([ |
39
|
|
|
self::createMemoryCache(), |
40
|
|
|
new PhpFilesCache('', 0, $cacheDir) |
41
|
|
|
]); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Create a "memory cache" depending on symfony/cache version |
46
|
|
|
* |
47
|
|
|
* @return CacheInterface |
48
|
|
|
*/ |
49
|
3 |
|
public static function createMemoryCache(): CacheInterface |
50
|
|
|
{ |
51
|
|
|
// >= Symfony 4.3 |
52
|
3 |
|
if (class_exists('Symfony\Component\Cache\Psr16Cache')) { |
53
|
3 |
|
return new Psr16Cache(new ArrayAdapter(0, false)); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return new ArrayCache(0, false); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Create a "null" cache (for annotations) depending on symfony/cache version |
61
|
|
|
* |
62
|
|
|
* @return CacheInterface |
63
|
|
|
*/ |
64
|
8 |
|
public static function createNullCache(): CacheInterface |
65
|
|
|
{ |
66
|
|
|
// >= Symfony 4.3 |
67
|
8 |
|
if (class_exists('Symfony\Component\Cache\Psr16Cache')) { |
68
|
8 |
|
return new Psr16Cache(new NullAdapter()); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
return new NullCache(); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths