Skip to content

Commit da1d714

Browse files
authored
Merge pull request #29 from InteractionDesignFoundation/fix-type-issue
MaxMindDatabase: Fix type issue caused by strict mode
2 parents dfdcdae + fe5fbf4 commit da1d714

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

psalm-baseline.xml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -313,29 +313,11 @@
313313
</RedundantConditionGivenDocblockType>
314314
</file>
315315
<file src="src/Services/MaxMindDatabase.php">
316-
<MissingClosureParamType>
317-
<code><![CDATA[$directory]]></code>
318-
</MissingClosureParamType>
319316
<MixedArgument>
320-
<code><![CDATA[$directory]]></code>
321-
<code><![CDATA[$directory]]></code>
322317
<code><![CDATA[$this->config('database_path')]]></code>
323318
<code><![CDATA[$this->config('locales', ['en'])]]></code>
324319
<code><![CDATA[$this->config('update_url')]]></code>
325320
</MixedArgument>
326-
<MixedAssignment>
327-
<code><![CDATA[$file]]></code>
328-
</MixedAssignment>
329-
<MixedMethodCall>
330-
<code><![CDATA[getFilename]]></code>
331-
</MixedMethodCall>
332-
<PossiblyInvalidArgument>
333-
<code><![CDATA[$file]]></code>
334-
</PossiblyInvalidArgument>
335-
<PossiblyInvalidMethodCall>
336-
<code><![CDATA[getPathName]]></code>
337-
<code><![CDATA[isDir]]></code>
338-
</PossiblyInvalidMethodCall>
339321
</file>
340322
<file src="src/Services/MaxMindWebService.php">
341323
<MixedArgument>

src/Services/MaxMindDatabase.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function update()
7474
throw new \Exception('Database path not set in config file.');
7575
}
7676

77-
$this->withTemporaryDirectory(function ($directory) {
77+
$this->withTemporaryDirectory(function ($directory): void {
7878
$tarFile = sprintf('%s/maxmind.tar.gz', $directory);
7979

8080
file_put_contents($tarFile, fopen($this->config('update_url'), 'rb'));
@@ -97,7 +97,7 @@ public function update()
9797
* Provide a temporary directory to perform operations in
9898
* and ensure it is removed afterward.
9999
*
100-
* @param callable $callback
100+
* @param callable(string):void $callback
101101
*
102102
* @return void
103103
*/
@@ -125,17 +125,18 @@ protected function withTemporaryDirectory(callable $callback)
125125
*
126126
* @param \PharData $archive
127127
*
128-
* @return mixed
128+
* @return \PharFileInfo
129129
* @throws \Exception
130130
*/
131-
protected function findDatabaseFile($archive)
131+
protected function findDatabaseFile(\PharData $archive)
132132
{
133+
/** @var \PharFileInfo $file */
133134
foreach ($archive as $file) {
134135
if ($file->isDir()) {
135136
return $this->findDatabaseFile(new \PharData($file->getPathName()));
136137
}
137138

138-
if (pathinfo($file, \PATHINFO_EXTENSION) === 'mmdb') {
139+
if (pathinfo($file->getPathName(), \PATHINFO_EXTENSION) === 'mmdb') {
139140
return $file;
140141
}
141142
}

0 commit comments

Comments
 (0)