Merge pull request #9416 from codeigniter4/develop

4.5.8 Ready code
This commit is contained in:
John Paul E. Balandan, CPA 2025-01-20 00:04:36 +08:00 committed by GitHub
commit 195c0dac03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
332 changed files with 1593 additions and 1442 deletions

51
.github/mergeable.yml vendored
View File

@ -2,40 +2,33 @@
version: 2 version: 2
mergeable: mergeable:
- when: issues.opened - when: issues.opened, issues.reopened
validate: validate:
- do: description - do: or
and: validate:
- must_include: - do: and
regex: '^### PHP Version' validate:
- must_include: - do: description
regex: '^### CodeIgniter4 Version' must_include:
- do: author regex: '### PHP Version'
and: - do: description
- must_exclude: must_include:
regex: 'kenjis' regex: '### CodeIgniter4 Version'
- must_exclude: - do: author
regex: 'lonnieezell' must_include:
- must_exclude: regex: ^kenjis|lonnieezell|MGatner|michalsn|paulbalandan|samsonasik$
regex: 'MGatner'
- must_exclude:
regex: 'michalsn'
- must_exclude:
regex: 'paulbalandan'
- must_exclude:
regex: 'samsonasik'
fail: fail:
- do: comment - do: comment
payload: | payload:
Hi there! :wave: body: |
Hi there, @@author! :wave:
It looks like you opened an issue without following the bug report template: It looks like you opened an issue without following the bug report template:
Bug report ([open an issue](https://github.com/codeigniter4/CodeIgniter4/issues/new?assignees=&labels=bug&projects=&template=bug_report.yml&title=Bug%3A+)) * Bug report ([open an issue](https://github.com/codeigniter4/CodeIgniter4/issues/new?assignees=&labels=bug&projects=&template=bug_report.yml&title=Bug%3A+))
* For feature request or support question, please use the [forums](https://forum.codeigniter.com/forum-30.html).
If you are opening a feature request or support question, please do so in the [forums](https://forum.codeigniter.com/forum-30.html). The current issue will be closed. This is a precaution to save maintainers' time, I hope you'll understand.
The current issue will be closed. This is a precaution to save maintainers' time, I hope you'll understand. Sincerely, the mergeable bot 🤖
Sincerely, the mergeable bot 🤖
- do: close - do: close

View File

@ -39,7 +39,9 @@ $finder = Finder::create()
__DIR__ . '/spark', __DIR__ . '/spark',
]); ]);
$overrides = []; $overrides = [
'modernize_strpos' => ['modernize_stripos' => true],
];
$options = [ $options = [
'cacheFile' => 'build/.php-cs-fixer.cache', 'cacheFile' => 'build/.php-cs-fixer.cache',
@ -53,5 +55,5 @@ $options = [
return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary( return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary(
'CodeIgniter 4 framework', 'CodeIgniter 4 framework',
'CodeIgniter Foundation', 'CodeIgniter Foundation',
'admin@codeigniter.com' 'admin@codeigniter.com',
); );

View File

@ -1,5 +1,32 @@
# Changelog # Changelog
## [v4.5.8](https://github.com/codeigniter4/CodeIgniter4/tree/v4.5.8) (2025-01-19)
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.5.7...v4.5.8)
### Security
* **HTTP** *Validation of header name and value*: Fixed a potential vulnerability on lack of proper header validation
for its name and value. See the [security advisory](https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-x5mq-jjr3-vmx6)
for more information. Credits to @neznaika0 for reporting.
* **Security** fix: ensure csrf token is string by @datlechin in https://github.com/codeigniter4/CodeIgniter4/pull/9365
### Fixed Bugs
* fix: gather affected rows after query call failed by @michalsn in https://github.com/codeigniter4/CodeIgniter4/pull/9363
### Refactoring
* refactor: use more strict result check on preg_match_all() result by @samsonasik in https://github.com/codeigniter4/CodeIgniter4/pull/9361
* refactor: Fix phpstan if.condNotBoolean by @neznaika0 in https://github.com/codeigniter4/CodeIgniter4/pull/9368
* refactor: Fix phpstan when delete string key by @neznaika0 in https://github.com/codeigniter4/CodeIgniter4/pull/9369
* refactor: Fix phpstan greaterOrEqual.invalid by @neznaika0 in https://github.com/codeigniter4/CodeIgniter4/pull/9370
* refactor: Fix phpstan nullCoalesce by @neznaika0 in https://github.com/codeigniter4/CodeIgniter4/pull/9374
* refactor: Fix phpstan isset offset by @neznaika0 in https://github.com/codeigniter4/CodeIgniter4/pull/9383
* refactor: Fix phpstan return.missing by @neznaika0 in https://github.com/codeigniter4/CodeIgniter4/pull/9382
* refactor: Fix phpstan booleanAnd.rightAlwaysTrue by @neznaika0 in https://github.com/codeigniter4/CodeIgniter4/pull/9367
* refactor: Fix phpstan codeigniter.configArgumentInstanceof by @neznaika0 in https://github.com/codeigniter4/CodeIgniter4/pull/9390
* refactor: Use `strtolower` with `str_contains`/`str_**_with` as replacement for `stripos` by @paulbalandan in https://github.com/codeigniter4/CodeIgniter4/pull/9414
## [v4.5.7](https://github.com/codeigniter4/CodeIgniter4/tree/v4.5.7) (2024-12-31) ## [v4.5.7](https://github.com/codeigniter4/CodeIgniter4/tree/v4.5.7) (2024-12-31)
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.5.6...v4.5.7) [Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.5.6...v4.5.7)

View File

@ -1,7 +1,7 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2014-2019 British Columbia Institute of Technology Copyright (c) 2014-2019 British Columbia Institute of Technology
Copyright (c) 2019-2024 CodeIgniter Foundation Copyright (c) 2019-present CodeIgniter Foundation
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -47,7 +47,7 @@ if ($isMinorUpdate) {
replace_file_content( replace_file_content(
$changelogIndex, $changelogIndex,
'/\.\. toctree::\n :titlesonly:\n/u', '/\.\. toctree::\n :titlesonly:\n/u',
".. toctree::\n :titlesonly:\n\n v{$version}" ".. toctree::\n :titlesonly:\n\n v{$version}",
); );
// Replace {version} // Replace {version}
$length = mb_strlen("Version {$version}"); $length = mb_strlen("Version {$version}");
@ -55,12 +55,12 @@ $underline = str_repeat('#', $length);
replace_file_content( replace_file_content(
$changelog, $changelog,
'/#################\nVersion {version}\n#################/u', '/#################\nVersion {version}\n#################/u',
"{$underline}\nVersion {$version}\n{$underline}" "{$underline}\nVersion {$version}\n{$underline}",
); );
replace_file_content( replace_file_content(
$changelog, $changelog,
'/{version}/u', '/{version}/u',
"{$version}" "{$version}",
); );
// Copy upgrading // Copy upgrading
@ -72,7 +72,7 @@ copy('./admin/next-upgrading-guide.rst', $upgrading);
replace_file_content( replace_file_content(
$upgradingIndex, $upgradingIndex,
'/ backward_compatibility_notes\n/u', '/ backward_compatibility_notes\n/u',
" backward_compatibility_notes\n\n upgrade_{$versionWithoutDots}" " backward_compatibility_notes\n\n upgrade_{$versionWithoutDots}",
); );
// Replace {version} // Replace {version}
$length = mb_strlen("Upgrading from {$versionCurrent} to {$version}"); $length = mb_strlen("Upgrading from {$versionCurrent} to {$version}");
@ -80,7 +80,7 @@ $underline = str_repeat('#', $length);
replace_file_content( replace_file_content(
$upgrading, $upgrading,
'/##############################\nUpgrading from {version} to {version}\n##############################/u', '/##############################\nUpgrading from {version} to {version}\n##############################/u',
"{$underline}\nUpgrading from {$versionCurrent} to {$version}\n{$underline}" "{$underline}\nUpgrading from {$versionCurrent} to {$version}\n{$underline}",
); );
// Commits // Commits

View File

@ -33,31 +33,31 @@ system('git switch -c release-' . $version);
replace_file_content( replace_file_content(
'./system/CodeIgniter.php', './system/CodeIgniter.php',
'/public const CI_VERSION = \'.*?\';/u', '/public const CI_VERSION = \'.*?\';/u',
"public const CI_VERSION = '{$version}';" "public const CI_VERSION = '{$version}';",
); );
// Updates version number in "conf.py". // Updates version number in "conf.py".
replace_file_content( replace_file_content(
'./user_guide_src/source/conf.py', './user_guide_src/source/conf.py',
'/^version = \'.*?\'/mu', '/^version = \'.*?\'/mu',
"version = '{$minor}'" "version = '{$minor}'",
); );
replace_file_content( replace_file_content(
'./user_guide_src/source/conf.py', './user_guide_src/source/conf.py',
'/^release = \'.*?\'/mu', '/^release = \'.*?\'/mu',
"release = '{$version}'" "release = '{$version}'",
); );
// Updates version number in "phpdoc.dist.xml". // Updates version number in "phpdoc.dist.xml".
replace_file_content( replace_file_content(
'./phpdoc.dist.xml', './phpdoc.dist.xml',
'!<title>CodeIgniter v.*? API</title>!mu', '!<title>CodeIgniter v.*? API</title>!mu',
"<title>CodeIgniter v{$minor} API</title>" "<title>CodeIgniter v{$minor} API</title>",
); );
replace_file_content( replace_file_content(
'./phpdoc.dist.xml', './phpdoc.dist.xml',
'/<version number=".*?">/mu', '/<version number=".*?">/mu',
"<version number=\"{$version}\">" "<version number=\"{$version}\">",
); );
// Updates release date in changelogs. // Updates release date in changelogs.
@ -65,7 +65,7 @@ $date = date('F j, Y');
replace_file_content( replace_file_content(
"./user_guide_src/source/changelogs/v{$version}.rst", "./user_guide_src/source/changelogs/v{$version}.rst",
'/^Release Date: .*/mu', '/^Release Date: .*/mu',
"Release Date: {$date}" "Release Date: {$date}",
); );
// Commits // Commits

View File

@ -32,7 +32,7 @@ final class HealthTest extends CIUnitTestCase
$config = new App(); $config = new App();
$this->assertTrue( $this->assertTrue(
$validation->check($config->baseURL, 'valid_url'), $validation->check($config->baseURL, 'valid_url'),
'baseURL "' . $config->baseURL . '" in .env is not valid URL' 'baseURL "' . $config->baseURL . '" in .env is not valid URL',
); );
} }
@ -43,7 +43,7 @@ final class HealthTest extends CIUnitTestCase
// BaseURL in app/Config/App.php is a valid URL? // BaseURL in app/Config/App.php is a valid URL?
$this->assertTrue( $this->assertTrue(
$validation->check($reader->baseURL, 'valid_url'), $validation->check($reader->baseURL, 'valid_url'),
'baseURL "' . $reader->baseURL . '" in app/Config/App.php is not valid URL' 'baseURL "' . $reader->baseURL . '" in app/Config/App.php is not valid URL',
); );
} }
} }

View File

