From 2849e7ff36b4c4aa1376d990a9a1e3f0c393b8d0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 7 Sep 2024 08:49:38 +0000 Subject: [PATCH] Release v4.5.5 --- composer.json | 2 +- preload.php | 10 ++-- system/BaseModel.php | 4 +- system/CodeIgniter.php | 2 +- system/Common.php | 2 + system/Database/BaseBuilder.php | 30 +++++++----- system/Database/BaseConnection.php | 4 +- system/Database/Database.php | 49 +++++++++++++++++-- system/Database/Postgre/Builder.php | 4 +- system/Entity/Entity.php | 4 +- system/Filters/CSRF.php | 11 ++--- system/HTTP/ContentSecurityPolicy.php | 12 +++-- system/Helpers/html_helper.php | 30 ++++++++---- system/Helpers/text_helper.php | 5 +- system/Helpers/url_helper.php | 2 +- system/Router/Router.php | 6 +-- system/Security/Security.php | 2 +- .../PSR/Log/LoggerAwareInterface.php | 4 -- .../ThirdParty/PSR/Log/LoggerAwareTrait.php | 4 -- system/ThirdParty/PSR/Log/LoggerInterface.php | 28 ----------- system/ThirdParty/PSR/Log/LoggerTrait.php | 46 +---------------- system/ThirdParty/PSR/Log/NullLogger.php | 6 +-- system/Validation/StrictRules/Rules.php | 16 ++++-- system/Validation/Validation.php | 5 +- 24 files changed, 138 insertions(+), 150 deletions(-) diff --git a/composer.json b/composer.json index d46c7490..79fc5c28 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "kint-php/kint": "^5.0.4", "mikey179/vfsstream": "^1.6", "nexusphp/cs-config": "^3.6", - "phpunit/phpunit": "^10.5.16", + "phpunit/phpunit": "^10.5.16 || ^11.2", "predis/predis": "^1.1 || ^2.0" }, "suggest": { diff --git a/preload.php b/preload.php index 75d86f5c..755df5e4 100644 --- a/preload.php +++ b/preload.php @@ -38,23 +38,25 @@ class preload [ 'include' => __DIR__ . '/vendor/codeigniter4/framework/system', // Change this path if using manual installation 'exclude' => [ - '/system/bootstrap.php', // Not needed if you don't use them. '/system/Database/OCI8/', '/system/Database/Postgre/', '/system/Database/SQLite3/', '/system/Database/SQLSRV/', - // Not needed. + // Not needed for web apps. '/system/Database/Seeder.php', '/system/Test/', - '/system/Language/', '/system/CLI/', '/system/Commands/', '/system/Publisher/', '/system/ComposerScripts.php', + // Not Class/Function files. + '/system/Config/Routes.php', + '/system/Language/', + '/system/bootstrap.php', + '/system/rewrite.php', '/Views/', // Errors occur. - '/system/Config/Routes.php', '/system/ThirdParty/', ], ], diff --git a/system/BaseModel.php b/system/BaseModel.php index 9b8bb70e..2b364bdc 100644 --- a/system/BaseModel.php +++ b/system/BaseModel.php @@ -541,7 +541,7 @@ abstract protected function doReplace(?array $row = null, bool $returnSQL = fals * Grabs the last error(s) that occurred from the Database connection. * This method works only with dbCalls. * - * @return array|null + * @return array */ abstract protected function doErrors(); @@ -1242,7 +1242,7 @@ public function replace(?array $row = null, bool $returnSQL = false) * * @param bool $forceDB Always grab the db error, not validation * - * @return array + * @return array */ public function errors(bool $forceDB = false) { diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index bcfb7bd6..48fbc9d7 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -56,7 +56,7 @@ class CodeIgniter /** * The current version of CodeIgniter Framework */ - public const CI_VERSION = '4.5.4'; + public const CI_VERSION = '4.5.5'; /** * App startup time. diff --git a/system/Common.php b/system/Common.php index 49b3d289..dcc9487c 100644 --- a/system/Common.php +++ b/system/Common.php @@ -28,6 +28,7 @@ use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; +use CodeIgniter\Language\Language; use CodeIgniter\Model; use CodeIgniter\Session\Session; use CodeIgniter\Test\TestLogger; @@ -732,6 +733,7 @@ function is_windows(?bool $mock = null): bool */ function lang(string $line, array $args = [], ?string $locale = null) { + /** @var Language $language */ $language = service('language'); // Get active locale diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 649a2011..9d5a02db 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -3164,21 +3164,27 @@ protected function compileWhereHaving(string $qbKey): string ); foreach ($conditions as &$condition) { - if (($op = $this->getOperator($condition)) === false - || ! preg_match('/^(\(?)(.*)(' . preg_quote($op, '/') . ')\s*(.*(?getOperator($condition); + if ( + $op === false + || ! preg_match( + '/^(\(?)(.*)(' . preg_quote($op, '/') . ')\s*(.*(? '(test <= foo)', /* the whole thing */ - // 1 => '(', /* optional */ - // 2 => 'test', /* the field name */ - // 3 => ' <= ', /* $op */ - // 4 => 'foo', /* optional, if $op is e.g. 'IS NULL' */ - // 5 => ')' /* optional */ - // ); - - if (! empty($matches[4])) { + // $matches = [ + // 0 => '(test <= foo)', /* the whole thing */ + // 1 => '(', /* optional */ + // 2 => 'test', /* the field name */ + // 3 => ' <= ', /* $op */ + // 4 => 'foo', /* optional, if $op is e.g. 'IS NULL' */ + // 5 => ')' /* optional */ + // ]; + + if (isset($matches[4]) && $matches[4] !== '') { $protectIdentifiers = false; if (str_contains($matches[4], '.')) { $protectIdentifiers = true; diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index dce399bd..56340c8d 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -784,9 +784,9 @@ public function transStart(bool $testMode = false): bool * * @return $this */ - public function transException(bool $transExcetion) + public function transException(bool $transException) { - $this->transException = $transExcetion; + $this->transException = $transException; return $this; } diff --git a/system/Database/Database.php b/system/Database/Database.php index c2bc66d3..23b6cd0f 100644 --- a/system/Database/Database.php +++ b/system/Database/Database.php @@ -13,6 +13,8 @@ namespace CodeIgniter\Database; +use CodeIgniter\Exceptions\ConfigException; +use CodeIgniter\Exceptions\CriticalError; use InvalidArgumentException; /** @@ -54,6 +56,8 @@ public function load(array $params = [], string $alias = '') throw new InvalidArgumentException('You have not selected a database type to connect to.'); } + assert($this->checkDbExtension($params['DBDriver'])); + $this->connections[$alias] = $this->initDriver($params['DBDriver'], 'Connection', $params); return $this->connections[$alias]; @@ -124,9 +128,9 @@ protected function parseDSN(array $params): array /** * Creates a database object. * - * @param string $driver Driver name. FQCN can be used. - * @param string $class 'Connection'|'Forge'|'Utils' - * @param array|object $argument The constructor parameter. + * @param string $driver Driver name. FQCN can be used. + * @param string $class 'Connection'|'Forge'|'Utils' + * @param array|ConnectionInterface $argument The constructor parameter or DB connection * * @return BaseConnection|BaseUtils|Forge */ @@ -138,4 +142,43 @@ protected function initDriver(string $driver, string $class, $argument): object return new $classname($argument); } + + /** + * Check the PHP database extension is loaded. + * + * @param string $driver DB driver or FQCN for custom driver + */ + private function checkDbExtension(string $driver): bool + { + if (str_contains($driver, '\\')) { + // Cannot check a fully qualified classname for a custom driver. + return true; + } + + $extensionMap = [ + // DBDriver => PHP extension + 'MySQLi' => 'mysqli', + 'SQLite3' => 'sqlite3', + 'Postgre' => 'pgsql', + 'SQLSRV' => 'sqlsrv', + 'OCI8' => 'oci8', + ]; + + $extension = $extensionMap[$driver] ?? ''; + + if ($extension === '') { + $message = 'Invalid DBDriver name: "' . $driver . '"'; + + throw new ConfigException($message); + } + + if (extension_loaded($extension)) { + return true; + } + + $message = 'The required PHP extension "' . $extension . '" is not loaded.' + . ' Install and enable it to use "' . $driver . '" driver.'; + + throw new CriticalError($message); + } } diff --git a/system/Database/Postgre/Builder.php b/system/Database/Postgre/Builder.php index 1071dfed..0d2dce09 100644 --- a/system/Database/Postgre/Builder.php +++ b/system/Database/Postgre/Builder.php @@ -411,10 +411,8 @@ static function ($key, $value) use ($table, $alias, $that) { * Returns cast expression. * * @TODO move this to BaseBuilder in 4.5.0 - * - * @param float|int|string $expression */ - private function cast($expression, ?string $type): string + private function cast(string $expression, ?string $type): string { return ($type === null) ? $expression : 'CAST(' . $expression . ' AS ' . strtoupper($type) . ')'; } diff --git a/system/Entity/Entity.php b/system/Entity/Entity.php index 5de8a421..464992af 100644 --- a/system/Entity/Entity.php +++ b/system/Entity/Entity.php @@ -106,7 +106,7 @@ class Entity implements JsonSerializable /** * Holds the current values of all class vars. * - * @var array + * @var array */ protected $attributes = []; @@ -115,7 +115,7 @@ class Entity implements JsonSerializable * what's actually been changed and not accidentally write * nulls where we shouldn't. * - * @var array + * @var array */ protected $original = []; diff --git a/system/Filters/CSRF.php b/system/Filters/CSRF.php index 90ccb9b5..beb15f62 100644 --- a/system/Filters/CSRF.php +++ b/system/Filters/CSRF.php @@ -18,6 +18,7 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\Security\Exceptions\SecurityException; +use CodeIgniter\Security\Security; /** * CSRF filter. @@ -30,14 +31,7 @@ class CSRF implements FilterInterface { /** - * Do whatever processing this filter needs to do. - * By default it should not return anything during - * normal execution. However, when an abnormal state - * is found, it should return an instance of - * CodeIgniter\HTTP\Response. If it does, script - * execution will end and that Response will be - * sent back to the client, allowing for error pages, - * redirects, etc. + * CSRF verification. * * @param list|null $arguments * @@ -51,6 +45,7 @@ public function before(RequestInterface $request, $arguments = null) return; } + /** @var Security $security */ $security = service('security'); try { diff --git a/system/HTTP/ContentSecurityPolicy.php b/system/HTTP/ContentSecurityPolicy.php index 945c3e08..7582bc46 100644 --- a/system/HTTP/ContentSecurityPolicy.php +++ b/system/HTTP/ContentSecurityPolicy.php @@ -31,7 +31,7 @@ class ContentSecurityPolicy /** * CSP directives * - * @var array + * @var array [name => property] */ protected array $directives = [ 'base-uri' => 'baseURI', @@ -166,7 +166,8 @@ class ContentSecurityPolicy protected $sandbox = []; /** - * Used for security enforcement + * A set of endpoints to which csp violation reports will be sent when + * particular behaviors are prevented. * * @var string|null */ @@ -189,7 +190,7 @@ class ContentSecurityPolicy /** * Used for security enforcement * - * @var array + * @var list */ protected $validSources = [ 'self', @@ -242,7 +243,7 @@ class ContentSecurityPolicy /** * An array of header info since we have - * to build ourself before passing to Response. + * to build ourselves before passing to Response. * * @var array */ @@ -594,6 +595,9 @@ public function addPluginType($mime, ?bool $explicitReporting = null) * * @see http://www.w3.org/TR/CSP/#directive-report-uri * + * @param string $uri URL to send reports. Set `''` if you want to remove + * this directive at runtime. + * * @return $this */ public function setReportURI(string $uri) diff --git a/system/Helpers/html_helper.php b/system/Helpers/html_helper.php index f3d33611..b9e5e5c8 100644 --- a/system/Helpers/html_helper.php +++ b/system/Helpers/html_helper.php @@ -21,9 +21,10 @@ /** * Unordered List * - * Generates an HTML unordered list from an single or - * multi-dimensional array. + * Generates an HTML unordered list from a single or + * multidimensional array. * + * @param array $list List entries * @param array|object|string $attributes HTML attributes string, array, object */ function ul(array $list, $attributes = ''): string @@ -36,8 +37,9 @@ function ul(array $list, $attributes = ''): string /** * Ordered List * - * Generates an HTML ordered list from an single or multi-dimensional array. + * Generates an HTML ordered list from a single or multidimensional array. * + * @param array $list List entries * @param array|object|string $attributes HTML attributes string, array, object */ function ol(array $list, $attributes = ''): string @@ -50,10 +52,10 @@ function ol(array $list, $attributes = ''): string /** * Generates the list * - * Generates an HTML ordered list from an single or multi-dimensional array. + * Generates an HTML ordered list from a single or multidimensional array. * - * @param array $list - * @param array|object|string $attributes string, array, object + * @param array $list List entries + * @param array|object|string $attributes HTML attributes string, array, object */ function _list(string $type = 'ul', $list = [], $attributes = '', int $depth = 0): string { @@ -92,7 +94,7 @@ function _list(string $type = 'ul', $list = [], $attributes = '', int $depth = 0 * Generates an image element * * @param array|string $src Image source URI, or array of attributes and values - * @param bool $indexPage Whether to treat $src as a routed URI string + * @param bool $indexPage Should `Config\App::$indexPage` be added to the source path * @param array|object|string $attributes Additional HTML attributes */ function img($src = '', bool $indexPage = false, $attributes = ''): string @@ -192,7 +194,7 @@ function doctype(string $type = 'html5'): string * Generates link to a JS file * * @param array|string $src Script source or an array of attributes - * @param bool $indexPage Should indexPage be added to the JS path + * @param bool $indexPage Should `Config\App::$indexPage` be added to the JS path */ function script_tag($src = '', bool $indexPage = false): string { @@ -227,7 +229,7 @@ function script_tag($src = '', bool $indexPage = false): string * Generates link tag * * @param array|string $href Stylesheet href or an array - * @param bool $indexPage should indexPage be added to the CSS path. + * @param bool $indexPage Should `Config\App::$indexPage` be added to the CSS path. */ function link_tag( $href = '', @@ -288,6 +290,7 @@ function link_tag( * @param array|string $src Either a source string or an array of sources * @param string $unsupportedMessage The message to display if the media tag is not supported by the browser * @param string $attributes HTML attributes + * @param bool $indexPage Should `Config\App::$indexPage` be added to the source path */ function video($src, string $unsupportedMessage = '', string $attributes = '', array $tracks = [], bool $indexPage = false): string { @@ -334,6 +337,7 @@ function video($src, string $unsupportedMessage = '', string $attributes = '', a * @param array|string $src Either a source string or an array of sources * @param string $unsupportedMessage The message to display if the media tag is not supported by the browser. * @param string $attributes HTML attributes + * @param bool $indexPage Should `Config\App::$indexPage` be added to the source path */ function audio($src, string $unsupportedMessage = '', string $attributes = '', array $tracks = [], bool $indexPage = false): string { @@ -413,6 +417,7 @@ function _media(string $name, array $types = [], string $unsupportedMessage = '' * @param string $src The path of the media resource * @param string $type The MIME-type of the resource with optional codecs parameters * @param string $attributes HTML attributes + * @param bool $indexPage Should `Config\App::$indexPage` be added to the source path */ function source(string $src, string $type = 'unknown', string $attributes = '', bool $indexPage = false): string { @@ -438,7 +443,10 @@ function source(string $src, string $type = 'unknown', string $attributes = '', * Generates a track element to specify timed tracks. The tracks are * formatted in WebVTT format. * - * @param string $src The path of the .VTT file + * @param string $src The path of the .VTT file + * @param string $kind How the text track is meant to be used + * @param string $srcLanguage Language of the track text data + * @param string $label A user-readable title of the text track */ function track(string $src, string $kind, string $srcLanguage, string $label): string { @@ -461,6 +469,7 @@ function track(string $src, string $kind, string $srcLanguage, string $label): s * @param string $data A resource URL * @param string $type Content-type of the resource * @param string $attributes HTML attributes + * @param bool $indexPage Should `Config\App::$indexPage` be added to the data path */ function object(string $data, string $type = 'unknown', string $attributes = '', array $params = [], bool $indexPage = false): string { @@ -513,6 +522,7 @@ function param(string $name, string $value, string $type = 'ref', string $attrib * @param string $src The path of the resource to embed * @param string $type MIME-type * @param string $attributes HTML attributes + * @param bool $indexPage Should `Config\App::$indexPage` be added to the source path */ function embed(string $src, string $type = 'unknown', string $attributes = '', bool $indexPage = false): string { diff --git a/system/Helpers/text_helper.php b/system/Helpers/text_helper.php index ae6b6f11..3de10573 100644 --- a/system/Helpers/text_helper.php +++ b/system/Helpers/text_helper.php @@ -526,9 +526,10 @@ function reduce_double_slashes(string $str): string */ function reduce_multiples(string $str, string $character = ',', bool $trim = false): string { - $str = preg_replace('#' . preg_quote($character, '#') . '{2,}#', $character, $str); + $pattern = '#' . preg_quote($character, '#') . '{2,}#'; + $str = preg_replace($pattern, $character, $str); - return ($trim) ? trim($str, $character) : $str; + return $trim ? trim($str, $character) : $str; } } diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 1d03132d..d68fea2a 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -351,7 +351,7 @@ function safe_mailto(string $email, string $title = '', $attributes = ''): strin function auto_link(string $str, string $type = 'both', bool $popup = false): string { // Find and replace any URLs. - if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[^\s()<>;]+\w#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { + if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[a-z0-9]+(-+[a-z0-9]+)*(\.[a-z0-9]+(-+[a-z0-9]+)*)+(/([^\s()<>;]+\w)?/?)?#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { // Set our target HTML if using popup links. $target = ($popup) ? ' target="_blank"' : ''; diff --git a/system/Router/Router.php b/system/Router/Router.php index dc778cd0..d60313f6 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -181,7 +181,7 @@ public function __construct(RouteCollectionInterface $routes, ?Request $request } /** - * Finds the controller method corresponding to the URI. + * Finds the controller corresponding to the URI. * * @param string|null $uri URI path relative to baseURL * @@ -241,7 +241,7 @@ public function getFilters(): array } /** - * Returns the name of the matched controller. + * Returns the name of the matched controller or closure. * * @return (Closure(mixed...): (ResponseInterface|string|void))|string Controller classname or Closure */ @@ -254,7 +254,7 @@ public function controllerName() /** * Returns the name of the method to run in the - * chosen container. + * chosen controller. */ public function methodName(): string { diff --git a/system/Security/Security.php b/system/Security/Security.php index 077b3b9c..0b51062e 100644 --- a/system/Security/Security.php +++ b/system/Security/Security.php @@ -233,7 +233,7 @@ private function configureCookie(CookieConfig $cookie): void } /** - * CSRF Verify + * CSRF verification. * * @return $this * diff --git a/system/ThirdParty/PSR/Log/LoggerAwareInterface.php b/system/ThirdParty/PSR/Log/LoggerAwareInterface.php index cc46a951..06218705 100644 --- a/system/ThirdParty/PSR/Log/LoggerAwareInterface.php +++ b/system/ThirdParty/PSR/Log/LoggerAwareInterface.php @@ -9,10 +9,6 @@ interface LoggerAwareInterface { /** * Sets a logger instance on the object. - * - * @param LoggerInterface $logger - * - * @return void */ public function setLogger(LoggerInterface $logger): void; } diff --git a/system/ThirdParty/PSR/Log/LoggerAwareTrait.php b/system/ThirdParty/PSR/Log/LoggerAwareTrait.php index 4fb57a29..85104dbc 100644 --- a/system/ThirdParty/PSR/Log/LoggerAwareTrait.php +++ b/system/ThirdParty/PSR/Log/LoggerAwareTrait.php @@ -9,15 +9,11 @@ trait LoggerAwareTrait { /** * The logger instance. - * - * @var LoggerInterface|null */ protected ?LoggerInterface $logger = null; /** * Sets a logger. - * - * @param LoggerInterface $logger */ public function setLogger(LoggerInterface $logger): void { diff --git a/system/ThirdParty/PSR/Log/LoggerInterface.php b/system/ThirdParty/PSR/Log/LoggerInterface.php index b3a24b5f..8afabc90 100644 --- a/system/ThirdParty/PSR/Log/LoggerInterface.php +++ b/system/ThirdParty/PSR/Log/LoggerInterface.php @@ -22,10 +22,7 @@ interface LoggerInterface /** * System is unusable. * - * @param string|\Stringable $message * @param mixed[] $context - * - * @return void */ public function emergency(string|\Stringable $message, array $context = []): void; @@ -35,10 +32,7 @@ public function emergency(string|\Stringable $message, array $context = []): voi * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. * - * @param string|\Stringable $message * @param mixed[] $context - * - * @return void */ public function alert(string|\Stringable $message, array $context = []): void; @@ -47,10 +41,7 @@ public function alert(string|\Stringable $message, array $context = []): void; * * Example: Application component unavailable, unexpected exception. * - * @param string|\Stringable $message * @param mixed[] $context - * - * @return void */ public function critical(string|\Stringable $message, array $context = []): void; @@ -58,10 +49,7 @@ public function critical(string|\Stringable $message, array $context = []): void * Runtime errors that do not require immediate action but should typically * be logged and monitored. * - * @param string|\Stringable $message * @param mixed[] $context - * - * @return void */ public function error(string|\Stringable $message, array $context = []): void; @@ -71,20 +59,14 @@ public function error(string|\Stringable $message, array $context = []): void; * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. * - * @param string|\Stringable $message * @param mixed[] $context - * - * @return void */ public function warning(string|\Stringable $message, array $context = []): void; /** * Normal but significant events. * - * @param string|\Stringable $message * @param mixed[] $context - * - * @return void */ public function notice(string|\Stringable $message, array $context = []): void; @@ -93,32 +75,22 @@ public function notice(string|\Stringable $message, array $context = []): void; * * Example: User logs in, SQL logs. * - * @param string|\Stringable $message * @param mixed[] $context - * - * @return void */ public function info(string|\Stringable $message, array $context = []): void; /** * Detailed debug information. * - * @param string|\Stringable $message * @param mixed[] $context - * - * @return void */ public function debug(string|\Stringable $message, array $context = []): void; /** * Logs with an arbitrary level. * - * @param mixed $level - * @param string|\Stringable $message * @param mixed[] $context * - * @return void - * * @throws \Psr\Log\InvalidArgumentException */ public function log($level, string|\Stringable $message, array $context = []): void; diff --git a/system/ThirdParty/PSR/Log/LoggerTrait.php b/system/ThirdParty/PSR/Log/LoggerTrait.php index 9c8733f9..a5d9980b 100644 --- a/system/ThirdParty/PSR/Log/LoggerTrait.php +++ b/system/ThirdParty/PSR/Log/LoggerTrait.php @@ -14,11 +14,6 @@ trait LoggerTrait { /** * System is unusable. - * - * @param string|\Stringable $message - * @param array $context - * - * @return void */ public function emergency(string|\Stringable $message, array $context = []): void { @@ -30,11 +25,6 @@ public function emergency(string|\Stringable $message, array $context = []): voi * * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. - * - * @param string|\Stringable $message - * @param array $context - * - * @return void */ public function alert(string|\Stringable $message, array $context = []): void { @@ -45,11 +35,6 @@ public function alert(string|\Stringable $message, array $context = []): void * Critical conditions. * * Example: Application component unavailable, unexpected exception. - * - * @param string|\Stringable $message - * @param array $context - * - * @return void */ public function critical(string|\Stringable $message, array $context = []): void { @@ -59,11 +44,6 @@ public function critical(string|\Stringable $message, array $context = []): void /** * Runtime errors that do not require immediate action but should typically * be logged and monitored. - * - * @param string|\Stringable $message - * @param array $context - * - * @return void */ public function error(string|\Stringable $message, array $context = []): void { @@ -75,11 +55,6 @@ public function error(string|\Stringable $message, array $context = []): void * * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. - * - * @param string|\Stringable $message - * @param array $context - * - * @return void */ public function warning(string|\Stringable $message, array $context = []): void { @@ -88,11 +63,6 @@ public function warning(string|\Stringable $message, array $context = []): void /** * Normal but significant events. - * - * @param string|\Stringable $message - * @param array $context - * - * @return void */ public function notice(string|\Stringable $message, array $context = []): void { @@ -103,11 +73,6 @@ public function notice(string|\Stringable $message, array $context = []): void * Interesting events. * * Example: User logs in, SQL logs. - * - * @param string|\Stringable $message - * @param array $context - * - * @return void */ public function info(string|\Stringable $message, array $context = []): void { @@ -116,11 +81,6 @@ public function info(string|\Stringable $message, array $context = []): void /** * Detailed debug information. - * - * @param string|\Stringable $message - * @param array $context - * - * @return void */ public function debug(string|\Stringable $message, array $context = []): void { @@ -130,11 +90,7 @@ public function debug(string|\Stringable $message, array $context = []): void /** * Logs with an arbitrary level. * - * @param mixed $level - * @param string|\Stringable $message - * @param array $context - * - * @return void + * @param mixed $level * * @throws \Psr\Log\InvalidArgumentException */ diff --git a/system/ThirdParty/PSR/Log/NullLogger.php b/system/ThirdParty/PSR/Log/NullLogger.php index c1cc3c06..de0561e2 100644 --- a/system/ThirdParty/PSR/Log/NullLogger.php +++ b/system/ThirdParty/PSR/Log/NullLogger.php @@ -15,11 +15,7 @@ class NullLogger extends AbstractLogger /** * Logs with an arbitrary level. * - * @param mixed $level - * @param string|\Stringable $message - * @param array $context - * - * @return void + * @param mixed[] $context * * @throws \Psr\Log\InvalidArgumentException */ diff --git a/system/Validation/StrictRules/Rules.php b/system/Validation/StrictRules/Rules.php index e4fc4fc9..ec02a4e0 100644 --- a/system/Validation/StrictRules/Rules.php +++ b/system/Validation/StrictRules/Rules.php @@ -48,11 +48,15 @@ public function differs( return $str !== dot_array_search($otherField, $data); } - if (! array_key_exists($field, $data)) { + if (! array_key_exists($otherField, $data)) { return false; } - if (! array_key_exists($otherField, $data)) { + if (str_contains($field, '.')) { + if (! ArrayHelper::dotKeyExists($field, $data)) { + return false; + } + } elseif (! array_key_exists($field, $data)) { return false; } @@ -281,11 +285,15 @@ public function matches( return $str === dot_array_search($otherField, $data); } - if (! array_key_exists($field, $data)) { + if (! array_key_exists($otherField, $data)) { return false; } - if (! array_key_exists($otherField, $data)) { + if (str_contains($field, '.')) { + if (! ArrayHelper::dotKeyExists($field, $data)) { + return false; + } + } elseif (! array_key_exists($field, $data)) { return false; } diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index bfc661c2..a4d817d2 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -51,7 +51,7 @@ class Validation implements ValidationInterface /** * Stores the actual rules that should be run against $data. * - * @var array + * @var array}> * * [ * field1 => [ @@ -163,6 +163,9 @@ public function run(?array $data = null, ?string $group = null, $dbGroup = null) // Run through each rule. If we have any field set for // this rule, then we need to run them through! foreach ($this->rules as $field => $setup) { + // An array key might be int. + $field = (string) $field; + $rules = $setup['rules']; if (is_string($rules)) {