mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
commit
195c0dac03
51
.github/mergeable.yml
vendored
51
.github/mergeable.yml
vendored
@ -2,40 +2,33 @@
|
||||
|
||||
version: 2
|
||||
mergeable:
|
||||
- when: issues.opened
|
||||
- when: issues.opened, issues.reopened
|
||||
validate:
|
||||
- do: description
|
||||
and:
|
||||
- must_include:
|
||||
regex: '^### PHP Version'
|
||||
- must_include:
|
||||
regex: '^### CodeIgniter4 Version'
|
||||
- do: author
|
||||
and:
|
||||
- must_exclude:
|
||||
regex: 'kenjis'
|
||||
- must_exclude:
|
||||
regex: 'lonnieezell'
|
||||
- must_exclude:
|
||||
regex: 'MGatner'
|
||||
- must_exclude:
|
||||
regex: 'michalsn'
|
||||
- must_exclude:
|
||||
regex: 'paulbalandan'
|
||||
- must_exclude:
|
||||
regex: 'samsonasik'
|
||||
- do: or
|
||||
validate:
|
||||
- do: and
|
||||
validate:
|
||||
- do: description
|
||||
must_include:
|
||||
regex: '### PHP Version'
|
||||
- do: description
|
||||
must_include:
|
||||
regex: '### CodeIgniter4 Version'
|
||||
- do: author
|
||||
must_include:
|
||||
regex: ^kenjis|lonnieezell|MGatner|michalsn|paulbalandan|samsonasik$
|
||||
fail:
|
||||
- do: comment
|
||||
payload: |
|
||||
Hi there! :wave:
|
||||
payload:
|
||||
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
|
||||
|
@ -39,7 +39,9 @@ $finder = Finder::create()
|
||||
__DIR__ . '/spark',
|
||||
]);
|
||||
|
||||
$overrides = [];
|
||||
$overrides = [
|
||||
'modernize_strpos' => ['modernize_stripos' => true],
|
||||
];
|
||||
|
||||
$options = [
|
||||
'cacheFile' => 'build/.php-cs-fixer.cache',
|
||||
@ -53,5 +55,5 @@ $options = [
|
||||
return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary(
|
||||
'CodeIgniter 4 framework',
|
||||
'CodeIgniter Foundation',
|
||||
'admin@codeigniter.com'
|
||||
'admin@codeigniter.com',
|
||||
);
|
||||
|
27
CHANGELOG.md
27
CHANGELOG.md
@ -1,5 +1,32 @@
|
||||
# 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)
|
||||
[Full Changelog](https://github.com/codeigniter4/CodeIgniter4/compare/v4.5.6...v4.5.7)
|
||||
|
||||
|
2
LICENSE
2
LICENSE
@ -1,7 +1,7 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
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
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -47,7 +47,7 @@ if ($isMinorUpdate) {
|
||||
replace_file_content(
|
||||
$changelogIndex,
|
||||
'/\.\. toctree::\n :titlesonly:\n/u',
|
||||
".. toctree::\n :titlesonly:\n\n v{$version}"
|
||||
".. toctree::\n :titlesonly:\n\n v{$version}",
|
||||
);
|
||||
// Replace {version}
|
||||
$length = mb_strlen("Version {$version}");
|
||||
@ -55,12 +55,12 @@ $underline = str_repeat('#', $length);
|
||||
replace_file_content(
|
||||
$changelog,
|
||||
'/#################\nVersion {version}\n#################/u',
|
||||
"{$underline}\nVersion {$version}\n{$underline}"
|
||||
"{$underline}\nVersion {$version}\n{$underline}",
|
||||
);
|
||||
replace_file_content(
|
||||
$changelog,
|
||||
'/{version}/u',
|
||||
"{$version}"
|
||||
"{$version}",
|
||||
);
|
||||
|
||||
// Copy upgrading
|
||||
@ -72,7 +72,7 @@ copy('./admin/next-upgrading-guide.rst', $upgrading);
|
||||
replace_file_content(
|
||||
$upgradingIndex,
|
||||
'/ backward_compatibility_notes\n/u',
|
||||
" backward_compatibility_notes\n\n upgrade_{$versionWithoutDots}"
|
||||
" backward_compatibility_notes\n\n upgrade_{$versionWithoutDots}",
|
||||
);
|
||||
// Replace {version}
|
||||
$length = mb_strlen("Upgrading from {$versionCurrent} to {$version}");
|
||||
@ -80,7 +80,7 @@ $underline = str_repeat('#', $length);
|
||||
replace_file_content(
|
||||
$upgrading,
|
||||
'/##############################\nUpgrading from {version} to {version}\n##############################/u',
|
||||
"{$underline}\nUpgrading from {$versionCurrent} to {$version}\n{$underline}"
|
||||
"{$underline}\nUpgrading from {$versionCurrent} to {$version}\n{$underline}",
|
||||
);
|
||||
|
||||
// Commits
|
||||
|
@ -33,31 +33,31 @@ system('git switch -c release-' . $version);
|
||||
replace_file_content(
|
||||
'./system/CodeIgniter.php',
|
||||
'/public const CI_VERSION = \'.*?\';/u',
|
||||
"public const CI_VERSION = '{$version}';"
|
||||
"public const CI_VERSION = '{$version}';",
|
||||
);
|
||||
|
||||
// Updates version number in "conf.py".
|
||||
replace_file_content(
|
||||
'./user_guide_src/source/conf.py',
|
||||
'/^version = \'.*?\'/mu',
|
||||
"version = '{$minor}'"
|
||||
"version = '{$minor}'",
|
||||
);
|
||||
replace_file_content(
|
||||
'./user_guide_src/source/conf.py',
|
||||
'/^release = \'.*?\'/mu',
|
||||
"release = '{$version}'"
|
||||
"release = '{$version}'",
|
||||
);
|
||||
|
||||
// Updates version number in "phpdoc.dist.xml".
|
||||
replace_file_content(
|
||||
'./phpdoc.dist.xml',
|
||||
'!<title>CodeIgniter v.*? API</title>!mu',
|
||||
"<title>CodeIgniter v{$minor} API</title>"
|
||||
"<title>CodeIgniter v{$minor} API</title>",
|
||||
);
|
||||
replace_file_content(
|
||||
'./phpdoc.dist.xml',
|
||||
'/<version number=".*?">/mu',
|
||||
"<version number=\"{$version}\">"
|
||||
"<version number=\"{$version}\">",
|
||||
);
|
||||
|
||||
// Updates release date in changelogs.
|
||||
@ -65,7 +65,7 @@ $date = date('F j, Y');
|
||||
replace_file_content(
|
||||
"./user_guide_src/source/changelogs/v{$version}.rst",
|
||||
'/^Release Date: .*/mu',
|
||||
"Release Date: {$date}"
|
||||
"Release Date: {$date}",
|
||||
);
|
||||
|
||||
// Commits
|
||||
|
@ -32,7 +32,7 @@ final class HealthTest extends CIUnitTestCase
|
||||
$config = new App();
|
||||
$this->assertTrue(
|
||||
$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?
|
||||
$this->assertTrue(
|
||||
$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',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
"phpunit/phpcov": "^9.0.2 || ^10.0",
|
||||
"phpunit/phpunit": "^10.5.16 || ^11.2",
|
||||
"predis/predis": "^1.1 || ^2.0",
|
||||
"rector/rector": "2.0.4",
|
||||
"rector/rector": "2.0.6",
|
||||
"shipmonk/phpstan-baseline-per-identifier": "^2.0"
|
||||
},
|
||||
"replace": {
|
||||
|
@ -10,7 +10,7 @@
|
||||
<output>api/build/</output>
|
||||
<cache>api/cache/</cache>
|
||||
</paths>
|
||||
<version number="4.5.7">
|
||||
<version number="4.5.8">
|
||||
<api format="php">
|
||||
<source dsn=".">
|
||||
<path>system</path>
|
||||
|
@ -11,7 +11,6 @@
|
||||
failOnWarning="true"
|
||||
cacheDirectory="build/.phpunit.cache">
|
||||
<coverage
|
||||
includeUncoveredFiles="true"
|
||||
pathCoverage="false"
|
||||
ignoreDeprecatedCodeUnits="true"
|
||||
disableCodeCoverageIgnore="true">
|
||||
|
@ -86,7 +86,7 @@ class preload
|
||||
$phpFiles = new RegexIterator(
|
||||
$fullTree,
|
||||
'/.+((?<!Test)+\.php$)/i',
|
||||
RecursiveRegexIterator::GET_MATCH
|
||||
RecursiveRegexIterator::GET_MATCH,
|
||||
);
|
||||
|
||||
foreach ($phpFiles as $key => $file) {
|
||||
|
@ -11,7 +11,7 @@ if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
|
||||
$message = sprintf(
|
||||
'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s',
|
||||
$minPhpVersion,
|
||||
PHP_VERSION
|
||||
PHP_VERSION,
|
||||
);
|
||||
|
||||
header('HTTP/1.1 503 Service Unavailable.', true, 503);
|
||||
|
@ -62,7 +62,7 @@ return RectorConfig::configure()
|
||||
->withCache(
|
||||
// Github action cache or local
|
||||
is_dir('/tmp') ? '/tmp/rector' : null,
|
||||
FileCacheStorage::class
|
||||
FileCacheStorage::class,
|
||||
)
|
||||
// paths to refactor; solid alternative to CLI arguments
|
||||
->withPaths([
|
||||
|
2
spark
2
spark
@ -40,7 +40,7 @@ if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
|
||||
$message = sprintf(
|
||||
'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s',
|
||||
$minPhpVersion,
|
||||
PHP_VERSION
|
||||
PHP_VERSION,
|
||||
);
|
||||
|
||||
exit($message);
|
||||
|
@ -319,7 +319,7 @@ trait ResponseTrait
|
||||
$mime = $this->request->negotiate(
|
||||
'media',
|
||||
$format->getConfig()->supportedResponseFormats,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ class Autoloader
|
||||
|
||||
throw new InvalidArgumentException(
|
||||
'The file path contains special characters "' . $chars
|
||||
. '" that are not allowed: "' . $filename . '"'
|
||||
. '" that are not allowed: "' . $filename . '"',
|
||||
);
|
||||
}
|
||||
if ($result === false) {
|
||||
@ -386,7 +386,7 @@ class Autoloader
|
||||
throw new RuntimeException(
|
||||
'Your Composer version is too old.'
|
||||
. ' 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.
|
||||
|
@ -295,9 +295,9 @@ class FileLocator implements FileLocatorInterface
|
||||
str_replace(
|
||||
'/',
|
||||
'\\',
|
||||
mb_substr($path, mb_strlen($namespace['path']))
|
||||
mb_substr($path, mb_strlen($namespace['path'])),
|
||||
),
|
||||
'\\'
|
||||
'\\',
|
||||
);
|
||||
// Remove the file extension (.php)
|
||||
$className = mb_substr($className, 0, -4);
|
||||
|
@ -379,7 +379,7 @@ abstract class BaseModel
|
||||
$this->converter = new DataConverter(
|
||||
$this->casts,
|
||||
$this->castHandlers,
|
||||
$this->db
|
||||
$this->db,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1081,7 +1081,7 @@ abstract class BaseModel
|
||||
if ($updateIndex === null) {
|
||||
throw new InvalidArgumentException(
|
||||
'The index ("' . $index . '") for updateBatch() is missing in the data: '
|
||||
. json_encode($row)
|
||||
. json_encode($row),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ class Boot
|
||||
|
||||
$message = sprintf(
|
||||
'The framework needs the following extension(s) installed and loaded: %s.',
|
||||
implode(', ', $missingExtensions)
|
||||
implode(', ', $missingExtensions),
|
||||
);
|
||||
|
||||
header('HTTP/1.1 503 Service Unavailable.', true, 503);
|
||||
|
@ -289,7 +289,7 @@ class CLI
|
||||
|
||||
CLI::isZeroOptions($options);
|
||||
|
||||
if ($line = array_shift($text)) {
|
||||
if (($line = array_shift($text)) !== null) {
|
||||
CLI::write($line);
|
||||
}
|
||||
|
||||
@ -348,7 +348,7 @@ class CLI
|
||||
// return the prompt again if $input contain(s) non-numeric character, except a comma.
|
||||
// And if max from $options less than max from input,
|
||||
// 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.');
|
||||
CLI::newLine();
|
||||
|
||||
@ -610,11 +610,11 @@ class CLI
|
||||
$nonColoredText = preg_replace(
|
||||
$pattern,
|
||||
'<<__colored_string__>>',
|
||||
$text
|
||||
$text,
|
||||
);
|
||||
$nonColoredChunks = preg_split(
|
||||
'/<<__colored_string__>>/u',
|
||||
$nonColoredText
|
||||
$nonColoredText,
|
||||
);
|
||||
|
||||
foreach ($nonColoredChunks as $i => $chunk) {
|
||||
|
@ -63,7 +63,7 @@ class Console
|
||||
'CodeIgniter v%s Command Line Tool - Server Time: %s UTC%s',
|
||||
CodeIgniter::CI_VERSION,
|
||||
date('Y-m-d H:i:s'),
|
||||
date('P')
|
||||
date('P'),
|
||||
), 'green');
|
||||
CLI::newLine();
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ trait GeneratorTrait
|
||||
CLI::prompt(
|
||||
'Are you sure you want to continue?',
|
||||
['y', 'n'],
|
||||
'required'
|
||||
'required',
|
||||
) === 'n'
|
||||
) {
|
||||
CLI::newLine();
|
||||
@ -193,7 +193,7 @@ trait GeneratorTrait
|
||||
CLI::error(
|
||||
lang('CLI.generator.fileExist', [clean_path($target)]),
|
||||
'light_gray',
|
||||
'red'
|
||||
'red',
|
||||
);
|
||||
CLI::newLine();
|
||||
|
||||
@ -216,7 +216,7 @@ trait GeneratorTrait
|
||||
CLI::error(
|
||||
lang('CLI.generator.fileError', [clean_path($target)]),
|
||||
'light_gray',
|
||||
'red'
|
||||
'red',
|
||||
);
|
||||
CLI::newLine();
|
||||
|
||||
@ -227,7 +227,7 @@ trait GeneratorTrait
|
||||
if ($this->getOption('force') && $isFile) {
|
||||
CLI::write(
|
||||
lang('CLI.generator.fileOverwrite', [clean_path($target)]),
|
||||
'yellow'
|
||||
'yellow',
|
||||
);
|
||||
CLI::newLine();
|
||||
|
||||
@ -236,7 +236,7 @@ trait GeneratorTrait
|
||||
|
||||
CLI::write(
|
||||
lang('CLI.generator.fileCreate', [clean_path($target)]),
|
||||
'green'
|
||||
'green',
|
||||
);
|
||||
CLI::newLine();
|
||||
}
|
||||
@ -326,10 +326,10 @@ trait GeneratorTrait
|
||||
'\\',
|
||||
array_map(
|
||||
pascalize(...),
|
||||
explode('\\', str_replace('/', '\\', trim($class)))
|
||||
)
|
||||
explode('\\', str_replace('/', '\\', trim($class))),
|
||||
),
|
||||
),
|
||||
'\\/'
|
||||
'\\/',
|
||||
);
|
||||
}
|
||||
|
||||
@ -351,7 +351,7 @@ trait GeneratorTrait
|
||||
return view(
|
||||
"CodeIgniter\\Commands\\Generators\\Views\\{$this->template}",
|
||||
$data,
|
||||
['debug' => false]
|
||||
['debug' => false],
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -370,15 +370,15 @@ trait GeneratorTrait
|
||||
string $class,
|
||||
array $search = [],
|
||||
array $replace = [],
|
||||
array $data = []
|
||||
array $data = [],
|
||||
): string {
|
||||
// Retrieves the namespace part from the fully qualified class name.
|
||||
$namespace = trim(
|
||||
implode(
|
||||
'\\',
|
||||
array_slice(explode('\\', $class), 0, -1)
|
||||
array_slice(explode('\\', $class), 0, -1),
|
||||
),
|
||||
'\\'
|
||||
'\\',
|
||||
);
|
||||
$search[] = '<@php';
|
||||
$search[] = '{namespace}';
|
||||
@ -404,7 +404,7 @@ trait GeneratorTrait
|
||||
&& preg_match(
|
||||
'/(?P<imports>(?:^use [^;]+;$\n?)+)/m',
|
||||
$template,
|
||||
$match
|
||||
$match,
|
||||
)
|
||||
) {
|
||||
$imports = explode("\n", trim($match['imports']));
|
||||
@ -432,7 +432,7 @@ trait GeneratorTrait
|
||||
CLI::error(
|
||||
lang('CLI.namespaceNotDefined', [$namespace]),
|
||||
'light_gray',
|
||||
'red'
|
||||
'red',
|
||||
);
|
||||
CLI::newLine();
|
||||
|
||||
@ -446,7 +446,7 @@ trait GeneratorTrait
|
||||
. str_replace(
|
||||
'\\',
|
||||
DIRECTORY_SEPARATOR,
|
||||
trim(str_replace($namespace . '\\', '', $class), '\\')
|
||||
trim(str_replace($namespace . '\\', '', $class), '\\'),
|
||||
) . '.php';
|
||||
|
||||
return implode(
|
||||
@ -454,8 +454,8 @@ trait GeneratorTrait
|
||||
array_slice(
|
||||
explode(DIRECTORY_SEPARATOR, $file),
|
||||
0,
|
||||
-1
|
||||
)
|
||||
-1,
|
||||
),
|
||||
) . DIRECTORY_SEPARATOR . $this->basename($file);
|
||||
}
|
||||
|
||||
@ -470,9 +470,9 @@ trait GeneratorTrait
|
||||
str_replace(
|
||||
'/',
|
||||
'\\',
|
||||
$this->getOption('namespace') ?? APP_NAMESPACE
|
||||
$this->getOption('namespace') ?? APP_NAMESPACE,
|
||||
),
|
||||
'\\'
|
||||
'\\',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class MemcachedHandler extends BaseHandler
|
||||
$this->memcached->addServer(
|
||||
$this->config['host'],
|
||||
$this->config['port'],
|
||||
$this->config['weight']
|
||||
$this->config['weight'],
|
||||
);
|
||||
|
||||
// attempt to get status of servers
|
||||
@ -103,7 +103,7 @@ class MemcachedHandler extends BaseHandler
|
||||
// Check if we can connect to the server
|
||||
$canConnect = $this->memcached->connect(
|
||||
$this->config['host'],
|
||||
$this->config['port']
|
||||
$this->config['port'],
|
||||
);
|
||||
|
||||
// If we can't connect, throw a CriticalError exception
|
||||
@ -116,7 +116,7 @@ class MemcachedHandler extends BaseHandler
|
||||
$this->config['host'],
|
||||
$this->config['port'],
|
||||
true,
|
||||
$this->config['weight']
|
||||
$this->config['weight'],
|
||||
);
|
||||
} else {
|
||||
throw new CriticalError('Cache: Not support Memcache(d) extension.');
|
||||
|
@ -82,7 +82,7 @@ class PredisHandler extends BaseHandler
|
||||
|
||||
$data = array_combine(
|
||||
['__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) {
|
||||
|
@ -112,7 +112,7 @@ final class ResponseCache
|
||||
return $this->cache->save(
|
||||
$this->generateCacheKey($request),
|
||||
serialize(['headers' => $headers, 'output' => $response->getBody()]),
|
||||
$this->ttl
|
||||
$this->ttl,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ class CodeIgniter
|
||||
/**
|
||||
* The current version of CodeIgniter Framework
|
||||
*/
|
||||
public const CI_VERSION = '4.5.7';
|
||||
public const CI_VERSION = '4.5.8';
|
||||
|
||||
/**
|
||||
* App startup time.
|
||||
@ -325,7 +325,7 @@ class CodeIgniter
|
||||
if ($this->context === null) {
|
||||
throw new LogicException(
|
||||
'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(
|
||||
['{elapsed_time}', '{memory_usage}'],
|
||||
[(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.
|
||||
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->getPath(),
|
||||
$uri->getQuery(),
|
||||
$uri->getFragment()
|
||||
$uri->getFragment(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ class ShowTableInfo extends BaseCommand
|
||||
$tableNameNo = CLI::promptByKey(
|
||||
['Here is the list of your database tables:', 'Which table do you want to see?'],
|
||||
$tables,
|
||||
'required'
|
||||
'required',
|
||||
);
|
||||
CLI::newLine();
|
||||
|
||||
@ -174,7 +174,7 @@ class ShowTableInfo extends BaseCommand
|
||||
]];
|
||||
CLI::table(
|
||||
$data,
|
||||
['hostname', 'database', 'username', 'DBDriver', 'DBPrefix', 'port']
|
||||
['hostname', 'database', 'username', 'DBDriver', 'DBPrefix', 'port'],
|
||||
);
|
||||
}
|
||||
|
||||
@ -272,7 +272,7 @@ class ShowTableInfo extends BaseCommand
|
||||
string $tableName,
|
||||
int $limitRows,
|
||||
int $limitFieldValue,
|
||||
?string $sortField = null
|
||||
?string $sortField = null,
|
||||
): array {
|
||||
$this->tbody = [];
|
||||
|
||||
@ -290,7 +290,7 @@ class ShowTableInfo extends BaseCommand
|
||||
static fn ($item): string => mb_strlen((string) $item) > $limitFieldValue
|
||||
? mb_substr((string) $item, 0, $limitFieldValue) . '...'
|
||||
: (string) $item,
|
||||
$row
|
||||
$row,
|
||||
);
|
||||
$this->tbody[] = $row;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ class GenerateKey extends BaseCommand
|
||||
$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',
|
||||
$replacementKey,
|
||||
$oldFileContents
|
||||
$oldFileContents,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ class CellGenerator extends BaseCommand
|
||||
$viewName = preg_replace(
|
||||
'/([a-z][a-z0-9_\/\\\\]+)(_cell)$/i',
|
||||
'$1',
|
||||
$viewName
|
||||
$viewName,
|
||||
) ?? $viewName;
|
||||
$namespace = substr($className, 0, strrpos($className, '\\') + 1);
|
||||
|
||||
|
@ -115,7 +115,7 @@ class CommandGenerator extends BaseCommand
|
||||
$class,
|
||||
['{group}', '{command}'],
|
||||
[$group, $command],
|
||||
['type' => $type]
|
||||
['type' => $type],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ class ControllerGenerator extends BaseCommand
|
||||
$class,
|
||||
['{useStatement}', '{extends}'],
|
||||
[$useStatement, $extends],
|
||||
['type' => $rest]
|
||||
['type' => $rest],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -102,9 +102,9 @@ class TestGenerator extends BaseCommand
|
||||
str_replace(
|
||||
'/',
|
||||
'\\',
|
||||
$this->getOption('namespace')
|
||||
$this->getOption('namespace'),
|
||||
),
|
||||
'\\'
|
||||
'\\',
|
||||
);
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ class TestGenerator extends BaseCommand
|
||||
CLI::error(
|
||||
lang('CLI.namespaceNotDefined', [$namespace]),
|
||||
'light_gray',
|
||||
'red'
|
||||
'red',
|
||||
);
|
||||
CLI::newLine();
|
||||
|
||||
@ -157,7 +157,7 @@ class TestGenerator extends BaseCommand
|
||||
. str_replace(
|
||||
'\\',
|
||||
DIRECTORY_SEPARATOR,
|
||||
trim(str_replace($namespace . '\\', '', $class), '\\')
|
||||
trim(str_replace($namespace . '\\', '', $class), '\\'),
|
||||
) . '.php';
|
||||
|
||||
return implode(
|
||||
@ -165,8 +165,8 @@ class TestGenerator extends BaseCommand
|
||||
array_slice(
|
||||
explode(DIRECTORY_SEPARATOR, $file),
|
||||
0,
|
||||
-1
|
||||
)
|
||||
-1,
|
||||
),
|
||||
) . DIRECTORY_SEPARATOR . $this->basename($file);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ class LocalizationFinder extends BaseCommand
|
||||
if (! in_array($optionLocale, config(App::class)->supportedLocales, true)) {
|
||||
CLI::error(
|
||||
'Error: "' . $optionLocale . '" is not supported. Supported locales: '
|
||||
. implode(', ', config(App::class)->supportedLocales)
|
||||
. implode(', ', config(App::class)->supportedLocales),
|
||||
);
|
||||
|
||||
return EXIT_USER_INPUT;
|
||||
@ -116,7 +116,7 @@ class LocalizationFinder extends BaseCommand
|
||||
[
|
||||
'foundLanguageKeys' => $foundLanguageKeys,
|
||||
'badLanguageKeys' => $badLanguageKeys,
|
||||
'countFiles' => $countFiles
|
||||
'countFiles' => $countFiles,
|
||||
] = $this->findLanguageKeysInFiles($files);
|
||||
|
||||
ksort($foundLanguageKeys);
|
||||
|
@ -109,7 +109,7 @@ final class ConfigCheck extends BaseCommand
|
||||
CLI::write($this->getKintD($config));
|
||||
} else {
|
||||
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(
|
||||
'!.*system/Commands/Utilities/ConfigCheck.php.*\n!u',
|
||||
'',
|
||||
$output
|
||||
$output,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ final class Environment extends BaseCommand
|
||||
|
||||
return file_put_contents(
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class FilterCheck extends BaseCommand
|
||||
CLI::color(
|
||||
'"' . strtoupper($method) . ' ' . $route . '"',
|
||||
'black',
|
||||
'light_gray'
|
||||
'light_gray',
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -110,13 +110,13 @@ final class Optimize extends BaseCommand
|
||||
[
|
||||
'public bool $configCacheEnabled = false;' => 'public bool $configCacheEnabled = true;',
|
||||
'public bool $locatorCacheEnabled = false;' => 'public bool $locatorCacheEnabled = true;',
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
if ($result) {
|
||||
CLI::write(
|
||||
'Config Caching and FileLocator Caching are enabled in "app/Config/Optimize.php".',
|
||||
'green'
|
||||
'green',
|
||||
);
|
||||
|
||||
return;
|
||||
|
@ -133,7 +133,7 @@ class Routes extends BaseCommand
|
||||
$collection->getDefaultController(),
|
||||
$collection->getDefaultMethod(),
|
||||
$methods,
|
||||
$collection->getRegisteredControllers('*')
|
||||
$collection->getRegisteredControllers('*'),
|
||||
);
|
||||
|
||||
$autoRoutes = $autoRouteCollector->get();
|
||||
@ -149,7 +149,7 @@ class Routes extends BaseCommand
|
||||
$collection->getDefaultMethod(),
|
||||
$methods,
|
||||
$collection->getRegisteredControllers('*'),
|
||||
$uri
|
||||
$uri,
|
||||
);
|
||||
|
||||
$autoRoutes = [...$autoRoutes, ...$autoRouteCollector->get()];
|
||||
@ -159,7 +159,7 @@ class Routes extends BaseCommand
|
||||
$autoRouteCollector = new AutoRouteCollector(
|
||||
$collection->getDefaultNamespace(),
|
||||
$collection->getDefaultController(),
|
||||
$collection->getDefaultMethod()
|
||||
$collection->getDefaultMethod(),
|
||||
);
|
||||
|
||||
$autoRoutes = $autoRouteCollector->get();
|
||||
|
@ -41,7 +41,7 @@ final class AutoRouteCollector
|
||||
$output = $reader->read(
|
||||
$class,
|
||||
$this->defaultController,
|
||||
$this->defaultMethod
|
||||
$this->defaultMethod,
|
||||
);
|
||||
|
||||
foreach ($output as $item) {
|
||||
|
@ -36,7 +36,7 @@ final class AutoRouteCollector
|
||||
private readonly string $defaultMethod,
|
||||
private readonly array $httpMethods,
|
||||
private readonly array $protectedControllers,
|
||||
private readonly string $prefix = ''
|
||||
private readonly string $prefix = '',
|
||||
) {
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ final class AutoRouteCollector
|
||||
$routes = $reader->read(
|
||||
$class,
|
||||
$this->defaultController,
|
||||
$this->defaultMethod
|
||||
$this->defaultMethod,
|
||||
);
|
||||
|
||||
if ($routes === []) {
|
||||
|
@ -33,7 +33,7 @@ final class ControllerMethodReader
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly string $namespace,
|
||||
private readonly array $httpMethods
|
||||
private readonly array $httpMethods,
|
||||
) {
|
||||
$config = config(Routing::class);
|
||||
$this->translateURIDashes = $config->translateURIDashes;
|
||||
@ -78,7 +78,7 @@ final class ControllerMethodReader
|
||||
$classname,
|
||||
$methodName,
|
||||
$httpVerb,
|
||||
$method
|
||||
$method,
|
||||
);
|
||||
|
||||
if ($routeForDefaultController !== []) {
|
||||
@ -193,7 +193,7 @@ final class ControllerMethodReader
|
||||
{
|
||||
if ($this->translateUriToCamelCase) {
|
||||
$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) {
|
||||
$string = str_replace('_', '-', $string);
|
||||
@ -214,7 +214,7 @@ final class ControllerMethodReader
|
||||
string $classname,
|
||||
string $methodName,
|
||||
string $httpVerb,
|
||||
ReflectionMethod $method
|
||||
ReflectionMethod $method,
|
||||
): array {
|
||||
$output = [];
|
||||
|
||||
|
@ -28,7 +28,7 @@ final class ControllerFinder
|
||||
* @param string $namespace namespace to search
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly string $namespace
|
||||
private readonly string $namespace,
|
||||
) {
|
||||
$this->locator = service('locator');
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ final class ControllerMethodReader
|
||||
$defaultController,
|
||||
$uriByClass,
|
||||
$classname,
|
||||
$methodName
|
||||
$methodName,
|
||||
);
|
||||
$output = [...$output, ...$routeWithoutController];
|
||||
|
||||
@ -89,7 +89,7 @@ final class ControllerMethodReader
|
||||
$defaultController,
|
||||
$uriByClass,
|
||||
$classname,
|
||||
$methodName
|
||||
$methodName,
|
||||
);
|
||||
$output = [...$output, ...$routeWithoutController];
|
||||
|
||||
@ -153,7 +153,7 @@ final class ControllerMethodReader
|
||||
string $defaultController,
|
||||
string $uriByClass,
|
||||
string $classname,
|
||||
string $methodName
|
||||
string $methodName,
|
||||
): array {
|
||||
if ($classShortname !== $defaultController) {
|
||||
return [];
|
||||
|
@ -32,7 +32,7 @@ final class FilterCollector
|
||||
*
|
||||
* 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(
|
||||
'Passing lowercase HTTP method "' . $method . '" is deprecated.'
|
||||
. ' Use uppercase HTTP method like "' . strtoupper($method) . '".',
|
||||
E_USER_DEPRECATED
|
||||
E_USER_DEPRECATED,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ final class SampleURIGenerator
|
||||
$sampleUri = str_replace(
|
||||
'{locale}',
|
||||
config(App::class)->defaultLocale,
|
||||
$routeKey
|
||||
$routeKey,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ if (! function_exists('command')) {
|
||||
// @codeCoverageIgnoreStart
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Unable to parse input near "... %s ...".',
|
||||
substr($command, $cursor, 10)
|
||||
substr($command, $cursor, 10),
|
||||
));
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
@ -470,7 +470,7 @@ if (! function_exists('force_https')) {
|
||||
function force_https(
|
||||
int $duration = 31_536_000,
|
||||
?RequestInterface $request = null,
|
||||
?ResponseInterface $response = null
|
||||
?ResponseInterface $response = null,
|
||||
): void {
|
||||
$request ??= service('request');
|
||||
|
||||
@ -1065,7 +1065,7 @@ if (! function_exists('slash_item')) {
|
||||
'Cannot convert "%s::$%s" of type "%s" to type "string".',
|
||||
App::class,
|
||||
$item,
|
||||
gettype($configItem)
|
||||
gettype($configItem),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ final class ComposerScripts
|
||||
/** @var SplFileInfo $file */
|
||||
foreach (new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator(rtrim($directory, '\\/'), FilesystemIterator::SKIP_DOTS),
|
||||
RecursiveIteratorIterator::CHILD_FIRST
|
||||
RecursiveIteratorIterator::CHILD_FIRST,
|
||||
) as $file) {
|
||||
$path = $file->getPathname();
|
||||
|
||||
@ -146,7 +146,7 @@ final class ComposerScripts
|
||||
/** @var SplFileInfo $file */
|
||||
foreach (new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($originDir, FilesystemIterator::SKIP_DOTS),
|
||||
RecursiveIteratorIterator::SELF_FIRST
|
||||
RecursiveIteratorIterator::SELF_FIRST,
|
||||
) as $file) {
|
||||
$origin = $file->getPathname();
|
||||
$target = $targetDir . substr($origin, $dirLen);
|
||||
|
@ -164,7 +164,7 @@ class DotEnv
|
||||
%1$s # and the closing quote
|
||||
.*$ # and discard any string after the closing quote
|
||||
/mx',
|
||||
$quote
|
||||
$quote,
|
||||
);
|
||||
|
||||
$value = preg_replace($regexPattern, '$1', $value);
|
||||
@ -206,7 +206,7 @@ class DotEnv
|
||||
|
||||
return $nestedVariable;
|
||||
},
|
||||
$value
|
||||
$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ final class Factories
|
||||
}
|
||||
|
||||
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::$aliases[$component],
|
||||
self::$instances[$component],
|
||||
self::$updated[$component]
|
||||
self::$updated[$component],
|
||||
);
|
||||
|
||||
return;
|
||||
|
@ -213,7 +213,7 @@ class Services extends BaseService
|
||||
$config,
|
||||
new URI($options['baseURI'] ?? null),
|
||||
$response,
|
||||
$options
|
||||
$options,
|
||||
);
|
||||
}
|
||||
|
||||
@ -267,7 +267,7 @@ class Services extends BaseService
|
||||
*/
|
||||
public static function exceptions(
|
||||
?ExceptionsConfig $config = null,
|
||||
bool $getShared = true
|
||||
bool $getShared = true,
|
||||
) {
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance('exceptions', $config);
|
||||
@ -569,7 +569,7 @@ class Services extends BaseService
|
||||
$config,
|
||||
AppServices::get('uri'),
|
||||
'php://input',
|
||||
new UserAgent()
|
||||
new UserAgent(),
|
||||
);
|
||||
}
|
||||
|
||||
@ -619,7 +619,7 @@ class Services extends BaseService
|
||||
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)) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Invalid session handler "%s" provided.',
|
||||
$driverName
|
||||
$driverName,
|
||||
));
|
||||
}
|
||||
|
||||
@ -721,7 +721,7 @@ class Services extends BaseService
|
||||
public static function siteurifactory(
|
||||
?App $config = null,
|
||||
?Superglobals $superglobals = null,
|
||||
bool $getShared = true
|
||||
bool $getShared = true,
|
||||
) {
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance('siteurifactory', $config, $superglobals);
|
||||
@ -741,7 +741,7 @@ class Services extends BaseService
|
||||
public static function superglobals(
|
||||
?array $server = null,
|
||||
?array $get = null,
|
||||
bool $getShared = true
|
||||
bool $getShared = true,
|
||||
) {
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance('superglobals', $server, $get);
|
||||
|
@ -24,7 +24,7 @@ class ArrayCast extends BaseCast implements CastInterface
|
||||
public static function get(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): array {
|
||||
if (! is_string($value)) {
|
||||
self::invalidTypeValueError($value);
|
||||
@ -40,7 +40,7 @@ class ArrayCast extends BaseCast implements CastInterface
|
||||
public static function set(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): string {
|
||||
return serialize($value);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ abstract class BaseCast implements CastInterface
|
||||
public static function get(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): mixed {
|
||||
return $value;
|
||||
}
|
||||
@ -28,7 +28,7 @@ abstract class BaseCast implements CastInterface
|
||||
public static function set(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): mixed {
|
||||
return $value;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class BooleanCast extends BaseCast
|
||||
public static function get(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): bool {
|
||||
// For PostgreSQL
|
||||
if ($value === 't') {
|
||||
|
@ -24,7 +24,7 @@ class CSVCast extends BaseCast
|
||||
public static function get(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): array {
|
||||
if (! is_string($value)) {
|
||||
self::invalidTypeValueError($value);
|
||||
@ -36,7 +36,7 @@ class CSVCast extends BaseCast
|
||||
public static function set(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): string {
|
||||
if (! is_array($value)) {
|
||||
self::invalidTypeValueError($value);
|
||||
|
@ -27,7 +27,7 @@ interface CastInterface
|
||||
public static function get(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): mixed;
|
||||
|
||||
/**
|
||||
@ -42,6 +42,6 @@ interface CastInterface
|
||||
public static function set(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): mixed;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class DatetimeCast extends BaseCast
|
||||
public static function get(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): Time {
|
||||
if (! is_string($value)) {
|
||||
self::invalidTypeValueError($value);
|
||||
@ -56,7 +56,7 @@ class DatetimeCast extends BaseCast
|
||||
public static function set(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): string {
|
||||
if (! $value instanceof Time) {
|
||||
self::invalidTypeValueError($value);
|
||||
|
@ -24,7 +24,7 @@ class FloatCast extends BaseCast
|
||||
public static function get(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): float {
|
||||
if (! is_float($value) && ! is_string($value)) {
|
||||
self::invalidTypeValueError($value);
|
||||
|
@ -24,7 +24,7 @@ final class IntBoolCast extends BaseCast
|
||||
public static function get(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): bool {
|
||||
if (! is_int($value) && ! is_string($value)) {
|
||||
self::invalidTypeValueError($value);
|
||||
@ -36,7 +36,7 @@ final class IntBoolCast extends BaseCast
|
||||
public static function set(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): int {
|
||||
if (! is_bool($value)) {
|
||||
self::invalidTypeValueError($value);
|
||||
|
@ -24,7 +24,7 @@ class IntegerCast extends BaseCast
|
||||
public static function get(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): int {
|
||||
if (! is_string($value) && ! is_int($value)) {
|
||||
self::invalidTypeValueError($value);
|
||||
|
@ -28,7 +28,7 @@ class JsonCast extends BaseCast
|
||||
public static function get(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): array|stdClass {
|
||||
if (! is_string($value)) {
|
||||
self::invalidTypeValueError($value);
|
||||
@ -50,7 +50,7 @@ class JsonCast extends BaseCast
|
||||
public static function set(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): string {
|
||||
try {
|
||||
$output = json_encode($value, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
|
||||
|
@ -26,7 +26,7 @@ class TimestampCast extends BaseCast
|
||||
public static function get(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): Time {
|
||||
if (! is_int($value) && ! is_string($value)) {
|
||||
self::invalidTypeValueError($value);
|
||||
@ -38,7 +38,7 @@ class TimestampCast extends BaseCast
|
||||
public static function set(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): int {
|
||||
if (! $value instanceof Time) {
|
||||
self::invalidTypeValueError($value);
|
||||
|
@ -26,7 +26,7 @@ class URICast extends BaseCast
|
||||
public static function get(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): URI {
|
||||
if (! is_string($value)) {
|
||||
self::invalidTypeValueError($value);
|
||||
@ -38,7 +38,7 @@ class URICast extends BaseCast
|
||||
public static function set(
|
||||
mixed $value,
|
||||
array $params = [],
|
||||
?object $helper = null
|
||||
?object $helper = null,
|
||||
): string {
|
||||
if (! $value instanceof URI) {
|
||||
self::invalidTypeValueError($value);
|
||||
|
@ -68,7 +68,7 @@ final class DataCaster
|
||||
?array $castHandlers = null,
|
||||
?array $types = null,
|
||||
private readonly ?object $helper = null,
|
||||
private readonly bool $strict = true
|
||||
private readonly bool $strict = true,
|
||||
) {
|
||||
$this->castHandlers = array_merge($this->castHandlers, $castHandlers);
|
||||
|
||||
@ -83,7 +83,7 @@ final class DataCaster
|
||||
&& ! is_subclass_of($handler, EntityCastInterface::class)
|
||||
) {
|
||||
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])) {
|
||||
throw new InvalidArgumentException(
|
||||
'No such handler for "' . $field . '". Invalid type: ' . $type
|
||||
'No such handler for "' . $field . '". Invalid type: ' . $type,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -663,7 +663,7 @@ class BaseBuilder
|
||||
} else {
|
||||
// Split multiple conditions
|
||||
// @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 = [];
|
||||
$joints = $joints[0];
|
||||
array_unshift($joints, ['', 0]);
|
||||
@ -807,7 +807,7 @@ class BaseBuilder
|
||||
'/\s*(!?=|<>|IS(?:\s+NOT)?)\s*$/i',
|
||||
$k,
|
||||
$match,
|
||||
PREG_OFFSET_CAPTURE
|
||||
PREG_OFFSET_CAPTURE,
|
||||
)
|
||||
) {
|
||||
$k = substr($k, 0, $match[0][1]);
|
||||
@ -2022,8 +2022,8 @@ class BaseBuilder
|
||||
' = ' . $value :
|
||||
' = VALUES(' . $value . ')'),
|
||||
array_keys($updateFields),
|
||||
$updateFields
|
||||
)
|
||||
$updateFields,
|
||||
),
|
||||
);
|
||||
|
||||
$this->QBOptions['sql'] = $sql;
|
||||
@ -2198,7 +2198,7 @@ class BaseBuilder
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
@ -2291,10 +2291,10 @@ class BaseBuilder
|
||||
$this->removeAlias($this->QBFrom[0]),
|
||||
true,
|
||||
null,
|
||||
false
|
||||
false,
|
||||
),
|
||||
array_keys($this->QBSet),
|
||||
array_values($this->QBSet)
|
||||
array_values($this->QBSet),
|
||||
);
|
||||
|
||||
if ($reset) {
|
||||
@ -2328,10 +2328,10 @@ class BaseBuilder
|
||||
$this->removeAlias($this->QBFrom[0]),
|
||||
true,
|
||||
$escape,
|
||||
false
|
||||
false,
|
||||
),
|
||||
array_keys($this->QBSet),
|
||||
array_values($this->QBSet)
|
||||
array_values($this->QBSet),
|
||||
);
|
||||
|
||||
if (! $this->testMode) {
|
||||
@ -2653,8 +2653,8 @@ class BaseBuilder
|
||||
' = ' . $value :
|
||||
' = ' . $alias . '.' . $value),
|
||||
array_keys($updateFields),
|
||||
$updateFields
|
||||
)
|
||||
$updateFields,
|
||||
),
|
||||
) . "\n";
|
||||
|
||||
$sql .= "FROM (\n{:_table_:}";
|
||||
@ -2678,8 +2678,8 @@ class BaseBuilder
|
||||
)
|
||||
),
|
||||
array_keys($constraints),
|
||||
$constraints
|
||||
)
|
||||
$constraints,
|
||||
),
|
||||
);
|
||||
|
||||
$this->QBOptions['sql'] = $sql;
|
||||
@ -2694,10 +2694,10 @@ class BaseBuilder
|
||||
static fn ($value): string => 'SELECT ' . implode(', ', array_map(
|
||||
static fn ($key, $index): string => $index . ' ' . $key,
|
||||
$keys,
|
||||
$value
|
||||
$value,
|
||||
)),
|
||||
$values
|
||||
)
|
||||
$values,
|
||||
),
|
||||
) . "\n";
|
||||
}
|
||||
|
||||
@ -2924,8 +2924,8 @@ class BaseBuilder
|
||||
)
|
||||
),
|
||||
array_keys($constraints),
|
||||
$constraints
|
||||
)
|
||||
$constraints,
|
||||
),
|
||||
);
|
||||
|
||||
// convert binds in where
|
||||
@ -2949,10 +2949,10 @@ class BaseBuilder
|
||||
static fn ($value): string => 'SELECT ' . implode(', ', array_map(
|
||||
static fn ($key, $index): string => $index . ' ' . $key,
|
||||
$keys,
|
||||
$value
|
||||
$value,
|
||||
)),
|
||||
$values
|
||||
)
|
||||
$values,
|
||||
),
|
||||
) . "\n";
|
||||
}
|
||||
|
||||
@ -3160,7 +3160,7 @@ class BaseBuilder
|
||||
'/((?:^|\s+)AND\s+|(?:^|\s+)OR\s+)/i',
|
||||
$qbkey['condition'],
|
||||
-1,
|
||||
PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
|
||||
PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY,
|
||||
);
|
||||
|
||||
foreach ($conditions as &$condition) {
|
||||
@ -3170,11 +3170,12 @@ class BaseBuilder
|
||||
|| preg_match(
|
||||
'/^(\(?)(.*)(' . preg_quote($op, '/') . ')\s*(.*(?<!\)))?(\)?)$/i',
|
||||
$condition,
|
||||
$matches
|
||||
$matches,
|
||||
) !== 1
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// $matches = [
|
||||
// 0 => '(test <= foo)', /* the whole thing */
|
||||
// 1 => '(', /* optional */
|
||||
@ -3184,7 +3185,7 @@ class BaseBuilder
|
||||
// 5 => ')' /* optional */
|
||||
// ];
|
||||
|
||||
if (isset($matches[4]) && $matches[4] !== '') {
|
||||
if ($matches[4] !== '') {
|
||||
$protectIdentifiers = false;
|
||||
if (str_contains($matches[4], '.')) {
|
||||
$protectIdentifiers = true;
|
||||
@ -3435,7 +3436,7 @@ class BaseBuilder
|
||||
{
|
||||
return preg_match(
|
||||
'/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sEXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i',
|
||||
trim($str)
|
||||
trim($str),
|
||||
) === 1;
|
||||
}
|
||||
|
||||
@ -3469,8 +3470,8 @@ class BaseBuilder
|
||||
return preg_match_all(
|
||||
'/' . implode('|', $this->pregOperators) . '/i',
|
||||
$str,
|
||||
$match
|
||||
) ? ($list ? $match[0] : $match[0][0]) : false;
|
||||
$match,
|
||||
) >= 1 ? ($list ? $match[0] : $match[0][0]) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3500,8 +3501,8 @@ class BaseBuilder
|
||||
return preg_match_all(
|
||||
'/' . implode('|', $pregOperators) . '/i',
|
||||
$whereKey,
|
||||
$match
|
||||
) ? $match[0] : false;
|
||||
$match,
|
||||
) >= 1 ? $match[0] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -424,7 +424,7 @@ abstract class BaseConnection implements ConnectionInterface
|
||||
$connectionErrors[] = sprintf(
|
||||
'Main connection [%s]: %s',
|
||||
$this->DBDriver,
|
||||
$e->getMessage()
|
||||
$e->getMessage(),
|
||||
);
|
||||
log_message('error', 'Error connecting to the database: ' . $e);
|
||||
}
|
||||
@ -450,7 +450,7 @@ abstract class BaseConnection implements ConnectionInterface
|
||||
'Failover #%d [%s]: %s',
|
||||
++$index,
|
||||
$this->DBDriver,
|
||||
$e->getMessage()
|
||||
$e->getMessage(),
|
||||
);
|
||||
log_message('error', 'Error connecting to the database: ' . $e);
|
||||
}
|
||||
@ -467,7 +467,7 @@ abstract class BaseConnection implements ConnectionInterface
|
||||
throw new DatabaseException(sprintf(
|
||||
'Unable to connect to the database.%s%s',
|
||||
PHP_EOL,
|
||||
implode(PHP_EOL, $connectionErrors)
|
||||
implode(PHP_EOL, $connectionErrors),
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -688,7 +688,7 @@ abstract class BaseConnection implements ConnectionInterface
|
||||
throw new DatabaseException(
|
||||
$exception->getMessage(),
|
||||
$exception->getCode(),
|
||||
$exception
|
||||
$exception,
|
||||
);
|
||||
}
|
||||
|
||||
@ -1220,7 +1220,7 @@ abstract class BaseConnection implements ConnectionInterface
|
||||
. str_replace(
|
||||
$this->escapeChar,
|
||||
$this->escapeChar . $this->escapeChar,
|
||||
$item
|
||||
$item,
|
||||
)
|
||||
. $this->escapeChar;
|
||||
}
|
||||
@ -1277,7 +1277,7 @@ abstract class BaseConnection implements ConnectionInterface
|
||||
return preg_replace(
|
||||
'/' . $this->pregEscapeChar[0] . '?([^' . $this->pregEscapeChar[1] . '\.]+)' . $this->pregEscapeChar[1] . '?\./i',
|
||||
$this->pregEscapeChar[2] . '$1' . $this->pregEscapeChar[3] . '.',
|
||||
$item
|
||||
$item,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1286,7 +1286,7 @@ abstract class BaseConnection implements ConnectionInterface
|
||||
return preg_replace(
|
||||
'/' . $this->pregEscapeChar[0] . '?([^' . $this->pregEscapeChar[1] . '\.]+)' . $this->pregEscapeChar[1] . '?(\.)?/i',
|
||||
$this->pregEscapeChar[2] . '$1' . $this->pregEscapeChar[3] . '$2',
|
||||
$item
|
||||
$item,
|
||||
);
|
||||
}
|
||||
|
||||
@ -1386,7 +1386,7 @@ abstract class BaseConnection implements ConnectionInterface
|
||||
$this->likeEscapeChar . '%',
|
||||
$this->likeEscapeChar . '_',
|
||||
],
|
||||
$str
|
||||
$str,
|
||||
);
|
||||
}
|
||||
|
||||
@ -1522,7 +1522,7 @@ abstract class BaseConnection implements ConnectionInterface
|
||||
$key = array_search(
|
||||
strtolower($tableName),
|
||||
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
|
||||
|
@ -217,7 +217,7 @@ abstract class BaseUtils
|
||||
$line[] = $enclosure . str_replace(
|
||||
$enclosure,
|
||||
$enclosure . $enclosure,
|
||||
(string) $item
|
||||
(string) $item,
|
||||
) . $enclosure;
|
||||
}
|
||||
|
||||
|
@ -234,8 +234,8 @@ class Forge
|
||||
$ifNotExists ? $this->createDatabaseIfStr : $this->createDatabaseStr,
|
||||
$this->db->escapeIdentifier($dbName),
|
||||
$this->db->charset,
|
||||
$this->db->DBCollat
|
||||
)
|
||||
$this->db->DBCollat,
|
||||
),
|
||||
)) {
|
||||
// @codeCoverageIgnoreStart
|
||||
if ($this->db->DBDebug) {
|
||||
@ -294,7 +294,7 @@ class Forge
|
||||
}
|
||||
|
||||
if (! $this->db->query(
|
||||
sprintf($this->dropDatabaseStr, $this->db->escapeIdentifier($dbName))
|
||||
sprintf($this->dropDatabaseStr, $this->db->escapeIdentifier($dbName)),
|
||||
)) {
|
||||
if ($this->db->DBDebug) {
|
||||
throw new DatabaseException('Unable to drop the specified database.');
|
||||
@ -307,7 +307,7 @@ class Forge
|
||||
$key = array_search(
|
||||
strtolower($dbName),
|
||||
array_map(strtolower(...), $this->db->dataCache['db_names']),
|
||||
true
|
||||
true,
|
||||
);
|
||||
if ($key !== false) {
|
||||
unset($this->db->dataCache['db_names'][$key]);
|
||||
@ -425,7 +425,7 @@ class Forge
|
||||
$tableField = '',
|
||||
string $onUpdate = '',
|
||||
string $onDelete = '',
|
||||
string $fkName = ''
|
||||
string $fkName = '',
|
||||
): Forge {
|
||||
$fieldName = (array) $fieldName;
|
||||
$tableField = (array) $tableField;
|
||||
@ -525,7 +525,7 @@ class Forge
|
||||
$sql = sprintf(
|
||||
(string) $this->dropConstraintStr,
|
||||
$this->db->escapeIdentifiers($this->db->DBPrefix . $table),
|
||||
$this->db->escapeIdentifiers($foreignName)
|
||||
$this->db->escapeIdentifiers($foreignName),
|
||||
);
|
||||
|
||||
if ($sql === '') {
|
||||
@ -618,7 +618,7 @@ class Forge
|
||||
'CREATE TABLE',
|
||||
$this->db->escapeIdentifiers($table),
|
||||
$processedFields,
|
||||
$this->_createTableAttributes($attributes)
|
||||
$this->_createTableAttributes($attributes),
|
||||
);
|
||||
}
|
||||
|
||||
@ -668,7 +668,7 @@ class Forge
|
||||
$key = array_search(
|
||||
strtolower($this->db->DBPrefix . $tableName),
|
||||
array_map(strtolower(...), $this->db->dataCache['table_names']),
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
if ($key !== false) {
|
||||
@ -723,14 +723,14 @@ class Forge
|
||||
$result = $this->db->query(sprintf(
|
||||
$this->renameTableStr,
|
||||
$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'])) {
|
||||
$key = array_search(
|
||||
strtolower($this->db->DBPrefix . $tableName),
|
||||
array_map(strtolower(...), $this->db->dataCache['table_names']),
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
if ($key !== false) {
|
||||
@ -1061,7 +1061,7 @@ class Forge
|
||||
protected function _attributeAutoIncrement(array &$attributes, array &$field)
|
||||
{
|
||||
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';
|
||||
}
|
||||
@ -1112,7 +1112,7 @@ class Forge
|
||||
|
||||
$this->fields = array_combine(
|
||||
array_map(static fn ($columnName) => $columnName->name, $fieldData),
|
||||
array_fill(0, count($fieldData), [])
|
||||
array_fill(0, count($fieldData), []),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -605,7 +605,7 @@ class MigrationRunner
|
||||
CLI::color(lang('Migrations.added'), 'yellow'),
|
||||
$migration->namespace,
|
||||
$migration->version,
|
||||
$migration->class
|
||||
$migration->class,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -625,7 +625,7 @@ class MigrationRunner
|
||||
CLI::color(lang('Migrations.removed'), 'yellow'),
|
||||
$history->namespace,
|
||||
$history->version,
|
||||
$history->class
|
||||
$history->class,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -106,8 +106,8 @@ class Builder extends BaseBuilder
|
||||
)
|
||||
),
|
||||
array_keys($constraints),
|
||||
$constraints
|
||||
)
|
||||
$constraints,
|
||||
),
|
||||
) . "\n";
|
||||
|
||||
$sql .= "SET\n";
|
||||
@ -119,8 +119,8 @@ class Builder extends BaseBuilder
|
||||
' = ' . $value :
|
||||
' = ' . $alias . '.' . $value),
|
||||
array_keys($updateFields),
|
||||
$updateFields
|
||||
)
|
||||
$updateFields,
|
||||
),
|
||||
);
|
||||
|
||||
$this->QBOptions['sql'] = $sql;
|
||||
@ -135,10 +135,10 @@ class Builder extends BaseBuilder
|
||||
static fn ($value): string => 'SELECT ' . implode(', ', array_map(
|
||||
static fn ($key, $index): string => $index . ' ' . $key,
|
||||
$keys,
|
||||
$value
|
||||
$value,
|
||||
)),
|
||||
$values
|
||||
)
|
||||
$values,
|
||||
),
|
||||
) . "\n";
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ class Connection extends BaseConnection
|
||||
if ($this->strictOn) {
|
||||
$this->mysqli->options(
|
||||
MYSQLI_INIT_COMMAND,
|
||||
"SET SESSION sql_mode = CONCAT(@@sql_mode, ',', 'STRICT_ALL_TABLES')"
|
||||
"SET SESSION sql_mode = CONCAT(@@sql_mode, ',', 'STRICT_ALL_TABLES')",
|
||||
);
|
||||
} else {
|
||||
$this->mysqli->options(
|
||||
@ -128,7 +128,7 @@ class Connection extends BaseConnection
|
||||
'STRICT_ALL_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['ca'] ?? null,
|
||||
$ssl['capath'] ?? null,
|
||||
$ssl['cipher'] ?? null
|
||||
$ssl['cipher'] ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ class Connection extends BaseConnection
|
||||
$this->database,
|
||||
$port,
|
||||
$socket,
|
||||
$clientFlags
|
||||
$clientFlags,
|
||||
)) {
|
||||
// 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', '<=')
|
||||
@ -381,7 +381,7 @@ class Connection extends BaseConnection
|
||||
return str_replace(
|
||||
[$this->likeEscapeChar, '%', '_'],
|
||||
['\\' . $this->likeEscapeChar, '\\%', '\\_'],
|
||||
$str
|
||||
$str,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ class Forge extends BaseForge
|
||||
{
|
||||
$sql = sprintf(
|
||||
'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);
|
||||
|
@ -92,10 +92,10 @@ class Builder extends BaseBuilder
|
||||
static fn ($value): string => 'SELECT ' . implode(', ', array_map(
|
||||
static fn ($key, $index): string => $index . ' ' . $key,
|
||||
$keys,
|
||||
$value
|
||||
$value,
|
||||
)),
|
||||
$values
|
||||
)
|
||||
$values,
|
||||
),
|
||||
) . " FROM DUAL\n";
|
||||
}
|
||||
|
||||
@ -287,8 +287,8 @@ class Builder extends BaseBuilder
|
||||
)
|
||||
),
|
||||
array_keys($constraints),
|
||||
$constraints
|
||||
)
|
||||
$constraints,
|
||||
),
|
||||
) . ")\n";
|
||||
|
||||
$sql .= "WHEN MATCHED THEN UPDATE\n";
|
||||
@ -302,8 +302,8 @@ class Builder extends BaseBuilder
|
||||
' = ' . $value :
|
||||
' = ' . $alias . '.' . $value),
|
||||
array_keys($updateFields),
|
||||
$updateFields
|
||||
)
|
||||
$updateFields,
|
||||
),
|
||||
);
|
||||
|
||||
$this->QBOptions['sql'] = $sql;
|
||||
@ -318,10 +318,10 @@ class Builder extends BaseBuilder
|
||||
static fn ($value): string => 'SELECT ' . implode(', ', array_map(
|
||||
static fn ($key, $index): string => $index . ' ' . $key,
|
||||
$keys,
|
||||
$value
|
||||
$value,
|
||||
)) . ' FROM DUAL',
|
||||
$values
|
||||
)
|
||||
$values,
|
||||
),
|
||||
) . "\n";
|
||||
}
|
||||
|
||||
@ -392,8 +392,8 @@ class Builder extends BaseBuilder
|
||||
)
|
||||
),
|
||||
array_keys($constraints),
|
||||
$constraints
|
||||
)
|
||||
$constraints,
|
||||
),
|
||||
) . ")\n";
|
||||
|
||||
$sql .= "WHEN MATCHED THEN UPDATE SET\n";
|
||||
@ -405,8 +405,8 @@ class Builder extends BaseBuilder
|
||||
" = {$value}" :
|
||||
" = {$alias}.{$value}"),
|
||||
array_keys($updateFields),
|
||||
$updateFields
|
||||
)
|
||||
$updateFields,
|
||||
),
|
||||
);
|
||||
|
||||
$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 ($key, $index): string => $index . ' ' . $key,
|
||||
$keys,
|
||||
$value
|
||||
$value,
|
||||
)),
|
||||
$values
|
||||
)
|
||||
$values,
|
||||
),
|
||||
) . " FROM DUAL\n";
|
||||
}
|
||||
|
||||
@ -477,8 +477,8 @@ class Builder extends BaseBuilder
|
||||
)
|
||||
),
|
||||
array_keys($constraints),
|
||||
$constraints
|
||||
)
|
||||
$constraints,
|
||||
),
|
||||
);
|
||||
|
||||
// convert binds in where
|
||||
@ -491,7 +491,7 @@ class Builder extends BaseBuilder
|
||||
$sql .= ' ' . str_replace(
|
||||
'WHERE ',
|
||||
'AND ',
|
||||
$this->compileWhereHaving('QBWhere')
|
||||
$this->compileWhereHaving('QBWhere'),
|
||||
) . ')';
|
||||
|
||||
$this->QBOptions['sql'] = $sql;
|
||||
@ -506,10 +506,10 @@ class Builder extends BaseBuilder
|
||||
static fn ($value): string => 'SELECT ' . implode(', ', array_map(
|
||||
static fn ($key, $index): string => $index . ' ' . $key,
|
||||
$keys,
|
||||
$value
|
||||
$value,
|
||||
)),
|
||||
$values
|
||||
)
|
||||
$values,
|
||||
),
|
||||
) . " FROM DUAL\n";
|
||||
}
|
||||
|
||||
|
@ -523,7 +523,7 @@ class Connection extends BaseConnection
|
||||
$sql = sprintf(
|
||||
'BEGIN %s (' . substr(str_repeat(',%s', count($params)), 1) . '); END;',
|
||||
$procedureName,
|
||||
...array_map(static fn ($row) => $row['name'], $params)
|
||||
...array_map(static fn ($row) => $row['name'], $params),
|
||||
);
|
||||
|
||||
$this->resetStmtId = false;
|
||||
@ -554,7 +554,7 @@ class Connection extends BaseConnection
|
||||
$param['name'],
|
||||
$param['value'],
|
||||
$param['length'] ?? -1,
|
||||
$param['type'] ?? SQLT_CHR
|
||||
$param['type'] ?? SQLT_CHR,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ class Forge extends BaseForge
|
||||
|
||||
$fields = array_map(
|
||||
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';
|
||||
@ -184,7 +184,7 @@ class Forge extends BaseForge
|
||||
protected function _attributeAutoIncrement(array &$attributes, array &$field)
|
||||
{
|
||||
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', '>=')
|
||||
) {
|
||||
$field['auto_increment'] = ' GENERATED BY DEFAULT ON NULL AS IDENTITY';
|
||||
|
@ -357,8 +357,8 @@ class Builder extends BaseBuilder
|
||||
' = ' . $value :
|
||||
' = ' . $that->cast($alias . '.' . $value, $that->getFieldType($table, $key))),
|
||||
array_keys($updateFields),
|
||||
$updateFields
|
||||
)
|
||||
$updateFields,
|
||||
),
|
||||
) . "\n";
|
||||
|
||||
$sql .= "FROM (\n{:_table_:}";
|
||||
@ -381,8 +381,8 @@ class Builder extends BaseBuilder
|
||||
. $that->cast($alias . '.' . $value, $that->getFieldType($table, $value));
|
||||
},
|
||||
array_keys($constraints),
|
||||
$constraints
|
||||
)
|
||||
$constraints,
|
||||
),
|
||||
);
|
||||
|
||||
$this->QBOptions['sql'] = $sql;
|
||||
@ -397,10 +397,10 @@ class Builder extends BaseBuilder
|
||||
static fn ($value): string => 'SELECT ' . implode(', ', array_map(
|
||||
static fn ($key, $index): string => $index . ' ' . $key,
|
||||
$keys,
|
||||
$value
|
||||
$value,
|
||||
)),
|
||||
$values
|
||||
)
|
||||
$values,
|
||||
),
|
||||
) . "\n";
|
||||
}
|
||||
|
||||
@ -528,8 +528,8 @@ class Builder extends BaseBuilder
|
||||
" = {$value}" :
|
||||
" = {$alias}.{$value}"),
|
||||
array_keys($updateFields),
|
||||
$updateFields
|
||||
)
|
||||
$updateFields,
|
||||
),
|
||||
);
|
||||
|
||||
$this->QBOptions['sql'] = $sql;
|
||||
@ -584,15 +584,15 @@ class Builder extends BaseBuilder
|
||||
return $table . '.' . $key . ' = '
|
||||
. $that->cast(
|
||||
$alias . '.' . $value,
|
||||
$that->getFieldType($table, $key)
|
||||
$that->getFieldType($table, $key),
|
||||
);
|
||||
}
|
||||
|
||||
return $table . '.' . $value . ' = ' . $alias . '.' . $value;
|
||||
},
|
||||
array_keys($constraints),
|
||||
$constraints
|
||||
)
|
||||
$constraints,
|
||||
),
|
||||
);
|
||||
|
||||
// convert binds in where
|
||||
@ -605,7 +605,7 @@ class Builder extends BaseBuilder
|
||||
$sql .= ' ' . str_replace(
|
||||
'WHERE ',
|
||||
'AND ',
|
||||
$this->compileWhereHaving('QBWhere')
|
||||
$this->compileWhereHaving('QBWhere'),
|
||||
);
|
||||
|
||||
$this->QBOptions['sql'] = $sql;
|
||||
@ -620,10 +620,10 @@ class Builder extends BaseBuilder
|
||||
static fn ($value): string => 'SELECT ' . implode(', ', array_map(
|
||||
static fn ($key, $index): string => $index . ' ' . $key,
|
||||
$keys,
|
||||
$value
|
||||
$value,
|
||||
)),
|
||||
$values
|
||||
)
|
||||
$values,
|
||||
),
|
||||
) . "\n";
|
||||
}
|
||||
|
||||
|
@ -227,6 +227,10 @@ class Connection extends BaseConnection
|
||||
*/
|
||||
public function affectedRows(): int
|
||||
{
|
||||
if ($this->resultID === false) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return pg_affected_rows($this->resultID);
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ class Forge extends BaseForge
|
||||
protected function _attributeType(array &$attributes)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -342,7 +342,7 @@ class Query implements QueryInterface, Stringable
|
||||
*/
|
||||
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);
|
||||
|
||||
// Bind values' count must match the count of markers in the query
|
||||
|
@ -122,7 +122,7 @@ class Builder extends BaseBuilder
|
||||
$cond = ' ON ' . $cond;
|
||||
} else {
|
||||
// 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 = [];
|
||||
$joints = $joints[0];
|
||||
array_unshift($joints, ['', 0]);
|
||||
@ -764,8 +764,8 @@ class Builder extends BaseBuilder
|
||||
)
|
||||
),
|
||||
array_keys($constraints),
|
||||
$constraints
|
||||
)
|
||||
$constraints,
|
||||
),
|
||||
) . ")\n";
|
||||
|
||||
$sql .= "WHEN MATCHED THEN UPDATE SET\n";
|
||||
@ -777,8 +777,8 @@ class Builder extends BaseBuilder
|
||||
' = ' . $value :
|
||||
" = {$alias}.{$value}"),
|
||||
array_keys($updateFields),
|
||||
$updateFields
|
||||
)
|
||||
$updateFields,
|
||||
),
|
||||
);
|
||||
|
||||
$sql .= "\nWHEN NOT MATCHED THEN INSERT (" . implode(', ', $keys) . ")\nVALUES ";
|
||||
@ -792,8 +792,8 @@ class Builder extends BaseBuilder
|
||||
. 'isnull(IDENT_CURRENT(\'' . $fullTableName . '\')+IDENT_INCR(\''
|
||||
. $fullTableName . "'),1)) ELSE {$alias}.{$columnName} END"
|
||||
: "{$alias}.{$columnName}",
|
||||
$keys
|
||||
)
|
||||
$keys,
|
||||
),
|
||||
) . ');'
|
||||
);
|
||||
|
||||
|
@ -444,6 +444,10 @@ class Connection extends BaseConnection
|
||||
*/
|
||||
public function affectedRows(): int
|
||||
{
|
||||
if ($this->resultID === false) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sqlsrv_rows_affected($this->resultID);
|
||||
}
|
||||
|
||||
|
@ -134,12 +134,12 @@ class Forge extends BaseForge
|
||||
$sql = sprintf(
|
||||
$this->createDatabaseIfStr,
|
||||
$dbName,
|
||||
$this->db->escapeIdentifier($dbName)
|
||||
$this->db->escapeIdentifier($dbName),
|
||||
);
|
||||
} else {
|
||||
$sql = sprintf(
|
||||
$this->createDatabaseStr,
|
||||
$this->db->escapeIdentifier($dbName)
|
||||
$this->db->escapeIdentifier($dbName),
|
||||
);
|
||||
}
|
||||
|
||||
@ -360,7 +360,7 @@ class Forge extends BaseForge
|
||||
protected function _attributeType(array &$attributes)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -381,8 +381,8 @@ class Forge extends BaseForge
|
||||
$maxLength = max(
|
||||
array_map(
|
||||
static fn ($value): int => strlen($value),
|
||||
$attributes['CONSTRAINT']
|
||||
)
|
||||
$attributes['CONSTRAINT'],
|
||||
),
|
||||
);
|
||||
|
||||
$attributes['TYPE'] = 'VARCHAR';
|
||||
@ -412,7 +412,7 @@ class Forge extends BaseForge
|
||||
*/
|
||||
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)';
|
||||
}
|
||||
}
|
||||
|
@ -196,8 +196,8 @@ class Builder extends BaseBuilder
|
||||
" = {$value}" :
|
||||
" = {$alias}.{$value}"),
|
||||
array_keys($updateFields),
|
||||
$updateFields
|
||||
)
|
||||
$updateFields,
|
||||
),
|
||||
);
|
||||
|
||||
$this->QBOptions['sql'] = $sql;
|
||||
@ -268,10 +268,10 @@ class Builder extends BaseBuilder
|
||||
static fn ($value): string => 'SELECT ' . implode(', ', array_map(
|
||||
static fn ($key, $index): string => $index . ' ' . $key,
|
||||
$keys,
|
||||
$value
|
||||
$value,
|
||||
)),
|
||||
$values
|
||||
)
|
||||
$values,
|
||||
),
|
||||
) . "\n";
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ class Forge extends BaseForge
|
||||
if (
|
||||
! empty($attributes['AUTO_INCREMENT'])
|
||||
&& $attributes['AUTO_INCREMENT'] === true
|
||||
&& stripos($field['type'], 'int') !== false
|
||||
&& str_contains(strtolower($field['type']), 'int')
|
||||
) {
|
||||
$field['type'] = 'INTEGER PRIMARY KEY';
|
||||
$field['default'] = '';
|
||||
|
@ -308,7 +308,7 @@ class Table
|
||||
|
||||
$this->keys = array_filter(
|
||||
$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
|
||||
@ -334,7 +334,7 @@ class Table
|
||||
$this->forge->addForeignKey(
|
||||
$foreignKey->column_name,
|
||||
trim($foreignKey->foreign_table_name, $this->db->DBPrefix),
|
||||
$foreignKey->foreign_column_name
|
||||
$foreignKey->foreign_column_name,
|
||||
);
|
||||
}
|
||||
|
||||
@ -358,15 +358,15 @@ class Table
|
||||
|
||||
$exFields = implode(
|
||||
', ',
|
||||
array_map(fn ($item) => $this->db->protectIdentifiers($item), $exFields)
|
||||
array_map(fn ($item) => $this->db->protectIdentifiers($item), $exFields),
|
||||
);
|
||||
$newFields = implode(
|
||||
', ',
|
||||
array_map(fn ($item) => $this->db->protectIdentifiers($item), $newFields)
|
||||
array_map(fn ($item) => $this->db->protectIdentifiers($item), $newFields),
|
||||
);
|
||||
|
||||
$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}",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ abstract class BaseExceptionHandler
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
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",
|
||||
$n + $start + 1,
|
||||
strip_tags($row),
|
||||
implode('', $tags[0])
|
||||
implode('', $tags[0]),
|
||||
);
|
||||
} else {
|
||||
$out .= sprintf('<span class="line"><span class="number">' . $format . '</span> %s', $n + $start + 1, $row) . "\n";
|
||||
|
@ -47,7 +47,7 @@ final class ExceptionHandler extends BaseExceptionHandler implements ExceptionHa
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
int $statusCode,
|
||||
int $exitCode
|
||||
int $exitCode,
|
||||
): void {
|
||||
// ResponseTrait needs these properties.
|
||||
$this->request = $request;
|
||||
@ -68,10 +68,10 @@ final class ExceptionHandler extends BaseExceptionHandler implements ExceptionHa
|
||||
'HTTP/%s %s %s',
|
||||
$request->getProtocolVersion(),
|
||||
$response->getStatusCode(),
|
||||
$response->getReasonPhrase()
|
||||
$response->getReasonPhrase(),
|
||||
),
|
||||
true,
|
||||
$statusCode
|
||||
$statusCode,
|
||||
);
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ final class ExceptionHandler extends BaseExceptionHandler implements ExceptionHa
|
||||
protected function determineView(
|
||||
Throwable $exception,
|
||||
string $templatePath,
|
||||
int $statusCode = 500
|
||||
int $statusCode = 500,
|
||||
): string {
|
||||
// Production environments should have a custom exception file.
|
||||
$view = 'production.php';
|
||||
@ -138,7 +138,7 @@ final class ExceptionHandler extends BaseExceptionHandler implements ExceptionHa
|
||||
in_array(
|
||||
strtolower(ini_get('display_errors')),
|
||||
['1', 'true', 'on', 'yes'],
|
||||
true
|
||||
true,
|
||||
)
|
||||
) {
|
||||
$view = 'error_exception.php';
|
||||
|
@ -27,6 +27,6 @@ interface ExceptionHandlerInterface
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
int $statusCode,
|
||||
int $exitCode
|
||||
int $exitCode,
|
||||
): void;
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ class Exceptions
|
||||
$this->request,
|
||||
$this->response,
|
||||
$statusCode,
|
||||
$exitCode
|
||||
$exitCode,
|
||||
);
|
||||
|
||||
return;
|
||||
@ -270,7 +270,7 @@ class Exceptions
|
||||
in_array(
|
||||
strtolower(ini_get('display_errors')),
|
||||
['1', 'true', 'on', 'yes'],
|
||||
true
|
||||
true,
|
||||
)
|
||||
) {
|
||||
$view = 'error_exception.php';
|
||||
@ -462,7 +462,7 @@ class Exceptions
|
||||
'errFile' => clean_path($file ?? ''),
|
||||
'errLine' => $line ?? 0,
|
||||
'trace' => self::renderBacktrace($trace),
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
return true;
|
||||
@ -567,7 +567,7 @@ class Exceptions
|
||||
"<span class='line highlight'><span class='number'>{$format}</span> %s\n</span>%s",
|
||||
$n + $start + 1,
|
||||
strip_tags($row),
|
||||
implode('', $tags[0])
|
||||
implode('', $tags[0]),
|
||||
);
|
||||
} else {
|
||||
$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['type'],
|
||||
$frame['function'],
|
||||
$args
|
||||
$args,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ class Toolbar
|
||||
log_message(
|
||||
'critical',
|
||||
'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;
|
||||
@ -391,7 +391,7 @@ class Toolbar
|
||||
$stats['startTime'],
|
||||
$stats['totalTime'],
|
||||
$request,
|
||||
$response
|
||||
$response,
|
||||
);
|
||||
|
||||
helper('filesystem');
|
||||
@ -439,8 +439,8 @@ class Toolbar
|
||||
'/<head>/',
|
||||
'<head>' . $script,
|
||||
$response->getBody(),
|
||||
1
|
||||
)
|
||||
1,
|
||||
),
|
||||
);
|
||||
|
||||
return;
|
||||
@ -516,7 +516,7 @@ class Toolbar
|
||||
$history = new History();
|
||||
$history->setFiles(
|
||||
$debugbarTime[0],
|
||||
$this->config->maxHistory
|
||||
$this->config->maxHistory,
|
||||
);
|
||||
|
||||
$data['collectors'][] = $history->getAsArray();
|
||||
|
@ -228,7 +228,7 @@ class Database extends BaseCollector
|
||||
$uniqueCount,
|
||||
$uniqueCount > 1 ? 'of them' : '',
|
||||
$connectionCount,
|
||||
$connectionCount > 1 ? 's' : ''
|
||||
$connectionCount > 1 ? 's' : '',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ class Routes extends BaseCollector
|
||||
' <empty> | default: '
|
||||
. var_export(
|
||||
$param->isDefaultValueAvailable() ? $param->getDefaultValue() : null,
|
||||
true
|
||||
true,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
@ -1031,7 +1031,7 @@ class Email
|
||||
|
||||
$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++) {
|
||||
$unwrap[] = $matches[1][$i];
|
||||
$str = str_replace($matches[0][$i], '{{unwrapped' . $i . '}}', $str);
|
||||
@ -1659,7 +1659,7 @@ class Email
|
||||
$this->finalBody = preg_replace_callback(
|
||||
'/\{unwrap\}(.*?)\{\/unwrap\}/si',
|
||||
$this->removeNLCallback(...),
|
||||
$this->finalBody
|
||||
$this->finalBody,
|
||||
);
|
||||
}
|
||||
|
||||
@ -1900,7 +1900,7 @@ class Email
|
||||
$this->SMTPPort,
|
||||
$errno,
|
||||
$errstr,
|
||||
$this->SMTPTimeout
|
||||
$this->SMTPTimeout,
|
||||
);
|
||||
|
||||
if (! is_resource($this->SMTPConnect)) {
|
||||
@ -1921,7 +1921,7 @@ class Email
|
||||
STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT
|
||||
| STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT
|
||||
| STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
|
||||
| STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT
|
||||
| STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT,
|
||||
);
|
||||
|
||||
if ($crypto !== true) {
|
||||
|
@ -138,7 +138,7 @@ class Entity implements JsonSerializable
|
||||
array_merge($this->defaultCastHandlers, $this->castHandlers),
|
||||
null,
|
||||
null,
|
||||
false
|
||||
false,
|
||||
);
|
||||
|
||||
$this->syncOriginal();
|
||||
@ -185,7 +185,7 @@ class Entity implements JsonSerializable
|
||||
|
||||
if (is_array($this->datamap)) {
|
||||
$keys = array_unique(
|
||||
[...array_diff($keys, $this->datamap), ...array_keys($this->datamap)]
|
||||
[...array_diff($keys, $this->datamap), ...array_keys($this->datamap)],
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ class Events
|
||||
return;
|
||||
}
|
||||
|
||||
$config = config(Modules::class);
|
||||
$config = new Modules();
|
||||
$events = APPPATH . 'Config' . DIRECTORY_SEPARATOR . 'Events.php';
|
||||
$files = [];
|
||||
|
||||
@ -212,7 +212,7 @@ class Events
|
||||
if ($check === $listener) {
|
||||
unset(
|
||||
static::$listeners[$eventName][1][$index],
|
||||
static::$listeners[$eventName][2][$index]
|
||||
static::$listeners[$eventName][2][$index],
|
||||
);
|
||||
|
||||
return true;
|
||||
|
@ -68,7 +68,7 @@ class FrameworkException extends RuntimeException implements ExceptionInterface
|
||||
// @codeCoverageIgnoreStart
|
||||
$message = sprintf(
|
||||
'The framework needs the following extension(s) installed and loaded: %s.',
|
||||
$extension
|
||||
$extension,
|
||||
);
|
||||
// @codeCoverageIgnoreEnd
|
||||
} else {
|
||||
|
@ -103,7 +103,7 @@ class FileCollection implements Countable, IteratorAggregate
|
||||
$pattern = str_replace(
|
||||
['#', '.', '*', '?'],
|
||||
['\#', '\.', '.*', '.'],
|
||||
$pattern
|
||||
$pattern,
|
||||
);
|
||||
$pattern = "#\\A{$pattern}\\z#";
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ class Filters
|
||||
$this->request = &$request;
|
||||
$this->setResponse($response);
|
||||
|
||||
$this->modules = $modules ?? config(Modules::class);
|
||||
$this->modules = $modules instanceof Modules ? $modules : new Modules();
|
||||
|
||||
if ($this->modules->shouldDiscover('filters')) {
|
||||
$this->discoverFilters();
|
||||
@ -202,7 +202,7 @@ class Filters
|
||||
|
||||
$result = $class->before(
|
||||
$this->request,
|
||||
$this->argumentsClass[$className] ?? null
|
||||
$this->argumentsClass[$className] ?? null,
|
||||
);
|
||||
|
||||
if ($result instanceof RequestInterface) {
|
||||
@ -241,7 +241,7 @@ class Filters
|
||||
$result = $class->after(
|
||||
$this->request,
|
||||
$this->response,
|
||||
$this->argumentsClass[$className] ?? null
|
||||
$this->argumentsClass[$className] ?? null,
|
||||
);
|
||||
|
||||
if ($result instanceof ResponseInterface) {
|
||||
@ -648,7 +648,7 @@ class Filters
|
||||
@trigger_error(
|
||||
'Setting lowercase HTTP method key "' . strtolower($method) . '" is deprecated.'
|
||||
. ' Use uppercase HTTP method like "' . strtoupper($method) . '".',
|
||||
E_USER_DEPRECATED
|
||||
E_USER_DEPRECATED,
|
||||
);
|
||||
|
||||
$found = true;
|
||||
@ -744,7 +744,7 @@ class Filters
|
||||
if ($check && array_key_exists($name, $this->arguments)) {
|
||||
throw new ConfigException(
|
||||
'"' . $name . '" already has arguments: '
|
||||
. (($this->arguments[$name] === null) ? 'null' : implode(',', $this->arguments[$name]))
|
||||
. (($this->arguments[$name] === null) ? 'null' : implode(',', $this->arguments[$name])),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ class PerformanceMetrics implements FilterInterface
|
||||
(string) $benchmark->getElapsedTime('total_execution'),
|
||||
number_format(memory_get_peak_usage() / 1024 / 1024, 3),
|
||||
],
|
||||
$body
|
||||
$body,
|
||||
);
|
||||
|
||||
$response->setBody($output);
|
||||
|
@ -342,7 +342,7 @@ class CURLRequest extends OutgoingRequest
|
||||
$uri->getAuthority(),
|
||||
$uri->getPath(),
|
||||
$uri->getQuery(),
|
||||
$uri->getFragment()
|
||||
$uri->getFragment(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ class Cors
|
||||
if (in_array('*', $this->config[$name], true) && $count > 1) {
|
||||
throw new ConfigException(
|
||||
"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(
|
||||
'When responding to a credentialed request, '
|
||||
. '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(
|
||||
'Access-Control-Allow-Headers',
|
||||
implode(', ', $this->config['allowedHeaders'])
|
||||
implode(', ', $this->config['allowedHeaders']),
|
||||
);
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ class Cors
|
||||
|
||||
$response->setHeader(
|
||||
'Access-Control-Allow-Methods',
|
||||
implode(', ', $this->config['allowedMethods'])
|
||||
implode(', ', $this->config['allowedMethods']),
|
||||
);
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ class Cors
|
||||
if ($this->config['exposedHeaders'] !== []) {
|
||||
$response->setHeader(
|
||||
'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
Loading…
x
Reference in New Issue
Block a user