@ -28,7 +28,7 @@
"phpunit/phpcov": "^9.0.2 || ^10.0", "phpunit/phpcov": "^9.0.2 || ^10.0",
"phpunit/phpunit": "^10.5.16 || ^11.2", "phpunit/phpunit": "^10.5.16 || ^11.2",
"predis/predis": "^1.1 || ^2.0", "predis/predis": "^1.1 || ^2.0",
"rector/rector": "2.0.4", "rector/rector": "2.0.6",
"shipmonk/phpstan-baseline-per-identifier": "^2.0" "shipmonk/phpstan-baseline-per-identifier": "^2.0"
}, },
"replace": { "replace": {

View File

@ -10,7 +10,7 @@
<output>api/build/</output> <output>api/build/</output>
<cache>api/cache/</cache> <cache>api/cache/</cache>
</paths> </paths>
<version number="4.5.7"> <version number="4.5.8">
<api format="php"> <api format="php">
<source dsn="."> <source dsn=".">
<path>system</path> <path>system</path>

View File

@ -11,7 +11,6 @@
failOnWarning="true" failOnWarning="true"
cacheDirectory="build/.phpunit.cache"> cacheDirectory="build/.phpunit.cache">
<coverage <coverage
includeUncoveredFiles="true"
pathCoverage="false" pathCoverage="false"
ignoreDeprecatedCodeUnits="true" ignoreDeprecatedCodeUnits="true"
disableCodeCoverageIgnore="true"> disableCodeCoverageIgnore="true">

View File

@ -86,7 +86,7 @@ class preload
$phpFiles = new RegexIterator( $phpFiles = new RegexIterator(
$fullTree, $fullTree,
'/.+((?<!Test)+\.php$)/i', '/.+((?<!Test)+\.php$)/i',
RecursiveRegexIterator::GET_MATCH RecursiveRegexIterator::GET_MATCH,
); );
foreach ($phpFiles as $key => $file) { foreach ($phpFiles as $key => $file) {

View File

@ -11,7 +11,7 @@ if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
$message = sprintf( $message = sprintf(
'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s', 'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s',
$minPhpVersion, $minPhpVersion,
PHP_VERSION PHP_VERSION,
); );
header('HTTP/1.1 503 Service Unavailable.', true, 503); header('HTTP/1.1 503 Service Unavailable.', true, 503);

View File

@ -62,7 +62,7 @@ return RectorConfig::configure()
->withCache( ->withCache(
// Github action cache or local // Github action cache or local
is_dir('/tmp') ? '/tmp/rector' : null, is_dir('/tmp') ? '/tmp/rector' : null,
FileCacheStorage::class FileCacheStorage::class,
) )
// paths to refactor; solid alternative to CLI arguments // paths to refactor; solid alternative to CLI arguments
->withPaths([ ->withPaths([

2
spark
View File

@ -40,7 +40,7 @@ if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
$message = sprintf( $message = sprintf(
'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s', 'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s',
$minPhpVersion, $minPhpVersion,
PHP_VERSION PHP_VERSION,
); );
exit($message); exit($message);

View File

@ -319,7 +319,7 @@ trait ResponseTrait
$mime = $this->request->negotiate( $mime = $this->request->negotiate(
'media', 'media',
$format->getConfig()->supportedResponseFormats, $format->getConfig()->supportedResponseFormats,
false false,
); );
} }

View File

@ -347,7 +347,7 @@ class Autoloader
throw new InvalidArgumentException( throw new InvalidArgumentException(
'The file path contains special characters "' . $chars 'The file path contains special characters "' . $chars
. '" that are not allowed: "' . $filename . '"' . '" that are not allowed: "' . $filename . '"',
); );
} }
if ($result === false) { if ($result === false) {
@ -386,7 +386,7 @@ class Autoloader
throw new RuntimeException( throw new RuntimeException(
'Your Composer version is too old.' 'Your Composer version is too old.'
. ' Please update Composer (run `composer self-update`) to v2.0.14 or later' . ' Please update Composer (run `composer self-update`) to v2.0.14 or later'
. ' and remove your vendor/ directory, and run `composer update`.' . ' and remove your vendor/ directory, and run `composer update`.',
); );
} }
// This method requires Composer 2.0.14 or later. // This method requires Composer 2.0.14 or later.

View File

@ -295,9 +295,9 @@ class FileLocator implements FileLocatorInterface
str_replace( str_replace(
'/', '/',
'\\', '\\',
mb_substr($path, mb_strlen($namespace['path'])) mb_substr($path, mb_strlen($namespace['path'])),
), ),
'\\' '\\',
); );
// Remove the file extension (.php) // Remove the file extension (.php)
$className = mb_substr($className, 0, -4); $className = mb_substr($className, 0, -4);

View File

@ -379,7 +379,7 @@ abstract class BaseModel
$this->converter = new DataConverter( $this->converter = new DataConverter(
$this->casts, $this->casts,
$this->castHandlers, $this->castHandlers,
$this->db $this->db,
); );
} }
} }
@ -1081,7 +1081,7 @@ abstract class BaseModel
if ($updateIndex === null) { if ($updateIndex === null) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
'The index ("' . $index . '") for updateBatch() is missing in the data: ' 'The index ("' . $index . '") for updateBatch() is missing in the data: '
. json_encode($row) . json_encode($row),
); );
} }

View File

@ -288,7 +288,7 @@ class Boot
$message = sprintf( $message = sprintf(
'The framework needs the following extension(s) installed and loaded: %s.', 'The framework needs the following extension(s) installed and loaded: %s.',
implode(', ', $missingExtensions) implode(', ', $missingExtensions),
); );
header('HTTP/1.1 503 Service Unavailable.', true, 503); header('HTTP/1.1 503 Service Unavailable.', true, 503);

View File

@ -289,7 +289,7 @@ class CLI
CLI::isZeroOptions($options); CLI::isZeroOptions($options);
if ($line = array_shift($text)) { if (($line = array_shift($text)) !== null) {
CLI::write($line); CLI::write($line);
} }
@ -348,7 +348,7 @@ class CLI
// return the prompt again if $input contain(s) non-numeric character, except a comma. // return the prompt again if $input contain(s) non-numeric character, except a comma.
// And if max from $options less than max from input, // And if max from $options less than max from input,
// it means user tried to access null value in $options // it means user tried to access null value in $options
if ($pattern === 0 || $maxOptions < $maxInput) { if ($pattern < 1 || $maxOptions < $maxInput) {
static::error('Please select correctly.'); static::error('Please select correctly.');
CLI::newLine(); CLI::newLine();
@ -610,11 +610,11 @@ class CLI
$nonColoredText = preg_replace( $nonColoredText = preg_replace(
$pattern, $pattern,
'<<__colored_string__>>', '<<__colored_string__>>',
$text $text,
); );
$nonColoredChunks = preg_split( $nonColoredChunks = preg_split(
'/<<__colored_string__>>/u', '/<<__colored_string__>>/u',
$nonColoredText $nonColoredText,
); );
foreach ($nonColoredChunks as $i => $chunk) { foreach ($nonColoredChunks as $i => $chunk) {

View File

@ -63,7 +63,7 @@ class Console
'CodeIgniter v%s Command Line Tool - Server Time: %s UTC%s', 'CodeIgniter v%s Command Line Tool - Server Time: %s UTC%s',
CodeIgniter::CI_VERSION, CodeIgniter::CI_VERSION,
date('Y-m-d H:i:s'), date('Y-m-d H:i:s'),
date('P') date('P'),
), 'green'); ), 'green');
CLI::newLine(); CLI::newLine();
} }

View File

@ -171,7 +171,7 @@ trait GeneratorTrait
CLI::prompt( CLI::prompt(
'Are you sure you want to continue?', 'Are you sure you want to continue?',
['y', 'n'], ['y', 'n'],
'required' 'required',
) === 'n' ) === 'n'
) { ) {
CLI::newLine(); CLI::newLine();
@ -193,7 +193,7 @@ trait GeneratorTrait
CLI::error( CLI::error(
lang('CLI.generator.fileExist', [clean_path($target)]), lang('CLI.generator.fileExist', [clean_path($target)]),
'light_gray', 'light_gray',
'red' 'red',
); );
CLI::newLine(); CLI::newLine();
@ -216,7 +216,7 @@ trait GeneratorTrait
CLI::error( CLI::error(
lang('CLI.generator.fileError', [clean_path($target)]), lang('CLI.generator.fileError', [clean_path($target)]),
'light_gray', 'light_gray',
'red' 'red',
); );
CLI::newLine(); CLI::newLine();
@ -227,7 +227,7 @@ trait GeneratorTrait
if ($this->getOption('force') && $isFile) { if ($this->getOption('force') && $isFile) {
CLI::write( CLI::write(
lang('CLI.generator.fileOverwrite', [clean_path($target)]), lang('CLI.generator.fileOverwrite', [clean_path($target)]),
'yellow' 'yellow',
); );
CLI::newLine(); CLI::newLine();
@ -236,7 +236,7 @@ trait GeneratorTrait
CLI::write( CLI::write(
lang('CLI.generator.fileCreate', [clean_path($target)]), lang('CLI.generator.fileCreate', [clean_path($target)]),
'green' 'green',
); );
CLI::newLine(); CLI::newLine();
} }
@ -326,10 +326,10 @@ trait GeneratorTrait
'\\', '\\',
array_map( array_map(
pascalize(...), pascalize(...),
explode('\\', str_replace('/', '\\', trim($class))) explode('\\', str_replace('/', '\\', trim($class))),
) ),
), ),
'\\/' '\\/',
); );
} }
@ -351,7 +351,7 @@ trait GeneratorTrait
return view( return view(
"CodeIgniter\\Commands\\Generators\\Views\\{$this->template}", "CodeIgniter\\Commands\\Generators\\Views\\{$this->template}",
$data, $data,
['debug' => false] ['debug' => false],
); );
} }
} }
@ -370,15 +370,15 @@ trait GeneratorTrait
string $class, string $class,
array $search = [], array $search = [],
array $replace = [], array $replace = [],
array $data = [] array $data = [],
): string { ): string {
// Retrieves the namespace part from the fully qualified class name. // Retrieves the namespace part from the fully qualified class name.
$namespace = trim( $namespace = trim(
implode( implode(
'\\', '\\',
array_slice(explode('\\', $class), 0, -1) array_slice(explode('\\', $class), 0, -1),
), ),
'\\' '\\',
); );
$search[] = '<@php'; $search[] = '<@php';
$search[] = '{namespace}'; $search[] = '{namespace}';
@ -404,7 +404,7 @@ trait GeneratorTrait
&& preg_match( && preg_match(
'/(?P<imports>(?:^use [^;]+;$\n?)+)/m', '/(?P<imports>(?:^use [^;]+;$\n?)+)/m',
$template, $template,
$match $match,
) )
) { ) {
$imports = explode("\n", trim($match['imports'])); $imports = explode("\n", trim($match['imports']));
@ -432,7 +432,7 @@ trait GeneratorTrait
CLI::error( CLI::error(
lang('CLI.namespaceNotDefined', [$namespace]), lang('CLI.namespaceNotDefined', [$namespace]),
'light_gray', 'light_gray',
'red' 'red',
); );
CLI::newLine(); CLI::newLine();
@ -446,7 +446,7 @@ trait GeneratorTrait
. str_replace( . str_replace(
'\\', '\\',
DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR,
trim(str_replace($namespace . '\\', '', $class), '\\') trim(str_replace($namespace . '\\', '', $class), '\\'),
) . '.php'; ) . '.php';
return implode( return implode(
@ -454,8 +454,8 @@ trait GeneratorTrait
array_slice( array_slice(
explode(DIRECTORY_SEPARATOR, $file), explode(DIRECTORY_SEPARATOR, $file),
0, 0,
-1 -1,
) ),
) . DIRECTORY_SEPARATOR . $this->basename($file); ) . DIRECTORY_SEPARATOR . $this->basename($file);
} }
@ -470,9 +470,9 @@ trait GeneratorTrait
str_replace( str_replace(
'/', '/',
'\\', '\\',
$this->getOption('namespace') ?? APP_NAMESPACE $this->getOption('namespace') ?? APP_NAMESPACE,
), ),
'\\' '\\',
); );
} }

View File

