diff --git a/admin/framework/composer.json b/admin/framework/composer.json index 7a6e1c58a1e1..499a97eae337 100644 --- a/admin/framework/composer.json +++ b/admin/framework/composer.json @@ -20,7 +20,7 @@ "codeigniter/coding-standard": "^1.7", "fakerphp/faker": "^1.24", "friendsofphp/php-cs-fixer": "^3.47.1", - "kint-php/kint": "^6.1", + "kint-php/kint": "^6.0", "mikey179/vfsstream": "^1.6.12", "nexusphp/cs-config": "^3.6", "phpunit/phpunit": "^10.5.16 || ^11.2", diff --git a/composer.json b/composer.json index 58db64bd0bf5..084068024c44 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require-dev": { "codeigniter/phpstan-codeigniter": "1.x-dev", "fakerphp/faker": "^1.24", - "kint-php/kint": "^6.1", + "kint-php/kint": "^6.0", "mikey179/vfsstream": "^1.6.12", "nexusphp/tachycardia": "^2.0", "phpstan/extension-installer": "^1.4", diff --git a/system/BaseModel.php b/system/BaseModel.php index fdc07ba2330d..4648ba0f0608 100644 --- a/system/BaseModel.php +++ b/system/BaseModel.php @@ -436,7 +436,7 @@ abstract protected function doFindColumn(string $columnName); * @param int|null $limit Limit * @param int $offset Offset * - * @return array + * @return array|object> */ abstract protected function doFindAll(?int $limit = null, int $offset = 0); @@ -629,7 +629,7 @@ public function find($id = null) * * @param string $columnName Column Name * - * @return array|null The resulting row of data, or null if no data found. + * @return array|null The resulting row of data, or null if no data found. * * @throws DataException */ @@ -650,7 +650,7 @@ public function findColumn(string $columnName) * @param int $limit Limit * @param int $offset Offset * - * @return array + * @return array */ public function findAll(?int $limit = null, int $offset = 0) { @@ -695,7 +695,7 @@ public function findAll(?int $limit = null, int $offset = 0) /** * Returns the first row of the result set. * - * @return array|object|null + * @return array|object|null */ public function first() { @@ -1593,9 +1593,10 @@ public function getValidationMessages(): array * currently so that rules don't block updating when only updating * a partial row. * - * @param array $rules Array containing field name and rule - * @param array $row Row data (@TODO Remove null in param type) + * @param array $rules + * @param array|null $row * @phpstan-param row_array $row + * @phpstan-return array */ protected function cleanValidationRules(array $rules, ?array $row = null): array { @@ -1889,7 +1890,7 @@ protected function transformDataToArray($row, string $type): array * * @param string $name Name * - * @return array|bool|float|int|object|string|null + * @return array|bool|float|int|object|string|null */ public function __get(string $name) { diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index b7c9ed64e2de..f96e2d716768 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -374,6 +374,10 @@ public static function promptByMultipleKeys(string $text, array $options): array /** * Validation for $options in promptByKey() and promptByMultipleKeys(). Return an error if $options is an empty array. + * + * @param array $options List of options + * + * @return void */ private static function isZeroOptions(array $options): void { diff --git a/system/Commands/ListCommands.php b/system/Commands/ListCommands.php index 8761e2bb7bbc..f0c3ecebef54 100644 --- a/system/Commands/ListCommands.php +++ b/system/Commands/ListCommands.php @@ -87,6 +87,8 @@ public function run(array $params) /** * Lists the commands with accompanying info. + * + * @param array> $commands Array of commands keyed by name, each with metadata * * @return int */ diff --git a/system/Commands/Translation/LocalizationFinder.php b/system/Commands/Translation/LocalizationFinder.php index e6557b74d1c4..0138f555402e 100644 --- a/system/Commands/Translation/LocalizationFinder.php +++ b/system/Commands/Translation/LocalizationFinder.php @@ -304,6 +304,11 @@ private function replaceArraySyntax(string $code): string /** * Create multidimensional array from another keys + * + * @param array $fromKeys List of keys to build nested array + * @param string $lastArrayValue Value to assign at the deepest key + * + * @return array Multidimensional associative array */ private function buildMultiArray(array $fromKeys, string $lastArrayValue = ''): array { @@ -323,6 +328,10 @@ private function buildMultiArray(array $fromKeys, string $lastArrayValue = ''): /** * Convert multi arrays to specific CLI table rows (flat array) + * + * @param array $array Input translations (nested array or strings) + * + * @return array Flat list of table rows [langFileNames, value] */ private function arrayToTableRows(string $langFileName, array $array): array { diff --git a/system/Commands/Utilities/Namespaces.php b/system/Commands/Utilities/Namespaces.php index 8dda8ce0732e..ad5e02f1b829 100644 --- a/system/Commands/Utilities/Namespaces.php +++ b/system/Commands/Utilities/Namespaces.php @@ -91,6 +91,11 @@ public function run(array $params) CLI::table($tbody, $thead); } + /** + * @param array{m:int,r?:mixed} $params + * + * @return array + */ private function outputAllNamespaces(array $params): array { $maxLength = $params['m']; diff --git a/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php b/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php index d29f6a9b7049..4054d86e982e 100644 --- a/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php +++ b/system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php @@ -95,9 +95,10 @@ public function get(): array /** * Adding Filters * - * @param list> $routes + * @param array>> $routes List of route definitions + * + * @return array>> $Updated route definitions with filters * - * @return list> */ private function addFilters(array $routes): array { diff --git a/system/Config/BaseService.php b/system/Config/BaseService.php index 0fb4c3c7c3ad..60487c14cce1 100644 --- a/system/Config/BaseService.php +++ b/system/Config/BaseService.php @@ -304,6 +304,7 @@ public static function locator(bool $getShared = true) * Provides the ability to perform case-insensitive calling of service * names. * + * @param array $arguments * @return object|null */ public static function __callStatic(string $name, array $arguments) diff --git a/system/Modules/Modules.php b/system/Modules/Modules.php index ca4fe40ab128..c69793c23756 100644 --- a/system/Modules/Modules.php +++ b/system/Modules/Modules.php @@ -60,6 +60,13 @@ public function shouldDiscover(string $alias): bool return in_array(strtolower($alias), $this->aliases, true); } + /** + * Restores the state of the object when exported with var_export() + * + * @param array $array Properties and their values + * + * @return static + */ public static function __set_state(array $array) { $obj = new static(); diff --git a/system/ThirdParty/Escaper/Escaper.php b/system/ThirdParty/Escaper/Escaper.php index 39d9b0b1cdac..25119a0e5158 100644 --- a/system/ThirdParty/Escaper/Escaper.php +++ b/system/ThirdParty/Escaper/Escaper.php @@ -247,7 +247,7 @@ public function escapeCss(string $string) protected function htmlAttrMatcher($matches) { $chr = $matches[0]; - $ord = ord($chr); + $ord = ord($chr[0]); /** * The following replaces characters undefined in HTML with the diff --git a/utils/phpstan-baseline/missingType.iterableValue.neon b/utils/phpstan-baseline/missingType.iterableValue.neon index 2a2c25c8689b..d9e9e761e6fc 100644 --- a/utils/phpstan-baseline/missingType.iterableValue.neon +++ b/utils/phpstan-baseline/missingType.iterableValue.neon @@ -1,4 +1,4 @@ -# total 1375 errors +# total 1197 errors parameters: ignoreErrors: @@ -7,21 +7,6 @@ parameters: count: 1 path: ../../system/BaseModel.php - - - message: '#^Method CodeIgniter\\BaseModel\:\:__get\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/BaseModel.php - - - - message: '#^Method CodeIgniter\\BaseModel\:\:cleanValidationRules\(\) has parameter \$rules with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/BaseModel.php - - - - message: '#^Method CodeIgniter\\BaseModel\:\:cleanValidationRules\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/BaseModel.php - - message: '#^Method CodeIgniter\\BaseModel\:\:convertToReturnType\(\) return type has no value type specified in iterable type array\.$#' count: 1 @@ -42,11 +27,6 @@ parameters: count: 1 path: ../../system/BaseModel.php - - - message: '#^Method CodeIgniter\\BaseModel\:\:doFindAll\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/BaseModel.php - - message: '#^Method CodeIgniter\\BaseModel\:\:doFindColumn\(\) return type has no value type specified in iterable type array\.$#' count: 1 @@ -87,21 +67,6 @@ parameters: count: 1 path: ../../system/BaseModel.php - - - message: '#^Method CodeIgniter\\BaseModel\:\:findAll\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/BaseModel.php - - - - message: '#^Method CodeIgniter\\BaseModel\:\:findColumn\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/BaseModel.php - - - - message: '#^Method CodeIgniter\\BaseModel\:\:first\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/BaseModel.php - - message: '#^Method CodeIgniter\\BaseModel\:\:getIdValue\(\) return type has no value type specified in iterable type array\.$#' count: 1 @@ -177,11 +142,6 @@ parameters: count: 1 path: ../../system/BaseModel.php - - - message: '#^Method CodeIgniter\\CLI\\CLI\:\:isZeroOptions\(\) has parameter \$options with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/CLI/CLI.php - - message: '#^Method CodeIgniter\\CLI\\CLI\:\:printKeysAndValues\(\) has parameter \$options with no value type specified in iterable type array\.$#' count: 1 @@ -242,36 +202,11 @@ parameters: count: 1 path: ../../system/CodeIgniter.php - - - message: '#^Method CodeIgniter\\Commands\\ListCommands\:\:listFull\(\) has parameter \$commands with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Commands/ListCommands.php - - message: '#^Method CodeIgniter\\Commands\\ListCommands\:\:listSimple\(\) has parameter \$commands with no value type specified in iterable type array\.$#' count: 1 path: ../../system/Commands/ListCommands.php - - - message: '#^Method CodeIgniter\\Commands\\Translation\\LocalizationFinder\:\:arrayToTableRows\(\) has parameter \$array with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Commands/Translation/LocalizationFinder.php - - - - message: '#^Method CodeIgniter\\Commands\\Translation\\LocalizationFinder\:\:arrayToTableRows\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Commands/Translation/LocalizationFinder.php - - - - message: '#^Method CodeIgniter\\Commands\\Translation\\LocalizationFinder\:\:buildMultiArray\(\) has parameter \$fromKeys with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Commands/Translation/LocalizationFinder.php - - - - message: '#^Method CodeIgniter\\Commands\\Translation\\LocalizationFinder\:\:buildMultiArray\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Commands/Translation/LocalizationFinder.php - - message: '#^Method CodeIgniter\\Commands\\Translation\\LocalizationFinder\:\:findTranslationsInFile\(\) return type has no value type specified in iterable type array\.$#' count: 1 @@ -282,16 +217,6 @@ parameters: count: 1 path: ../../system/Commands/Translation/LocalizationFinder.php - - - message: '#^Method CodeIgniter\\Commands\\Utilities\\Namespaces\:\:outputAllNamespaces\(\) has parameter \$params with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Commands/Utilities/Namespaces.php - - - - message: '#^Method CodeIgniter\\Commands\\Utilities\\Namespaces\:\:outputAllNamespaces\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Commands/Utilities/Namespaces.php - - message: '#^Method CodeIgniter\\Commands\\Utilities\\Namespaces\:\:outputCINamespaces\(\) has parameter \$params with no value type specified in iterable type array\.$#' count: 1 @@ -302,16 +227,6 @@ parameters: count: 1 path: ../../system/Commands/Utilities/Namespaces.php - - - message: '#^Method CodeIgniter\\Commands\\Utilities\\Routes\\AutoRouterImproved\\AutoRouteCollector\:\:addFilters\(\) has parameter \$routes with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php - - - - message: '#^Method CodeIgniter\\Commands\\Utilities\\Routes\\AutoRouterImproved\\AutoRouteCollector\:\:addFilters\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php - - message: '#^Method CodeIgniter\\Commands\\Utilities\\Routes\\AutoRouterImproved\\AutoRouteCollector\:\:generateSampleUri\(\) has parameter \$route with no value type specified in iterable type array\.$#' count: 1 @@ -402,11 +317,6 @@ parameters: count: 1 path: ../../system/Config/BaseService.php - - - message: '#^Method CodeIgniter\\Config\\BaseService\:\:__callStatic\(\) has parameter \$arguments with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Config/BaseService.php - - message: '#^Method CodeIgniter\\Config\\BaseService\:\:getSharedInstance\(\) has parameter \$params with no value type specified in iterable type array\.$#' count: 1 @@ -4172,11 +4082,6 @@ parameters: count: 1 path: ../../system/Model.php - - - message: '#^Method CodeIgniter\\Modules\\Modules\:\:__set_state\(\) has parameter \$array with no value type specified in iterable type array\.$#' - count: 1 - path: ../../system/Modules/Modules.php - - message: '#^Method CodeIgniter\\Pager\\Pager\:\:getDetails\(\) return type has no value type specified in iterable type array\.$#' count: 1