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\Psr16Cache; |
|
|
|
|
13
|
|
|
use Symfony\Component\Cache\Simple\ArrayCache; |
14
|
|
|
use Symfony\Component\Cache\Simple\ChainCache; |
15
|
|
|
use Symfony\Component\Cache\Simple\NullCache; |
16
|
|
|
use Symfony\Component\Cache\Simple\PhpFilesCache; |
17
|
|
|
|
18
|
|
|
final class CacheProvider |
19
|
|
|
{ |
20
|
|
|
public static function createFileCache(string $cacheDir): CacheInterface |
21
|
|
|
{ |
22
|
|
|
// >= Symfony 4.3 |
23
|
|
|
if (class_exists('Symfony\Component\Cache\Psr16Cache')) { |
24
|
|
|
return new Psr16Cache(new ChainAdapter([ |
25
|
|
|
new Psr16Adapter(self::createMemoryCache()), |
|
|
|
|
26
|
|
|
new PhpFilesAdapter('', 0, $cacheDir), |
27
|
|
|
])); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
return new ChainCache([ |
31
|
|
|
self::createMemoryCache(), |
32
|
|
|
new PhpFilesCache('', 0, $cacheDir) |
33
|
|
|
]); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Create a "memory cache" depending on symfony/cache version |
38
|
|
|
* @return CacheInterface |
39
|
|
|
*/ |
40
|
3 |
|
public static function createMemoryCache(): CacheInterface |
41
|
|
|
{ |
42
|
|
|
// >= Symfony 4.3 |
43
|
3 |
|
if (class_exists('Symfony\Component\Cache\Psr16Cache')) { |
44
|
|
|
return new Psr16Cache(new ArrayAdapter(0, false)); |
45
|
|
|
} |
46
|
|
|
|
47
|
3 |
|
return new ArrayCache(0, false); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Create a "null" cache (for annotations) depending on symfony/cache version |
52
|
|
|
* |
53
|
|
|
* @return CacheInterface |
54
|
|
|
*/ |
55
|
3 |
|
public static function createNullCache(): CacheInterface |
56
|
|
|
{ |
57
|
|
|
// >= Symfony 4.3 |
58
|
3 |
|
if (class_exists('Symfony\Component\Cache\Psr16Cache')) { |
59
|
|
|
return new Psr16Cache(new NullAdapter()); |
60
|
|
|
} |
61
|
|
|
|
62
|
3 |
|
return new NullCache(); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
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