@ -85,7 +85,7 @@ class MemcachedHandler extends BaseHandler
$this->memcached->addServer( $this->memcached->addServer(
$this->config['host'], $this->config['host'],
$this->config['port'], $this->config['port'],
$this->config['weight'] $this->config['weight'],
); );
// attempt to get status of servers // attempt to get status of servers
@ -103,7 +103,7 @@ class MemcachedHandler extends BaseHandler
// Check if we can connect to the server // Check if we can connect to the server
$canConnect = $this->memcached->connect( $canConnect = $this->memcached->connect(
$this->config['host'], $this->config['host'],
$this->config['port'] $this->config['port'],
); );
// If we can't connect, throw a CriticalError exception // If we can't connect, throw a CriticalError exception
@ -116,7 +116,7 @@ class MemcachedHandler extends BaseHandler
$this->config['host'], $this->config['host'],
$this->config['port'], $this->config['port'],
true, true,
$this->config['weight'] $this->config['weight'],
); );
} else { } else {
throw new CriticalError('Cache: Not support Memcache(d) extension.'); throw new CriticalError('Cache: Not support Memcache(d) extension.');

View File

@ -82,7 +82,7 @@ class PredisHandler extends BaseHandler
$data = array_combine( $data = array_combine(
['__ci_type', '__ci_value'], ['__ci_type', '__ci_value'],
$this->redis->hmget($key, ['__ci_type', '__ci_value']) $this->redis->hmget($key, ['__ci_type', '__ci_value']),
); );
if (! isset($data['__ci_type'], $data['__ci_value']) || $data['__ci_value'] === false) { if (! isset($data['__ci_type'], $data['__ci_value']) || $data['__ci_value'] === false) {

View File

@ -112,7 +112,7 @@ final class ResponseCache
return $this->cache->save( return $this->cache->save(
$this->generateCacheKey($request), $this->generateCacheKey($request),
serialize(['headers' => $headers, 'output' => $response->getBody()]), serialize(['headers' => $headers, 'output' => $response->getBody()]),
$this->ttl $this->ttl,
); );
} }

View File

@ -56,7 +56,7 @@ class CodeIgniter
/** /**
* The current version of CodeIgniter Framework * The current version of CodeIgniter Framework
*/ */
public const CI_VERSION = '4.5.7'; public const CI_VERSION = '4.5.8';
/** /**
* App startup time. * App startup time.
@ -325,7 +325,7 @@ class CodeIgniter
if ($this->context === null) { if ($this->context === null) {
throw new LogicException( throw new LogicException(
'Context must be set before run() is called. If you are upgrading from 4.1.x, ' 'Context must be set before run() is called. If you are upgrading from 4.1.x, '
. 'you need to merge `public/index.php` and `spark` file from `vendor/codeigniter4/framework`.' . 'you need to merge `public/index.php` and `spark` file from `vendor/codeigniter4/framework`.',
); );
} }
@ -799,7 +799,7 @@ class CodeIgniter
return str_replace( return str_replace(
['{elapsed_time}', '{memory_usage}'], ['{elapsed_time}', '{memory_usage}'],
[(string) $this->totalTime, number_format(memory_get_peak_usage() / 1024 / 1024, 3)], [(string) $this->totalTime, number_format(memory_get_peak_usage() / 1024 / 1024, 3)],
$output $output,
); );
} }
@ -979,7 +979,7 @@ class CodeIgniter
// Throws new PageNotFoundException and remove exception message on production. // Throws new PageNotFoundException and remove exception message on production.
throw PageNotFoundException::forPageNotFound( throw PageNotFoundException::forPageNotFound(
(ENVIRONMENT !== 'production' || ! $this->isWeb()) ? $e->getMessage() : null (ENVIRONMENT !== 'production' || ! $this->isWeb()) ? $e->getMessage() : null,
); );
} }
@ -1064,7 +1064,7 @@ class CodeIgniter
$uri->getAuthority(), $uri->getAuthority(),
$uri->getPath(), $uri->getPath(),
$uri->getQuery(), $uri->getQuery(),
$uri->getFragment() $uri->getFragment(),
)); ));
} }
} }

View File

@ -144,7 +144,7 @@ class ShowTableInfo extends BaseCommand
$tableNameNo = CLI::promptByKey( $tableNameNo = CLI::promptByKey(
['Here is the list of your database tables:', 'Which table do you want to see?'], ['Here is the list of your database tables:', 'Which table do you want to see?'],
$tables, $tables,
'required' 'required',
); );
CLI::newLine(); CLI::newLine();
@ -174,7 +174,7 @@ class ShowTableInfo extends BaseCommand
]]; ]];
CLI::table( CLI::table(
$data, $data,
['hostname', 'database', 'username', 'DBDriver', 'DBPrefix', 'port'] ['hostname', 'database', 'username', 'DBDriver', 'DBPrefix', 'port'],
); );
} }
@ -272,7 +272,7 @@ class ShowTableInfo extends BaseCommand
string $tableName, string $tableName,
int $limitRows, int $limitRows,
int $limitFieldValue, int $limitFieldValue,
?string $sortField = null ?string $sortField = null,
): array { ): array {
$this->tbody = []; $this->tbody = [];
@ -290,7 +290,7 @@ class ShowTableInfo extends BaseCommand
static fn ($item): string => mb_strlen((string) $item) > $limitFieldValue static fn ($item): string => mb_strlen((string) $item) > $limitFieldValue
? mb_substr((string) $item, 0, $limitFieldValue) . '...' ? mb_substr((string) $item, 0, $limitFieldValue) . '...'
: (string) $item, : (string) $item,
$row $row,
); );
$this->tbody[] = $row; $this->tbody[] = $row;
} }

View File

@ -182,7 +182,7 @@ class GenerateKey extends BaseCommand
$newFileContents = preg_replace( $newFileContents = preg_replace(
'/^[#\s]*encryption.key[=\s]*(?:hex2bin\:[a-f0-9]{64}|base64\:(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?)$/m', '/^[#\s]*encryption.key[=\s]*(?:hex2bin\:[a-f0-9]{64}|base64\:(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?)$/m',
$replacementKey, $replacementKey,
$oldFileContents $oldFileContents,
); );
} }

View File

@ -96,7 +96,7 @@ class CellGenerator extends BaseCommand
$viewName = preg_replace( $viewName = preg_replace(
'/([a-z][a-z0-9_\/\\\\]+)(_cell)$/i', '/([a-z][a-z0-9_\/\\\\]+)(_cell)$/i',
'$1', '$1',
$viewName $viewName,
) ?? $viewName; ) ?? $viewName;
$namespace = substr($className, 0, strrpos($className, '\\') + 1); $namespace = substr($className, 0, strrpos($className, '\\') + 1);

View File

@ -115,7 +115,7 @@ class CommandGenerator extends BaseCommand
$class, $class,
['{group}', '{command}'], ['{group}', '{command}'],
[$group, $command], [$group, $command],
['type' => $type] ['type' => $type],
); );
} }
} }

View File

@ -130,7 +130,7 @@ class ControllerGenerator extends BaseCommand
$class, $class,
['{useStatement}', '{extends}'], ['{useStatement}', '{extends}'],
[$useStatement, $extends], [$useStatement, $extends],
['type' => $rest] ['type' => $rest],
); );
} }
} }

View File

@ -102,9 +102,9 @@ class TestGenerator extends BaseCommand
str_replace( str_replace(
'/', '/',
'\\', '\\',
$this->getOption('namespace') $this->getOption('namespace'),
), ),
'\\' '\\',
); );
} }
@ -143,7 +143,7 @@ class TestGenerator extends BaseCommand
CLI::error( CLI::error(
lang('CLI.namespaceNotDefined', [$namespace]), lang('CLI.namespaceNotDefined', [$namespace]),
'light_gray', 'light_gray',
'red' 'red',
); );
CLI::newLine(); CLI::newLine();
@ -157,7 +157,7 @@ class TestGenerator extends BaseCommand
. str_replace( . str_replace(
'\\', '\\',
DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR,
trim(str_replace($namespace . '\\', '', $class), '\\') trim(str_replace($namespace . '\\', '', $class), '\\'),
) . '.php'; ) . '.php';
return implode( return implode(
@ -165,8 +165,8 @@ class TestGenerator extends BaseCommand
array_slice( array_slice(
explode(DIRECTORY_SEPARATOR, $file), explode(DIRECTORY_SEPARATOR, $file),
0, 0,
-1 -1,
) ),
) . DIRECTORY_SEPARATOR . $this->basename($file); ) . DIRECTORY_SEPARATOR . $this->basename($file);
} }

View File

@ -70,7 +70,7 @@ class LocalizationFinder extends BaseCommand
if (! in_array($optionLocale, config(App::class)->supportedLocales, true)) { if (! in_array($optionLocale, config(App::class)->supportedLocales, true)) {
CLI::error( CLI::error(
'Error: "' . $optionLocale . '" is not supported. Supported locales: ' 'Error: "' . $optionLocale . '" is not supported. Supported locales: '
. implode(', ', config(App::class)->supportedLocales) . implode(', ', config(App::class)->supportedLocales),
); );
return EXIT_USER_INPUT; return EXIT_USER_INPUT;
@ -116,7 +116,7 @@ class LocalizationFinder extends BaseCommand
[ [
'foundLanguageKeys' => $foundLanguageKeys, 'foundLanguageKeys' => $foundLanguageKeys,
'badLanguageKeys' => $badLanguageKeys, 'badLanguageKeys' => $badLanguageKeys,
'countFiles' => $countFiles 'countFiles' => $countFiles,
] = $this->findLanguageKeysInFiles($files); ] = $this->findLanguageKeysInFiles($files);
ksort($foundLanguageKeys); ksort($foundLanguageKeys);

View File

@ -109,7 +109,7 @@ final class ConfigCheck extends BaseCommand
CLI::write($this->getKintD($config)); CLI::write($this->getKintD($config));
} else { } else {
CLI::write( CLI::write(
CLI::color($this->getVarDump($config), 'cyan') CLI::color($this->getVarDump($config), 'cyan'),
); );
} }
@ -150,7 +150,7 @@ final class ConfigCheck extends BaseCommand
return preg_replace( return preg_replace(
'!.*system/Commands/Utilities/ConfigCheck.php.*\n!u', '!.*system/Commands/Utilities/ConfigCheck.php.*\n!u',
'', '',
$output $output,
); );
} }
} }

View File

@ -151,7 +151,7 @@ final class Environment extends BaseCommand
return file_put_contents( return file_put_contents(
$envFile, $envFile,
preg_replace($pattern, "\nCI_ENVIRONMENT = {$newEnv}", file_get_contents($envFile), -1, $count) preg_replace($pattern, "\nCI_ENVIRONMENT = {$newEnv}", file_get_contents($envFile), -1, $count),
) !== false && $count > 0; ) !== false && $count > 0;
} }
} }

View File

@ -100,7 +100,7 @@ class FilterCheck extends BaseCommand
CLI::color( CLI::color(
'"' . strtoupper($method) . ' ' . $route . '"', '"' . strtoupper($method) . ' ' . $route . '"',
'black', 'black',
'light_gray' 'light_gray',
), ),
); );

View File

@ -110,13 +110,13 @@ final class Optimize extends BaseCommand
[ [
'public bool $configCacheEnabled = false;' => 'public bool $configCacheEnabled = true;', 'public bool $configCacheEnabled = false;' => 'public bool $configCacheEnabled = true;',
'public bool $locatorCacheEnabled = false;' => 'public bool $locatorCacheEnabled = true;', 'public bool $locatorCacheEnabled = false;' => 'public bool $locatorCacheEnabled = true;',
] ],
); );
if ($result) { if ($result) {
CLI::write( CLI::write(
'Config Caching and FileLocator Caching are enabled in "app/Config/Optimize.php".', 'Config Caching and FileLocator Caching are enabled in "app/Config/Optimize.php".',
'green' 'green',
); );
return; return;

View File

@ -133,7 +133,7 @@ class Routes extends BaseCommand
$collection->getDefaultController(), $collection->getDefaultController(),
$collection->getDefaultMethod(), $collection->getDefaultMethod(),
$methods, $methods,
$collection->getRegisteredControllers('*') $collection->getRegisteredControllers('*'),
); );
$autoRoutes = $autoRouteCollector->get(); $autoRoutes = $autoRouteCollector->get();
@ -149,7 +149,7 @@ class Routes extends BaseCommand
$collection->getDefaultMethod(), $collection->getDefaultMethod(),
$methods, $methods,
$collection->getRegisteredControllers('*'), $collection->getRegisteredControllers('*'),
$uri $uri,
); );
$autoRoutes = [...$autoRoutes, ...$autoRouteCollector->get()]; $autoRoutes = [...$autoRoutes, ...$autoRouteCollector->get()];
@ -159,7 +159,7 @@ class Routes extends BaseCommand
$autoRouteCollector = new AutoRouteCollector( $autoRouteCollector = new AutoRouteCollector(
$collection->getDefaultNamespace(), $collection->getDefaultNamespace(),
$collection->getDefaultController(), $collection->getDefaultController(),
$collection->getDefaultMethod() $collection->getDefaultMethod(),
); );
$autoRoutes = $autoRouteCollector->get(); $autoRoutes = $autoRouteCollector->get();

View File

@ -41,7 +41,7 @@ final class AutoRouteCollector
$output = $reader->read( $output = $reader->read(
$class, $class,
$this->defaultController, $this->defaultController,
$this->defaultMethod $this->defaultMethod,
); );
foreach ($output as $item) { foreach ($output as $item) {

View File

@ -36,7 +36,7 @@ final class AutoRouteCollector
private readonly string $defaultMethod, private readonly string $defaultMethod,
private readonly array $httpMethods, private readonly array $httpMethods,
private readonly array $protectedControllers, private readonly array $protectedControllers,
private readonly string $prefix = '' private readonly string $prefix = '',
) { ) {
} }
@ -59,7 +59,7 @@ final class AutoRouteCollector
$routes = $reader->read( $routes = $reader->read(
$class, $class,
$this->defaultController, $this->defaultController,
$this->defaultMethod $this->defaultMethod,
); );
if ($routes === []) { if ($routes === []) {

View File

@ -33,7 +33,7 @@ final class ControllerMethodReader
*/ */
public function __construct( public function __construct(
private readonly string $namespace, private readonly string $namespace,
private readonly array $httpMethods private readonly array $httpMethods,
) { ) {
$config = config(Routing::class); $config = config(Routing::class);
$this->translateURIDashes = $config->translateURIDashes; $this->translateURIDashes = $config->translateURIDashes;
@ -78,7 +78,7 @@ final class ControllerMethodReader
$classname, $classname,
$methodName, $methodName,
$httpVerb, $httpVerb,
$method $method,
); );
if ($routeForDefaultController !== []) { if ($routeForDefaultController !== []) {
@ -193,7 +193,7 @@ final class ControllerMethodReader
{ {
if ($this->translateUriToCamelCase) { if ($this->translateUriToCamelCase) {
$string = strtolower( $string = strtolower(
preg_replace('/([a-z\d])([A-Z])/', '$1-$2', $string) preg_replace('/([a-z\d])([A-Z])/', '$1-$2', $string),
); );
} elseif ($this->translateURIDashes) { } elseif ($this->translateURIDashes) {
$string = str_replace('_', '-', $string); $string = str_replace('_', '-', $string);
@ -214,7 +214,7 @@ final class ControllerMethodReader
string $classname, string $classname,
string $methodName, string $methodName,
string $httpVerb, string $httpVerb,
ReflectionMethod $method ReflectionMethod $method,
): array { ): array {
$output = []; $output = [];

View File

@ -28,7 +28,7 @@ final class ControllerFinder
* @param string $namespace namespace to search * @param string $namespace namespace to search
*/ */
public function __construct( public function __construct(
private readonly string $namespace private readonly string $namespace,
) { ) {
$this->locator = service('locator'); $this->locator = service('locator');
} }

View File

@ -57,7 +57,7 @@ final class ControllerMethodReader
$defaultController, $defaultController,
$uriByClass, $uriByClass,
$classname, $classname,
$methodName $methodName,
); );
$output = [...$output, ...$routeWithoutController]; $output = [...$output, ...$routeWithoutController];
@ -89,7 +89,7 @@ final class ControllerMethodReader
$defaultController, $defaultController,
$uriByClass, $uriByClass,
$classname, $classname,
$methodName $methodName,
); );
$output = [...$output, ...$routeWithoutController]; $output = [...$output, ...$routeWithoutController];
@ -153,7 +153,7 @@ final class ControllerMethodReader
string $defaultController, string $defaultController,
string $uriByClass, string $uriByClass,
string $classname, string $classname,
string $methodName string $methodName,
): array { ): array {
if ($classShortname !== $defaultController) { if ($classShortname !== $defaultController) {
return []; return [];

View File

@ -32,7 +32,7 @@ final class FilterCollector
* *
* If set to true, route filters are not found. * If set to true, route filters are not found.
*/ */
private readonly bool $resetRoutes = false private readonly bool $resetRoutes = false,
) { ) {
} }
@ -50,7 +50,7 @@ final class FilterCollector
@trigger_error( @trigger_error(
'Passing lowercase HTTP method "' . $method . '" is deprecated.' 'Passing lowercase HTTP method "' . $method . '" is deprecated.'
. ' Use uppercase HTTP method like "' . strtoupper($method) . '".', . ' Use uppercase HTTP method like "' . strtoupper($method) . '".',
E_USER_DEPRECATED E_USER_DEPRECATED,
); );
} }

View File

@ -57,7 +57,7 @@ final class SampleURIGenerator
$sampleUri = str_replace( $sampleUri = str_replace(
'{locale}', '{locale}',
config(App::class)->defaultLocale, config(App::class)->defaultLocale,
$routeKey $routeKey,
); );
} }

