1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the reliforp/reli-prof package. |
5
|
|
|
* |
6
|
|
|
* (c) sji <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Reli\Lib\PhpProcessReader\CallTraceReader; |
15
|
|
|
|
16
|
|
|
use Reli\Lib\Process\Pointer\Dereferencable as T; |
17
|
|
|
use Reli\Lib\Process\Pointer\Dereferencer; |
18
|
|
|
use Reli\Lib\Process\Pointer\Pointer; |
19
|
|
|
|
20
|
|
|
final class TraceCache |
21
|
|
|
{ |
22
|
|
|
/** @param array<string, array<int, \Reli\Lib\Process\Pointer\Dereferencable>> $cache */ |
23
|
|
|
public function __construct( |
24
|
|
|
private float $key = 0, |
25
|
|
|
private array $cache = [], |
26
|
|
|
) { |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function clearCache(): void |
30
|
|
|
{ |
31
|
|
|
$this->cache = []; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function updateCacheKey(float $key): void |
35
|
|
|
{ |
36
|
|
|
if ($this->key !== $key) { |
37
|
|
|
$this->key = $key; |
38
|
|
|
$this->clearCache(); |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function getDereferencer(Dereferencer $dereferencer): Dereferencer |
43
|
|
|
{ |
44
|
|
|
return new class ($dereferencer, $this) implements Dereferencer { |
45
|
|
|
public function __construct( |
46
|
|
|
private Dereferencer $dereferencer, |
47
|
|
|
private TraceCache $trace_cache, |
48
|
|
|
) { |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function deref(Pointer $pointer): mixed |
52
|
|
|
{ |
53
|
|
|
$item = $this->trace_cache->getCache($pointer); |
54
|
|
|
if (is_null($item)) { |
55
|
|
|
$item = $this->dereferencer->deref($pointer); |
56
|
|
|
$this->trace_cache->setCache( |
57
|
|
|
$pointer, |
58
|
|
|
$item, |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
return $item; |
62
|
|
|
} |
63
|
|
|
}; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @template TCached of \Reli\Lib\Process\Pointer\Dereferencable |
68
|
|
|
* @param Pointer<TCached> $pointer |
69
|
|
|
* @param TCached $item |
|
|
|
|
70
|
|
|
*/ |
71
|
|
|
public function setCache(Pointer $pointer, mixed $item): void |
72
|
|
|
{ |
73
|
|
|
$this->cache[$pointer->type][$pointer->address] = $item; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @template TCached of \Reli\Lib\Process\Pointer\Dereferencable |
78
|
|
|
* @param Pointer<TCached> $pointer |
79
|
|
|
* @return TCached|null |
80
|
|
|
*/ |
81
|
|
|
public function getCache(Pointer $pointer): mixed |
82
|
|
|
{ |
83
|
|
|
/** @var TCached|null */ |
84
|
|
|
return $this->cache[$pointer->type][$pointer->address] ?? null; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
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