From d608eafda01ca3ded3ee6c6d788af1a239127b21 Mon Sep 17 00:00:00 2001 From: John Paul E Balandan Date: Mon, 17 Aug 2026 02:54:34 +0800 Subject: [PATCH 1/3] refactor: fix phpstan errors in `Helpers` (#10459) --- system/Helpers/Array/ArrayHelper.php | 29 +- system/Helpers/array_helper.php | 25 +- system/Helpers/filesystem_helper.php | 7 +- system/Helpers/form_helper.php | 82 +-- system/Helpers/html_helper.php | 53 +- system/Helpers/kint_helper.php | 6 +- system/Helpers/number_helper.php | 2 + system/Helpers/test_helper.php | 8 +- system/Helpers/text_helper.php | 10 +- system/Helpers/url_helper.php | 46 +- utils/phpstan-baseline/argument.type.neon | 7 +- utils/phpstan-baseline/loader.neon | 2 +- .../missingType.iterableValue.neon | 472 +----------------- 13 files changed, 155 insertions(+), 594 deletions(-) diff --git a/system/Helpers/Array/ArrayHelper.php b/system/Helpers/Array/ArrayHelper.php index 1e7d6904796c..f70f6905ca5d 100644 --- a/system/Helpers/Array/ArrayHelper.php +++ b/system/Helpers/Array/ArrayHelper.php @@ -33,7 +33,8 @@ final class ArrayHelper * * @used-by dot_array_search() * - * @param string $index The index as dot array syntax. + * @param string $index The index as dot array syntax. + * @param array $array * * @return mixed */ @@ -68,6 +69,9 @@ private static function convertToArray(string $index): array * * @used-by dotSearch() * + * @param list $indexes + * @param array $array + * * @return mixed */ private static function arraySearchDot(array $indexes, array $array) @@ -125,6 +129,8 @@ private static function arraySearchDot(array $indexes, array $array) * array_key_exists() with dot array syntax. * * If wildcard `*` is used, all items for the key after it must have the key. + * + * @param array $array */ public static function dotKeyExists(string $index, array $array): bool { @@ -179,11 +185,11 @@ public static function dotKeyExists(string $index, array $array): bool * * @used-by array_group_by() * - * @param array $array Data array (i.e. from query result) - * @param array $indexes Indexes to group by. Dot syntax used. Returns $array if empty - * @param bool $includeEmpty If true, null and '' are also added as valid keys to group + * @param array $array Data array (i.e. from query result) + * @param list $indexes Indexes to group by. Dot syntax used. Returns $array if empty + * @param bool $includeEmpty If true, null and '' are also added as valid keys to group * - * @return array Result array where rows are grouped together by indexes values. + * @return array Result array where rows are grouped together by indexes values. */ public static function groupBy(array $array, array $indexes, bool $includeEmpty = false): array { @@ -205,6 +211,12 @@ public static function groupBy(array $array, array $indexes, bool $includeEmpty * `dot_array_search()`. * * @used-by groupBy() + * + * @param array $result + * @param array $row + * @param list $indexes + * + * @return array */ private static function arrayAttachIndexedValue( array $result, @@ -244,6 +256,11 @@ private static function arrayAttachIndexedValue( /** * Compare recursively two associative arrays and return difference as new array. * Returns keys that exist in `$original` but not in `$compareWith`. + * + * @param array $original + * @param array $compareWith + * + * @return array */ public static function recursiveDiff(array $original, array $compareWith): array { @@ -284,6 +301,8 @@ public static function recursiveDiff(array $original, array $compareWith): array /** * Recursively count all keys. + * + * @param array $array */ public static function recursiveCount(array $array, int $counter = 0): int { diff --git a/system/Helpers/array_helper.php b/system/Helpers/array_helper.php index 4d5d12488d78..f0ea0637c545 100644 --- a/system/Helpers/array_helper.php +++ b/system/Helpers/array_helper.php @@ -20,6 +20,8 @@ * Searches an array through dot syntax. Supports * wildcard searches, like foo.*.bar * + * @param array $array + * * @return mixed */ function dot_array_search(string $index, array $array) @@ -32,7 +34,8 @@ function dot_array_search(string $index, array $array) /** * Returns the value of an element at a key in an array of uncertain depth. * - * @param int|string $key + * @param int|string $key + * @param array $array * * @return mixed */ @@ -78,9 +81,9 @@ function array_deep_search($key, array $array) * For information on multi-level array sorting, refer to Example #3 here: * https://www.php.net/manual/de/function.array-multisort.php * - * @param array $array the reference of the array to be sorted - * @param array $sortColumns an associative array of columns to sort - * after and their sorting flags + * @param array $array The reference of the array to be sorted + * @param array $sortColumns An associative array of columns to sort + * after and their sorting flags */ function array_sort_by_multiple_keys(array &$array, array $sortColumns): bool { @@ -129,10 +132,10 @@ function array_sort_by_multiple_keys(array &$array, array $sortColumns): bool /** * Flatten a multidimensional array using dots as separators. * - * @param iterable $array The multi-dimensional array - * @param string $id Something to initially prepend to the flattened keys + * @param iterable $array The multi-dimensional array + * @param string $id Something to initially prepend to the flattened keys * - * @return array The flattened array + * @return array The flattened array */ function array_flatten_with_dots(iterable $array, string $id = ''): array { @@ -156,11 +159,11 @@ function array_flatten_with_dots(iterable $array, string $id = ''): array /** * Groups all rows by their index values. Result's depth equals number of indexes * - * @param array $array Data array (i.e. from query result) - * @param array $indexes Indexes to group by. Dot syntax used. Returns $array if empty - * @param bool $includeEmpty If true, null and '' are also added as valid keys to group + * @param array $array Data array (i.e. from query result) + * @param list $indexes Indexes to group by. Dot syntax used. Returns $array if empty + * @param bool $includeEmpty If true, null and '' are also added as valid keys to group * - * @return array Result array where rows are grouped together by indexes values. + * @return array Result array where rows are grouped together by indexes values. */ function array_group_by(array $array, array $indexes, bool $includeEmpty = false): array { diff --git a/system/Helpers/filesystem_helper.php b/system/Helpers/filesystem_helper.php index 3f5ed25f8531..f9a04dd142df 100644 --- a/system/Helpers/filesystem_helper.php +++ b/system/Helpers/filesystem_helper.php @@ -24,9 +24,10 @@ * directory will be mapped as well. * * @param string $sourceDir Path to source - * @param int $directoryDepth Depth of directories to traverse - * (0 = fully recursive, 1 = current dir, etc) + * @param int $directoryDepth Depth of directories to traverse (0 = fully recursive, 1 = current dir, etc) * @param bool $hidden Whether to show hidden files + * + * @return array|string> */ function directory_map(string $sourceDir, int $directoryDepth = 0, bool $hidden = false): array { @@ -200,6 +201,8 @@ function delete_files(string $path, bool $delDir = false, bool $htdocs = false, * @param bool|null $includePath Whether to include the path as part of the filename; false for no path, null for a relative path, true for full path * @param bool $hidden Whether to include hidden files (files beginning with a period) * @param bool $includeDir Whether to include directories + * + * @return list */ function get_filenames( string $sourceDir, diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php index a1f7defc4d14..fc67aac601bf 100644 --- a/system/Helpers/form_helper.php +++ b/system/Helpers/form_helper.php @@ -23,9 +23,9 @@ * * Creates the opening portion of the form. * - * @param string $action the URI segments of the form destination - * @param array|string $attributes a key/value pair of attributes, or string representation - * @param array $hidden a key/value pair hidden data + * @param string $action The URI segments of the form destination + * @param array|string $attributes A key/value pair of attributes, or string representation + * @param array $hidden A key/value pair hidden data */ function form_open(string $action = '', $attributes = [], array $hidden = []): string { @@ -80,9 +80,9 @@ function form_open(string $action = '', $attributes = [], array $hidden = []): s * * Creates the opening portion of the form, but with "multipart/form-data". * - * @param string $action The URI segments of the form destination - * @param array|string $attributes A key/value pair of attributes, or the same as a string - * @param array $hidden A key/value pair hidden data + * @param string $action The URI segments of the form destination + * @param array|string $attributes A key/value pair of attributes, or the same as a string + * @param array $hidden A key/value pair hidden data */ function form_open_multipart(string $action = '', $attributes = [], array $hidden = []): string { @@ -103,8 +103,8 @@ function form_open_multipart(string $action = '', $attributes = [], array $hidde * Generates hidden fields. You can pass a simple key/value string or * an associative array with multiple values. * - * @param array|string $name Field name or associative array to create multiple fields - * @param array|string $value Field value + * @param array|string $name Field name or associative array to create multiple fields + * @param array|string|null $value Field value */ function form_hidden($name, $value = '', bool $recursing = false): string { @@ -140,8 +140,8 @@ function form_hidden($name, $value = '', bool $recursing = false): string * Text Input Field. If 'type' is passed in the $type field, it will be * used as the input type, for making 'email', 'phone', etc input fields. * - * @param array|string $data - * @param array|object|string $extra string, array, object that can be cast to array + * @param array|string $data + * @param array|object|string $extra String, array, object that can be cast to array */ function form_input($data = '', string $value = '', $extra = '', string $type = 'text'): string { @@ -161,8 +161,8 @@ function form_input($data = '', string $value = '', $extra = '', string $type = * * Identical to the input function but adds the "password" type * - * @param array|string $data - * @param array|object|string $extra string, array, object that can be cast to array + * @param array|string $data + * @param array|object|string $extra String, array, object that can be cast to array */ function form_password($data = '', string $value = '', $extra = ''): string { @@ -181,8 +181,8 @@ function form_password($data = '', string $value = '', $extra = ''): string * * Identical to the input function but adds the "file" type * - * @param array|string $data - * @param array|object|string $extra string, array, object that can be cast to array + * @param array|string $data + * @param array|object|string $extra String, array, object that can be cast to array */ function form_upload($data = '', string $value = '', $extra = ''): string { @@ -205,8 +205,8 @@ function form_upload($data = '', string $value = '', $extra = ''): string /** * Textarea field * - * @param array|string $data - * @param array|object|string $extra string, array, object that can be cast to array + * @param array|string $data + * @param array|object|string $extra String, array, object that can be cast to array */ function form_textarea($data = '', string $value = '', $extra = ''): string { @@ -241,8 +241,10 @@ function form_textarea($data = '', string $value = '', $extra = ''): string /** * Multi-select menu * - * @param array|string $name - * @param array|object|string $extra string, array, object that can be cast to array + * @param array|string $name + * @param array|string> $options + * @param array $selected + * @param array|object|string $extra String, array, object that can be cast to array */ function form_multiselect($name = '', array $options = [], array $selected = [], $extra = ''): string { @@ -260,10 +262,10 @@ function form_multiselect($name = '', array $options = [], array $selected = [], /** * Drop-down Menu * - * @param array|string $data - * @param array|string $options - * @param array|string $selected - * @param array|object|string $extra string, array, object that can be cast to array + * @param array|string $data + * @param array|string>|string $options + * @param array|string $selected + * @param array|object|string $extra String, array, object that can be cast to array */ function form_dropdown($data = '', $options = [], $selected = [], $extra = ''): string { @@ -348,8 +350,8 @@ function form_dropdown($data = '', $options = [], $selected = [], $extra = ''): /** * Checkbox Field * - * @param array|string $data - * @param array|object|string $extra string, array, object that can be cast to array + * @param array|string $data + * @param array|object|string $extra String, array, object that can be cast to array */ function form_checkbox($data = '', string $value = '', bool $checked = false, $extra = ''): string { @@ -381,8 +383,8 @@ function form_checkbox($data = '', string $value = '', bool $checked = false, $e /** * Radio Button * - * @param array|string $data - * @param array|object|string $extra string, array, object that can be cast to array + * @param array|string $data + * @param array|object|string $extra String, array, object that can be cast to array */ function form_radio($data = '', string $value = '', bool $checked = false, $extra = ''): string { @@ -399,8 +401,8 @@ function form_radio($data = '', string $value = '', bool $checked = false, $extr /** * Submit Button * - * @param array|string $data - * @param array|object|string $extra string, array, object that can be cast to array + * @param array|string $data + * @param array|object|string $extra String, array, object that can be cast to array */ function form_submit($data = '', string $value = '', $extra = ''): string { @@ -412,8 +414,8 @@ function form_submit($data = '', string $value = '', $extra = ''): string /** * Reset Button * - * @param array|string $data - * @param array|object|string $extra string, array, object that can be cast to array + * @param array|string $data + * @param array|object|string $extra String, array, object that can be cast to array */ function form_reset($data = '', string $value = '', $extra = ''): string { @@ -425,8 +427,8 @@ function form_reset($data = '', string $value = '', $extra = ''): string /** * Form Button * - * @param array|string $data - * @param array|object|string $extra string, array, object that can be cast to array + * @param array|string $data + * @param array|object|string $extra String, array, object that can be cast to array */ function form_button($data = '', string $content = '', $extra = ''): string { @@ -450,9 +452,9 @@ function form_button($data = '', string $content = '', $extra = ''): string /** * Form Label Tag * - * @param string $labelText The text to appear onscreen - * @param string $id The id the label applies to - * @param array $attributes Additional attributes + * @param string $labelText The text to appear onscreen + * @param string $id The id the label applies to + * @param array $attributes Additional attributes */ function form_label(string $labelText = '', string $id = '', array $attributes = []): string { @@ -477,6 +479,8 @@ function form_label(string $labelText = '', string $id = '', array $attributes = * The element specifies a list of pre-defined options for an element. * Users will see a drop-down list of pre-defined options as they input data. * The list attribute of the element, must refer to the id attribute of the element. + * + * @param list $options */ function form_datalist(string $name, string $value, array $options): string { @@ -506,8 +510,8 @@ function form_datalist(string $name, string $value, array $options): string * Used to produce
text. To close fieldset * use form_fieldset_close() * - * @param string $legendText The legend text - * @param array $attributes Additional attributes + * @param string $legendText The legend text + * @param array $attributes Additional attributes */ function form_fieldset(string $legendText = '', array $attributes = []): string { @@ -770,8 +774,8 @@ function validation_show_error(string $field, string $template = 'single'): stri * * @internal * - * @param array|string $attributes List of attributes - * @param array $default Default values + * @param array|string $attributes List of attributes + * @param array $default Default values */ function parse_form_attributes($attributes, array $default): string { diff --git a/system/Helpers/html_helper.php b/system/Helpers/html_helper.php index 9dcf82536eeb..e206cbd0f5e5 100644 --- a/system/Helpers/html_helper.php +++ b/system/Helpers/html_helper.php @@ -24,8 +24,8 @@ * 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 + * @param array|string> $list List entries + * @param array|object|string $attributes HTML attributes string, array, object */ function ul(array $list, $attributes = ''): string { @@ -39,8 +39,8 @@ function ul(array $list, $attributes = ''): string * * 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 + * @param array|string> $list List entries + * @param array|object|string $attributes HTML attributes string, array, object */ function ol(array $list, $attributes = ''): string { @@ -54,8 +54,8 @@ function ol(array $list, $attributes = ''): string * * 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 + * @param array|string> $list List entries + * @param array|object|string $attributes HTML attributes string, array, object */ function _list(string $type = 'ul', $list = [], $attributes = '', int $depth = 0): string { @@ -93,9 +93,9 @@ 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 Should `Config\App::$indexPage` be added to the source path - * @param array|object|string $attributes Additional HTML attributes + * @param array|string $src Image source URI, or array of attributes and values + * @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 { @@ -193,8 +193,8 @@ 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 `Config\App::$indexPage` be added to the JS path + * @param array|string $src Script source or an array of attributes + * @param bool $indexPage Should `Config\App::$indexPage` be added to the JS path */ function script_tag($src = '', bool $indexPage = false): string { @@ -287,10 +287,11 @@ function link_tag( * Generates a video element to embed videos. The video element can * contain one or more video sources * - * @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 + * @param list|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 list $tracks Track elements + * @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,10 +335,11 @@ function video($src, string $unsupportedMessage = '', string $attributes = '', a * * Generates an audio element to embed sounds * - * @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 + * @param list|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 list $tracks Track elements + * @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 { @@ -377,7 +379,9 @@ function audio($src, string $unsupportedMessage = '', string $attributes = '', a /** * Generate media based tag * - * @param string $unsupportedMessage The message to display if the media tag is not supported by the browser. + * @param list $types Source elements + * @param string $unsupportedMessage The message to display if the media tag is not supported by the browser. + * @param list $tracks Track elements */ function _media(string $name, array $types = [], string $unsupportedMessage = '', string $attributes = '', array $tracks = []): string { @@ -466,10 +470,11 @@ function track(string $src, string $kind, string $srcLanguage, string $label): s * as either image or a resource plugin such as audio, video, * Java applets, ActiveX, PDF and Flash * - * @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 + * @param string $data A resource URL + * @param string $type Content-type of the resource + * @param string $attributes HTML attributes + * @param list $params Param elements + * @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 { diff --git a/system/Helpers/kint_helper.php b/system/Helpers/kint_helper.php index 8d8e73bfc92f..02d180328e92 100644 --- a/system/Helpers/kint_helper.php +++ b/system/Helpers/kint_helper.php @@ -18,7 +18,7 @@ /** * Prints a Kint debug report and exits. * - * @param array $vars + * @param mixed ...$vars * * @return never * @@ -38,7 +38,7 @@ function dd(...$vars): void /** * dd function * - * @param array $vars + * @param mixed ...$vars * * @return int */ @@ -54,7 +54,7 @@ function dd(...$vars) /** * d function * - * @param array $vars + * @param mixed ...$vars * * @return int */ diff --git a/system/Helpers/number_helper.php b/system/Helpers/number_helper.php index bf577ed293f6..120e33d795cd 100644 --- a/system/Helpers/number_helper.php +++ b/system/Helpers/number_helper.php @@ -134,6 +134,8 @@ function number_to_currency(float $num, string $currency, ?string $locale = null /** * A general purpose, locale-aware, number_format method. * Used by all of the functions of the number_helper. + * + * @param array $options */ function format_number(float $num, int $precision = 1, ?string $locale = null, array $options = []): string { diff --git a/system/Helpers/test_helper.php b/system/Helpers/test_helper.php index 645d407dfcbf..b455aa301e2f 100644 --- a/system/Helpers/test_helper.php +++ b/system/Helpers/test_helper.php @@ -22,11 +22,11 @@ /** * Creates a single item using Fabricator. * - * @param Model|object|string $model Instance or name of the model - * @param array|null $overrides Overriding data to pass to Fabricator::setOverrides() - * @param bool $persist + * @param Model|object|string $model Instance or name of the model + * @param array|null $overrides Overriding data to pass to Fabricator::setOverrides() + * @param bool $persist * - * @return array|object + * @return array|object */ function fake($model, ?array $overrides = null, $persist = true) { diff --git a/system/Helpers/text_helper.php b/system/Helpers/text_helper.php index b8298953bdd3..f8ea0c15447c 100644 --- a/system/Helpers/text_helper.php +++ b/system/Helpers/text_helper.php @@ -174,9 +174,9 @@ function entities_to_ascii(string $str, bool $all = true): string * matched words will be converted to #### or to the replacement * word you've submitted. * - * @param string $str the text string - * @param array $censored the array of censored words - * @param string $replacement the optional replacement value + * @param string $str The text string + * @param list $censored The array of censored words + * @param string $replacement The optional replacement value */ function word_censor(string $str, array $censored, string $replacement = ''): string { @@ -454,9 +454,9 @@ function ellipsize(string $str, int $maxLength, $position = 1, string $ellipsis * * Removes slashes contained in a string or in an array * - * @param array|string $str string or array + * @param array|string $str string or array * - * @return array|string string or array + * @return array|string string or array */ function strip_slashes($str) { diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 208ae722a2f2..0b3fa5f72c9c 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -25,11 +25,11 @@ /** * Returns a site URL as defined by the App config. * - * @param array|string $relativePath URI string or array of URI segments. - * @param string|null $scheme URI scheme. E.g., http, ftp. If empty - * string '' is set, a protocol-relative - * link is returned. - * @param App|null $config Alternate configuration to use. + * @param list|string $relativePath URI string or array of URI segments. + * @param string|null $scheme URI scheme. E.g., http, ftp. If empty + * string '' is set, a protocol-relative + * link is returned. + * @param App|null $config Alternate configuration to use. */ function site_url($relativePath = '', ?string $scheme = null, ?App $config = null): string { @@ -46,10 +46,10 @@ function site_url($relativePath = '', ?string $scheme = null, ?App $config = nul * Returns the base URL as defined by the App config. * Base URLs are trimmed site URLs without the index page. * - * @param array|string $relativePath URI string or array of URI segments. - * @param string|null $scheme URI scheme. E.g., http, ftp. If empty - * string '' is set, a protocol-relative - * link is returned. + * @param list|string $relativePath URI string or array of URI segments. + * @param string|null $scheme URI scheme. E.g., http, ftp. If empty + * string '' is set, a protocol-relative + * link is returned. */ function base_url($relativePath = '', ?string $scheme = null): string { @@ -146,10 +146,10 @@ function index_page(?App $altConfig = null): string * * Creates an anchor based on the local URL. * - * @param array|string $uri URI string or array of URI segments - * @param string $title The link title - * @param array|object|string $attributes Any attributes - * @param App|null $altConfig Alternate configuration to use + * @param list|string $uri URI string or array of URI segments + * @param string $title The link title + * @param array|object|string $attributes Any attributes + * @param App|null $altConfig Alternate configuration to use */ function anchor($uri = '', string $title = '', $attributes = '', ?App $altConfig = null): string { @@ -179,10 +179,10 @@ function anchor($uri = '', string $title = '', $attributes = '', ?App $altConfig * Creates an anchor based on the local URL. The link * opens a new window based on the attributes specified. * - * @param string $uri the URL - * @param string $title the link title - * @param array|false|object|string $attributes any attributes - * @param App|null $altConfig Alternate configuration to use + * @param string $uri the URL + * @param string $title the link title + * @param array|false|object|string $attributes any attributes + * @param App|null $altConfig Alternate configuration to use */ function anchor_popup($uri = '', string $title = '', $attributes = false, ?App $altConfig = null): string { @@ -231,9 +231,9 @@ function anchor_popup($uri = '', string $title = '', $attributes = false, ?App $ /** * Mailto Link * - * @param string $email the email address - * @param string $title the link title - * @param array|object|string $attributes any attributes + * @param string $email the email address + * @param string $title the link title + * @param array|object|string $attributes any attributes */ function mailto(string $email, string $title = '', $attributes = ''): string { @@ -251,9 +251,9 @@ function mailto(string $email, string $title = '', $attributes = ''): string * * Create a spam-protected mailto link written in Javascript * - * @param string $email the email address - * @param string $title the link title - * @param array|object|string $attributes any attributes + * @param string $email the email address + * @param string $title the link title + * @param array|object|string $attributes any attributes */ function safe_mailto(string $email, string $title = '', $attributes = ''): string { diff --git a/utils/phpstan-baseline/argument.type.neon b/utils/phpstan-baseline/argument.type.neon index 80cb40694994..282cf8b2aa8b 100644 --- a/utils/phpstan-baseline/argument.type.neon +++ b/utils/phpstan-baseline/argument.type.neon @@ -1,4 +1,4 @@ -# total 64 errors +# total 63 errors parameters: ignoreErrors: @@ -122,11 +122,6 @@ parameters: count: 1 path: ../../tests/system/HTTP/SiteURITest.php - - - message: '#^Parameter \#2 \$value of function form_hidden expects array\|string, null given\.$#' - count: 1 - path: ../../tests/system/Helpers/FormHelperTest.php - - message: '#^Parameter \#1 \$num of function number_to_size expects int\|string, float given\.$#' count: 1 diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 57a1c5ee9257..0c6937677154 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 1381 errors +# total 1285 errors includes: - argument.type.neon diff --git a/utils/phpstan-baseline/missingType.iterableValue.neon b/utils/phpstan-baseline/missingType.iterableValue.neon index 518e931c13d8..5c67c58552fd 100644 --- a/utils/phpstan-baseline/missingType.iterableValue.neon +++ b/utils/phpstan-baseline/missingType.iterableValue.neon @@ -1,4 +1,4 @@ -# total 1129 errors +# total 1034 errors parameters: ignoreErrors: @@ -2737,476 +2737,6 @@ parameters: count: 1 path: ../../system/HTTP/URI.php - - - message: '#^Method CodeIgniter\\Helpers\\Array\\ArrayHelper\:\:arrayAttachIndexedValue\(\) has parameter \$indexes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/Array/ArrayHelper.php - - - - message: '#^Method CodeIgniter\\Helpers\\Array\\ArrayHelper\:\:arrayAttachIndexedValue\(\) has parameter \$result with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/Array/ArrayHelper.php - - - - message: '#^Method CodeIgniter\\Helpers\\Array\\ArrayHelper\:\:arrayAttachIndexedValue\(\) has parameter \$row with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/Array/ArrayHelper.php - - - - message: '#^Method CodeIgniter\\Helpers\\Array\\ArrayHelper\:\:arrayAttachIndexedValue\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/Array/ArrayHelper.php - - - - message: '#^Method CodeIgniter\\Helpers\\Array\\ArrayHelper\:\:arraySearchDot\(\) has parameter \$array with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/Array/ArrayHelper.php - - - - message: '#^Method CodeIgniter\\Helpers\\Array\\ArrayHelper\:\:arraySearchDot\(\) has parameter \$indexes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/Array/ArrayHelper.php - - - - message: '#^Method CodeIgniter\\Helpers\\Array\\ArrayHelper\:\:dotKeyExists\(\) has parameter \$array with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/Array/ArrayHelper.php - - - - message: '#^Method CodeIgniter\\Helpers\\Array\\ArrayHelper\:\:dotSearch\(\) has parameter \$array with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/Array/ArrayHelper.php - - - - message: '#^Method CodeIgniter\\Helpers\\Array\\ArrayHelper\:\:groupBy\(\) has parameter \$array with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/Array/ArrayHelper.php - - - - message: '#^Method CodeIgniter\\Helpers\\Array\\ArrayHelper\:\:groupBy\(\) has parameter \$indexes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/Array/ArrayHelper.php - - - - message: '#^Method CodeIgniter\\Helpers\\Array\\ArrayHelper\:\:groupBy\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/Array/ArrayHelper.php - - - - message: '#^Method CodeIgniter\\Helpers\\Array\\ArrayHelper\:\:recursiveCount\(\) has parameter \$array with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/Array/ArrayHelper.php - - - - message: '#^Method CodeIgniter\\Helpers\\Array\\ArrayHelper\:\:recursiveDiff\(\) has parameter \$compareWith with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/Array/ArrayHelper.php - - - - message: '#^Method CodeIgniter\\Helpers\\Array\\ArrayHelper\:\:recursiveDiff\(\) has parameter \$original with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/Array/ArrayHelper.php - - - - message: '#^Method CodeIgniter\\Helpers\\Array\\ArrayHelper\:\:recursiveDiff\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/Array/ArrayHelper.php - - - - message: '#^Function array_deep_search\(\) has parameter \$array with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/array_helper.php - - - - message: '#^Function array_flatten_with_dots\(\) has parameter \$array with no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../system/Helpers/array_helper.php - - - - message: '#^Function array_flatten_with_dots\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/array_helper.php - - - - message: '#^Function array_group_by\(\) has parameter \$array with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/array_helper.php - - - - message: '#^Function array_group_by\(\) has parameter \$indexes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/array_helper.php - - - - message: '#^Function array_group_by\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/array_helper.php - - - - message: '#^Function array_sort_by_multiple_keys\(\) has parameter \$array with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/array_helper.php - - - - message: '#^Function array_sort_by_multiple_keys\(\) has parameter \$sortColumns with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/array_helper.php - - - - message: '#^Function dot_array_search\(\) has parameter \$array with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/array_helper.php - - - - message: '#^Function directory_map\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/filesystem_helper.php - - - - message: '#^Function get_filenames\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/filesystem_helper.php - - - - message: '#^Function form_button\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_button\(\) has parameter \$extra with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_checkbox\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_checkbox\(\) has parameter \$extra with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_datalist\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_dropdown\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_dropdown\(\) has parameter \$extra with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_dropdown\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_dropdown\(\) has parameter \$selected with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_fieldset\(\) has parameter \$attributes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_hidden\(\) has parameter \$name with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_hidden\(\) has parameter \$value with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_input\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_input\(\) has parameter \$extra with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_label\(\) has parameter \$attributes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_multiselect\(\) has parameter \$extra with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_multiselect\(\) has parameter \$name with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_multiselect\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_multiselect\(\) has parameter \$selected with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_open\(\) has parameter \$attributes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_open\(\) has parameter \$hidden with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_open_multipart\(\) has parameter \$attributes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_open_multipart\(\) has parameter \$hidden with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_password\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_password\(\) has parameter \$extra with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_radio\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_radio\(\) has parameter \$extra with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_reset\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_reset\(\) has parameter \$extra with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_submit\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_submit\(\) has parameter \$extra with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_textarea\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_textarea\(\) has parameter \$extra with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_upload\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function form_upload\(\) has parameter \$extra with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function parse_form_attributes\(\) has parameter \$attributes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function parse_form_attributes\(\) has parameter \$default with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Function _list\(\) has parameter \$attributes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function _list\(\) has parameter \$list with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function _media\(\) has parameter \$tracks with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function _media\(\) has parameter \$types with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function audio\(\) has parameter \$src with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function audio\(\) has parameter \$tracks with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function img\(\) has parameter \$attributes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function img\(\) has parameter \$src with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function object\(\) has parameter \$params with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function ol\(\) has parameter \$attributes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function ol\(\) has parameter \$list with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function script_tag\(\) has parameter \$src with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function ul\(\) has parameter \$attributes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function ul\(\) has parameter \$list with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function video\(\) has parameter \$src with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function video\(\) has parameter \$tracks with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/html_helper.php - - - - message: '#^Function d\(\) has parameter \$vars with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/kint_helper.php - - - - message: '#^Function dd\(\) has parameter \$vars with no value type specified in iterable type array\.$#' - count: 2 - path: ../../system/Helpers/kint_helper.php - - - - message: '#^Function format_number\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/number_helper.php - - - - message: '#^Function fake\(\) has parameter \$overrides with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/test_helper.php - - - - message: '#^Function fake\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/test_helper.php - - - - message: '#^Function strip_slashes\(\) has parameter \$str with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/text_helper.php - - - - message: '#^Function strip_slashes\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/text_helper.php - - - - message: '#^Function word_censor\(\) has parameter \$censored with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/text_helper.php - - - - message: '#^Function anchor\(\) has parameter \$attributes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/url_helper.php - - - - message: '#^Function anchor\(\) has parameter \$uri with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/url_helper.php - - - - message: '#^Function anchor_popup\(\) has parameter \$attributes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/url_helper.php - - - - message: '#^Function base_url\(\) has parameter \$relativePath with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/url_helper.php - - - - message: '#^Function mailto\(\) has parameter \$attributes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/url_helper.php - - - - message: '#^Function safe_mailto\(\) has parameter \$attributes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/url_helper.php - - - - message: '#^Function site_url\(\) has parameter \$relativePath with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Helpers/url_helper.php - - message: '#^Method CodeIgniter\\HotReloader\\DirectoryHasher\:\:hashApp\(\) return type has no value type specified in iterable type array\.$#' count: 1 From 2ac2615749abeb9639ac1d3e662d13a99c5bb196 Mon Sep 17 00:00:00 2001 From: John Paul E Balandan Date: Mon, 17 Aug 2026 03:55:02 +0800 Subject: [PATCH 2/3] refactor: fix phpstan errors in `Router` (#10460) --- system/Router/Attributes/Filter.php | 6 + system/Router/Attributes/Restrict.php | 5 + system/Router/AutoRouter.php | 17 +- system/Router/AutoRouterImproved.php | 19 +- system/Router/AutoRouterInterface.php | 6 +- system/Router/RouteCollection.php | 237 +++--------- system/Router/RouteCollectionInterface.php | 21 +- system/Router/Router.php | 20 +- system/Router/RouterInterface.php | 2 +- tests/system/Router/RouteCollectionTest.php | 4 +- utils/phpstan-baseline/argument.type.neon | 8 +- utils/phpstan-baseline/loader.neon | 2 +- .../missingType.iterableValue.neon | 342 +----------------- 13 files changed, 115 insertions(+), 574 deletions(-) diff --git a/system/Router/Attributes/Filter.php b/system/Router/Attributes/Filter.php index 130d2946f0dc..edba9452619e 100644 --- a/system/Router/Attributes/Filter.php +++ b/system/Router/Attributes/Filter.php @@ -38,6 +38,9 @@ #[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] class Filter implements RouteAttributeInterface { + /** + * @param array $having + */ public function __construct( public string $by, public array $having = [], @@ -56,6 +59,9 @@ public function after(RequestInterface $request, ResponseInterface $response): ? return null; } + /** + * @return list + */ public function getFilters(): array { if ($this->having === []) { diff --git a/system/Router/Attributes/Restrict.php b/system/Router/Attributes/Restrict.php index 79344a7c6982..3bf250ab7966 100644 --- a/system/Router/Attributes/Restrict.php +++ b/system/Router/Attributes/Restrict.php @@ -42,6 +42,11 @@ #[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)] class Restrict implements RouteAttributeInterface { + /** + * @param list|string|null $environment + * @param list|string|null $hostname + * @param list|string|null $subdomain + */ public function __construct( public array|string|null $environment = null, public array|string|null $hostname = null, diff --git a/system/Router/AutoRouter.php b/system/Router/AutoRouter.php index 1033478c9e30..e887469b9037 100644 --- a/system/Router/AutoRouter.php +++ b/system/Router/AutoRouter.php @@ -55,14 +55,6 @@ public function __construct( ) { } - /** - * Attempts to match a URI path against Controllers and directories - * found in APPPATH/Controllers, to find a matching route. - * - * @param string $httpVerb HTTP verb like `GET`,`POST` - * - * @return array [directory_name, controller_name, controller_method, params] - */ public function getRoute(string $uri, string $httpVerb): array { $segments = explode('/', $uri); @@ -95,7 +87,7 @@ public function getRoute(string $uri, string $httpVerb): array throw PageNotFoundException::forPageNotFound(); } - /** @var array $params An array of params to the controller method. */ + /** @var list $params An array of params to the controller method. */ $params = []; if ($segments !== []) { @@ -177,11 +169,12 @@ public function setTranslateURIDashes(bool $val = false): self } /** - * Scans the controller directory, attempting to locate a controller matching the supplied uri $segments + * Scans the controller directory, attempting to locate a controller matching the supplied uri `$segments`. + * Returns an array of remaining uri segments that don't map onto a directory. * - * @param array $segments URI segments + * @param list $segments URI segments * - * @return array returns an array of remaining uri segments that don't map onto a directory + * @return list */ private function scanControllers(array $segments): array { diff --git a/system/Router/AutoRouterImproved.php b/system/Router/AutoRouterImproved.php index a00c04d265d7..c7dbf04efec5 100644 --- a/system/Router/AutoRouterImproved.php +++ b/system/Router/AutoRouterImproved.php @@ -63,12 +63,11 @@ final class AutoRouterImproved implements AutoRouterInterface * Map of URI segments and namespaces. * * The key is the first URI segment. The value is the controller namespace. - * E.g., - * [ - * 'blog' => 'Acme\Blog\Controllers', - * ] + * ``` + * ['blog' => 'Acme\Blog\Controllers'] + * ``` * - * @var array [ uri_segment => namespace ] + * @var array */ private array $moduleRoutes; @@ -133,6 +132,9 @@ public function __construct( $this->controller = $this->defaultController; } + /** + * @return list + */ private function createSegments(string $uri): array { $segments = explode('/', $uri); @@ -250,13 +252,6 @@ private function searchLastDefaultController(): bool return false; } - /** - * Finds controller, method and params from the URI. - * - * @param string $httpVerb HTTP verb like `GET`,`POST` - * - * @return array [directory_name, controller_name, controller_method, params] - */ public function getRoute(string $uri, string $httpVerb): array { $this->uri = $uri; diff --git a/system/Router/AutoRouterInterface.php b/system/Router/AutoRouterInterface.php index 7edec821dbfd..58f22393881e 100644 --- a/system/Router/AutoRouterInterface.php +++ b/system/Router/AutoRouterInterface.php @@ -19,9 +19,11 @@ interface AutoRouterInterface { /** - * Returns controller, method and params from the URI. + * Returns the directory name, controller name, controller method, and any parameters for the given URI and HTTP verb. * - * @return array [directory_name, controller_name, controller_method, params] + * @param string $httpVerb HTTP verb like `GET`,`POST` + * + * @return array{string|null, string, string, list} */ public function getRoute(string $uri, string $httpVerb): array; } diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 6dfb42286972..b5bd4ee76597 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -96,6 +96,8 @@ class RouteCollection implements RouteCollectionInterface /** * An array of files that would contain route definitions. + * + * @var list */ protected array $routeFiles = []; @@ -116,9 +118,7 @@ class RouteCollection implements RouteCollectionInterface /** * An array of all routes and their mappings. - * - * @var array - * + *``` * [ * verb => [ * routeKey(regex) => [ @@ -137,6 +137,9 @@ class RouteCollection implements RouteCollectionInterface * ], * ], * ] + * ``` + * + * @var array>> */ protected $routes = [ '*' => [], @@ -154,14 +157,11 @@ class RouteCollection implements RouteCollectionInterface /** * Array of routes names + * ``` + * [verb => [routeName => routeKey(regex)]] + * ``` * - * @var array - * - * [ - * verb => [ - * routeName => routeKey(regex) - * ], - * ] + * @var array> */ protected $routesNames = [ '*' => [], @@ -179,9 +179,7 @@ class RouteCollection implements RouteCollectionInterface /** * Array of routes options - * - * @var array - * + * ``` * [ * verb => [ * routeKey(regex) => [ @@ -189,6 +187,9 @@ class RouteCollection implements RouteCollectionInterface * ] * ], * ] + * ``` + * + * @var array>> */ protected $routesOptions = []; @@ -225,7 +226,7 @@ class RouteCollection implements RouteCollectionInterface * Stores copy of current options being * applied during creation. * - * @var array|null + * @var array|null */ protected $currentOptions; @@ -376,16 +377,6 @@ protected function discoverRoutes() $this->didDiscover = true; } - /** - * Registers a new constraint with the system. Constraints are used - * by the routes as placeholders for regular expressions to make defining - * the routes more human-friendly. - * - * You can pass an associative array as $placeholder, and have - * multiple placeholders added at once. - * - * @param array|string $placeholder - */ public function addPlaceholder($placeholder, ?string $pattern = null): RouteCollectionInterface { if (! is_array($placeholder)) { @@ -409,10 +400,6 @@ public function getPlaceholders(): array return $this->placeholders; } - /** - * Sets the default namespace to use for Controllers when no other - * namespace has been specified. - */ public function setDefaultNamespace(string $value): RouteCollectionInterface { $this->defaultNamespace = esc(strip_tags($value)); @@ -421,10 +408,6 @@ public function setDefaultNamespace(string $value): RouteCollectionInterface return $this; } - /** - * Sets the default controller to use when no other controller has been - * specified. - */ public function setDefaultController(string $value): RouteCollectionInterface { $this->defaultController = esc(strip_tags($value)); @@ -432,10 +415,6 @@ public function setDefaultController(string $value): RouteCollectionInterface return $this; } - /** - * Sets the default method to call on the controller when no other - * method has been set in the route. - */ public function setDefaultMethod(string $value): RouteCollectionInterface { $this->defaultMethod = esc(strip_tags($value)); @@ -443,13 +422,6 @@ public function setDefaultMethod(string $value): RouteCollectionInterface return $this; } - /** - * Tells the system whether to convert dashes in URI strings into - * underscores. In some search engines, including Google, dashes - * create more meaning and make it easier for the search engine to - * find words and meaning in the URI for better SEO. But it - * doesn't work well with PHP method names.... - */ public function setTranslateURIDashes(bool $value): RouteCollectionInterface { $this->translateURIDashes = $value; @@ -457,14 +429,6 @@ public function setTranslateURIDashes(bool $value): RouteCollectionInterface return $this; } - /** - * If TRUE, the system will attempt to match the URI against - * Controllers by matching each segment against folders/files - * in APPPATH/Controllers, when a match wasn't found against - * defined routes. - * - * If FALSE, will stop searching and do NO automatic routing. - */ public function setAutoRoute(bool $value): RouteCollectionInterface { $this->autoRoute = $value; @@ -472,15 +436,6 @@ public function setAutoRoute(bool $value): RouteCollectionInterface return $this; } - /** - * Sets the class/method that should be called if routing doesn't - * find a match. It can be either a closure or the controller/method - * name exactly like a route is defined: Users::index - * - * This setting is passed to the Router class and handled there. - * - * @param (callable(string): (ResponseInterface|string|void))|string|null $callable - */ public function set404Override($callable = null): RouteCollectionInterface { $this->override404 = $callable; @@ -488,12 +443,6 @@ public function set404Override($callable = null): RouteCollectionInterface return $this; } - /** - * Returns the 404 Override setting, which can be null, a closure - * or the controller/string. - * - * @return (Closure(string): (ResponseInterface|string|void))|string|null - */ public function get404Override() { return $this->override404; @@ -512,52 +461,31 @@ public function setDefaultConstraint(string $placeholder): RouteCollectionInterf return $this; } - /** - * Returns the name of the default controller. With Namespace. - */ public function getDefaultController(): string { return $this->defaultController; } - /** - * Returns the name of the default method to use within the controller. - */ public function getDefaultMethod(): string { return $this->defaultMethod; } - /** - * Returns the default namespace as set in the Routes config file. - */ public function getDefaultNamespace(): string { return $this->defaultNamespace; } - /** - * Returns the current value of the translateURIDashes setting. - */ public function shouldTranslateURIDashes(): bool { return $this->translateURIDashes; } - /** - * Returns the flag that tells whether to autoRoute URI against Controllers. - */ public function shouldAutoRoute(): bool { return $this->autoRoute; } - /** - * Returns the raw array of available routes. - * - * @param non-empty-string|null $verb HTTP verb like `GET`,`POST` or `*` or `CLI`. - * @param bool $includeWildcard Whether to include '*' routes. - */ public function getRoutes(?string $verb = null, bool $includeWildcard = true): array { if ((string) $verb === '') { @@ -598,13 +526,6 @@ public function getRoutes(?string $verb = null, bool $includeWildcard = true): a return $routes; } - /** - * Returns one or all routes options - * - * @param string|null $verb HTTP verb like `GET`,`POST` or `*` or `CLI`. - * - * @return array [key => value] - */ public function getRoutesOptions(?string $from = null, ?string $verb = null): array { $options = $this->loadRoutesOptions($verb); @@ -612,22 +533,11 @@ public function getRoutesOptions(?string $from = null, ?string $verb = null): ar return ((string) $from !== '') ? $options[$from] ?? [] : $options; } - /** - * Returns the current HTTP Verb being used. - */ public function getHTTPVerb(): string { return $this->HTTPVerb; } - /** - * Sets the current HTTP verb. - * Used primarily for testing. - * - * @param string $verb HTTP verb - * - * @return $this - */ public function setHTTPVerb(string $verb) { if ($verb !== '*' && $verb === strtolower($verb)) { @@ -651,6 +561,9 @@ public function setHTTPVerb(string $verb) * A shortcut method to add a number of routes at a single time. * It does not allow any options to be set on the route, or to * define the method used. + * + * @param array $routes + * @param array|null $options */ public function map(array $routes = [], ?array $options = null): RouteCollectionInterface { @@ -661,14 +574,6 @@ public function map(array $routes = [], ?array $options = null): RouteCollection return $this; } - /** - * Adds a single route to the collection. - * - * Example: - * $routes->add('news', 'Posts::index'); - * - * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to - */ public function add(string $from, $to, ?array $options = null): RouteCollectionInterface { $this->create('*', $from, $to, $options); @@ -708,11 +613,6 @@ public function addRedirect(string $from, string $to, int $status = 302) return $this; } - /** - * Determines if the route is a redirecting route. - * - * @param string $routeKey routeKey or route name - */ public function isRedirect(string $routeKey): bool { if (isset($this->routes['*'][$routeKey]['redirect'])) { @@ -730,11 +630,6 @@ public function isRedirect(string $routeKey): bool return false; } - /** - * Grabs the HTTP status code from a redirecting Route. - * - * @param string $routeKey routeKey or route name - */ public function getRedirectCode(string $routeKey): int { if (isset($this->routes['*'][$routeKey]['redirect'])) { @@ -762,8 +657,8 @@ public function getRedirectCode(string $routeKey): int * $route->resource('users'); * }); * - * @param string $name The name to group/prefix the routes with. - * @param array|(callable(self): void) ...$params + * @param string $name The name to group/prefix the routes with. + * @param array|(callable(self): void) ...$params * * @return void */ @@ -844,8 +739,8 @@ public function group(string $name, ...$params) * POST /photos/{id}/delete delete * POST /photos/{id} update * - * @param string $name The name of the resource/controller to route to. - * @param array|null $options A list of possible ways to customize the routing. + * @param string $name The name of the resource/controller to route to. + * @param array|null $options A list of possible ways to customize the routing. */ public function resource(string $name, ?array $options = null): RouteCollectionInterface { @@ -938,8 +833,8 @@ public function resource(string $name, ?array $options = null): RouteCollectionI * GET /photos/remove/{id} remove show a form to confirm deletion of a specific photo object * POST /photos/delete/{id} delete deleting the specified photo object * - * @param string $name The name of the controller to route to. - * @param array|null $options A list of possible ways to customize the routing. + * @param string $name The name of the controller to route to. + * @param array|null $options A list of possible ways to customize the routing. */ public function presenter(string $name, ?array $options = null): RouteCollectionInterface { @@ -1013,7 +908,9 @@ public function presenter(string $name, ?array $options = null): RouteCollection * Example: * $route->match( ['GET', 'POST'], 'users/(:num)', 'users/$1); * - * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param list $verbs + * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|null $options */ public function match(array $verbs = [], string $from = '', $to = '', ?array $options = null): RouteCollectionInterface { @@ -1045,7 +942,8 @@ public function match(array $verbs = [], string $from = '', $to = '', ?array $op /** * Specifies a route that is only available to GET requests. * - * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|null $options */ public function get(string $from, $to, ?array $options = null): RouteCollectionInterface { @@ -1057,7 +955,8 @@ public function get(string $from, $to, ?array $options = null): RouteCollectionI /** * Specifies a route that is only available to POST requests. * - * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|null $options */ public function post(string $from, $to, ?array $options = null): RouteCollectionInterface { @@ -1069,7 +968,8 @@ public function post(string $from, $to, ?array $options = null): RouteCollection /** * Specifies a route that is only available to PUT requests. * - * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|null $options */ public function put(string $from, $to, ?array $options = null): RouteCollectionInterface { @@ -1081,7 +981,8 @@ public function put(string $from, $to, ?array $options = null): RouteCollectionI /** * Specifies a route that is only available to DELETE requests. * - * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|null $options */ public function delete(string $from, $to, ?array $options = null): RouteCollectionInterface { @@ -1093,7 +994,8 @@ public function delete(string $from, $to, ?array $options = null): RouteCollecti /** * Specifies a route that is only available to HEAD requests. * - * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|null $options */ public function head(string $from, $to, ?array $options = null): RouteCollectionInterface { @@ -1105,7 +1007,8 @@ public function head(string $from, $to, ?array $options = null): RouteCollection /** * Specifies a route that is only available to PATCH requests. * - * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|null $options */ public function patch(string $from, $to, ?array $options = null): RouteCollectionInterface { @@ -1117,7 +1020,8 @@ public function patch(string $from, $to, ?array $options = null): RouteCollectio /** * Specifies a route that is only available to OPTIONS requests. * - * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|null $options */ public function options(string $from, $to, ?array $options = null): RouteCollectionInterface { @@ -1129,7 +1033,8 @@ public function options(string $from, $to, ?array $options = null): RouteCollect /** * Specifies a route that is only available to command-line requests. * - * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|null $options */ public function cli(string $from, $to, ?array $options = null): RouteCollectionInterface { @@ -1141,6 +1046,8 @@ public function cli(string $from, $to, ?array $options = null): RouteCollectionI /** * Specifies a route that will only display a view. * Only works for GET requests. + * + * @param array|null $options */ public function view(string $from, string $view, ?array $options = null): RouteCollectionInterface { @@ -1170,25 +1077,6 @@ public function environment(string $env, Closure $callback): RouteCollectionInte return $this; } - /** - * Attempts to look up a route based on its destination. - * - * If a route exists: - * - * 'path/(:any)/(:any)' => 'Controller::method/$1/$2' - * - * This method allows you to know the Controller and method - * and get the route that leads to it. - * - * // Equals 'path/$param1/$param2' - * reverseRoute('Controller::method', $param1, $param2); - * - * @param string $search Route name or Controller::method - * @param int|string ...$params One or more parameters to be passed to the route. - * The last parameter allows you to set the locale. - * - * @return false|string The route (URI path relative to baseURL) or false if not found. - */ public function reverseRoute(string $search, ...$params) { if ($search === '') { @@ -1262,11 +1150,6 @@ protected function localizeRoute(string $route): string return strtr($route, ['{locale}' => service('request')->getLocale()]); } - /** - * Checks a route (using the "from") to see if it's filtered or not. - * - * @param string|null $verb HTTP verb like `GET`,`POST` or `*` or `CLI`. - */ public function isFiltered(string $search, ?string $verb = null): bool { $options = $this->loadRoutesOptions($verb); @@ -1274,21 +1157,6 @@ public function isFiltered(string $search, ?string $verb = null): bool return isset($options[$search]['filter']); } - /** - * Returns the filters that should be applied for a single route, along - * with any parameters it might have. Parameters are found by splitting - * the parameter name on a colon to separate the filter name from the parameter list, - * and the splitting the result on commas. So: - * - * 'role:admin,manager' - * - * has a filter of "role", with parameters of ['admin', 'manager']. - * - * @param string $search routeKey - * @param string|null $verb HTTP verb like `GET`,`POST` or `*` or `CLI`. - * - * @return list filter_name or filter_name:arguments like 'role:admin,manager' - */ public function getFiltersForRoute(string $search, ?string $verb = null): array { $options = $this->loadRoutesOptions($verb); @@ -1307,6 +1175,8 @@ public function getFiltersForRoute(string $search, ?string $verb = null): array /** * Given a * + * @param list|null $params + * * @throws RouterException * * @deprecated Unused. Now uses buildReverseRoute(). @@ -1345,8 +1215,8 @@ protected function fillRouteParams(string $from, ?array $params = null): string /** * Builds reverse route * - * @param array $params One or more parameters to be passed to the route. - * The last parameter allows you to set the locale. + * @param list $params One or more parameters to be passed to the route. + * The last parameter allows you to set the locale. */ protected function buildReverseRoute(string $from, array $params): string { @@ -1435,7 +1305,8 @@ private function replaceLocale(string $route, ?string $locale = null): string * the request method(s) that this route will work for. They can be separated * by a pipe character "|" if there is more than one. * - * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to + * @param array|null $options * * @return void */ @@ -1582,6 +1453,9 @@ private function checkHostname($hostname): bool return strtolower($this->httpHost) === strtolower($hostname); } + /** + * @param array $to + */ private function processArrayCallableSyntax(string $from, array $to): string { // [classname, method] @@ -1797,9 +1671,6 @@ public function useSupportedLocalesOnly(bool $useOnly): self return $this; } - /** - * Get the flag that limit or not the routes with {locale} placeholder to App::$supportedLocales - */ public function shouldUseSupportedLocalesOnly(): bool { return $this->useSupportedLocalesOnly; diff --git a/system/Router/RouteCollectionInterface.php b/system/Router/RouteCollectionInterface.php index 10587d81ee4c..e3c83955e28f 100644 --- a/system/Router/RouteCollectionInterface.php +++ b/system/Router/RouteCollectionInterface.php @@ -28,9 +28,12 @@ interface RouteCollectionInterface /** * Adds a single route to the collection. * - * @param string $from The route path (with placeholders or regex) - * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to The route handler - * @param array|null $options The route options + * Example: + * $routes->add('news', 'Posts::index'); + * + * @param string $from The route path (with placeholders or regex) + * @param array|(Closure(mixed...): (ResponseInterface|string|void))|string $to The route handler + * @param array|null $options The route options * * @return RouteCollectionInterface */ @@ -44,8 +47,8 @@ public function add(string $from, $to, ?array $options = null); * You can pass an associative array as $placeholder, and have * multiple placeholders added at once. * - * @param array|string $placeholder - * @param string|null $pattern The regex pattern + * @param array|string $placeholder + * @param string|null $pattern The regex pattern * * @return RouteCollectionInterface */ @@ -177,6 +180,8 @@ public function shouldAutoRoute(); * * @param non-empty-string|null $verb HTTP verb like `GET`,`POST` or `*` or `CLI`. * @param bool $includeWildcard Whether to include '*' routes. + * + * @return array|(Closure(mixed...): (ResponseInterface|string|void))|string> */ public function getRoutes(?string $verb = null, bool $includeWildcard = true): array; @@ -192,6 +197,7 @@ public function getRoutesOptions(?string $from = null, ?string $verb = null): ar /** * Sets the current HTTP verb. + * Used primarily for testing. * * @param string $verb HTTP verb * @@ -219,8 +225,9 @@ public function getHTTPVerb(); * // Equals 'path/$param1/$param2' * reverseRoute('Controller::method', $param1, $param2); * - * @param string $search Named route or Controller::method - * @param int|string ...$params + * @param string $search Route name or Controller::method + * @param int|string ...$params One or more parameters to be passed to the route. + * The last parameter allows you to set the locale. * * @return false|string The route (URI path relative to baseURL) or false if not found. */ diff --git a/system/Router/Router.php b/system/Router/Router.php index c886bf45f396..6e5a4630832b 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -86,7 +86,7 @@ class Router implements RouterInterface * An array of binds that were collected * so they can be sent to closure routes. * - * @var array + * @var list */ protected $params = []; @@ -108,14 +108,14 @@ class Router implements RouterInterface /** * The route that was matched for this request. * - * @var array|null + * @var array{string, (callable(mixed...): (ResponseInterface|string|void))|string}|null */ protected $matchedRoute; /** * The options set for the matched route. * - * @var array|null + * @var array|null */ protected $matchedRouteOptions; @@ -346,7 +346,7 @@ public function directory(): string * Returns the routing information that was matched for this * request, if a route was defined. * - * @return array|null + * @return array{string, (callable(mixed...): (ResponseInterface|string|void))|string}|null */ public function getMatchedRoute() { @@ -356,7 +356,7 @@ public function getMatchedRoute() /** * Returns all options set for the matched route * - * @return array|null + * @return array|null */ public function getMatchedRouteOptions() { @@ -562,6 +562,8 @@ protected function checkRoutes(string $uri): bool /** * Replace string `$n` with `$matches[n]` value. + * + * @param list $matches */ private function replaceBackReferences(string $input, array $matches): string { @@ -595,9 +597,9 @@ public function autoRoute(string $uri) /** * Scans the controller directory, attempting to locate a controller matching the supplied uri $segments * - * @param array $segments URI segments + * @param list $segments URI segments * - * @return array returns an array of remaining uri segments that don't map onto a directory + * @return list Returns an array of remaining uri segments that don't map onto a directory * * @deprecated this function name does not properly describe its behavior so it has been deprecated * @@ -611,9 +613,9 @@ protected function validateRequest(array $segments): array /** * Scans the controller directory, attempting to locate a controller matching the supplied uri $segments * - * @param array $segments URI segments + * @param list $segments URI segments * - * @return array returns an array of remaining uri segments that don't map onto a directory + * @return list Returns an array of remaining uri segments that don't map onto a directory * * @deprecated Not used. Moved to AutoRouter class. */ diff --git a/system/Router/RouterInterface.php b/system/Router/RouterInterface.php index c50de86d43df..05dd2caf279e 100644 --- a/system/Router/RouterInterface.php +++ b/system/Router/RouterInterface.php @@ -55,7 +55,7 @@ public function methodName(); * during the parsing process as an array, ready to send to * instance->method(...$params). * - * @return array + * @return list */ public function params(); diff --git a/tests/system/Router/RouteCollectionTest.php b/tests/system/Router/RouteCollectionTest.php index 6346697d206a..bf35a3f6fe63 100644 --- a/tests/system/Router/RouteCollectionTest.php +++ b/tests/system/Router/RouteCollectionTest.php @@ -196,13 +196,13 @@ public function testMatchIgnoresInvalidHTTPMethods(): void $this->assertSame([], $routes); } - public function testAddWorksWithArrayOFHTTPMethods(): void + public function testAddWorksWithArrayOfHTTPMethods(): void { service('request')->setMethod(Method::POST); $routes = $this->getCollector(); - $routes->add('home', 'controller', ['get', 'post']); + $routes->add('home', 'controller'); $expects = [ 'home' => '\controller', diff --git a/utils/phpstan-baseline/argument.type.neon b/utils/phpstan-baseline/argument.type.neon index 282cf8b2aa8b..addcb1d223e7 100644 --- a/utils/phpstan-baseline/argument.type.neon +++ b/utils/phpstan-baseline/argument.type.neon @@ -23,22 +23,22 @@ parameters: path: ../../system/Database/SQLite3/Builder.php - - message: '#^Parameter \#2 \$to of method CodeIgniter\\Router\\RouteCollection\:\:add\(\) expects array\|\(Closure\(mixed \.\.\.\)\: \(CodeIgniter\\HTTP\\ResponseInterface\|string\|void\)\)\|string, Closure\(mixed\)\: CodeIgniter\\HTTP\\ResponseInterface given\.$#' + message: '#^Parameter \#2 \$to of method CodeIgniter\\Router\\RouteCollection\:\:add\(\) expects array\\|\(Closure\(mixed \.\.\.\)\: \(CodeIgniter\\HTTP\\ResponseInterface\|string\|void\)\)\|string, Closure\(mixed\)\: CodeIgniter\\HTTP\\ResponseInterface given\.$#' count: 1 path: ../../tests/system/CodeIgniterTest.php - - message: '#^Parameter \#2 \$to of method CodeIgniter\\Router\\RouteCollection\:\:add\(\) expects array\|\(Closure\(mixed \.\.\.\)\: \(CodeIgniter\\HTTP\\ResponseInterface\|string\|void\)\)\|string, Closure\(mixed\)\: \(CodeIgniter\\HTTP\\DownloadResponse\|null\) given\.$#' + message: '#^Parameter \#2 \$to of method CodeIgniter\\Router\\RouteCollection\:\:add\(\) expects array\\|\(Closure\(mixed \.\.\.\)\: \(CodeIgniter\\HTTP\\ResponseInterface\|string\|void\)\)\|string, Closure\(mixed\)\: \(CodeIgniter\\HTTP\\DownloadResponse\|null\) given\.$#' count: 1 path: ../../tests/system/CodeIgniterTest.php - - message: '#^Parameter \#2 \$to of method CodeIgniter\\Router\\RouteCollection\:\:add\(\) expects array\|\(Closure\(mixed \.\.\.\)\: \(CodeIgniter\\HTTP\\ResponseInterface\|string\|void\)\)\|string, Closure\(mixed\)\: non\-falsy\-string given\.$#' + message: '#^Parameter \#2 \$to of method CodeIgniter\\Router\\RouteCollection\:\:add\(\) expects array\\|\(Closure\(mixed \.\.\.\)\: \(CodeIgniter\\HTTP\\ResponseInterface\|string\|void\)\)\|string, Closure\(mixed\)\: non\-falsy\-string given\.$#' count: 1 path: ../../tests/system/CodeIgniterTest.php - - message: '#^Parameter \#2 \$to of method CodeIgniter\\Router\\RouteCollection\:\:add\(\) expects array\|\(Closure\(mixed \.\.\.\)\: \(CodeIgniter\\HTTP\\ResponseInterface\|string\|void\)\)\|string, Closure\(mixed\)\: void given\.$#' + message: '#^Parameter \#2 \$to of method CodeIgniter\\Router\\RouteCollection\:\:add\(\) expects array\\|\(Closure\(mixed \.\.\.\)\: \(CodeIgniter\\HTTP\\ResponseInterface\|string\|void\)\)\|string, Closure\(mixed\)\: void given\.$#' count: 1 path: ../../tests/system/CodeIgniterTest.php diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 0c6937677154..a382fda9a5d4 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 1285 errors +# total 1217 errors includes: - argument.type.neon diff --git a/utils/phpstan-baseline/missingType.iterableValue.neon b/utils/phpstan-baseline/missingType.iterableValue.neon index 5c67c58552fd..f67d1b49920c 100644 --- a/utils/phpstan-baseline/missingType.iterableValue.neon +++ b/utils/phpstan-baseline/missingType.iterableValue.neon @@ -1,4 +1,4 @@ -# total 1034 errors +# total 966 errors parameters: ignoreErrors: @@ -2817,346 +2817,6 @@ parameters: count: 1 path: ../../system/Publisher/Publisher.php - - - message: '#^Method CodeIgniter\\Router\\Attributes\\Filter\:\:__construct\(\) has parameter \$having with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Attributes/Filter.php - - - - message: '#^Method CodeIgniter\\Router\\Attributes\\Filter\:\:getFilters\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Attributes/Filter.php - - - - message: '#^Method CodeIgniter\\Router\\Attributes\\Restrict\:\:__construct\(\) has parameter \$environment with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Attributes/Restrict.php - - - - message: '#^Method CodeIgniter\\Router\\Attributes\\Restrict\:\:__construct\(\) has parameter \$hostname with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Attributes/Restrict.php - - - - message: '#^Method CodeIgniter\\Router\\Attributes\\Restrict\:\:__construct\(\) has parameter \$subdomain with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Attributes/Restrict.php - - - - message: '#^Method CodeIgniter\\Router\\AutoRouter\:\:getRoute\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/AutoRouter.php - - - - message: '#^Method CodeIgniter\\Router\\AutoRouter\:\:scanControllers\(\) has parameter \$segments with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/AutoRouter.php - - - - message: '#^Method CodeIgniter\\Router\\AutoRouter\:\:scanControllers\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/AutoRouter.php - - - - message: '#^PHPDoc tag @var for variable \$params has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/AutoRouter.php - - - - message: '#^Method CodeIgniter\\Router\\AutoRouterImproved\:\:createSegments\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/AutoRouterImproved.php - - - - message: '#^Method CodeIgniter\\Router\\AutoRouterImproved\:\:getRoute\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/AutoRouterImproved.php - - - - message: '#^Property CodeIgniter\\Router\\AutoRouterImproved\:\:\$moduleRoutes type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/AutoRouterImproved.php - - - - message: '#^Method CodeIgniter\\Router\\AutoRouterInterface\:\:getRoute\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/AutoRouterInterface.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:addPlaceholder\(\) has parameter \$placeholder with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:add\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:add\(\) has parameter \$to with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:buildReverseRoute\(\) has parameter \$params with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:cli\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:cli\(\) has parameter \$to with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:create\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:create\(\) has parameter \$to with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:delete\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:delete\(\) has parameter \$to with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:fillRouteParams\(\) has parameter \$params with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:getRoutes\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:get\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:get\(\) has parameter \$to with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:group\(\) has parameter \$params with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:head\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:head\(\) has parameter \$to with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:map\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:map\(\) has parameter \$routes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:match\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:match\(\) has parameter \$to with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:match\(\) has parameter \$verbs with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:options\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:options\(\) has parameter \$to with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:patch\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:patch\(\) has parameter \$to with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:post\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:post\(\) has parameter \$to with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:presenter\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:processArrayCallableSyntax\(\) has parameter \$to with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:put\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:put\(\) has parameter \$to with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:resource\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollection\:\:view\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Property CodeIgniter\\Router\\RouteCollection\:\:\$currentOptions type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Property CodeIgniter\\Router\\RouteCollection\:\:\$routeFiles type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Property CodeIgniter\\Router\\RouteCollection\:\:\$routes type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Property CodeIgniter\\Router\\RouteCollection\:\:\$routesNames type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Property CodeIgniter\\Router\\RouteCollection\:\:\$routesOptions type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollectionInterface\:\:addPlaceholder\(\) has parameter \$placeholder with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollectionInterface.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollectionInterface\:\:add\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollectionInterface.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollectionInterface\:\:add\(\) has parameter \$to with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollectionInterface.php - - - - message: '#^Method CodeIgniter\\Router\\RouteCollectionInterface\:\:getRoutes\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouteCollectionInterface.php - - - - message: '#^Method CodeIgniter\\Router\\Router\:\:getMatchedRouteOptions\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Router.php - - - - message: '#^Method CodeIgniter\\Router\\Router\:\:getMatchedRoute\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Router.php - - - - message: '#^Method CodeIgniter\\Router\\Router\:\:params\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Router.php - - - - message: '#^Method CodeIgniter\\Router\\Router\:\:replaceBackReferences\(\) has parameter \$matches with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Router.php - - - - message: '#^Method CodeIgniter\\Router\\Router\:\:scanControllers\(\) has parameter \$segments with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Router.php - - - - message: '#^Method CodeIgniter\\Router\\Router\:\:scanControllers\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Router.php - - - - message: '#^Method CodeIgniter\\Router\\Router\:\:validateRequest\(\) has parameter \$segments with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Router.php - - - - message: '#^Method CodeIgniter\\Router\\Router\:\:validateRequest\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Router.php - - - - message: '#^Property CodeIgniter\\Router\\Router\:\:\$matchedRoute type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Router.php - - - - message: '#^Property CodeIgniter\\Router\\Router\:\:\$matchedRouteOptions type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Router.php - - - - message: '#^Property CodeIgniter\\Router\\Router\:\:\$params type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/Router.php - - - - message: '#^Method CodeIgniter\\Router\\RouterInterface\:\:params\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Router/RouterInterface.php - - message: '#^Method CodeIgniter\\Test\\Constraints\\SeeInDatabase\:\:__construct\(\) has parameter \$data with no value type specified in iterable type array\.$#' count: 1 From cf54b82d0b8cb01b55f6421c55f2058091e7a20f Mon Sep 17 00:00:00 2001 From: John Paul E Balandan Date: Mon, 17 Aug 2026 04:24:49 +0800 Subject: [PATCH 3/3] refactor: clear out phpstan errors in `Validation` source and tests (#10461) --- system/Validation/CreditCardRules.php | 2 +- system/Validation/DotArrayFilter.php | 12 +- system/Validation/Rules.php | 44 +- system/Validation/StrictRules/Rules.php | 35 +- system/Validation/Validation.php | 132 +-- system/Validation/ValidationInterface.php | 34 +- tests/system/Validation/FormatRulesTest.php | 63 ++ tests/system/Validation/RulesTest.php | 102 ++- .../StrictRules/CreditCardRulesTest.php | 2 + .../Validation/StrictRules/RulesTest.php | 31 + tests/system/Validation/ValidationTest.php | 53 +- utils/phpstan-baseline/argument.type.neon | 7 +- utils/phpstan-baseline/loader.neon | 2 +- .../missingType.iterableValue.neon | 772 +----------------- 14 files changed, 352 insertions(+), 939 deletions(-) diff --git a/system/Validation/CreditCardRules.php b/system/Validation/CreditCardRules.php index e484c35f66cb..a31b303fcb86 100644 --- a/system/Validation/CreditCardRules.php +++ b/system/Validation/CreditCardRules.php @@ -31,7 +31,7 @@ class CreditCardRules * prefixes - List of possible prefixes for the card * checkdigit - Boolean on whether we should do a modulus10 check on the numbers. * - * @var array + * @var array */ protected $cards = [ 'American Express' => [ diff --git a/system/Validation/DotArrayFilter.php b/system/Validation/DotArrayFilter.php index 673fe67ed138..8e059c3661ae 100644 --- a/system/Validation/DotArrayFilter.php +++ b/system/Validation/DotArrayFilter.php @@ -21,10 +21,10 @@ final class DotArrayFilter /** * Creates a new array with only the elements specified in dot array syntax. * - * @param array $indexes The dot array syntax pattern to use for filtering. - * @param array $array The array to filter. + * @param list $indexes The dot array syntax pattern to use for filtering. + * @param array $array The array to filter. * - * @return array The filtered array. + * @return array The filtered array. */ public static function run(array $indexes, array $array): array { @@ -47,10 +47,10 @@ public static function run(array $indexes, array $array): array /** * Used by `run()` to recursively filter the array with wildcards. * - * @param array $indexes The dot array syntax pattern to use for filtering. - * @param array $array The array to filter. + * @param list $indexes The dot array syntax pattern to use for filtering. + * @param array $array The array to filter. * - * @return array The filtered array. + * @return array The filtered array. */ private static function filter(array $indexes, array $array): array { diff --git a/system/Validation/Rules.php b/system/Validation/Rules.php index 31aa042c5d36..c48465b327e0 100644 --- a/system/Validation/Rules.php +++ b/system/Validation/Rules.php @@ -28,8 +28,8 @@ class Rules /** * The value does not match another field in $data. * - * @param string|null $str - * @param array $data Other field/value pairs + * @param string|null $str + * @param array $data Other field/value pairs */ public function differs($str, string $field, array $data): bool { @@ -110,12 +110,14 @@ public function greater_than_equal_to($str, string $min): bool * Can ignore records by field/value to filter (currently * accept only one filter). * - * Example: + * ``` * is_not_unique[dbGroup.table.field,where_field,where_value] * is_not_unique[table.field,where_field,where_value] * is_not_unique[menu.id,active,1] + * ``` * - * @param string|null $str + * @param string|null $str + * @param array $data */ public function is_not_unique($str, string $field, array $data): bool { @@ -158,7 +160,8 @@ public function in_list($value, string $list): bool * is_unique[table.field,ignore_field,ignore_value] * is_unique[users.email,id,5] * - * @param string|null $str + * @param string|null $str + * @param array $data */ public function is_unique($str, string $field, array $data): bool { @@ -178,9 +181,9 @@ public function is_unique($str, string $field, array $data): bool /** * Prepares the database query for uniqueness checks. * - * @param mixed $value The value to check. - * @param string $field The field parameters. - * @param array $data Additional data. + * @param mixed $value The value to check. + * @param string $field The field parameters. + * @param array $data Additional data. * * @return array{0: BaseBuilder, 1: string|null, 2: string|null} */ @@ -247,8 +250,8 @@ public function less_than_equal_to($str, string $max): bool /** * Matches the value of another field in $data. * - * @param string|null $str - * @param array $data Other field/value pairs + * @param string|null $str + * @param array $data Other field/value pairs */ public function matches($str, string $field, array $data): bool { @@ -343,9 +346,9 @@ public function required($str = null): bool * * required_with[password] * - * @param string|null $str - * @param string|null $fields List of fields that we should check if present - * @param array $data Complete list of fields from the form + * @param string|null $str + * @param string|null $fields List of fields that we should check if present + * @param array $data Complete list of fields from the form */ public function required_with($str = null, ?string $fields = null, array $data = []): bool { @@ -387,9 +390,10 @@ public function required_with($str = null, ?string $fields = null, array $data = * * required_without[id,email] * - * @param string|null $str - * @param string|null $otherFields The param fields of required_without[]. - * @param string|null $field This rule param fields aren't present, this field is required. + * @param string|null $str + * @param string|null $otherFields The param fields of required_without[]. + * @param string|null $field This rule param fields aren't present, this field is required. + * @param array $data */ public function required_without( $str = null, @@ -454,10 +458,10 @@ public function required_without( /** * The field exists in $data. * - * @param mixed $value The field value. - * @param string|null $param The rule's parameter. - * @param array $data The data to be validated. - * @param string|null $field The field name. + * @param mixed $value The field value. + * @param string|null $param The rule's parameter. + * @param array $data The data to be validated. + * @param string|null $field The field name. */ public function field_exists( $value = null, diff --git a/system/Validation/StrictRules/Rules.php b/system/Validation/StrictRules/Rules.php index 6d8dce14588b..cca4fdf494be 100644 --- a/system/Validation/StrictRules/Rules.php +++ b/system/Validation/StrictRules/Rules.php @@ -33,8 +33,8 @@ public function __construct() /** * The value does not match another field in $data. * - * @param mixed $str - * @param array $data Other field/value pairs + * @param mixed $str + * @param array $data Other field/value pairs */ public function differs( $str, @@ -137,7 +137,8 @@ public function greater_than_equal_to($str, string $min): bool * is_not_unique[table.field,where_field,where_value] * is_not_unique[menu.id,active,1] * - * @param mixed $str + * @param mixed $str + * @param array $data */ public function is_not_unique($str, string $field, array $data): bool { @@ -176,7 +177,8 @@ public function in_list($value, string $list): bool * is_unique[table.field,ignore_field,ignore_value] * is_unique[users.email,id,5] * - * @param mixed $str + * @param mixed $str + * @param array $data */ public function is_unique($str, string $field, array $data): bool { @@ -226,8 +228,8 @@ public function less_than_equal_to($str, string $max): bool /** * Matches the value of another field in $data. * - * @param mixed $str - * @param array $data Other field/value pairs + * @param mixed $str + * @param array $data Other field/value pairs */ public function matches( $str, @@ -339,9 +341,9 @@ public function required($str = null): bool * * required_with[password] * - * @param mixed $str - * @param string|null $fields List of fields that we should check if present - * @param array $data Complete list of fields from the form + * @param mixed $str + * @param string|null $fields List of fields that we should check if present + * @param array $data Complete list of fields from the form */ public function required_with($str = null, ?string $fields = null, array $data = []): bool { @@ -356,9 +358,10 @@ public function required_with($str = null, ?string $fields = null, array $data = * * required_without[id,email] * - * @param mixed $str - * @param string|null $otherFields The param fields of required_without[]. - * @param string|null $field This rule param fields aren't present, this field is required. + * @param mixed $str + * @param string|null $otherFields The param fields of required_without[]. + * @param string|null $field This rule param fields aren't present, this field is required. + * @param array $data */ public function required_without( $str = null, @@ -373,10 +376,10 @@ public function required_without( /** * The field exists in $data. * - * @param mixed $value The field value. - * @param string|null $param The rule's parameter. - * @param array $data The data to be validated. - * @param string|null $field The field name. + * @param mixed $value The field value. + * @param string|null $param The rule's parameter. + * @param array $data The data to be validated. + * @param string|null $field The field name. */ public function field_exists( $value = null, diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index ceaa557ea404..b7c702aee6bc 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -14,7 +14,6 @@ namespace CodeIgniter\Validation; use Closure; -use CodeIgniter\Database\BaseConnection; use CodeIgniter\Exceptions\InvalidArgumentException; use CodeIgniter\Exceptions\LogicException; use CodeIgniter\HTTP\Exceptions\HTTPException; @@ -34,22 +33,20 @@ class Validation implements ValidationInterface /** * Files to load with validation functions. * - * @var array + * @var list */ protected $ruleSetFiles; /** * The loaded instances of our validation files. * - * @var array + * @var array */ protected $ruleSetInstances = []; /** * Stores the actual rules that should be run against $data. - * - * @var array}> - * + * ``` * [ * field1 => [ * 'label' => label, @@ -58,6 +55,9 @@ class Validation implements ValidationInterface * ], * ], * ] + * ``` + * + * @var array=, string|null=, string|null=): (bool|string))|string>}> */ protected $rules = []; @@ -65,14 +65,14 @@ class Validation implements ValidationInterface * The data that should be validated, * where 'key' is the alias, with value. * - * @var array + * @var array */ protected $data = []; /** * The data that was actually validated. * - * @var array + * @var array */ protected $validated = []; @@ -80,7 +80,7 @@ class Validation implements ValidationInterface * Any generated errors during validation. * 'key' is the alias, 'value' is the message. * - * @var array + * @var array */ protected $errors = []; @@ -88,7 +88,7 @@ class Validation implements ValidationInterface * Stores custom error message to use * during validation. Where 'key' is the alias. * - * @var array + * @var array> */ protected $customErrors = []; @@ -122,14 +122,6 @@ public function __construct($config, RendererInterface $view) $this->loadRuleSets(); } - /** - * Runs the validation process, returning true/false determining whether - * validation was successful or not. - * - * @param array|null $data The array of data to validate. - * @param string|null $group The predefined group of rules to apply. - * @param array|BaseConnection|non-empty-string|null $dbGroup The database group to use. - */ public function run(?array $data = null, ?string $group = null, $dbGroup = null): bool { if ($data === null) { @@ -165,10 +157,6 @@ public function run(?array $data = null, ?string $group = null, $dbGroup = null) $rules = $setup['rules']; - if (is_string($rules)) { - $rules = $this->splitRules($rules); - } - if (str_contains($field, '*')) { $flattenedArray = array_flatten_with_dots($data); @@ -238,15 +226,6 @@ private static function getRegex(string $field): string . '\z/'; } - /** - * Runs the validation process, returning true or false determining whether - * validation was successful or not. - * - * @param mixed $value The data to validate. - * @param array|string $rules The validation rules. - * @param list $errors The custom error message. - * @param string|null $dbGroup The database group to use. - */ public function check($value, $rules, array $errors = [], $dbGroup = null): bool { $this->reset(); @@ -263,9 +242,6 @@ public function check($value, $rules, array $errors = [], $dbGroup = null): bool ); } - /** - * Returns the actual validated data. - */ public function getValidated(): array { return $this->validated; @@ -277,10 +253,10 @@ public function getValidated(): array * the error to $this->errors and moves on to the next, * so that we can collect all of the first errors. * - * @param array|string $value - * @param array $rules - * @param array $data The array of data to validate, with `DBGroup`. - * @param string|null $originalField The original asterisk field name like "foo.*.bar". + * @param array|string $value + * @param list<(Closure(mixed, array=, string|null=, string|null=): (bool|string))|string> $rules + * @param array $data The array of data to validate, with `DBGroup`. + * @param string|null $originalField The original asterisk field name like "foo.*.bar". */ protected function processRules( string $field, @@ -386,9 +362,10 @@ protected function processRules( } /** - * @param array $data The array of data to validate, with `DBGroup`. + * @param list<(Closure(mixed, array=, string|null=, string|null=): (bool|string))|string> $rules + * @param array $data The array of data to validate, with `DBGroup`. * - * @return array|true The modified rules or true if we return early + * @return list<(Closure(mixed, array=, string|null=, string|null=): (bool|string))|string>|true The modified rules or true if we return early */ private function processIfExist(string $field, array $rules, array $data) { @@ -427,10 +404,11 @@ private function processIfExist(string $field, array $rules, array $data) } /** - * @param array|string $value - * @param array $data The array of data to validate, with `DBGroup`. + * @param array|string $value + * @param list<(Closure(mixed, array=, string|null=, string|null=): (bool|string))|string> $rules + * @param array $data The array of data to validate, with `DBGroup`. * - * @return array|true The modified rules or true if we return early + * @return list<(Closure(mixed, array=, string|null=, string|null=): (bool|string))|string>|true The modified rules or true if we return early */ private function processPermitEmpty($value, array $rules, array $data) { @@ -474,7 +452,7 @@ private function processPermitEmpty($value, array $rules, array $data) } /** - * @param Closure(bool|float|int|list|object|string|null, bool|float|int|list|object|string|null, string|null, string|null): (bool|string) $rule + * @param Closure(mixed, array=, string|null=, string|null=): (bool|string) $rule */ private function isClosure($rule): bool { @@ -483,6 +461,8 @@ private function isClosure($rule): bool /** * Is the array a string list `list`? + * + * @param array $array */ private function isStringList(array $array): bool { @@ -535,24 +515,6 @@ public function withRequest(RequestInterface $request): ValidationInterface return $this; } - /** - * Sets (or adds) an individual rule and custom error messages for a single - * field. - * - * The custom error message should be just the messages that apply to - * this field, like so: - * [ - * 'rule1' => 'message1', - * 'rule2' => 'message2', - * ] - * - * @param array|string $rules The validation rules. - * @param array $errors The custom error message. - * - * @return $this - * - * @throws InvalidArgumentException - */ public function setRule(string $field, ?string $label, $rules, array $errors = []) { if (! is_array($rules) && ! is_string($rules)) { @@ -575,24 +537,6 @@ public function setRule(string $field, ?string $label, $rules, array $errors = [ return $this; } - /** - * Stores the rules that should be used to validate the items. - * - * Rules should be an array formatted like: - * [ - * 'field' => 'rule1|rule2' - * ] - * - * The $errors array should be formatted like: - * [ - * 'field' => [ - * 'rule1' => 'message1', - * 'rule2' => 'message2', - * ], - * ] - * - * @param array $errors An array of custom error messages - */ public function setRules(array $rules, array $errors = []): ValidationInterface { $this->customErrors = $errors; @@ -625,9 +569,6 @@ public function setRules(array $rules, array $errors = []): ValidationInterface return $this; } - /** - * Returns all of the rules currently defined. - */ public function getRules(): array { return $this->rules; @@ -736,20 +677,6 @@ protected function loadRuleSets() } } - /** - * Loads custom rule groups (if set) into the current rules. - * - * Rules can be pre-defined in Config\Validation and can - * be any name, but must all still be an array of the - * same format used with setRules(). Additionally, check - * for {group}_errors for an array of custom error messages. - * - * @param non-empty-string|null $group - * - * @return array [rules, customErrors] - * - * @throws ValidationException - */ public function loadRuleGroup(?string $group = null) { if ($group === null || $group === '') { @@ -791,6 +718,11 @@ public function loadRuleGroup(?string $group = null) * The value of {id} would be replaced with the actual id in the form data: * * 'is_unique[users,email,id,13]' + * + * @param array=, string|null=, string|null=): (bool|string))|string>}> $rules + * @param array $data + * + * @return array=, string|null=, string|null=): (bool|string))|string>}> */ protected function fillPlaceholders(array $rules, array $data): array { @@ -850,6 +782,10 @@ protected function fillPlaceholders(array $rules, array $data): array /** * Retrieves valid placeholder fields. + * + * @param array $data + * + * @return list */ private function retrievePlaceholders(string $rule, array $data): array { @@ -957,6 +893,8 @@ protected function getErrorMessage( /** * Split rules string by pipe operator. + * + * @return list */ protected function splitRules(string $rules): array { diff --git a/system/Validation/ValidationInterface.php b/system/Validation/ValidationInterface.php index 836516d561b8..e90c41ffd341 100644 --- a/system/Validation/ValidationInterface.php +++ b/system/Validation/ValidationInterface.php @@ -25,9 +25,9 @@ interface ValidationInterface * Runs the validation process, returning true/false determining whether * validation was successful or not. * - * @param array|null $data The array of data to validate. - * @param string|null $group The predefined group of rules to apply. - * @param array|BaseConnection|non-empty-string|null $dbGroup The database group to use. + * @param array|null $data The array of data to validate. + * @param string|null $group The predefined group of rules to apply. + * @param array|BaseConnection|non-empty-string|null $dbGroup The database group to use. */ public function run(?array $data = null, ?string $group = null, $dbGroup = null): bool; @@ -35,10 +35,10 @@ public function run(?array $data = null, ?string $group = null, $dbGroup = null) * Check; runs the validation process, returning true or false * determining whether or not validation was successful. * - * @param mixed $value Value to validate. - * @param array|string $rules - * @param list $errors - * @param string|null $dbGroup The database group to use. + * @param mixed $value Value to validate. + * @param array|string $rules + * @param array $errors + * @param string|null $dbGroup The database group to use. * * @return bool True if valid, else false. */ @@ -55,13 +55,12 @@ public function withRequest(RequestInterface $request): ValidationInterface; * * The custom error message should be just the messages that apply to * this field, like so: + * ``` + * ['rule1' => 'message', 'rule2' => 'message'] + * ``` * - * [ - * 'rule' => 'message', - * 'rule' => 'message', - * ] - * - * @param array|string $rules + * @param array|string $rules + * @param array $errors * * @return $this */ @@ -69,11 +68,16 @@ public function setRule(string $field, ?string $label, $rules, array $errors = [ /** * Stores the rules that should be used to validate the items. + * + * @param array|string> $rules + * @param array> $messages */ public function setRules(array $rules, array $messages = []): ValidationInterface; /** * Returns all of the rules currently defined. + * + * @return array}> */ public function getRules(): array; @@ -139,7 +143,7 @@ public function reset(): ValidationInterface; * * @param non-empty-string|null $group * - * @return array + * @return list> */ public function loadRuleGroup(?string $group = null); @@ -160,6 +164,8 @@ public function showError(string $field, string $template = 'single'): string; /** * Returns the actual validated data. + * + * @return array */ public function getValidated(): array; } diff --git a/tests/system/Validation/FormatRulesTest.php b/tests/system/Validation/FormatRulesTest.php index d35855865e05..c2b6e0ca480c 100644 --- a/tests/system/Validation/FormatRulesTest.php +++ b/tests/system/Validation/FormatRulesTest.php @@ -160,6 +160,9 @@ public function testValidURLStrict(?string $url, bool $isLoose, bool $isStrict): $this->assertSame($isStrict, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideValidUrl(): iterable { yield from [ @@ -286,6 +289,9 @@ public function testValidEmail(?string $email, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideValidEmail(): iterable { yield from [ @@ -318,6 +324,9 @@ public function testValidEmails(?string $email, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideValidEmails(): iterable { yield from [ @@ -362,6 +371,9 @@ public function testValidIP(?string $ip, ?string $which, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideValidIP(): iterable { yield from [ @@ -430,6 +442,9 @@ public function testString($str, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideString(): iterable { yield from [ @@ -462,6 +477,9 @@ public function testAlpha(?string $str, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideAlpha(): iterable { yield from [ @@ -502,6 +520,9 @@ public function testAlphaSpace(?string $value, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideAlphaSpace(): iterable { yield from [ @@ -546,6 +567,9 @@ public function testAlphaNumeric(?string $str, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function alphaNumericProvider(): iterable { yield from [ @@ -582,6 +606,9 @@ public function testAlphaNumericPunct(?string $str, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideAlphaNumericPunct(): iterable { yield from [ @@ -710,6 +737,9 @@ public function testAlphaDash(?string $str, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideAlphaDash(): iterable { yield from [ @@ -746,6 +776,9 @@ public function testHex(?string $str, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideHex(): iterable { yield from [ @@ -782,6 +815,9 @@ public function testNumeric(?string $str, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideNumeric(): iterable { yield from [ @@ -856,6 +892,9 @@ public function testNumericWithInvalidTypeData($value, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideInvalidIntegerType(): iterable { // TypeError : CodeIgniter\Validation\FormatRules::integer(): Argument #1 ($str) must be of type ?string, array given @@ -900,6 +939,9 @@ public function testInteger(?string $str, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideInteger(): iterable { yield from [ @@ -952,6 +994,9 @@ public function testDecimal(?string $str, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideDecimal(): iterable { yield from [ @@ -1008,6 +1053,9 @@ public function testNatural(?string $str, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideNatural(): iterable { yield from [ @@ -1048,6 +1096,9 @@ public function testNaturalNoZero(?string $str, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideNaturalNoZero(): iterable { yield from [ @@ -1088,6 +1139,9 @@ public function testBase64(?string $str, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideBase64(): iterable { yield from [ @@ -1124,6 +1178,9 @@ public function testJson(?string $str, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideJson(): iterable { yield from [ @@ -1180,6 +1237,9 @@ public function testTimeZone(?string $str, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideTimeZone(): iterable { yield from [ @@ -1216,6 +1276,9 @@ public function testValidDate(?string $str, ?string $format, bool $expected): vo $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideValidDate(): iterable { yield from [ diff --git a/tests/system/Validation/RulesTest.php b/tests/system/Validation/RulesTest.php index deddab05dc4d..27806ac0fdbc 100644 --- a/tests/system/Validation/RulesTest.php +++ b/tests/system/Validation/RulesTest.php @@ -59,6 +59,9 @@ protected function setUp(): void $this->validation->reset(); } + /** + * @param array $data + */ #[DataProvider('provideRequired')] public function testRequired(array $data, bool $expected): void { @@ -66,6 +69,9 @@ public function testRequired(array $data, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable, bool}> + */ public static function provideRequired(): iterable { yield from [ @@ -79,6 +85,10 @@ public static function provideRequired(): iterable ]; } + /** + * @param array|string> $rules + * @param array $data + */ #[DataProvider('provideIfExist')] public function testIfExist(array $rules, array $data, bool $expected): void { @@ -86,6 +96,9 @@ public function testIfExist(array $rules, array $data, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable|string>, array, bool}> + */ public static function provideIfExist(): iterable { yield from [ @@ -143,6 +156,10 @@ public function testIfExistArray(): void $this->validation->run($data); } + /** + * @param array|string> $rules + * @param array $data + */ #[DataProvider('providePermitEmpty')] public function testPermitEmpty(array $rules, array $data, bool $expected): void { @@ -150,6 +167,9 @@ public function testPermitEmpty(array $rules, array $data, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable|string>, array, bool}> + */ public static function providePermitEmpty(): iterable { yield from [ @@ -310,6 +330,9 @@ public static function providePermitEmpty(): iterable ]; } + /** + * @param array $data + */ #[DataProvider('provideMatches')] public function testMatches(array $data, bool $expected): void { @@ -317,6 +340,9 @@ public function testMatches(array $data, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable, bool}> + */ public static function provideMatches(): iterable { yield from [ @@ -332,6 +358,9 @@ public static function provideMatches(): iterable ]; } + /** + * @param array $data + */ #[DataProvider('provideMatchesNestedCases')] public function testMatchesNested(array $data, bool $expected): void { @@ -383,6 +412,9 @@ public function testMatchesWithDotArrayFail(): void ); } + /** + * @param array $data + */ #[DataProvider('provideDiffers')] public function testDiffers(array $data, bool $expected): void { @@ -390,6 +422,9 @@ public function testDiffers(array $data, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable, bool}> + */ public static function provideDiffers(): iterable { yield from [ @@ -405,6 +440,9 @@ public static function provideDiffers(): iterable ]; } + /** + * @param array $data + */ #[DataProvider('provideMatchesNestedCases')] public function testDiffersNested(array $data, bool $expected): void { @@ -412,6 +450,9 @@ public function testDiffersNested(array $data, bool $expected): void $this->assertSame(! $expected, $this->validation->run($data)); } + /** + * @return iterable, bool}> + */ public static function provideMatchesNestedCases(): iterable { yield from [ @@ -464,6 +505,9 @@ public function testDiffersWithDotArrayFail(): void ); } + /** + * @param array $data + */ #[DataProvider('provideEquals')] public function testEquals(array $data, string $param, bool $expected): void { @@ -471,6 +515,9 @@ public function testEquals(array $data, string $param, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable, string, bool}> + */ public static function provideEquals(): iterable { yield from [ @@ -489,6 +536,9 @@ public function testMinLength(?string $data, string $length, bool $expected): vo $this->assertSame($expected, $this->validation->run(['foo' => $data])); } + /** + * @return iterable + */ public static function provideMinLengthCases(): iterable { yield from [ @@ -522,6 +572,9 @@ public function testExactLength($data, bool $expected): void $this->assertSame($expected, $this->validation->run(['foo' => $data])); } + /** + * @return iterable + */ public static function provideExactLength(): iterable { yield from [ @@ -550,6 +603,9 @@ public function testGreaterThan(?string $first, ?string $second, bool $expected) $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideGreaterThan(): iterable { yield from [ @@ -573,6 +629,9 @@ public function testGreaterThanEqual(?string $first, ?string $second, bool $expe $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideGreaterThanEqual(): iterable { yield from [ @@ -597,6 +656,9 @@ public function testLessThan(?string $first, ?string $second, bool $expected): v $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideLessThan(): iterable { yield from [ @@ -621,6 +683,9 @@ public function testLessThanEqual(?string $first, ?string $second, bool $expecte $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideLessThanEqual(): iterable { yield from [ @@ -653,6 +718,9 @@ public function testNotInList(?string $first, ?string $second, bool $expected): $this->assertSame(! $expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideInList(): iterable { yield from [ @@ -687,6 +755,9 @@ public function testRequiredWith(string $field, ?string $check, bool $expected): $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideRequiredWith(): iterable { yield from [ @@ -719,8 +790,9 @@ public static function provideRequiredWith(): iterable ]; } + /** @see https://github.com/codeigniter4/CodeIgniter4/issues/7557 */ /** - * @see https://github.com/codeigniter4/CodeIgniter4/issues/7557 + * @param array $data */ #[DataProvider('provideRequiredWithAndOtherRules')] public function testRequiredWithAndOtherRules(bool $expected, array $data): void @@ -734,6 +806,9 @@ public function testRequiredWithAndOtherRules(bool $expected, array $data): void $this->assertSame($expected, $result); } + /** + * @return iterable}> + */ public static function provideRequiredWithAndOtherRules(): iterable { yield from [ @@ -756,6 +831,9 @@ public static function provideRequiredWithAndOtherRules(): iterable ]; } + /** + * @param array $data + */ #[DataProvider('provideRequiredWithAndOtherRuleWithValueZero')] public function testRequiredWithAndOtherRuleWithValueZero(bool $expected, array $data): void { @@ -769,6 +847,9 @@ public function testRequiredWithAndOtherRuleWithValueZero(bool $expected, array $this->assertSame($expected, $result); } + /** + * @return iterable}> + */ public static function provideRequiredWithAndOtherRuleWithValueZero(): iterable { yield from [ @@ -797,6 +878,9 @@ public function testRequiredWithout(string $field, ?string $check, bool $expecte $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideRequiredWithout(): iterable { yield from [ @@ -841,6 +925,9 @@ public function testRequiredWithoutMultiple(string $foo, string $bar, string $ba $this->assertSame($result, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideRequiredWithoutMultiple(): iterable { yield from [ @@ -877,6 +964,9 @@ public static function provideRequiredWithoutMultiple(): iterable ]; } + /** + * @param array $data + */ #[DataProvider('provideRequiredWithoutMultipleWithoutFields')] public function testRequiredWithoutMultipleWithoutFields(array $data, bool $result): void { @@ -885,6 +975,9 @@ public function testRequiredWithoutMultipleWithoutFields(array $data, bool $resu $this->assertSame($result, $this->validation->run($data)); } + /** + * @return iterable, bool}> + */ public static function provideRequiredWithoutMultipleWithoutFields(): iterable { yield from [ @@ -917,6 +1010,10 @@ public static function provideRequiredWithoutMultipleWithoutFields(): iterable ]; } + /** + * @param array|string> $rules + * @param array $data + */ #[DataProvider('provideFieldExists')] public function testFieldExists(array $rules, array $data, bool $expected): void { @@ -924,6 +1021,9 @@ public function testFieldExists(array $rules, array $data, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable|string>, array, bool}> + */ public static function provideFieldExists(): iterable { // Do not use `foo`, because there is a lang file `Foo`, and diff --git a/tests/system/Validation/StrictRules/CreditCardRulesTest.php b/tests/system/Validation/StrictRules/CreditCardRulesTest.php index 21691ebd6fae..deda7d76f984 100644 --- a/tests/system/Validation/StrictRules/CreditCardRulesTest.php +++ b/tests/system/Validation/StrictRules/CreditCardRulesTest.php @@ -69,6 +69,8 @@ public function testValidCCNumber(string $type, ?string $number, bool $expected) * Cards shown are test cards found around the web. * * @see https://www.paypalobjects.com/en_US/vhelp/paypalmanager_help/credit_card_numbers.htm + * + * @return iterable */ public static function provideValidCCNumber(): iterable { diff --git a/tests/system/Validation/StrictRules/RulesTest.php b/tests/system/Validation/StrictRules/RulesTest.php index 0fc4f9e38c6e..9cb5744a285d 100644 --- a/tests/system/Validation/StrictRules/RulesTest.php +++ b/tests/system/Validation/StrictRules/RulesTest.php @@ -48,6 +48,10 @@ final class RulesTest extends TraditionalRulesTest ], ]; + /** + * @param array|string> $rules + * @param array $data + */ #[DataProvider('providePermitEmptyStrict')] public function testPermitEmptyStrict(array $rules, array $data, bool $expected): void { @@ -55,6 +59,9 @@ public function testPermitEmptyStrict(array $rules, array $data, bool $expected) $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable|string>, array, bool}> + */ public static function providePermitEmptyStrict(): iterable { yield from [ @@ -114,6 +121,9 @@ public function testGreaterThanEqualStrict($value, string $param, bool $expected $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideGreaterThanEqualStrict(): iterable { yield from [ @@ -139,6 +149,9 @@ public function testGreaterThanStrict($value, string $param, bool $expected): vo $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideGreaterThanStrict(): iterable { yield from [ @@ -165,6 +178,9 @@ public function testLessThanStrict($value, string $param, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideLessThanStrict(): iterable { yield from [ @@ -192,6 +208,9 @@ public function testLessEqualThanStrict($value, ?string $param, bool $expected): $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideLessEqualThanStrict(): iterable { yield from [ @@ -205,6 +224,9 @@ public static function provideLessEqualThanStrict(): iterable ]; } + /** + * @param array $data + */ #[DataProvider('provideMatches')] public function testMatches(array $data, bool $expected): void { @@ -212,6 +234,9 @@ public function testMatches(array $data, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable, bool}> + */ public static function provideMatches(): iterable { yield from [ @@ -227,6 +252,9 @@ public static function provideMatches(): iterable ]; } + /** + * @param array $data + */ #[DataProvider('provideDiffers')] public function testDiffers(array $data, bool $expected): void { @@ -234,6 +262,9 @@ public function testDiffers(array $data, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable, bool}> + */ public static function provideDiffers(): iterable { yield from [ diff --git a/tests/system/Validation/ValidationTest.php b/tests/system/Validation/ValidationTest.php index 3a0f57a0e8e6..6c7cb20de0e9 100644 --- a/tests/system/Validation/ValidationTest.php +++ b/tests/system/Validation/ValidationTest.php @@ -213,6 +213,9 @@ public function testSetRuleRulesFormat(bool $expected, $rules): void $this->addToAssertionCount(1); } + /** + * @return iterable + */ public static function provideSetRuleRulesFormat(): iterable { yield 'fail-simple-object' => [ @@ -403,6 +406,8 @@ public function testCallableRule(): void /** * Validation rule2 + * + * @param array $data */ public function rule2(mixed $value, array $data, ?string &$error, string $field): bool { @@ -473,6 +478,9 @@ public function testCanValidatetArrayData($value, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideCanValidatetArrayData(): iterable { yield 'list array' => [ @@ -524,6 +532,9 @@ public function testIsIntWithInvalidTypeData($value, bool $expected): void $this->assertSame($expected, $this->validation->run($data)); } + /** + * @return iterable + */ public static function provideIsIntWithInvalidTypeData(): iterable { yield 'array with int' => [ @@ -752,6 +763,11 @@ public function testRunWithCustomErrorsAndAsteriskField(): void * @param list|string $rules * @param string $expected */ + /** + * @param array|string> $errors + * @param mixed $rules + * @param mixed $expected + */ #[DataProvider('provideRulesSetup')] public function testRulesSetup($rules, $expected, array $errors = []): void { @@ -762,6 +778,9 @@ public function testRulesSetup($rules, $expected, array $errors = []): void $this->assertSame($expected, $this->validation->getError('foo')); } + /** + * @return iterable|string, string, array|string>}> + */ public static function provideRulesSetup(): iterable { yield from [ @@ -1054,9 +1073,9 @@ public function testShowBadTemplate(): void public function testNoRuleSetsSetup(): void { - try { - $rulesets = static::$config['ruleSets']; + $rulesets = static::$config['ruleSets']; + try { static::$config['ruleSets'] = null; (new Validation((object) static::$config, service('renderer'))) ->reset() @@ -1188,6 +1207,11 @@ public function testRulesForObjectField(): void ], $this->validation->getErrors()); } + /** + * @param array $body + * @param array|string> $rules + * @param array $results + */ #[DataProvider('provideRulesForArrayField')] public function testRulesForArrayField(array $body, array $rules, array $results): void { @@ -1201,6 +1225,9 @@ public function testRulesForArrayField(array $body, array $rules, array $results $this->assertSame($results, $this->validation->getErrors()); } + /** + * @return iterable, rules: array|string>, results: array}> + */ public static function provideRulesForArrayField(): iterable { yield from [ @@ -1450,8 +1477,10 @@ public function testTranslatedLabelTagReplacement(): void $this->assertSame($expected, $errors['Username']); } + /** @see https://github.com/codeigniter4/CodeIgniter4/issues/4521 */ /** - * @see https://github.com/codeigniter4/CodeIgniter4/issues/4521 + * @param array|string> $rules + * @param array $data */ #[DataProvider('provideIfExistRuleWithAsterisk')] public function testIfExistRuleWithAsterisk(bool $expected, array $rules, array $data): void @@ -1460,6 +1489,9 @@ public function testIfExistRuleWithAsterisk(bool $expected, array $rules, array $this->assertSame($expected, $actual); } + /** + * @return iterable|string>, array}> + */ public static function provideIfExistRuleWithAsterisk(): iterable { yield 'dot-on-end-fail' => [ @@ -1519,8 +1551,10 @@ public static function provideIfExistRuleWithAsterisk(): iterable ]; } + /** @see https://github.com/codeigniter4/CodeIgniter4/issues/4510 */ /** - * @see https://github.com/codeigniter4/CodeIgniter4/issues/4510 + * @param array|string> $rules + * @param array $data */ #[DataProvider('provideValidationOfArrayData')] public function testValidationOfArrayData(bool $expected, array $rules, array $data): void @@ -1529,6 +1563,9 @@ public function testValidationOfArrayData(bool $expected, array $rules, array $d $this->assertSame($expected, $actual); } + /** + * @return iterable|string>, array}> + */ public static function provideValidationOfArrayData(): iterable { yield 'fail-empty-string' => [ @@ -1574,8 +1611,9 @@ public static function provideValidationOfArrayData(): iterable ]; } + /** @see https://github.com/codeigniter4/CodeIgniter4/issues/4929 */ /** - * @see https://github.com/codeigniter4/CodeIgniter4/issues/4929 + * @param array $expected */ #[DataProvider('provideSplittingOfComplexStringRules')] public function testSplittingOfComplexStringRules(string $input, array $expected): void @@ -1584,6 +1622,9 @@ public function testSplittingOfComplexStringRules(string $input, array $expected $this->assertSame($expected, $splitter($input)); } + /** + * @return iterable}> + */ public static function provideSplittingOfComplexStringRules(): iterable { yield [ @@ -1636,7 +1677,7 @@ public static function provideSplittingOfComplexStringRules(): iterable * internal method to simplify placeholder replacement test * REQUIRES THE RULES TO BE SET FOR THE FIELD "foo" * - * @param array|null $data optional POST data, needs to contain the key $placeholderField to pass + * @param array|null $data Optional POST data, needs to contain the key $placeholderField to pass * * @source https://github.com/codeigniter4/CodeIgniter4/pull/3910#issuecomment-784922913 */ diff --git a/utils/phpstan-baseline/argument.type.neon b/utils/phpstan-baseline/argument.type.neon index addcb1d223e7..98aa86990719 100644 --- a/utils/phpstan-baseline/argument.type.neon +++ b/utils/phpstan-baseline/argument.type.neon @@ -1,4 +1,4 @@ -# total 63 errors +# total 62 errors parameters: ignoreErrors: @@ -167,11 +167,6 @@ parameters: count: 1 path: ../../tests/system/Test/TestResponseTest.php - - - message: '#^Parameter \#3 \$errors of method CodeIgniter\\Validation\\Validation\:\:check\(\) expects list\, array\{is_numeric\: ''Nope\. Not a number\.''\} given\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - message: '#^Parameter \#2 \$context of method CodeIgniter\\View\\Parser\:\:setData\(\) expects ''attr''\|''css''\|''html''\|''js''\|''raw''\|''url''\|null, ''unknown'' given\.$#' count: 3 diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index a382fda9a5d4..1aabccca5c16 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 1217 errors +# total 1062 errors includes: - argument.type.neon diff --git a/utils/phpstan-baseline/missingType.iterableValue.neon b/utils/phpstan-baseline/missingType.iterableValue.neon index f67d1b49920c..94b09bc195b7 100644 --- a/utils/phpstan-baseline/missingType.iterableValue.neon +++ b/utils/phpstan-baseline/missingType.iterableValue.neon @@ -1,4 +1,4 @@ -# total 966 errors +# total 812 errors parameters: ignoreErrors: @@ -2922,326 +2922,6 @@ parameters: count: 1 path: ../../system/Typography/Typography.php - - - message: '#^Property CodeIgniter\\Validation\\CreditCardRules\:\:\$cards type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/CreditCardRules.php - - - - message: '#^Method CodeIgniter\\Validation\\DotArrayFilter\:\:filter\(\) has parameter \$array with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/DotArrayFilter.php - - - - message: '#^Method CodeIgniter\\Validation\\DotArrayFilter\:\:filter\(\) has parameter \$indexes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/DotArrayFilter.php - - - - message: '#^Method CodeIgniter\\Validation\\DotArrayFilter\:\:filter\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/DotArrayFilter.php - - - - message: '#^Method CodeIgniter\\Validation\\DotArrayFilter\:\:run\(\) has parameter \$array with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/DotArrayFilter.php - - - - message: '#^Method CodeIgniter\\Validation\\DotArrayFilter\:\:run\(\) has parameter \$indexes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/DotArrayFilter.php - - - - message: '#^Method CodeIgniter\\Validation\\DotArrayFilter\:\:run\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/DotArrayFilter.php - - - - message: '#^Method CodeIgniter\\Validation\\Rules\:\:differs\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Rules.php - - - - message: '#^Method CodeIgniter\\Validation\\Rules\:\:field_exists\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Rules.php - - - - message: '#^Method CodeIgniter\\Validation\\Rules\:\:is_not_unique\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Rules.php - - - - message: '#^Method CodeIgniter\\Validation\\Rules\:\:is_unique\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Rules.php - - - - message: '#^Method CodeIgniter\\Validation\\Rules\:\:matches\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Rules.php - - - - message: '#^Method CodeIgniter\\Validation\\Rules\:\:required_with\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Rules.php - - - - message: '#^Method CodeIgniter\\Validation\\Rules\:\:required_without\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Rules.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\Rules\:\:differs\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/StrictRules/Rules.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\Rules\:\:field_exists\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/StrictRules/Rules.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\Rules\:\:is_not_unique\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/StrictRules/Rules.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\Rules\:\:is_unique\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/StrictRules/Rules.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\Rules\:\:matches\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/StrictRules/Rules.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\Rules\:\:required_with\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/StrictRules/Rules.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\Rules\:\:required_without\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/StrictRules/Rules.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:check\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:fillPlaceholders\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:fillPlaceholders\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:fillPlaceholders\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:getRules\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:getValidated\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:isStringList\(\) has parameter \$array with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:loadRuleGroup\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:processIfExist\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:processIfExist\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:processIfExist\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:processPermitEmpty\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:processPermitEmpty\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:processPermitEmpty\(\) has parameter \$value with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:processPermitEmpty\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:processRules\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:processRules\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:processRules\(\) has parameter \$value with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:retrievePlaceholders\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:retrievePlaceholders\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:run\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:run\(\) has parameter \$dbGroup with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:setRule\(\) has parameter \$errors with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:setRule\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:setRules\(\) has parameter \$errors with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:setRules\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\Validation\:\:splitRules\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Property CodeIgniter\\Validation\\Validation\:\:\$customErrors type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Property CodeIgniter\\Validation\\Validation\:\:\$data type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Property CodeIgniter\\Validation\\Validation\:\:\$errors type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Property CodeIgniter\\Validation\\Validation\:\:\$ruleSetFiles type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Property CodeIgniter\\Validation\\Validation\:\:\$ruleSetInstances type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Property CodeIgniter\\Validation\\Validation\:\:\$validated type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/Validation.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationInterface\:\:check\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/ValidationInterface.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationInterface\:\:getRules\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/ValidationInterface.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationInterface\:\:getValidated\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/ValidationInterface.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationInterface\:\:loadRuleGroup\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/ValidationInterface.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationInterface\:\:run\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/ValidationInterface.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationInterface\:\:run\(\) has parameter \$dbGroup with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/ValidationInterface.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationInterface\:\:setRule\(\) has parameter \$errors with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/ValidationInterface.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationInterface\:\:setRule\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/ValidationInterface.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationInterface\:\:setRules\(\) has parameter \$messages with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/ValidationInterface.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationInterface\:\:setRules\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Validation/ValidationInterface.php - - message: '#^Method CodeIgniter\\View\\Cell\:\:determineClass\(\) return type has no value type specified in iterable type array\.$#' count: 1 @@ -4317,456 +3997,6 @@ parameters: count: 1 path: ../../tests/system/Throttle/ThrottleTest.php - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:alphaNumericProvider\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideAlphaDash\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideAlphaNumericPunct\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideAlphaSpace\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideAlpha\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideBase64\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideDecimal\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideHex\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideInteger\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideInvalidIntegerType\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideJson\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideNaturalNoZero\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideNatural\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideNumeric\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideString\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideTimeZone\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideValidDate\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideValidEmail\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideValidEmails\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideValidIP\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\FormatRulesTest\:\:provideValidUrl\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideDiffers\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideEquals\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideExactLength\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideFieldExists\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideGreaterThanEqual\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideGreaterThan\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideIfExist\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideInList\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideLessThanEqual\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideLessThan\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideMatchesNestedCases\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideMatches\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideMinLengthCases\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:providePermitEmpty\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideRequiredWithAndOtherRuleWithValueZero\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideRequiredWithAndOtherRules\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideRequiredWith\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideRequiredWithoutMultipleWithoutFields\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideRequiredWithoutMultiple\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideRequiredWithout\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:provideRequired\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:testDiffersNested\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:testDiffers\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:testEquals\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:testFieldExists\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:testFieldExists\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:testIfExist\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:testIfExist\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:testMatchesNested\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:testMatches\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:testPermitEmpty\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:testPermitEmpty\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:testRequiredWithAndOtherRuleWithValueZero\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:testRequiredWithAndOtherRules\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:testRequiredWithoutMultipleWithoutFields\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\RulesTest\:\:testRequired\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\CreditCardRulesTest\:\:provideValidCCNumber\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/StrictRules/CreditCardRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\FormatRulesTest\:\:provideAlphaSpace\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/StrictRules/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\FormatRulesTest\:\:provideInvalidIntegerType\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/StrictRules/FormatRulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\RulesTest\:\:provideDiffers\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/StrictRules/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\RulesTest\:\:provideGreaterThanEqualStrict\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/StrictRules/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\RulesTest\:\:provideGreaterThanStrict\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/StrictRules/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\RulesTest\:\:provideLessEqualThanStrict\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/StrictRules/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\RulesTest\:\:provideLessThanStrict\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/StrictRules/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\RulesTest\:\:provideMatches\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/StrictRules/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\RulesTest\:\:providePermitEmptyStrict\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/StrictRules/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\RulesTest\:\:testDiffers\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/StrictRules/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\RulesTest\:\:testMatches\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/StrictRules/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\RulesTest\:\:testPermitEmptyStrict\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/StrictRules/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\StrictRules\\RulesTest\:\:testPermitEmptyStrict\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/StrictRules/RulesTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:placeholderReplacementResultDetermination\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:provideCanValidatetArrayData\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:provideIfExistRuleWithAsterisk\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:provideIsIntWithInvalidTypeData\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:provideRulesForArrayField\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:provideRulesSetup\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:provideSetRuleRulesFormat\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:provideSplittingOfComplexStringRules\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:provideValidationOfArrayData\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:rule2\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:testIfExistRuleWithAsterisk\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:testIfExistRuleWithAsterisk\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:testRulesForArrayField\(\) has parameter \$body with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:testRulesForArrayField\(\) has parameter \$results with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:testRulesForArrayField\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:testRulesSetup\(\) has parameter \$errors with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:testSplittingOfComplexStringRules\(\) has parameter \$expected with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:testValidationOfArrayData\(\) has parameter \$data with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - - - message: '#^Method CodeIgniter\\Validation\\ValidationTest\:\:testValidationOfArrayData\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/Validation/ValidationTest.php - - message: '#^Method CodeIgniter\\View\\DBResultDummy\:\:getFieldNames\(\) return type has no value type specified in iterable type array\.$#' count: 1