View File

@ -146,7 +146,7 @@ if (! function_exists('command')) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(sprintf(
'Unable to parse input near "... %s ...".', 'Unable to parse input near "... %s ...".',
substr($command, $cursor, 10) substr($command, $cursor, 10),
)); ));
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
} }
@ -470,7 +470,7 @@ if (! function_exists('force_https')) {
function force_https( function force_https(
int $duration = 31_536_000, int $duration = 31_536_000,
?RequestInterface $request = null, ?RequestInterface $request = null,
?ResponseInterface $response = null ?ResponseInterface $response = null,
): void { ): void {
$request ??= service('request'); $request ??= service('request');
@ -1065,7 +1065,7 @@ if (! function_exists('slash_item')) {
'Cannot convert "%s::$%s" of type "%s" to type "string".', 'Cannot convert "%s::$%s" of type "%s" to type "string".',
App::class, App::class,
$item, $item,
gettype($configItem) gettype($configItem),
)); ));
} }

View File

@ -102,7 +102,7 @@ final class ComposerScripts
/** @var SplFileInfo $file */ /** @var SplFileInfo $file */
foreach (new RecursiveIteratorIterator( foreach (new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(rtrim($directory, '\\/'), FilesystemIterator::SKIP_DOTS), new RecursiveDirectoryIterator(rtrim($directory, '\\/'), FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST RecursiveIteratorIterator::CHILD_FIRST,
) as $file) { ) as $file) {
$path = $file->getPathname(); $path = $file->getPathname();
@ -146,7 +146,7 @@ final class ComposerScripts
/** @var SplFileInfo $file */ /** @var SplFileInfo $file */
foreach (new RecursiveIteratorIterator( foreach (new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($originDir, FilesystemIterator::SKIP_DOTS), new RecursiveDirectoryIterator($originDir, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST RecursiveIteratorIterator::SELF_FIRST,
) as $file) { ) as $file) {
$origin = $file->getPathname(); $origin = $file->getPathname();
$target = $targetDir . substr($origin, $dirLen); $target = $targetDir . substr($origin, $dirLen);

View File

@ -164,7 +164,7 @@ class DotEnv
%1$s # and the closing quote %1$s # and the closing quote
.*$ # and discard any string after the closing quote .*$ # and discard any string after the closing quote
/mx', /mx',
$quote $quote,
); );
$value = preg_replace($regexPattern, '$1', $value); $value = preg_replace($regexPattern, '$1', $value);
@ -206,7 +206,7 @@ class DotEnv
return $nestedVariable; return $nestedVariable;
}, },
$value $value,
); );
} }

View File

@ -106,7 +106,7 @@ final class Factories
} }
throw new InvalidArgumentException( throw new InvalidArgumentException(
'Already defined in Factories: ' . $component . ' ' . $alias . ' -> ' . self::$aliases[$component][$alias] 'Already defined in Factories: ' . $component . ' ' . $alias . ' -> ' . self::$aliases[$component][$alias],
); );
} }
@ -448,7 +448,7 @@ final class Factories
self::$options[$component], self::$options[$component],
self::$aliases[$component], self::$aliases[$component],
self::$instances[$component], self::$instances[$component],
self::$updated[$component] self::$updated[$component],
); );
return; return;

View File

