Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions system/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function load(array $params = [], string $alias = '')
throw new InvalidArgumentException('You have not selected a database type to connect to.');
}

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

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

Expand Down Expand Up @@ -154,15 +154,17 @@ protected function initDriver(string $driver, string $class, $argument): object
}

/**
* Check the PHP database extension is loaded.
* Check if the PHP database extension is loaded.
*
* @param string $driver DB driver or FQCN for custom driver
*
* @throws ConfigException if the driver is invalid
* @throws CriticalError if the required PHP extension is not loaded
*/
private function checkDbExtension(string $driver): bool
private function checkDbExtension(string $driver): void
{
if (str_contains($driver, '\\')) {
// Cannot check a fully qualified classname for a custom driver.
return true;
return; // Cannot check a fully qualified classname for a custom driver.
}

$extensionMap = [
Expand All @@ -174,21 +176,17 @@ private function checkDbExtension(string $driver): bool
'OCI8' => 'oci8',
];

$extension = $extensionMap[$driver] ?? '';

if ($extension === '') {
$message = 'Invalid DBDriver name: "' . $driver . '"';

throw new ConfigException($message);
}
$extension = $extensionMap[$driver]
?? throw new ConfigException(sprintf('Invalid DBDriver name: "%s".', $driver));

if (extension_loaded($extension)) {
return true;
return;
}

$message = 'The required PHP extension "' . $extension . '" is not loaded.'
. ' Install and enable it to use "' . $driver . '" driver.';

throw new CriticalError($message);
throw new CriticalError(sprintf(
'The required PHP extension "%s" is not loaded. Install and enable it to use "%s" driver.',
$extension,
$driver,
));
}
}
2 changes: 1 addition & 1 deletion system/HTTP/Files/FileCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected function createFileObject(array $array)

return new UploadedFile(
$array['tmp_name'] ?? null,
$array['name'] ?? null,
$array['name'],
$array['type'] ?? null,
($array['size'] ?? null) === null ? null : (int) $array['size'],
$array['error'] ?? null,
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/SiteURIFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private function createURIFromRoutePath(string $routePath): SiteURI
*/
private function getHost(): ?string
{
$httpHostPort = $this->superglobals->server('HTTP_HOST') ?? null;
$httpHostPort = $this->superglobals->server('HTTP_HOST');

if ($httpHostPort !== null) {
[$httpHost] = explode(':', $httpHostPort, 2);
Expand Down
2 changes: 1 addition & 1 deletion system/Helpers/Array/ArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public static function recursiveCount(array $array, int $counter = 0): int
* @param list<int|list<int|string>|string> $array
* @param int|string|null $sortByIndex
*/
public static function sortValuesByNatural(array &$array, $sortByIndex = null): bool
public static function sortValuesByNatural(array &$array, $sortByIndex = null): true
{
return usort($array, static function ($currentValue, $nextValue) use ($sortByIndex): int {
if ($sortByIndex !== null) {
Expand Down
2 changes: 1 addition & 1 deletion system/Router/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@ private function checkSubdomains($subdomains): bool

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

Expand Down
Loading