Skip to content

Commit 0129026

Browse files
authored
Fix PHP 8.4 compatibility (#3)
1 parent 24736c0 commit 0129026

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/Concrete/Updater.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,13 @@ public function getCache()
102102
/**
103103
* Set the cache to be used.
104104
*
105+
* @param \Concrete\Core\Cache\Cache|null $cache
106+
*
105107
* @return $this
106108
*/
107-
public function setCache(Cache $cache = null)
109+
public function setCache($cache = null)
108110
{
109-
$this->cache = $cache;
111+
$this->cache = $cache instanceof Cache ? $cache : null;
110112

111113
return $this;
112114
}
@@ -188,12 +190,13 @@ protected function getCurrentLocalDatabaseMD5()
188190
* @param string $querystring
189191
* @param string $saveToFilename
190192
* @param string[] $userAndPassword
193+
* @param callable|null $validHttpStatusCodeChecker
191194
*
192195
* @throws \Concrete\Package\MaxmindGeolocator\Exception\HttpException
193196
*
194197
* @return array
195198
*/
196-
protected function performRequest($path, $querystring = '', $saveToFilename = '', array $userAndPassword = [], callable $validHttpStatusCodeChecker = null)
199+
protected function performRequest($path, $querystring = '', $saveToFilename = '', array $userAndPassword = [], $validHttpStatusCodeChecker = null)
197200
{
198201
$uri = 'https://' . $this->configuration->getHost() . '/' . ltrim($path, '/');
199202
if ($querystring !== '' && $querystring !== '?') {
@@ -209,10 +212,10 @@ protected function performRequest($path, $querystring = '', $saveToFilename = ''
209212
} catch (\Exception $x) {
210213
throw new HttpException($x->getMessage());
211214
}
212-
if ($validHttpStatusCodeChecker === null) {
213-
$ok = 200 <= $response['statusCode'] && $response['statusCode'] < 300;
214-
} else {
215+
if (is_callable($validHttpStatusCodeChecker)) {
215216
$ok = $validHttpStatusCodeChecker($response['statusCode']);
217+
} else {
218+
$ok = 200 <= $response['statusCode'] && $response['statusCode'] < 300;
216219
}
217220
if (!$ok) {
218221
$failureReason = $response['reasonPhrase'];

0 commit comments

Comments
 (0)