@ -213,7 +213,7 @@ class Services extends BaseService
$config, $config,
new URI($options['baseURI'] ?? null), new URI($options['baseURI'] ?? null),
$response, $response,
$options $options,
); );
} }
@ -267,7 +267,7 @@ class Services extends BaseService
*/ */
public static function exceptions( public static function exceptions(
?ExceptionsConfig $config = null, ?ExceptionsConfig $config = null,
bool $getShared = true bool $getShared = true,
) { ) {
if ($getShared) { if ($getShared) {
return static::getSharedInstance('exceptions', $config); return static::getSharedInstance('exceptions', $config);
@ -569,7 +569,7 @@ class Services extends BaseService
$config, $config,
AppServices::get('uri'), AppServices::get('uri'),
'php://input', 'php://input',
new UserAgent() new UserAgent(),
); );
} }
@ -619,7 +619,7 @@ class Services extends BaseService
return static::getSharedInstance('routes'); return static::getSharedInstance('routes');
} }
return new RouteCollection(AppServices::get('locator'), config(Modules::class), config(Routing::class)); return new RouteCollection(AppServices::get('locator'), new Modules(), config(Routing::class));
} }
/** /**
@ -689,7 +689,7 @@ class Services extends BaseService
if (! class_exists($driverName) || ! is_a($driverName, SessionBaseHandler::class, true)) { if (! class_exists($driverName) || ! is_a($driverName, SessionBaseHandler::class, true)) {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(sprintf(
'Invalid session handler "%s" provided.', 'Invalid session handler "%s" provided.',
$driverName $driverName,
)); ));
} }
@ -721,7 +721,7 @@ class Services extends BaseService
public static function siteurifactory( public static function siteurifactory(
?App $config = null, ?App $config = null,
?Superglobals $superglobals = null, ?Superglobals $superglobals = null,
bool $getShared = true bool $getShared = true,
) { ) {
if ($getShared) { if ($getShared) {
return static::getSharedInstance('siteurifactory', $config, $superglobals); return static::getSharedInstance('siteurifactory', $config, $superglobals);
@ -741,7 +741,7 @@ class Services extends BaseService
public static function superglobals( public static function superglobals(
?array $server = null, ?array $server = null,
?array $get = null, ?array $get = null,
bool $getShared = true bool $getShared = true,
) { ) {
if ($getShared) { if ($getShared) {
return static::getSharedInstance('superglobals', $server, $get); return static::getSharedInstance('superglobals', $server, $get);

View File

@ -24,7 +24,7 @@ class ArrayCast extends BaseCast implements CastInterface
public static function get( public static function get(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): array { ): array {
if (! is_string($value)) { if (! is_string($value)) {
self::invalidTypeValueError($value); self::invalidTypeValueError($value);
@ -40,7 +40,7 @@ class ArrayCast extends BaseCast implements CastInterface
public static function set( public static function set(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): string { ): string {
return serialize($value); return serialize($value);
} }

View File

@ -20,7 +20,7 @@ abstract class BaseCast implements CastInterface
public static function get( public static function get(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): mixed { ): mixed {
return $value; return $value;
} }
@ -28,7 +28,7 @@ abstract class BaseCast implements CastInterface
public static function set( public static function set(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): mixed { ): mixed {
return $value; return $value;
} }

View File

@ -24,7 +24,7 @@ class BooleanCast extends BaseCast
public static function get( public static function get(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): bool { ): bool {
// For PostgreSQL // For PostgreSQL
if ($value === 't') { if ($value === 't') {

View File

@ -24,7 +24,7 @@ class CSVCast extends BaseCast
public static function get( public static function get(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): array { ): array {
if (! is_string($value)) { if (! is_string($value)) {
self::invalidTypeValueError($value); self::invalidTypeValueError($value);
@ -36,7 +36,7 @@ class CSVCast extends BaseCast
public static function set( public static function set(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): string { ): string {
if (! is_array($value)) { if (! is_array($value)) {
self::invalidTypeValueError($value); self::invalidTypeValueError($value);

View File

@ -27,7 +27,7 @@ interface CastInterface
public static function get( public static function get(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): mixed; ): mixed;
/** /**
@ -42,6 +42,6 @@ interface CastInterface
public static function set( public static function set(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): mixed; ): mixed;
} }

View File

@ -28,7 +28,7 @@ class DatetimeCast extends BaseCast
public static function get( public static function get(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): Time { ): Time {
if (! is_string($value)) { if (! is_string($value)) {
self::invalidTypeValueError($value); self::invalidTypeValueError($value);
@ -56,7 +56,7 @@ class DatetimeCast extends BaseCast
public static function set( public static function set(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): string { ): string {
if (! $value instanceof Time) { if (! $value instanceof Time) {
self::invalidTypeValueError($value); self::invalidTypeValueError($value);

View File

@ -24,7 +24,7 @@ class FloatCast extends BaseCast
public static function get( public static function get(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): float { ): float {
if (! is_float($value) && ! is_string($value)) { if (! is_float($value) && ! is_string($value)) {
self::invalidTypeValueError($value); self::invalidTypeValueError($value);

View File

@ -24,7 +24,7 @@ final class IntBoolCast extends BaseCast
public static function get( public static function get(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): bool { ): bool {
if (! is_int($value) && ! is_string($value)) { if (! is_int($value) && ! is_string($value)) {
self::invalidTypeValueError($value); self::invalidTypeValueError($value);
@ -36,7 +36,7 @@ final class IntBoolCast extends BaseCast
public static function set( public static function set(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): int { ): int {
if (! is_bool($value)) { if (! is_bool($value)) {
self::invalidTypeValueError($value); self::invalidTypeValueError($value);

View File

@ -24,7 +24,7 @@ class IntegerCast extends BaseCast
public static function get( public static function get(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): int { ): int {
if (! is_string($value) && ! is_int($value)) { if (! is_string($value) && ! is_int($value)) {
self::invalidTypeValueError($value); self::invalidTypeValueError($value);

View File

@ -28,7 +28,7 @@ class JsonCast extends BaseCast
public static function get( public static function get(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): array|stdClass { ): array|stdClass {
if (! is_string($value)) { if (! is_string($value)) {
self::invalidTypeValueError($value); self::invalidTypeValueError($value);
@ -50,7 +50,7 @@ class JsonCast extends BaseCast
public static function set( public static function set(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): string { ): string {
try { try {
$output = json_encode($value, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR); $output = json_encode($value, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);

View File

@ -26,7 +26,7 @@ class TimestampCast extends BaseCast
public static function get( public static function get(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): Time { ): Time {
if (! is_int($value) && ! is_string($value)) { if (! is_int($value) && ! is_string($value)) {
self::invalidTypeValueError($value); self::invalidTypeValueError($value);
@ -38,7 +38,7 @@ class TimestampCast extends BaseCast
public static function set( public static function set(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): int { ): int {
if (! $value instanceof Time) { if (! $value instanceof Time) {
self::invalidTypeValueError($value); self::invalidTypeValueError($value);

View File

@ -26,7 +26,7 @@ class URICast extends BaseCast
public static function get( public static function get(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): URI { ): URI {
if (! is_string($value)) { if (! is_string($value)) {
self::invalidTypeValueError($value); self::invalidTypeValueError($value);
@ -38,7 +38,7 @@ class URICast extends BaseCast
public static function set( public static function set(
mixed $value, mixed $value,
array $params = [], array $params = [],
?object $helper = null ?object $helper = null,
): string { ): string {
if (! $value instanceof URI) { if (! $value instanceof URI) {
self::invalidTypeValueError($value); self::invalidTypeValueError($value);

View File

@ -68,7 +68,7 @@ final class DataCaster
?array $castHandlers = null, ?array $castHandlers = null,
?array $types = null, ?array $types = null,
private readonly ?object $helper = null, private readonly ?object $helper = null,
private readonly bool $strict = true private readonly bool $strict = true,
) { ) {
$this->castHandlers = array_merge($this->castHandlers, $castHandlers); $this->castHandlers = array_merge($this->castHandlers, $castHandlers);
@ -83,7 +83,7 @@ final class DataCaster
&& ! is_subclass_of($handler, EntityCastInterface::class) && ! is_subclass_of($handler, EntityCastInterface::class)
) { ) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
'Invalid class type. It must implement CastInterface. class: ' . $handler 'Invalid class type. It must implement CastInterface. class: ' . $handler,
); );
} }
} }
@ -169,7 +169,7 @@ final class DataCaster
if (! isset($handlers[$type])) { if (! isset($handlers[$type])) {
throw new InvalidArgumentException( throw new InvalidArgumentException(
'No such handler for "' . $field . '". Invalid type: ' . $type 'No such handler for "' . $field . '". Invalid type: ' . $type,
); );
} }

View File

@ -663,7 +663,7 @@ class BaseBuilder
} else { } else {
// Split multiple conditions // Split multiple conditions
// @TODO This does not parse `BETWEEN a AND b` correctly. // @TODO This does not parse `BETWEEN a AND b` correctly.
if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE)) { if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE) >= 1) {
$conditions = []; $conditions = [];
$joints = $joints[0]; $joints = $joints[0];
array_unshift($joints, ['', 0]); array_unshift($joints, ['', 0]);
@ -807,7 +807,7 @@ class BaseBuilder
'/\s*(!?=|<>|IS(?:\s+NOT)?)\s*$/i', '/\s*(!?=|<>|IS(?:\s+NOT)?)\s*$/i',
$k, $k,
$match, $match,
PREG_OFFSET_CAPTURE PREG_OFFSET_CAPTURE,
) )
) { ) {
$k = substr($k, 0, $match[0][1]); $k = substr($k, 0, $match[0][1]);
@ -2022,8 +2022,8 @@ class BaseBuilder
' = ' . $value : ' = ' . $value :
' = VALUES(' . $value . ')'), ' = VALUES(' . $value . ')'),
array_keys($updateFields), array_keys($updateFields),
$updateFields $updateFields,
) ),
); );
$this->QBOptions['sql'] = $sql; $this->QBOptions['sql'] = $sql;
@ -2198,7 +2198,7 @@ class BaseBuilder
* *
* @param array|object|null $set a dataset * @param array|object|null $set a dataset
* *
* @return false|int|list<string> Number of rows inserted or FALSE on failure, SQL array when testMode * @return false|int|list<string> Number of rows inserted or FALSE on no data to perform an insert operation, SQL array when testMode
*/ */
public function insertBatch($set = null, ?bool $escape = null, int $batchSize = 100) public function insertBatch($set = null, ?bool $escape = null, int $batchSize = 100)
{ {
@ -2291,10 +2291,10 @@ class BaseBuilder
$this->removeAlias($this->QBFrom[0]), $this->removeAlias($this->QBFrom[0]),
true, true,
null, null,
false false,
), ),
array_keys($this->QBSet), array_keys($this->QBSet),
array_values($this->QBSet) array_values($this->QBSet),
); );
if ($reset) { if ($reset) {
@ -2328,10 +2328,10 @@ class BaseBuilder
$this->removeAlias($this->QBFrom[0]), $this->removeAlias($this->QBFrom[0]),
true, true,
$escape, $escape,
false false,
), ),
array_keys($this->QBSet), array_keys($this->QBSet),
array_values($this->QBSet) array_values($this->QBSet),
); );
if (! $this->testMode) { if (! $this->testMode) {
@ -2653,8 +2653,8 @@ class BaseBuilder
' = ' . $value : ' = ' . $value :
' = ' . $alias . '.' . $value), ' = ' . $alias . '.' . $value),
array_keys($updateFields), array_keys($updateFields),
$updateFields $updateFields,
) ),
) . "\n"; ) . "\n";
$sql .= "FROM (\n{:_table_:}"; $sql .= "FROM (\n{:_table_:}";
@ -2678,8 +2678,8 @@ class BaseBuilder
) )
), ),
array_keys($constraints), array_keys($constraints),
$constraints $constraints,
) ),
); );
$this->QBOptions['sql'] = $sql; $this->QBOptions['sql'] = $sql;
@ -2694,10 +2694,10 @@ class BaseBuilder
static fn ($value): string => 'SELECT ' . implode(', ', array_map( static fn ($value): string => 'SELECT ' . implode(', ', array_map(
static fn ($key, $index): string => $index . ' ' . $key, static fn ($key, $index): string => $index . ' ' . $key,
$keys, $keys,
$value $value,
)), )),
$values $values,
) ),
) . "\n"; ) . "\n";
} }
@ -2924,8 +2924,8 @@ class BaseBuilder
) )
), ),
array_keys($constraints), array_keys($constraints),
$constraints $constraints,
) ),
); );
// convert binds in where // convert binds in where
@ -2949,10 +2949,10 @@ class BaseBuilder
static fn ($value): string => 'SELECT ' . implode(', ', array_map( static fn ($value): string => 'SELECT ' . implode(', ', array_map(
static fn ($key, $index): string => $index . ' ' . $key, static fn ($key, $index): string => $index . ' ' . $key,
$keys, $keys,
$value $value,
)), )),
$values $values,
) ),
) . "\n"; ) . "\n";
} }
@ -3160,7 +3160,7 @@ class BaseBuilder
'/((?:^|\s+)AND\s+|(?:^|\s+)OR\s+)/i', '/((?:^|\s+)AND\s+|(?:^|\s+)OR\s+)/i',
$qbkey['condition'], $qbkey['condition'],
-1, -1,
PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY,
); );
foreach ($conditions as &$condition) { foreach ($conditions as &$condition) {
@ -3170,11 +3170,12 @@ class BaseBuilder
|| preg_match( || preg_match(
'/^(\(?)(.*)(' . preg_quote($op, '/') . ')\s*(.*(?<!\)))?(\)?)$/i', '/^(\(?)(.*)(' . preg_quote($op, '/') . ')\s*(.*(?<!\)))?(\)?)$/i',
$condition, $condition,
$matches $matches,
) !== 1 ) !== 1
) { ) {
continue; continue;
} }
// $matches = [ // $matches = [
// 0 => '(test <= foo)', /* the whole thing */ // 0 => '(test <= foo)', /* the whole thing */
// 1 => '(', /* optional */ // 1 => '(', /* optional */
@ -3184,7 +3185,7 @@ class BaseBuilder
// 5 => ')' /* optional */ // 5 => ')' /* optional */
// ]; // ];
if (isset($matches[4]) && $matches[4] !== '') { if ($matches[4] !== '') {
$protectIdentifiers = false; $protectIdentifiers = false;
if (str_contains($matches[4], '.')) { if (str_contains($matches[4], '.')) {
$protectIdentifiers = true; $protectIdentifiers = true;
@ -3435,7 +3436,7 @@ class BaseBuilder
{ {
return preg_match( return preg_match(
'/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sEXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', '/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sEXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i',
trim($str) trim($str),
) === 1; ) === 1;
} }
@ -3469,8 +3470,8 @@ class BaseBuilder
return preg_match_all( return preg_match_all(
'/' . implode('|', $this->pregOperators) . '/i', '/' . implode('|', $this->pregOperators) . '/i',
$str, $str,
$match $match,
) ? ($list ? $match[0] : $match[0][0]) : false; ) >= 1 ? ($list ? $match[0] : $match[0][0]) : false;
} }
/** /**
@ -3500,8 +3501,8 @@ class BaseBuilder
return preg_match_all( return preg_match_all(
'/' . implode('|', $pregOperators) . '/i', '/' . implode('|', $pregOperators) . '/i',
$whereKey, $whereKey,
$match $match,
) ? $match[0] : false; ) >= 1 ? $match[0] : false;
} }
/** /**

View File

@ -424,7 +424,7 @@ abstract class BaseConnection implements ConnectionInterface
$connectionErrors[] = sprintf( $connectionErrors[] = sprintf(
'Main connection [%s]: %s', 'Main connection [%s]: %s',
$this->DBDriver, $this->DBDriver,
$e->getMessage() $e->getMessage(),
); );
log_message('error', 'Error connecting to the database: ' . $e); log_message('error', 'Error connecting to the database: ' . $e);
} }
@ -450,7 +450,7 @@ abstract class BaseConnection implements ConnectionInterface
'Failover #%d [%s]: %s', 'Failover #%d [%s]: %s',
++$index, ++$index,
$this->DBDriver, $this->DBDriver,
$e->getMessage() $e->getMessage(),
); );
log_message('error', 'Error connecting to the database: ' . $e); log_message('error', 'Error connecting to the database: ' . $e);
} }
@ -467,7 +467,7 @@ abstract class BaseConnection implements ConnectionInterface
throw new DatabaseException(sprintf( throw new DatabaseException(sprintf(
'Unable to connect to the database.%s%s', 'Unable to connect to the database.%s%s',
PHP_EOL, PHP_EOL,
implode(PHP_EOL, $connectionErrors) implode(PHP_EOL, $connectionErrors),
)); ));
} }
} }
@ -688,7 +688,7 @@ abstract class BaseConnection implements ConnectionInterface
throw new DatabaseException( throw new DatabaseException(
$exception->getMessage(), $exception->getMessage(),
$exception->getCode(), $exception->getCode(),
$exception $exception,
); );
} }
@ -1220,7 +1220,7 @@ abstract class BaseConnection implements ConnectionInterface
. str_replace( . str_replace(
$this->escapeChar, $this->escapeChar,
$this->escapeChar . $this->escapeChar, $this->escapeChar . $this->escapeChar,
$item $item,
) )
. $this->escapeChar; . $this->escapeChar;
} }
@ -1277,7 +1277,7 @@ abstract class BaseConnection implements ConnectionInterface
return preg_replace( return preg_replace(
'/' . $this->pregEscapeChar[0] . '?([^' . $this->pregEscapeChar[1] . '\.]+)' . $this->pregEscapeChar[1] . '?\./i', '/' . $this->pregEscapeChar[0] . '?([^' . $this->pregEscapeChar[1] . '\.]+)' . $this->pregEscapeChar[1] . '?\./i',
$this->pregEscapeChar[2] . '$1' . $this->pregEscapeChar[3] . '.', $this->pregEscapeChar[2] . '$1' . $this->pregEscapeChar[3] . '.',
$item $item,
); );
} }
} }
@ -1286,7 +1286,7 @@ abstract class BaseConnection implements ConnectionInterface
return preg_replace( return preg_replace(
'/' . $this->pregEscapeChar[0] . '?([^' . $this->pregEscapeChar[1] . '\.]+)' . $this->pregEscapeChar[1] . '?(\.)?/i', '/' . $this->pregEscapeChar[0] . '?([^' . $this->pregEscapeChar[1] . '\.]+)' . $this->pregEscapeChar[1] . '?(\.)?/i',
$this->pregEscapeChar[2] . '$1' . $this->pregEscapeChar[3] . '$2', $this->pregEscapeChar[2] . '$1' . $this->pregEscapeChar[3] . '$2',
$item $item,
); );
} }
@ -1386,7 +1386,7 @@ abstract class BaseConnection implements ConnectionInterface
$this->likeEscapeChar . '%', $this->likeEscapeChar . '%',
$this->likeEscapeChar . '_', $this->likeEscapeChar . '_',
], ],
$str $str,
); );
} }
@ -1522,7 +1522,7 @@ abstract class BaseConnection implements ConnectionInterface
$key = array_search( $key = array_search(
strtolower($tableName), strtolower($tableName),
array_map(strtolower(...), $this->dataCache['table_names']), array_map(strtolower(...), $this->dataCache['table_names']),
true true,
); );
// table doesn't exist but still in cache - lets reset cache, it can be rebuilt later // table doesn't exist but still in cache - lets reset cache, it can be rebuilt later

View File

@ -217,7 +217,7 @@ abstract class BaseUtils
$line[] = $enclosure . str_replace( $line[] = $enclosure . str_replace(
$enclosure, $enclosure,
$enclosure . $enclosure, $enclosure . $enclosure,
(string) $item (string) $item,
) . $enclosure; ) . $enclosure;
} }

View File

@ -234,8 +234,8 @@ class Forge
$ifNotExists ? $this->createDatabaseIfStr : $this->createDatabaseStr, $ifNotExists ? $this->createDatabaseIfStr : $this->createDatabaseStr,
$this->db->escapeIdentifier($dbName), $this->db->escapeIdentifier($dbName),
$this->db->charset, $this->db->charset,
$this->db->DBCollat $this->db->DBCollat,
) ),
)) { )) {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
if ($this->db->DBDebug) { if ($this->db->DBDebug) {
@ -294,7 +294,7 @@ class Forge
} }
if (! $this->db->query( if (! $this->db->query(
sprintf($this->dropDatabaseStr, $this->db->escapeIdentifier($dbName)) sprintf($this->dropDatabaseStr, $this->db->escapeIdentifier($dbName)),
)) { )) {
if ($this->db->DBDebug) { if ($this->db->DBDebug) {
throw new DatabaseException('Unable to drop the specified database.'); throw new DatabaseException('Unable to drop the specified database.');
@ -307,7 +307,7 @@ class Forge
$key = array_search( $key = array_search(
strtolower($dbName), strtolower($dbName),
array_map(strtolower(...), $this->db->dataCache['db_names']), array_map(strtolower(...), $this->db->dataCache['db_names']),
true true,
); );
if ($key !== false) { if ($key !== false) {
unset($this->db->dataCache['db_names'][$key]); unset($this->db->dataCache['db_names'][$key]);
@ -425,7 +425,7 @@ class Forge
$tableField = '', $tableField = '',
string $onUpdate = '', string $onUpdate = '',
string $onDelete = '', string $onDelete = '',
string $fkName = '' string $fkName = '',
): Forge { ): Forge {
$fieldName = (array) $fieldName; $fieldName = (array) $fieldName;
$tableField = (array) $tableField; $tableField = (array) $tableField;
@ -525,7 +525,7 @@ class Forge
$sql = sprintf( $sql = sprintf(
(string) $this->dropConstraintStr, (string) $this->dropConstraintStr,
$this->db->escapeIdentifiers($this->db->DBPrefix . $table), $this->db->escapeIdentifiers($this->db->DBPrefix . $table),
$this->db->escapeIdentifiers($foreignName) $this->db->escapeIdentifiers($foreignName),
); );
if ($sql === '') { if ($sql === '') {
@ -618,7 +618,7 @@ class Forge
'CREATE TABLE', 'CREATE TABLE',
$this->db->escapeIdentifiers($table), $this->db->escapeIdentifiers($table),
$processedFields, $processedFields,
$this->_createTableAttributes($attributes) $this->_createTableAttributes($attributes),
); );
} }
@ -668,7 +668,7 @@ class Forge
$key = array_search( $key = array_search(
strtolower($this->db->DBPrefix . $tableName), strtolower($this->db->DBPrefix . $tableName),
array_map(strtolower(...), $this->db->dataCache['table_names']), array_map(strtolower(...), $this->db->dataCache['table_names']),
true true,
); );
if ($key !== false) { if ($key !== false) {
@ -723,14 +723,14 @@ class Forge
$result = $this->db->query(sprintf( $result = $this->db->query(sprintf(
$this->renameTableStr, $this->renameTableStr,
$this->db->escapeIdentifiers($this->db->DBPrefix . $tableName), $this->db->escapeIdentifiers($this->db->DBPrefix . $tableName),
$this->db->escapeIdentifiers($this->db->DBPrefix . $newTableName) $this->db->escapeIdentifiers($this->db->DBPrefix . $newTableName),
)); ));
if ($result && ! empty($this->db->dataCache['table_names'])) { if ($result && ! empty($this->db->dataCache['table_names'])) {
$key = array_search( $key = array_search(
strtolower($this->db->DBPrefix . $tableName), strtolower($this->db->DBPrefix . $tableName),
array_map(strtolower(...), $this->db->dataCache['table_names']), array_map(strtolower(...), $this->db->dataCache['table_names']),
true true,
); );
if ($key !== false) { if ($key !== false) {
@ -1061,7 +1061,7 @@ class Forge
protected function _attributeAutoIncrement(array &$attributes, array &$field) protected function _attributeAutoIncrement(array &$attributes, array &$field)
{ {
if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true
&& stripos($field['type'], 'int') !== false && str_contains(strtolower($field['type']), 'int')
) { ) {
$field['auto_increment'] = ' AUTO_INCREMENT'; $field['auto_increment'] = ' AUTO_INCREMENT';
} }
@ -1112,7 +1112,7 @@ class Forge
$this->fields = array_combine( $this->fields = array_combine(
array_map(static fn ($columnName) => $columnName->name, $fieldData), array_map(static fn ($columnName) => $columnName->name, $fieldData),
array_fill(0, count($fieldData), []) array_fill(0, count($fieldData), []),
); );
} }

View File

@ -605,7 +605,7 @@ class MigrationRunner
CLI::color(lang('Migrations.added'), 'yellow'), CLI::color(lang('Migrations.added'), 'yellow'),
$migration->namespace, $migration->namespace,
$migration->version, $migration->version,
$migration->class $migration->class,
); );
} }
} }
@ -625,7 +625,7 @@ class MigrationRunner
CLI::color(lang('Migrations.removed'), 'yellow'), CLI::color(lang('Migrations.removed'), 'yellow'),
$history->namespace, $history->namespace,
$history->version, $history->version,
$history->class $history->class,
); );
} }
} }

View File

@ -106,8 +106,8 @@ class Builder extends BaseBuilder
) )
), ),
array_keys($constraints), array_keys($constraints),
$constraints $constraints,
) ),
) . "\n"; ) . "\n";
$sql .= "SET\n"; $sql .= "SET\n";
@ -119,8 +119,8 @@ class Builder extends BaseBuilder
' = ' . $value : ' = ' . $value :
' = ' . $alias . '.' . $value), ' = ' . $alias . '.' . $value),
array_keys($updateFields), array_keys($updateFields),
$updateFields $updateFields,
) ),
); );
$this->QBOptions['sql'] = $sql; $this->QBOptions['sql'] = $sql;
@ -135,10 +135,10 @@ class Builder extends BaseBuilder
static fn ($value): string => 'SELECT ' . implode(', ', array_map( static fn ($value): string => 'SELECT ' . implode(', ', array_map(
static fn ($key, $index): string => $index . ' ' . $key, static fn ($key, $index): string => $index . ' ' . $key,
$keys, $keys,
$value $value,
)), )),
$values $values,
) ),
) . "\n"; ) . "\n";
} }

View File

@ -116,7 +116,7 @@ class Connection extends BaseConnection
if ($this->strictOn) { if ($this->strictOn) {
$this->mysqli->options( $this->mysqli->options(
MYSQLI_INIT_COMMAND, MYSQLI_INIT_COMMAND,
"SET SESSION sql_mode = CONCAT(@@sql_mode, ',', 'STRICT_ALL_TABLES')" "SET SESSION sql_mode = CONCAT(@@sql_mode, ',', 'STRICT_ALL_TABLES')",
); );
} else { } else {
$this->mysqli->options( $this->mysqli->options(
@ -128,7 +128,7 @@ class Connection extends BaseConnection
'STRICT_ALL_TABLES', ''), 'STRICT_ALL_TABLES', ''),
'STRICT_TRANS_TABLES,', ''), 'STRICT_TRANS_TABLES,', ''),
',STRICT_TRANS_TABLES', ''), ',STRICT_TRANS_TABLES', ''),
'STRICT_TRANS_TABLES', '')" 'STRICT_TRANS_TABLES', '')",
); );
} }
} }
@ -175,7 +175,7 @@ class Connection extends BaseConnection
$ssl['cert'] ?? null, $ssl['cert'] ?? null,
$ssl['ca'] ?? null, $ssl['ca'] ?? null,
$ssl['capath'] ?? null, $ssl['capath'] ?? null,
$ssl['cipher'] ?? null $ssl['cipher'] ?? null,
); );
} }
@ -190,7 +190,7 @@ class Connection extends BaseConnection
$this->database, $this->database,
$port, $port,
$socket, $socket,
$clientFlags $clientFlags,
)) { )) {
// Prior to version 5.7.3, MySQL silently downgrades to an unencrypted connection if SSL setup fails // Prior to version 5.7.3, MySQL silently downgrades to an unencrypted connection if SSL setup fails
if (($clientFlags & MYSQLI_CLIENT_SSL) !== 0 && version_compare($this->mysqli->client_info, 'mysqlnd 5.7.3', '<=') if (($clientFlags & MYSQLI_CLIENT_SSL) !== 0 && version_compare($this->mysqli->client_info, 'mysqlnd 5.7.3', '<=')
@ -381,7 +381,7 @@ class Connection extends BaseConnection
return str_replace( return str_replace(
[$this->likeEscapeChar, '%', '_'], [$this->likeEscapeChar, '%', '_'],
['\\' . $this->likeEscapeChar, '\\%', '\\_'], ['\\' . $this->likeEscapeChar, '\\%', '\\_'],
$str $str,
); );
} }

View File

@ -258,7 +258,7 @@ class Forge extends BaseForge
{ {
$sql = sprintf( $sql = sprintf(
'ALTER TABLE %s DROP PRIMARY KEY', 'ALTER TABLE %s DROP PRIMARY KEY',
$this->db->escapeIdentifiers($this->db->DBPrefix . $table) $this->db->escapeIdentifiers($this->db->DBPrefix . $table),
); );
return $this->db->query($sql); return $this->db->query($sql);

View File

@ -92,10 +92,10 @@ class Builder extends BaseBuilder
static fn ($value): string => 'SELECT ' . implode(', ', array_map( static fn ($value): string => 'SELECT ' . implode(', ', array_map(
static fn ($key, $index): string => $index . ' ' . $key, static fn ($key, $index): string => $index . ' ' . $key,
$keys, $keys,
$value $value,
)), )),
$values $values,
) ),
) . " FROM DUAL\n"; ) . " FROM DUAL\n";
} }
@ -287,8 +287,8 @@ class Builder extends BaseBuilder
) )
), ),
array_keys($constraints), array_keys($constraints),
$constraints $constraints,
) ),
) . ")\n"; ) . ")\n";
$sql .= "WHEN MATCHED THEN UPDATE\n"; $sql .= "WHEN MATCHED THEN UPDATE\n";
@ -302,8 +302,8 @@ class Builder extends BaseBuilder
' = ' . $value : ' = ' . $value :
' = ' . $alias . '.' . $value), ' = ' . $alias . '.' . $value),
array_keys($updateFields), array_keys($updateFields),
$updateFields $updateFields,
) ),
); );
$this->QBOptions['sql'] = $sql; $this->QBOptions['sql'] = $sql;
@ -318,10 +318,10 @@ class Builder extends BaseBuilder
static fn ($value): string => 'SELECT ' . implode(', ', array_map( static fn ($value): string => 'SELECT ' . implode(', ', array_map(
static fn ($key, $index): string => $index . ' ' . $key, static fn ($key, $index): string => $index . ' ' . $key,
$keys, $keys,
$value $value,
)) . ' FROM DUAL', )) . ' FROM DUAL',
$values $values,
) ),
) . "\n"; ) . "\n";
} }
@ -392,8 +392,8 @@ class Builder extends BaseBuilder
) )
), ),
array_keys($constraints), array_keys($constraints),
$constraints $constraints,
) ),
) . ")\n"; ) . ")\n";
$sql .= "WHEN MATCHED THEN UPDATE SET\n"; $sql .= "WHEN MATCHED THEN UPDATE SET\n";
@ -405,8 +405,8 @@ class Builder extends BaseBuilder
" = {$value}" : " = {$value}" :
" = {$alias}.{$value}"), " = {$alias}.{$value}"),
array_keys($updateFields), array_keys($updateFields),
$updateFields $updateFields,
) ),
); );
$sql .= "\nWHEN NOT MATCHED THEN INSERT (" . implode(', ', $keys) . ")\nVALUES "; $sql .= "\nWHEN NOT MATCHED THEN INSERT (" . implode(', ', $keys) . ")\nVALUES ";
@ -427,10 +427,10 @@ class Builder extends BaseBuilder
static fn ($value): string => 'SELECT ' . implode(', ', array_map( static fn ($value): string => 'SELECT ' . implode(', ', array_map(
static fn ($key, $index): string => $index . ' ' . $key, static fn ($key, $index): string => $index . ' ' . $key,
$keys, $keys,
$value $value,
)), )),
$values $values,
) ),
) . " FROM DUAL\n"; ) . " FROM DUAL\n";
} }
@ -477,8 +477,8 @@ class Builder extends BaseBuilder
) )
), ),
array_keys($constraints), array_keys($constraints),
$constraints $constraints,
) ),
); );
// convert binds in where // convert binds in where
@ -491,7 +491,7 @@ class Builder extends BaseBuilder
$sql .= ' ' . str_replace( $sql .= ' ' . str_replace(
'WHERE ', 'WHERE ',
'AND ', 'AND ',
$this->compileWhereHaving('QBWhere') $this->compileWhereHaving('QBWhere'),
) . ')'; ) . ')';
$this->QBOptions['sql'] = $sql; $this->QBOptions['sql'] = $sql;
@ -506,10 +506,10 @@ class Builder extends BaseBuilder
static fn ($value): string => 'SELECT ' . implode(', ', array_map( static fn ($value): string => 'SELECT ' . implode(', ', array_map(
static fn ($key, $index): string => $index . ' ' . $key, static fn ($key, $index): string => $index . ' ' . $key,
$keys, $keys,
$value $value,
)), )),
$values $values,
) ),
) . " FROM DUAL\n"; ) . " FROM DUAL\n";
} }

View File

@ -523,7 +523,7 @@ class Connection extends BaseConnection
$sql = sprintf( $sql = sprintf(
'BEGIN %s (' . substr(str_repeat(',%s', count($params)), 1) . '); END;', 'BEGIN %s (' . substr(str_repeat(',%s', count($params)), 1) . '); END;',
$procedureName, $procedureName,
...array_map(static fn ($row) => $row['name'], $params) ...array_map(static fn ($row) => $row['name'], $params),
); );
$this->resetStmtId = false; $this->resetStmtId = false;
@ -554,7 +554,7 @@ class Connection extends BaseConnection
$param['name'], $param['name'],
$param['value'], $param['value'],
$param['length'] ?? -1, $param['length'] ?? -1,
$param['type'] ?? SQLT_CHR $param['type'] ?? SQLT_CHR,
); );
} }
} }

View File

@ -112,7 +112,7 @@ class Forge extends BaseForge
$fields = array_map( $fields = array_map(
fn ($field) => $this->db->escapeIdentifiers(trim($field)), fn ($field) => $this->db->escapeIdentifiers(trim($field)),
is_string($columnNamesToDrop) ? explode(',', $columnNamesToDrop) : $columnNamesToDrop is_string($columnNamesToDrop) ? explode(',', $columnNamesToDrop) : $columnNamesToDrop,
); );
return $sql . ' DROP (' . implode(',', $fields) . ') CASCADE CONSTRAINT INVALIDATE'; return $sql . ' DROP (' . implode(',', $fields) . ') CASCADE CONSTRAINT INVALIDATE';
@ -184,7 +184,7 @@ class Forge extends BaseForge
protected function _attributeAutoIncrement(array &$attributes, array &$field) protected function _attributeAutoIncrement(array &$attributes, array &$field)
{ {
if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true
&& stripos($field['type'], 'NUMBER') !== false && str_contains(strtolower($field['type']), 'number')
&& version_compare($this->db->getVersion(), '12.1', '>=') && version_compare($this->db->getVersion(), '12.1', '>=')
) { ) {
$field['auto_increment'] = ' GENERATED BY DEFAULT ON NULL AS IDENTITY'; $field['auto_increment'] = ' GENERATED BY DEFAULT ON NULL AS IDENTITY';

View File

@ -357,8 +357,8 @@ class Builder extends BaseBuilder
' = ' . $value : ' = ' . $value :
' = ' . $that->cast($alias . '.' . $value, $that->getFieldType($table, $key))), ' = ' . $that->cast($alias . '.' . $value, $that->getFieldType($table, $key))),
array_keys($updateFields), array_keys($updateFields),
$updateFields $updateFields,
) ),
) . "\n"; ) . "\n";
$sql .= "FROM (\n{:_table_:}"; $sql .= "FROM (\n{:_table_:}";
@ -381,8 +381,8 @@ class Builder extends BaseBuilder
. $that->cast($alias . '.' . $value, $that->getFieldType($table, $value)); . $that->cast($alias . '.' . $value, $that->getFieldType($table, $value));
}, },
array_keys($constraints), array_keys($constraints),
$constraints $constraints,
) ),
); );
$this->QBOptions['sql'] = $sql; $this->QBOptions['sql'] = $sql;
@ -397,10 +397,10 @@ class Builder extends BaseBuilder
static fn ($value): string => 'SELECT ' . implode(', ', array_map( static fn ($value): string => 'SELECT ' . implode(', ', array_map(
static fn ($key, $index): string => $index . ' ' . $key, static fn ($key, $index): string => $index . ' ' . $key,
$keys, $keys,
$value $value,
)), )),
$values $values,
) ),
) . "\n"; ) . "\n";
} }
@ -528,8 +528,8 @@ class Builder extends BaseBuilder
" = {$value}" : " = {$value}" :
" = {$alias}.{$value}"), " = {$alias}.{$value}"),
array_keys($updateFields), array_keys($updateFields),
$updateFields $updateFields,
) ),
); );
$this->QBOptions['sql'] = $sql; $this->QBOptions['sql'] = $sql;
@ -584,15 +584,15 @@ class Builder extends BaseBuilder
return $table . '.' . $key . ' = ' return $table . '.' . $key . ' = '
. $that->cast( . $that->cast(
$alias . '.' . $value, $alias . '.' . $value,
$that->getFieldType($table, $key) $that->getFieldType($table, $key),
); );
} }
return $table . '.' . $value . ' = ' . $alias . '.' . $value; return $table . '.' . $value . ' = ' . $alias . '.' . $value;
}, },
array_keys($constraints), array_keys($constraints),
$constraints $constraints,
) ),
); );
// convert binds in where // convert binds in where
@ -605,7 +605,7 @@ class Builder extends BaseBuilder
$sql .= ' ' . str_replace( $sql .= ' ' . str_replace(
'WHERE ', 'WHERE ',
'AND ', 'AND ',
$this->compileWhereHaving('QBWhere') $this->compileWhereHaving('QBWhere'),
); );
$this->QBOptions['sql'] = $sql; $this->QBOptions['sql'] = $sql;
@ -620,10 +620,10 @@ class Builder extends BaseBuilder
static fn ($value): string => 'SELECT ' . implode(', ', array_map( static fn ($value): string => 'SELECT ' . implode(', ', array_map(
static fn ($key, $index): string => $index . ' ' . $key, static fn ($key, $index): string => $index . ' ' . $key,
$keys, $keys,
$value $value,
)), )),
$values $values,
) ),
) . "\n"; ) . "\n";
} }

View File

@ -227,6 +227,10 @@ class Connection extends BaseConnection
*/ */
public function affectedRows(): int public function affectedRows(): int
{ {
if ($this->resultID === false) {
return 0;
}
return pg_affected_rows($this->resultID); return pg_affected_rows($this->resultID);
} }

View File

@ -154,7 +154,7 @@ class Forge extends BaseForge
protected function _attributeType(array &$attributes) protected function _attributeType(array &$attributes)
{ {
// Reset field lengths for data types that don't support it // Reset field lengths for data types that don't support it
if (isset($attributes['CONSTRAINT']) && stripos($attributes['TYPE'], 'int') !== false) { if (isset($attributes['CONSTRAINT']) && str_contains(strtolower($attributes['TYPE']), 'int')) {
$attributes['CONSTRAINT'] = null; $attributes['CONSTRAINT'] = null;
} }

View File

@ -342,7 +342,7 @@ class Query implements QueryInterface, Stringable
*/ */
protected function matchSimpleBinds(string $sql, array $binds, int $bindCount, int $ml): string protected function matchSimpleBinds(string $sql, array $binds, int $bindCount, int $ml): string
{ {
if ($c = preg_match_all("/'[^']*'/", $sql, $matches)) { if ($c = preg_match_all("/'[^']*'/", $sql, $matches) >= 1) {
$c = preg_match_all('/' . preg_quote($this->bindMarker, '/') . '/i', str_replace($matches[0], str_replace($this->bindMarker, str_repeat(' ', $ml), $matches[0]), $sql, $c), $matches, PREG_OFFSET_CAPTURE); $c = preg_match_all('/' . preg_quote($this->bindMarker, '/') . '/i', str_replace($matches[0], str_replace($this->bindMarker, str_repeat(' ', $ml), $matches[0]), $sql, $c), $matches, PREG_OFFSET_CAPTURE);
// Bind values' count must match the count of markers in the query // Bind values' count must match the count of markers in the query

View File

@ -122,7 +122,7 @@ class Builder extends BaseBuilder
$cond = ' ON ' . $cond; $cond = ' ON ' . $cond;
} else { } else {
// Split multiple conditions // Split multiple conditions
if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE)) { if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE) >= 1) {
$conditions = []; $conditions = [];
$joints = $joints[0]; $joints = $joints[0];
array_unshift($joints, ['', 0]); array_unshift($joints, ['', 0]);
@ -764,8 +764,8 @@ class Builder extends BaseBuilder
) )
), ),
array_keys($constraints), array_keys($constraints),
$constraints $constraints,
) ),
) . ")\n"; ) . ")\n";
$sql .= "WHEN MATCHED THEN UPDATE SET\n"; $sql .= "WHEN MATCHED THEN UPDATE SET\n";
@ -777,8 +777,8 @@ class Builder extends BaseBuilder
' = ' . $value : ' = ' . $value :
" = {$alias}.{$value}"), " = {$alias}.{$value}"),
array_keys($updateFields), array_keys($updateFields),
$updateFields $updateFields,
) ),
); );
$sql .= "\nWHEN NOT MATCHED THEN INSERT (" . implode(', ', $keys) . ")\nVALUES "; $sql .= "\nWHEN NOT MATCHED THEN INSERT (" . implode(', ', $keys) . ")\nVALUES ";
@ -792,8 +792,8 @@ class Builder extends BaseBuilder
. 'isnull(IDENT_CURRENT(\'' . $fullTableName . '\')+IDENT_INCR(\'' . 'isnull(IDENT_CURRENT(\'' . $fullTableName . '\')+IDENT_INCR(\''
. $fullTableName . "'),1)) ELSE {$alias}.{$columnName} END" . $fullTableName . "'),1)) ELSE {$alias}.{$columnName} END"
: "{$alias}.{$columnName}", : "{$alias}.{$columnName}",
$keys $keys,
) ),
) . ');' ) . ');'
); );

