|
3 | 3 | namespace PHPStan\Parser; |
4 | 4 |
|
5 | 5 | use PhpParser\Node; |
6 | | -use PHPStan\File\FileReader; |
7 | 6 | use function array_slice; |
8 | 7 |
|
9 | 8 | final class CachedParser implements Parser |
10 | 9 | { |
11 | 10 |
|
12 | | - /** @var array<string, Node\Stmt[]>*/ |
13 | | - private array $cachedNodesByString = []; |
14 | | - |
15 | | - private int $cachedNodesByStringCount = 0; |
16 | | - |
17 | 11 | /** @var array<string, Node\Stmt[]>*/ |
18 | 12 | private array $cachedNodesByFile = []; |
19 | 13 |
|
@@ -55,40 +49,12 @@ public function parseFile(string $file): array |
55 | 49 | */ |
56 | 50 | public function parseString(string $sourceCode): array |
57 | 51 | { |
58 | | - if ($this->cachedNodesByStringCountMax !== 0 && $this->cachedNodesByStringCount >= $this->cachedNodesByStringCountMax) { |
59 | | - $this->cachedNodesByString = array_slice( |
60 | | - $this->cachedNodesByString, |
61 | | - 1, |
62 | | - preserve_keys: true, |
63 | | - ); |
64 | | - |
65 | | - --$this->cachedNodesByStringCount; |
66 | | - } |
67 | | - |
68 | | - if (!isset($this->cachedNodesByString[$sourceCode])) { |
69 | | - $this->cachedNodesByString[$sourceCode] = $this->originalParser->parseString($sourceCode); |
70 | | - $this->cachedNodesByStringCount++; |
71 | | - } |
72 | | - |
73 | | - return $this->cachedNodesByString[$sourceCode]; |
74 | | - } |
75 | | - |
76 | | - public function getCachedNodesByStringCount(): int |
77 | | - { |
78 | | - return $this->cachedNodesByStringCount; |
| 52 | + return $this->originalParser->parseString($sourceCode); |
79 | 53 | } |
80 | 54 |
|
81 | 55 | public function getCachedNodesByStringCountMax(): int |
82 | 56 | { |
83 | 57 | return $this->cachedNodesByStringCountMax; |
84 | 58 | } |
85 | 59 |
|
86 | | - /** |
87 | | - * @return array<string, Node[]> |
88 | | - */ |
89 | | - public function getCachedNodesByString(): array |
90 | | - { |
91 | | - return $this->cachedNodesByString; |
92 | | - } |
93 | | - |
94 | 60 | } |
0 commit comments