Skip to content

Commit 797bf69

Browse files
committed
refactor: fix minor type inaccuracies found via PHPStan bleeding edge
1 parent 17b02c4 commit 797bf69

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

system/Database/Database.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function load(array $params = [], string $alias = '')
5858
throw new InvalidArgumentException('You have not selected a database type to connect to.');
5959
}
6060

61-
assert($this->checkDbExtension($params['DBDriver']));
61+
$this->checkDbExtension($params['DBDriver']);
6262

6363
$this->connections[$alias] = $this->initDriver($params['DBDriver'], 'Connection', $params);
6464

@@ -158,11 +158,11 @@ protected function initDriver(string $driver, string $class, $argument): object
158158
*
159159
* @param string $driver DB driver or FQCN for custom driver
160160
*/
161-
private function checkDbExtension(string $driver): bool
161+
private function checkDbExtension(string $driver): void
162162
{
163163
if (str_contains($driver, '\\')) {
164164
// Cannot check a fully qualified classname for a custom driver.
165-
return true;
165+
return;
166166
}
167167

168168
$extensionMap = [
@@ -183,7 +183,7 @@ private function checkDbExtension(string $driver): bool
183183
}
184184

185185
if (extension_loaded($extension)) {
186-
return true;
186+
return;
187187
}
188188

189189
$message = 'The required PHP extension "' . $extension . '" is not loaded.'

system/HTTP/Files/FileCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ protected function createFileObject(array $array)
189189

190190
return new UploadedFile(
191191
$array['tmp_name'] ?? null,
192-
$array['name'] ?? null,
192+
$array['name'],
193193
$array['type'] ?? null,
194194
($array['size'] ?? null) === null ? null : (int) $array['size'],
195195
$array['error'] ?? null,

system/HTTP/SiteURIFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ private function createURIFromRoutePath(string $routePath): SiteURI
227227
*/
228228
private function getHost(): ?string
229229
{
230-
$httpHostPort = $this->superglobals->server('HTTP_HOST') ?? null;
230+
$httpHostPort = $this->superglobals->server('HTTP_HOST');
231231

232232
if ($httpHostPort !== null) {
233233
[$httpHost] = explode(':', $httpHostPort, 2);

system/Helpers/Array/ArrayHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public static function recursiveCount(array $array, int $counter = 0): int
324324
* @param list<int|list<int|string>|string> $array
325325
* @param int|string|null $sortByIndex
326326
*/
327-
public static function sortValuesByNatural(array &$array, $sortByIndex = null): bool
327+
public static function sortValuesByNatural(array &$array, $sortByIndex = null): true
328328
{
329329
return usort($array, static function ($currentValue, $nextValue) use ($sortByIndex): int {
330330
if ($sortByIndex !== null) {

system/Router/RouteCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,7 @@ private function checkSubdomains($subdomains): bool
15201520

15211521
// Routes can be limited to any sub-domain. In that case, though,
15221522
// it does require a sub-domain to be present.
1523-
if (! in_array($this->currentSubdomain, [null, ''], true) && in_array('*', $subdomains, true)) {
1523+
if ($this->currentSubdomain !== '' && in_array('*', $subdomains, true)) {
15241524
return true;
15251525
}
15261526

0 commit comments

Comments
 (0)