View File

@ -444,6 +444,10 @@ class Connection extends BaseConnection
*/ */
public function affectedRows(): int public function affectedRows(): int
{ {
if ($this->resultID === false) {
return 0;
}
return sqlsrv_rows_affected($this->resultID); return sqlsrv_rows_affected($this->resultID);
} }

View File

@ -134,12 +134,12 @@ class Forge extends BaseForge
$sql = sprintf( $sql = sprintf(
$this->createDatabaseIfStr, $this->createDatabaseIfStr,
$dbName, $dbName,
$this->db->escapeIdentifier($dbName) $this->db->escapeIdentifier($dbName),
); );
} else { } else {
$sql = sprintf( $sql = sprintf(
$this->createDatabaseStr, $this->createDatabaseStr,
$this->db->escapeIdentifier($dbName) $this->db->escapeIdentifier($dbName),
); );
} }
@ -360,7 +360,7 @@ class Forge extends BaseForge
protected function _attributeType(array &$attributes) protected function _attributeType(array &$attributes)
{ {
// Reset field lengths for data types that don't support it // Reset field lengths for data types that don't support it
if (isset($attributes['CONSTRAINT']) && stripos($attributes['TYPE'], 'int') !== false) { if (isset($attributes['CONSTRAINT']) && str_contains(strtolower($attributes['TYPE']), 'int')) {
$attributes['CONSTRAINT'] = null; $attributes['CONSTRAINT'] = null;
} }
@ -381,8 +381,8 @@ class Forge extends BaseForge
$maxLength = max( $maxLength = max(
array_map( array_map(
static fn ($value): int => strlen($value), static fn ($value): int => strlen($value),
$attributes['CONSTRAINT'] $attributes['CONSTRAINT'],
) ),
); );
$attributes['TYPE'] = 'VARCHAR'; $attributes['TYPE'] = 'VARCHAR';
@ -412,7 +412,7 @@ class Forge extends BaseForge
*/ */
protected function _attributeAutoIncrement(array &$attributes, array &$field) protected function _attributeAutoIncrement(array &$attributes, array &$field)
{ {
if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true && stripos($field['type'], 'INT') !== false) { if (! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === true && str_contains(strtolower($field['type']), strtolower('INT'))) {
$field['auto_increment'] = ' IDENTITY(1,1)'; $field['auto_increment'] = ' IDENTITY(1,1)';
} }
} }

View File

@ -196,8 +196,8 @@ class Builder extends BaseBuilder
" = {$value}" : " = {$value}" :
" = {$alias}.{$value}"), " = {$alias}.{$value}"),
array_keys($updateFields), array_keys($updateFields),
$updateFields $updateFields,
) ),
); );
$this->QBOptions['sql'] = $sql; $this->QBOptions['sql'] = $sql;
@ -268,10 +268,10 @@ class Builder extends BaseBuilder
static fn ($value): string => 'SELECT ' . implode(', ', array_map( static fn ($value): string => 'SELECT ' . implode(', ', array_map(
static fn ($key, $index): string => $index . ' ' . $key, static fn ($key, $index): string => $index . ' ' . $key,
$keys, $keys,
$value $value,
)), )),
$values $values,
) ),
) . "\n"; ) . "\n";
} }

