Skip to content

Commit a2a3b4c

Browse files
committed
Update Psalm's baseline
1 parent 8f95e87 commit a2a3b4c

File tree

4 files changed

+111
-71
lines changed

4 files changed

+111
-71
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"phpstan/phpstan": "^1.10",
2626
"phpunit/phpunit": "^10.5 || ^11.0",
2727
"squizlabs/php_codesniffer": "^3.9",
28-
"vimeo/psalm": "^5.22"
28+
"vimeo/psalm": "^5.25"
2929
},
3030
"suggest": {
3131
"geoip2/geoip2": "Required to use the MaxMind database or web service with GeoIP (~2.1).",

psalm-baseline.xml

Lines changed: 108 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.24.0@462c80e31c34e58cc4f750c656be3927e80e550e">
2+
<files psalm-version="5.25.0@01a8eb06b9e9cc6cfb6a320bf9fb14331919d505">
33
<file src="src/Cache.php">
4-
<MixedAssignment>
5-
<code><![CDATA[$value]]></code>
6-
</MixedAssignment>
74
<MixedInferredReturnType>
85
<code><![CDATA[bool]]></code>
96
</MixedInferredReturnType>
107
<MixedReturnStatement>
118
<code><![CDATA[$this->cache->flush()]]></code>
129
</MixedReturnStatement>
1310
<PossiblyInvalidPropertyAssignmentValue>
14-
<code><![CDATA[$tags ? $cache->tags($tags) : $cache]]></code>
11+
<code><![CDATA[($tags === [] || !$cache->supportsTags()) ? $cache : $cache->tags($tags)]]></code>
1512
</PossiblyInvalidPropertyAssignmentValue>
1613
</file>
1714
<file src="src/Console/Clear.php">
15+
<DeprecatedMethod>
16+
<code><![CDATA[fire]]></code>
17+
</DeprecatedMethod>
1818
<InvalidReturnStatement>
1919
<code><![CDATA[$this->output->error('Default cache system does not support tags')]]></code>
2020
</InvalidReturnStatement>
@@ -32,11 +32,11 @@
3232
<code><![CDATA[Clear]]></code>
3333
<code><![CDATA[Clear]]></code>
3434
</PropertyNotSetInConstructor>
35-
<UndefinedFunction>
36-
<code><![CDATA[config('cache.default')]]></code>
37-
</UndefinedFunction>
3835
</file>
3936
<file src="src/Console/Update.php">
37+
<DeprecatedMethod>
38+
<code><![CDATA[fire]]></code>
39+
</DeprecatedMethod>
4040
<MixedArgument>
4141
<code><![CDATA[$result]]></code>
4242
<code><![CDATA[$service]]></code>
@@ -58,13 +58,28 @@
5858
<code><![CDATA[Update]]></code>
5959
</PropertyNotSetInConstructor>
6060
</file>
61+
<file src="src/Contracts/ServiceInterface.php">
62+
<InvalidParamDefault>
63+
<code><![CDATA[LocationArray]]></code>
64+
<code><![CDATA[LocationArray]]></code>
65+
</InvalidParamDefault>
66+
</file>
6167
<file src="src/GeoIP.php">
68+
<DeprecatedConstant>
69+
<code><![CDATA[Logger::ERROR]]></code>
70+
</DeprecatedConstant>
71+
<DeprecatedMethod>
72+
<code><![CDATA[setPrefix]]></code>
73+
</DeprecatedMethod>
74+
<DeprecatedProperty>
75+
<code><![CDATA[$this->remote_ip]]></code>
76+
<code><![CDATA[$this->remote_ip]]></code>
77+
</DeprecatedProperty>
6278
<DocblockTypeContradiction>
6379
<code><![CDATA[$this->currencies === null]]></code>
6480
<code><![CDATA[$this->service === null]]></code>
6581
</DocblockTypeContradiction>
6682
<InvalidPropertyAssignmentValue>
67-
<code><![CDATA[$this->default_location['ip'] = $this->getClientIP()]]></code>
6883
<code><![CDATA[new Cache(
6984
$cache,
7085
$this->config('cache_tags'),
@@ -86,18 +101,18 @@
86101
<code><![CDATA[$this->config('cache_tags')]]></code>
87102
<code><![CDATA[$this->config('default_location', [])]]></code>
88103
</MixedArgument>
104+
<MixedArgumentTypeCoercion>
105+
<code><![CDATA[$this->default_location]]></code>
106+
</MixedArgumentTypeCoercion>
89107
<MixedAssignment>
90108
<code><![CDATA[$class]]></code>
91109
<code><![CDATA[$config]]></code>
92-
<code><![CDATA[$log]]></code>
93110
</MixedAssignment>
94111
<MixedInferredReturnType>
95112
<code><![CDATA[string]]></code>
96113
</MixedInferredReturnType>
97114
<MixedMethodCall>
98-
<code><![CDATA[error]]></code>
99115
<code><![CDATA[new $class($config)]]></code>
100-
<code><![CDATA[pushHandler]]></code>
101116
</MixedMethodCall>
102117
<MixedOperand>
103118
<code><![CDATA[$this->config('service')]]></code>
@@ -108,34 +123,25 @@
108123
<MoreSpecificReturnType>
109124
<code><![CDATA[\InteractionDesignFoundation\GeoIP\Contracts\ServiceInterface]]></code>
110125
</MoreSpecificReturnType>
111-
<PossiblyInvalidArgument>
112-
<code><![CDATA[$ip]]></code>
113-
<code><![CDATA[$ip]]></code>
114-
<code><![CDATA[$ip]]></code>
115-
</PossiblyInvalidArgument>
116126
<PossiblyNullArgument>
117127
<code><![CDATA[$ip]]></code>
118128
<code><![CDATA[$location->iso_code]]></code>
119129
</PossiblyNullArgument>
120130
<PossiblyNullPropertyAssignmentValue>
121131
<code><![CDATA[null]]></code>
122132
<code><![CDATA[null]]></code>
123-
<code><![CDATA[null]]></code>
124133
</PossiblyNullPropertyAssignmentValue>
125134
<PropertyNotSetInConstructor>
126135
<code><![CDATA[$service]]></code>
127136
</PropertyNotSetInConstructor>
128137
<PropertyTypeCoercion>
129138
<code><![CDATA[new $class($config)]]></code>
130139
</PropertyTypeCoercion>
131-
<RedundantCondition>
132-
<code><![CDATA['some']]></code>
133-
</RedundantCondition>
134-
<UndefinedClass>
135-
<code><![CDATA[Logger]]></code>
136-
<code><![CDATA[Logger]]></code>
137-
<code><![CDATA[StreamHandler]]></code>
138-
</UndefinedClass>
140+
<RiskyTruthyFalsyComparison>
141+
<code><![CDATA[! $location->currency]]></code>
142+
<code><![CDATA[$address = getenv($key)]]></code>
143+
<code><![CDATA[$ip]]></code>
144+
</RiskyTruthyFalsyComparison>
139145
</file>
140146
<file src="src/GeoIPServiceProvider.php">
141147
<MissingClosureParamType>
@@ -154,11 +160,11 @@
154160
<MixedPropertyFetch>
155161
<code><![CDATA[$app->config]]></code>
156162
</MixedPropertyFetch>
157-
<UndefinedFunction>
158-
<code><![CDATA[config_path('geoip.php')]]></code>
159-
</UndefinedFunction>
160163
</file>
161164
<file src="src/Location.php">
165+
<InvalidParamDefault>
166+
<code><![CDATA[LocationArray]]></code>
167+
</InvalidParamDefault>
162168
<MissingParamType>
163169
<code><![CDATA[$key]]></code>
164170
<code><![CDATA[$value]]></code>
@@ -189,30 +195,31 @@
189195
<code><![CDATA[$this->config('continent_path')]]></code>
190196
<code><![CDATA[$this->config('continent_path')]]></code>
191197
</MixedArgument>
198+
<MixedArgumentTypeCoercion>
199+
<code><![CDATA[[
200+
'ip' => $ip,
201+
'iso_code' => $json->countryCode,
202+
'country' => $json->country,
203+
'city' => $json->city,
204+
'state' => $json->region,
205+
'state_name' => $json->regionName,
206+
'postal_code' => $json->zip,
207+
'lat' => $json->lat,
208+
'lon' => $json->lon,
209+
'timezone' => $json->timezone,
210+
'continent' => $this->getContinent($json->countryCode),
211+
]]]></code>
212+
</MixedArgumentTypeCoercion>
192213
<MixedAssignment>
193214
<code><![CDATA[$base['query']['key']]]></code>
194-
<code><![CDATA[$json]]></code>
195215
<code><![CDATA[$path]]></code>
196216
<code><![CDATA[$this->continents]]></code>
197217
</MixedAssignment>
198218
<MixedInferredReturnType>
199219
<code><![CDATA[string]]></code>
200220
</MixedInferredReturnType>
201-
<MixedOperand>
202-
<code><![CDATA[$json->message]]></code>
203-
</MixedOperand>
204221
<MixedPropertyFetch>
205-
<code><![CDATA[$json->city]]></code>
206-
<code><![CDATA[$json->country]]></code>
207-
<code><![CDATA[$json->countryCode]]></code>
208-
<code><![CDATA[$json->lat]]></code>
209-
<code><![CDATA[$json->lon]]></code>
210222
<code><![CDATA[$json->message]]></code>
211-
<code><![CDATA[$json->region]]></code>
212-
<code><![CDATA[$json->regionName]]></code>
213-
<code><![CDATA[$json->status]]></code>
214-
<code><![CDATA[$json->timezone]]></code>
215-
<code><![CDATA[$json->zip]]></code>
216223
</MixedPropertyFetch>
217224
<MixedReturnStatement>
218225
<code><![CDATA[Arr::get($this->continents, $code, 'Unknown')]]></code>
@@ -235,6 +242,22 @@
235242
<code><![CDATA[$json]]></code>
236243
<code><![CDATA[$json]]></code>
237244
</MixedArgument>
245+
<MixedArgumentTypeCoercion>
246+
<code><![CDATA[[
247+
'ip' => $ip,
248+
'iso_code' => $json['country_code'],
249+
'country' => $json['country_name'],
250+
'city' => $json['city'],
251+
'state' => $json['region_code'],
252+
'state_name' => $json['region'],
253+
'postal_code' => $json['postal'],
254+
'lat' => $json['latitude'],
255+
'lon' => $json['longitude'],
256+
'timezone' => Arr::get($json, 'time_zone.name'),
257+
'continent' => Arr::get($json, 'continent_code'),
258+
'currency' => Arr::get($json, 'currency.code'),
259+
]]]></code>
260+
</MixedArgumentTypeCoercion>
238261
<MixedArrayAccess>
239262
<code><![CDATA[$json['city']]]></code>
240263
<code><![CDATA[$json['country_code']]]></code>
@@ -280,52 +303,64 @@
280303
</RedundantConditionGivenDocblockType>
281304
</file>
282305
<file src="src/Services/MaxMindDatabase.php">
283-
<ImplicitToStringCast>
284-
<code><![CDATA[$file]]></code>
285-
</ImplicitToStringCast>
286-
<MissingClosureParamType>
287-
<code><![CDATA[$directory]]></code>
288-
</MissingClosureParamType>
306+
<InvalidReturnStatement>
307+
<code><![CDATA[$localizations]]></code>
308+
</InvalidReturnStatement>
309+
<InvalidReturnType>
310+
<code><![CDATA[array<string, string|null>]]></code>
311+
</InvalidReturnType>
289312
<MixedArgument>
290-
<code><![CDATA[$directory]]></code>
291-
<code><![CDATA[$directory]]></code>
292-
<code><![CDATA[$path]]></code>
293-
<code><![CDATA[$path]]></code>
294-
<code><![CDATA[$path]]></code>
295-
<code><![CDATA[$path]]></code>
313+
<code><![CDATA[$lang]]></code>
314+
<code><![CDATA[$lang]]></code>
315+
<code><![CDATA[$lang]]></code>
296316
<code><![CDATA[$this->config('database_path')]]></code>
297317
<code><![CDATA[$this->config('locales', ['en'])]]></code>
298318
<code><![CDATA[$this->config('update_url')]]></code>
299319
</MixedArgument>
320+
<MixedArrayOffset>
321+
<code><![CDATA[$localizations[$lang]]]></code>
322+
<code><![CDATA[$localizations[$lang]]]></code>
323+
<code><![CDATA[$localizations[$lang]]]></code>
324+
</MixedArrayOffset>
300325
<MixedAssignment>
301-
<code><![CDATA[$file]]></code>
302-
<code><![CDATA[$path]]></code>
326+
<code><![CDATA[$lang]]></code>
327+
<code><![CDATA[$localizations[$lang]['city']]]></code>
328+
<code><![CDATA[$localizations[$lang]['country']]]></code>
329+
<code><![CDATA[$localizations[$lang]['state_name']]]></code>
303330
</MixedAssignment>
304-
<MixedMethodCall>
305-
<code><![CDATA[getFilename]]></code>
306-
</MixedMethodCall>
307-
<PossiblyInvalidMethodCall>
308-
<code><![CDATA[getPathName]]></code>
309-
<code><![CDATA[isDir]]></code>
310-
</PossiblyInvalidMethodCall>
311331
</file>
312332
<file src="src/Services/MaxMindWebService.php">
333+
<InvalidReturnStatement>
334+
<code><![CDATA[$localizations]]></code>
335+
</InvalidReturnStatement>
336+
<InvalidReturnType>
337+
<code><![CDATA[array<string, string|null>]]></code>
338+
</InvalidReturnType>
313339
<MixedArgument>
340+
<code><![CDATA[$lang]]></code>
341+
<code><![CDATA[$lang]]></code>
342+
<code><![CDATA[$lang]]></code>
314343
<code><![CDATA[$this->config('license_key')]]></code>
315344
<code><![CDATA[$this->config('locales', ['en'])]]></code>
316345
<code><![CDATA[$this->config('user_id')]]></code>
317346
</MixedArgument>
347+
<MixedArrayOffset>
348+
<code><![CDATA[$localizations[$lang]]]></code>
349+
<code><![CDATA[$localizations[$lang]]]></code>
350+
<code><![CDATA[$localizations[$lang]]]></code>
351+
</MixedArrayOffset>
352+
<MixedAssignment>
353+
<code><![CDATA[$lang]]></code>
354+
<code><![CDATA[$localizations[$lang]['city']]]></code>
355+
<code><![CDATA[$localizations[$lang]['country']]]></code>
356+
<code><![CDATA[$localizations[$lang]['state_name']]]></code>
357+
</MixedAssignment>
318358
</file>
319359
<file src="src/Support/HttpClient.php">
320360
<DocblockTypeContradiction>
321361
<code><![CDATA[is_null($this->errors)]]></code>
322362
</DocblockTypeContradiction>
323-
<InvalidScalarArgument>
324-
<code><![CDATA[$response]]></code>
325-
<code><![CDATA[$response]]></code>
326-
</InvalidScalarArgument>
327363
<MixedArgument>
328-
<code><![CDATA[$header_size]]></code>
329364
<code><![CDATA[$header_size]]></code>
330365
<code><![CDATA[Arr::get($this->config, 'headers', [])]]></code>
331366
<code><![CDATA[Arr::get($this->config, 'query', [])]]></code>
@@ -342,10 +377,13 @@
342377
<code><![CDATA[null]]></code>
343378
<code><![CDATA[null]]></code>
344379
</PossiblyNullPropertyAssignmentValue>
380+
<RiskyTruthyFalsyComparison>
381+
<code><![CDATA[strpos($url, '?')]]></code>
382+
</RiskyTruthyFalsyComparison>
345383
</file>
346384
<file src="src/helpers.php">
347385
<MixedInferredReturnType>
348-
<code><![CDATA[\InteractionDesignFoundation\GeoIP\GeoIP|\InteractionDesignFoundation\GeoIP\Location]]></code>
386+
<code><![CDATA[($ip is null ? \InteractionDesignFoundation\GeoIP\GeoIP : \InteractionDesignFoundation\GeoIP\Location)]]></code>
349387
</MixedInferredReturnType>
350388
<MixedMethodCall>
351389
<code><![CDATA[getLocation]]></code>

src/Location.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
* currency?: string|null,
4343
* default?: bool,
4444
* cached?: bool,
45+
* localizations?: array<string, string|null>,
4546
* }
4647
* How to use it: @@psalm-import-type LocationArray from \InteractionDesignFoundation\GeoIP\Location
4748
*/

src/Services/MaxMindWebService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function locate($ip)
5151
'localizations' => $this->getLocalizations($record),
5252
]);
5353
}
54+
5455
/**
5556
* Get localized country name, state name and city name based on config languages
5657
* @return array<string, string|null>

0 commit comments

Comments
 (0)