Skip to content

Commit f0ded73

Browse files
committed
chore(deps): bump phpstan to ^2.0 with baseline
PHPStan 1.x ships php-parser 4.x which cannot parse the asymmetric visibility (`public protected(set)`) used by utopia-php/query 0.3.x's ClickHouse schema layer (Schema\Table\ClickHouse), causing an internal "Lexer::getNextToken returned null" crash on the usage adapter source file. Bump to PHPStan ^2.0 (ships php-parser 5.x, understands PHP 8.4) and capture the pre-existing "mixed array access" findings from json_decode result handling in a baseline so net analysis stays green while the adapter migrates. Wire up a phpstan.neon that runs at level max over src + tests.
1 parent e84ff76 commit f0ded73

4 files changed

Lines changed: 220 additions & 7 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"require-dev": {
2727
"phpunit/phpunit": "^9.5",
2828
"utopia-php/cache": "1.*",
29-
"phpstan/phpstan": "1.*",
29+
"phpstan/phpstan": "^2.0",
3030
"laravel/pint": "1.*"
3131
},
3232
"autoload": {

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan-baseline.neon

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Call to function is_array\(\) with array\<string, mixed\> will always evaluate to true\.$#'
5+
identifier: function.alreadyNarrowedType
6+
count: 1
7+
path: src/Usage/Adapter/ClickHouse.php
8+
9+
-
10+
message: '#^Cannot access offset ''agg_val'' on mixed\.$#'
11+
identifier: offsetAccess.nonOffsetAccessible
12+
count: 1
13+
path: src/Usage/Adapter/ClickHouse.php
14+
15+
-
16+
message: '#^Cannot access offset ''agg_value'' on mixed\.$#'
17+
identifier: offsetAccess.nonOffsetAccessible
18+
count: 1
19+
path: src/Usage/Adapter/ClickHouse.php
20+
21+
-
22+
message: '#^Cannot access offset ''bucket'' on mixed\.$#'
23+
identifier: offsetAccess.nonOffsetAccessible
24+
count: 1
25+
path: src/Usage/Adapter/ClickHouse.php
26+
27+
-
28+
message: '#^Cannot access offset ''metric'' on mixed\.$#'
29+
identifier: offsetAccess.nonOffsetAccessible
30+
count: 3
31+
path: src/Usage/Adapter/ClickHouse.php
32+
33+
-
34+
message: '#^Cannot access offset ''ping'' on mixed\.$#'
35+
identifier: offsetAccess.nonOffsetAccessible
36+
count: 1
37+
path: src/Usage/Adapter/ClickHouse.php
38+
39+
-
40+
message: '#^Cannot access offset ''total'' on mixed\.$#'
41+
identifier: offsetAccess.nonOffsetAccessible
42+
count: 6
43+
path: src/Usage/Adapter/ClickHouse.php
44+
45+
-
46+
message: '#^Cannot access offset ''uptime'' on mixed\.$#'
47+
identifier: offsetAccess.nonOffsetAccessible
48+
count: 1
49+
path: src/Usage/Adapter/ClickHouse.php
50+
51+
-
52+
message: '#^Cannot access offset ''version'' on mixed\.$#'
53+
identifier: offsetAccess.nonOffsetAccessible
54+
count: 1
55+
path: src/Usage/Adapter/ClickHouse.php
56+
57+
-
58+
message: '#^Cannot access offset 0 on mixed\.$#'
59+
identifier: offsetAccess.nonOffsetAccessible
60+
count: 7
61+
path: src/Usage/Adapter/ClickHouse.php
62+
63+
-
64+
message: '#^Cannot cast mixed to float\.$#'
65+
identifier: cast.double
66+
count: 1
67+
path: src/Usage/Adapter/ClickHouse.php
68+
69+
-
70+
message: '#^Cannot cast mixed to int\.$#'
71+
identifier: cast.int
72+
count: 9
73+
path: src/Usage/Adapter/ClickHouse.php
74+
75+
-
76+
message: '#^Cannot cast mixed to string\.$#'
77+
identifier: cast.string
78+
count: 5
79+
path: src/Usage/Adapter/ClickHouse.php
80+
81+
-
82+
message: '#^Method Utopia\\Usage\\Adapter\\ClickHouse\:\:getTimeSeriesFromTable\(\) should return array\<string, array\{total\: float, data\: array\<array\{value\: float, date\: string\}\>\}\> but returns array\<array\{total\: 0\|float, data\: list\<array\{value\: float, date\: string\}\>\}\>\.$#'
83+
identifier: return.type
84+
count: 1
85+
path: src/Usage/Adapter/ClickHouse.php
86+
87+
-
88+
message: '#^Method Utopia\\Usage\\Adapter\\ClickHouse\:\:runStatement\(\) is unused\.$#'
89+
identifier: method.unused
90+
count: 1
91+
path: src/Usage/Adapter/ClickHouse.php
92+
93+
-
94+
message: '#^Parameter \#1 \$input of class Utopia\\Usage\\Metric constructor expects array\<string, mixed\>, array\<mixed\> given\.$#'
95+
identifier: argument.type
96+
count: 2
97+
path: src/Usage/Adapter/ClickHouse.php
98+
99+
-
100+
message: '#^Part \$metricName \(mixed\) of encapsed string cannot be cast to string\.$#'
101+
identifier: encapsedStringPart.nonString
102+
count: 1
103+
path: src/Usage/Adapter/ClickHouse.php
104+
105+
-
106+
message: '#^Possibly invalid array key type mixed\.$#'
107+
identifier: offsetAccess.invalidOffset
108+
count: 10
109+
path: src/Usage/Adapter/ClickHouse.php
110+
111+
-
112+
message: '#^Method Utopia\\Usage\\Metric\:\:getTags\(\) should return array\<string, mixed\> but returns array\<mixed\>\.$#'
113+
identifier: return.type
114+
count: 1
115+
path: src/Usage/Metric.php
116+
117+
-
118+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\) with array\<Utopia\\Usage\\Metric\> will always evaluate to true\.$#'
119+
identifier: method.alreadyNarrowedType
120+
count: 1
121+
path: tests/Usage/Adapter/ClickHouseTest.php
122+
123+
-
124+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\) with array\<string, array\{total\: float, data\: array\<array\{value\: float, date\: string\}\>\}\> will always evaluate to true\.$#'
125+
identifier: method.alreadyNarrowedType
126+
count: 1
127+
path: tests/Usage/Adapter/ClickHouseTest.php
128+
129+
-
130+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\) with array\<string, int\> will always evaluate to true\.$#'
131+
identifier: method.alreadyNarrowedType
132+
count: 2
133+
path: tests/Usage/Adapter/ClickHouseTest.php
134+
135+
-
136+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\) with array\<string, mixed\> will always evaluate to true\.$#'
137+
identifier: method.alreadyNarrowedType
138+
count: 1
139+
path: tests/Usage/Adapter/ClickHouseTest.php
140+
141+
-
142+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\) with array\{healthy\: bool, host\: string, port\: int, database\: string, secure\: bool, version\?\: string, uptime\?\: int, error\?\: string, \.\.\.\} will always evaluate to true\.$#'
143+
identifier: method.alreadyNarrowedType
144+
count: 1
145+
path: tests/Usage/Adapter/ClickHouseTest.php
146+
147+
-
148+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\) with array\{request_count\: int, keep_alive_enabled\: bool, compression_enabled\: bool, query_logging_enabled\: bool, max_retries\: int, retry_delay\: int, async_inserts\: bool, async_insert_wait\: bool\} will always evaluate to true\.$#'
149+
identifier: method.alreadyNarrowedType
150+
count: 1
151+
path: tests/Usage/Adapter/ClickHouseTest.php
152+
153+
-
154+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertIsInt\(\) with int will always evaluate to true\.$#'
155+
identifier: method.alreadyNarrowedType
156+
count: 3
157+
path: tests/Usage/Adapter/ClickHouseTest.php
158+
159+
-
160+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with true will always evaluate to true\.$#'
161+
identifier: method.alreadyNarrowedType
162+
count: 2
163+
path: tests/Usage/Adapter/ClickHouseTest.php
164+
165+
-
166+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\) with array\<string, array\{total\: float, data\: array\<array\{value\: float, date\: string\}\>\}\> will always evaluate to true\.$#'
167+
identifier: method.alreadyNarrowedType
168+
count: 1
169+
path: tests/Usage/Adapter/DatabaseTest.php
170+
171+
-
172+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\) with array\<string, int\> will always evaluate to true\.$#'
173+
identifier: method.alreadyNarrowedType
174+
count: 2
175+
path: tests/Usage/Adapter/DatabaseTest.php
176+
177+
-
178+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\) with array\<string, mixed\> will always evaluate to true\.$#'
179+
identifier: method.alreadyNarrowedType
180+
count: 1
181+
path: tests/Usage/Adapter/DatabaseTest.php
182+
183+
-
184+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\) with array\{healthy\: bool, database\?\: string, collection\?\: string, error\?\: string\} will always evaluate to true\.$#'
185+
identifier: method.alreadyNarrowedType
186+
count: 1
187+
path: tests/Usage/Adapter/DatabaseTest.php
188+
189+
-
190+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\) with array\<int, array\<string, mixed\>\> will always evaluate to true\.$#'
191+
identifier: method.alreadyNarrowedType
192+
count: 4
193+
path: tests/Usage/MetricTest.php
194+
195+
-
196+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\) with array\<string, mixed\> will always evaluate to true\.$#'
197+
identifier: method.alreadyNarrowedType
198+
count: 2
199+
path: tests/Usage/MetricTest.php
200+
201+
-
202+
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertTrue\(\) with true will always evaluate to true\.$#'
203+
identifier: method.alreadyNarrowedType
204+
count: 6
205+
path: tests/Usage/MetricTest.php

phpstan.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
4+
parameters:
5+
level: max
6+
paths:
7+
- src
8+
- tests

0 commit comments

Comments
 (0)