View File

@ -226,7 +226,7 @@ class Forge extends BaseForge
if ( if (
! empty($attributes['AUTO_INCREMENT']) ! empty($attributes['AUTO_INCREMENT'])
&& $attributes['AUTO_INCREMENT'] === true && $attributes['AUTO_INCREMENT'] === true
&& stripos($field['type'], 'int') !== false && str_contains(strtolower($field['type']), 'int')
) { ) {
$field['type'] = 'INTEGER PRIMARY KEY'; $field['type'] = 'INTEGER PRIMARY KEY';
$field['default'] = ''; $field['default'] = '';

View File

@ -308,7 +308,7 @@ class Table
$this->keys = array_filter( $this->keys = array_filter(
$this->keys, $this->keys,
static fn ($index): bool => count(array_intersect($index['fields'], $fieldNames)) === count($index['fields']) static fn ($index): bool => count(array_intersect($index['fields'], $fieldNames)) === count($index['fields']),
); );
// Unique/Index keys // Unique/Index keys
@ -334,7 +334,7 @@ class Table
$this->forge->addForeignKey( $this->forge->addForeignKey(
$foreignKey->column_name, $foreignKey->column_name,
trim($foreignKey->foreign_table_name, $this->db->DBPrefix), trim($foreignKey->foreign_table_name, $this->db->DBPrefix),
$foreignKey->foreign_column_name $foreignKey->foreign_column_name,
); );
} }
@ -358,15 +358,15 @@ class Table
$exFields = implode( $exFields = implode(
', ', ', ',
array_map(fn ($item) => $this->db->protectIdentifiers($item), $exFields) array_map(fn ($item) => $this->db->protectIdentifiers($item), $exFields),
); );
$newFields = implode( $newFields = implode(
', ', ', ',
array_map(fn ($item) => $this->db->protectIdentifiers($item), $newFields) array_map(fn ($item) => $this->db->protectIdentifiers($item), $newFields),
); );
$this->db->query( $this->db->query(
"INSERT INTO {$this->prefixedTableName}({$newFields}) SELECT {$exFields} FROM {$this->db->DBPrefix}temp_{$this->tableName}" "INSERT INTO {$this->prefixedTableName}({$newFields}) SELECT {$exFields} FROM {$this->db->DBPrefix}temp_{$this->tableName}",
); );
} }

View File

@ -61,7 +61,7 @@ abstract class BaseExceptionHandler
RequestInterface $request, RequestInterface $request,
ResponseInterface $response, ResponseInterface $response,
int $statusCode, int $statusCode,
int $exitCode int $exitCode,
); );
/** /**
@ -221,7 +221,7 @@ abstract class BaseExceptionHandler
"<span class='line highlight'><span class='number'>{$format}</span> %s\n</span>%s", "<span class='line highlight'><span class='number'>{$format}</span> %s\n</span>%s",
$n + $start + 1, $n + $start + 1,
strip_tags($row), strip_tags($row),
implode('', $tags[0]) implode('', $tags[0]),
); );
} else { } else {
$out .= sprintf('<span class="line"><span class="number">' . $format . '</span> %s', $n + $start + 1, $row) . "\n"; $out .= sprintf('<span class="line"><span class="number">' . $format . '</span> %s', $n + $start + 1, $row) . "\n";

View File

@ -47,7 +47,7 @@ final class ExceptionHandler extends BaseExceptionHandler implements ExceptionHa
RequestInterface $request, RequestInterface $request,
ResponseInterface $response, ResponseInterface $response,
int $statusCode, int $statusCode,
int $exitCode int $exitCode,
): void { ): void {
// ResponseTrait needs these properties. // ResponseTrait needs these properties.
$this->request = $request; $this->request = $request;
@ -68,10 +68,10 @@ final class ExceptionHandler extends BaseExceptionHandler implements ExceptionHa
'HTTP/%s %s %s', 'HTTP/%s %s %s',
$request->getProtocolVersion(), $request->getProtocolVersion(),
$response->getStatusCode(), $response->getStatusCode(),
$response->getReasonPhrase() $response->getReasonPhrase(),
), ),
true, true,
$statusCode $statusCode,
); );
} }
@ -129,7 +129,7 @@ final class ExceptionHandler extends BaseExceptionHandler implements ExceptionHa
protected function determineView( protected function determineView(
Throwable $exception, Throwable $exception,
string $templatePath, string $templatePath,
int $statusCode = 500 int $statusCode = 500,
): string { ): string {
// Production environments should have a custom exception file. // Production environments should have a custom exception file.
$view = 'production.php'; $view = 'production.php';
@ -138,7 +138,7 @@ final class ExceptionHandler extends BaseExceptionHandler implements ExceptionHa
in_array( in_array(
strtolower(ini_get('display_errors')), strtolower(ini_get('display_errors')),
['1', 'true', 'on', 'yes'], ['1', 'true', 'on', 'yes'],
true true,
) )
) { ) {
$view = 'error_exception.php'; $view = 'error_exception.php';

View File

@ -27,6 +27,6 @@ interface ExceptionHandlerInterface
RequestInterface $request, RequestInterface $request,
ResponseInterface $response, ResponseInterface $response,
int $statusCode, int $statusCode,
int $exitCode int $exitCode,
): void; ): void;
} }

View File

@ -164,7 +164,7 @@ class Exceptions
$this->request, $this->request,
$this->response, $this->response,
$statusCode, $statusCode,
$exitCode $exitCode,
); );
return; return;
@ -270,7 +270,7 @@ class Exceptions
in_array( in_array(
strtolower(ini_get('display_errors')), strtolower(ini_get('display_errors')),
['1', 'true', 'on', 'yes'], ['1', 'true', 'on', 'yes'],
true true,
) )
) { ) {
$view = 'error_exception.php'; $view = 'error_exception.php';
@ -462,7 +462,7 @@ class Exceptions
'errFile' => clean_path($file ?? ''), 'errFile' => clean_path($file ?? ''),
'errLine' => $line ?? 0, 'errLine' => $line ?? 0,
'trace' => self::renderBacktrace($trace), 'trace' => self::renderBacktrace($trace),
] ],
); );
return true; return true;
@ -567,7 +567,7 @@ class Exceptions
"<span class='line highlight'><span class='number'>{$format}</span> %s\n</span>%s", "<span class='line highlight'><span class='number'>{$format}</span> %s\n</span>%s",
$n + $start + 1, $n + $start + 1,
strip_tags($row), strip_tags($row),
implode('', $tags[0]) implode('', $tags[0]),
); );
} else { } else {
$out .= sprintf('<span class="line"><span class="number">' . $format . '</span> %s', $n + $start + 1, $row) . "\n"; $out .= sprintf('<span class="line"><span class="number">' . $format . '</span> %s', $n + $start + 1, $row) . "\n";
@ -611,7 +611,7 @@ class Exceptions
$frame['class'], $frame['class'],
$frame['type'], $frame['type'],
$frame['function'], $frame['function'],
$args $args,
); );
} }

View File

@ -58,7 +58,7 @@ class Toolbar
log_message( log_message(
'critical', 'critical',
'Toolbar collector does not exist (' . $collector . ').' 'Toolbar collector does not exist (' . $collector . ').'
. ' Please check $collectors in the app/Config/Toolbar.php file.' . ' Please check $collectors in the app/Config/Toolbar.php file.',
); );
continue; continue;
@ -391,7 +391,7 @@ class Toolbar
$stats['startTime'], $stats['startTime'],
$stats['totalTime'], $stats['totalTime'],
$request, $request,
$response $response,
); );
helper('filesystem'); helper('filesystem');
@ -439,8 +439,8 @@ class Toolbar
'/<head>/', '/<head>/',
'<head>' . $script, '<head>' . $script,
$response->getBody(), $response->getBody(),
1 1,
) ),
); );
return; return;
@ -516,7 +516,7 @@ class Toolbar
$history = new History(); $history = new History();
$history->setFiles( $history->setFiles(
$debugbarTime[0], $debugbarTime[0],
$this->config->maxHistory $this->config->maxHistory,
); );
$data['collectors'][] = $history->getAsArray(); $data['collectors'][] = $history->getAsArray();

View File

@ -228,7 +228,7 @@ class Database extends BaseCollector
$uniqueCount, $uniqueCount,
$uniqueCount > 1 ? 'of them' : '', $uniqueCount > 1 ? 'of them' : '',
$connectionCount, $connectionCount,
$connectionCount > 1 ? 's' : '' $connectionCount > 1 ? 's' : '',
); );
} }

View File

@ -109,7 +109,7 @@ class Routes extends BaseCollector
' <empty> | default: ' ' <empty> | default: '
. var_export( . var_export(
$param->isDefaultValueAvailable() ? $param->getDefaultValue() : null, $param->isDefaultValueAvailable() ? $param->getDefaultValue() : null,
true true,
), ),
]; ];
} }

View File

@ -1031,7 +1031,7 @@ class Email
$unwrap = []; $unwrap = [];
if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches)) { if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches) >= 1) {
for ($i = 0, $c = count($matches[0]); $i < $c; $i++) { for ($i = 0, $c = count($matches[0]); $i < $c; $i++) {
$unwrap[] = $matches[1][$i]; $unwrap[] = $matches[1][$i];
$str = str_replace($matches[0][$i], '{{unwrapped' . $i . '}}', $str); $str = str_replace($matches[0][$i], '{{unwrapped' . $i . '}}', $str);
@ -1659,7 +1659,7 @@ class Email
$this->finalBody = preg_replace_callback( $this->finalBody = preg_replace_callback(
'/\{unwrap\}(.*?)\{\/unwrap\}/si', '/\{unwrap\}(.*?)\{\/unwrap\}/si',
$this->removeNLCallback(...), $this->removeNLCallback(...),
$this->finalBody $this->finalBody,
); );
} }
@ -1900,7 +1900,7 @@ class Email
$this->SMTPPort, $this->SMTPPort,
$errno, $errno,
$errstr, $errstr,
$this->SMTPTimeout $this->SMTPTimeout,
); );
if (! is_resource($this->SMTPConnect)) { if (! is_resource($this->SMTPConnect)) {
@ -1921,7 +1921,7 @@ class Email
STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT
| STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT
| STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
| STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT,
); );
if ($crypto !== true) { if ($crypto !== true) {

View File

@ -138,7 +138,7 @@ class Entity implements JsonSerializable
array_merge($this->defaultCastHandlers, $this->castHandlers), array_merge($this->defaultCastHandlers, $this->castHandlers),
null, null,
null, null,
false false,
); );
$this->syncOriginal(); $this->syncOriginal();
@ -185,7 +185,7 @@ class Entity implements JsonSerializable
if (is_array($this->datamap)) { if (is_array($this->datamap)) {
$keys = array_unique( $keys = array_unique(
[...array_diff($keys, $this->datamap), ...array_keys($this->datamap)] [...array_diff($keys, $this->datamap), ...array_keys($this->datamap)],
); );
} }

View File

@ -76,7 +76,7 @@ class Events
return; return;
} }
$config = config(Modules::class); $config = new Modules();
$events = APPPATH . 'Config' . DIRECTORY_SEPARATOR . 'Events.php'; $events = APPPATH . 'Config' . DIRECTORY_SEPARATOR . 'Events.php';
$files = []; $files = [];
@ -212,7 +212,7 @@ class Events
if ($check === $listener) { if ($check === $listener) {
unset( unset(
static::$listeners[$eventName][1][$index], static::$listeners[$eventName][1][$index],
static::$listeners[$eventName][2][$index] static::$listeners[$eventName][2][$index],
); );
return true; return true;

View File

@ -68,7 +68,7 @@ class FrameworkException extends RuntimeException implements ExceptionInterface
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$message = sprintf( $message = sprintf(
'The framework needs the following extension(s) installed and loaded: %s.', 'The framework needs the following extension(s) installed and loaded: %s.',
$extension $extension,
); );
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
} else { } else {

View File

@ -103,7 +103,7 @@ class FileCollection implements Countable, IteratorAggregate
$pattern = str_replace( $pattern = str_replace(
['#', '.', '*', '?'], ['#', '.', '*', '?'],
['\#', '\.', '.*', '.'], ['\#', '\.', '.*', '.'],
$pattern $pattern,
); );
$pattern = "#\\A{$pattern}\\z#"; $pattern = "#\\A{$pattern}\\z#";
} }

View File

@ -116,7 +116,7 @@ class Filters
$this->request = &$request; $this->request = &$request;
$this->setResponse($response); $this->setResponse($response);
$this->modules = $modules ?? config(Modules::class); $this->modules = $modules instanceof Modules ? $modules : new Modules();
if ($this->modules->shouldDiscover('filters')) { if ($this->modules->shouldDiscover('filters')) {
$this->discoverFilters(); $this->discoverFilters();
@ -202,7 +202,7 @@ class Filters
$result = $class->before( $result = $class->before(
$this->request, $this->request,
$this->argumentsClass[$className] ?? null $this->argumentsClass[$className] ?? null,
); );
if ($result instanceof RequestInterface) { if ($result instanceof RequestInterface) {
@ -241,7 +241,7 @@ class Filters
$result = $class->after( $result = $class->after(
$this->request, $this->request,
$this->response, $this->response,
$this->argumentsClass[$className] ?? null $this->argumentsClass[$className] ?? null,
); );
if ($result instanceof ResponseInterface) { if ($result instanceof ResponseInterface) {
@ -648,7 +648,7 @@ class Filters
@trigger_error( @trigger_error(
'Setting lowercase HTTP method key "' . strtolower($method) . '" is deprecated.' 'Setting lowercase HTTP method key "' . strtolower($method) . '" is deprecated.'
. ' Use uppercase HTTP method like "' . strtoupper($method) . '".', . ' Use uppercase HTTP method like "' . strtoupper($method) . '".',
E_USER_DEPRECATED E_USER_DEPRECATED,
); );
$found = true; $found = true;
@ -744,7 +744,7 @@ class Filters
if ($check && array_key_exists($name, $this->arguments)) { if ($check && array_key_exists($name, $this->arguments)) {
throw new ConfigException( throw new ConfigException(
'"' . $name . '" already has arguments: ' '"' . $name . '" already has arguments: '
. (($this->arguments[$name] === null) ? 'null' : implode(',', $this->arguments[$name])) . (($this->arguments[$name] === null) ? 'null' : implode(',', $this->arguments[$name])),
); );
} }

View File

@ -53,7 +53,7 @@ class PerformanceMetrics implements FilterInterface
(string) $benchmark->getElapsedTime('total_execution'), (string) $benchmark->getElapsedTime('total_execution'),
number_format(memory_get_peak_usage() / 1024 / 1024, 3), number_format(memory_get_peak_usage() / 1024 / 1024, 3),
], ],
$body $body,
); );
$response->setBody($output); $response->setBody($output);

View File

@ -342,7 +342,7 @@ class CURLRequest extends OutgoingRequest
$uri->getAuthority(), $uri->getAuthority(),
$uri->getPath(), $uri->getPath(),
$uri->getQuery(), $uri->getQuery(),
$uri->getFragment() $uri->getFragment(),
); );
} }

View File

@ -107,7 +107,7 @@ class Cors
if (in_array('*', $this->config[$name], true) && $count > 1) { if (in_array('*', $this->config[$name], true) && $count > 1) {
throw new ConfigException( throw new ConfigException(
"If wildcard is specified, you must set `'{$name}' => ['*']`." "If wildcard is specified, you must set `'{$name}' => ['*']`."
. ' But using wildcard is not recommended.' . ' But using wildcard is not recommended.',
); );
} }
} }
@ -121,7 +121,7 @@ class Cors
throw new ConfigException( throw new ConfigException(
'When responding to a credentialed request, ' 'When responding to a credentialed request, '
. 'the server must not specify the "*" wildcard for the ' . 'the server must not specify the "*" wildcard for the '
. $header . ' response-header value.' . $header . ' response-header value.',
); );
} }
} }
@ -176,7 +176,7 @@ class Cors
$response->setHeader( $response->setHeader(
'Access-Control-Allow-Headers', 'Access-Control-Allow-Headers',
implode(', ', $this->config['allowedHeaders']) implode(', ', $this->config['allowedHeaders']),
); );
} }
@ -187,7 +187,7 @@ class Cors
$response->setHeader( $response->setHeader(
'Access-Control-Allow-Methods', 'Access-Control-Allow-Methods',
implode(', ', $this->config['allowedMethods']) implode(', ', $this->config['allowedMethods']),
); );
} }
@ -223,7 +223,7 @@ class Cors
if ($this->config['exposedHeaders'] !== []) { if ($this->config['exposedHeaders'] !== []) {
$response->setHeader( $response->setHeader(
'Access-Control-Expose-Headers', 'Access-Control-Expose-Headers',
implode(', ', $this->config['exposedHeaders']) implode(', ', $this->config['exposedHeaders']),
); );
} }
} }

Some files were not shown because too many files have changed in this diff Show More