diff --git a/phpstan-baseline.php b/phpstan-baseline.php index e775d6b9f5ef..93705a8a1121 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -25,12 +25,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/BaseModel.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\BaseModel\\:\\:chunk\\(\\) has parameter \\$userFunc with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/BaseModel.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\BaseModel\\:\\:cleanValidationRules\\(\\) has parameter \\$rules with no value type specified in iterable type array\\.$#', @@ -1441,24 +1435,12 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseBuilder.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_whereIn\\(\\) has parameter \\$values with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:_whereIn\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseBuilder.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:addUnionStatement\\(\\) has parameter \\$union with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:batchObjectToArray\\(\\) has parameter \\$object with no value type specified in iterable type array\\.$#', @@ -1471,12 +1453,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseBuilder.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:buildSubquery\\(\\) has parameter \\$builder with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:delete\\(\\) has parameter \\$where with no value type specified in iterable type array\\.$#', @@ -1561,12 +1537,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseBuilder.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:havingIn\\(\\) has parameter \\$values with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:havingIn\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', @@ -1579,12 +1549,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseBuilder.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:havingNotIn\\(\\) has parameter \\$values with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:havingNotIn\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', @@ -1645,12 +1609,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseBuilder.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:orHavingIn\\(\\) has parameter \\$values with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:orHavingIn\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', @@ -1663,12 +1621,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseBuilder.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:orHavingNotIn\\(\\) has parameter \\$values with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:orHavingNotIn\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', @@ -1699,24 +1651,12 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseBuilder.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:orWhereIn\\(\\) has parameter \\$values with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:orWhereIn\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseBuilder.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:orWhereNotIn\\(\\) has parameter \\$values with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:orWhereNotIn\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', @@ -1783,18 +1723,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseBuilder.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:union\\(\\) has parameter \\$union with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:unionAll\\(\\) has parameter \\$union with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:update\\(\\) has parameter \\$set with no value type specified in iterable type array\\.$#', @@ -1849,24 +1777,12 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseBuilder.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:whereIn\\(\\) has parameter \\$values with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:whereIn\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseBuilder.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:whereNotIn\\(\\) has parameter \\$values with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseBuilder.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseBuilder\\:\\:whereNotIn\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#', @@ -2047,12 +1963,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Database/BaseConnection.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:prepare\\(\\) has parameter \\$func with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Database/BaseConnection.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Database\\\\BaseConnection\\:\\:prepare\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#', @@ -7837,12 +7747,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Model.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Model\\:\\:chunk\\(\\) has parameter \\$userFunc with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Model.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Model\\:\\:doDelete\\(\\) has parameter \\$id with no value type specified in iterable type array\\.$#', @@ -8197,12 +8101,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Router/RouteCollection.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Router\\\\RouteCollection\\:\\:environment\\(\\) has parameter \\$callback with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Router/RouteCollection.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Router\\\\RouteCollection\\:\\:fillRouteParams\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#', @@ -10219,12 +10117,6 @@ 'count' => 1, 'path' => __DIR__ . '/system/Validation/Validation.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Validation\\\\Validation\\:\\:isClosure\\(\\) has parameter \\$rule with no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/system/Validation/Validation.php', -]; $ignoreErrors[] = [ // identifier: missingType.iterableValue 'message' => '#^Method CodeIgniter\\\\Validation\\\\Validation\\:\\:isStringList\\(\\) has parameter \\$array with no value type specified in iterable type array\\.$#', @@ -17317,12 +17209,6 @@ 'count' => 1, 'path' => __DIR__ . '/tests/system/Test/FilterTestTraitTest.php', ]; -$ignoreErrors[] = [ - // identifier: missingType.callable - 'message' => '#^Method CodeIgniter\\\\Test\\\\FilterTestTraitTest\\:\\:getFilterCaller\\(\\) return type has no signature specified for Closure\\.$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/system/Test/FilterTestTraitTest.php', -]; $ignoreErrors[] = [ // identifier: if.condNotBoolean 'message' => '#^Only booleans are allowed in an if condition, array\\ given\\.$#', diff --git a/system/BaseModel.php b/system/BaseModel.php index a360fe57f47f..3ced5599a1b5 100644 --- a/system/BaseModel.php +++ b/system/BaseModel.php @@ -570,8 +570,8 @@ abstract public function countAllResults(bool $reset = true, bool $test = false) * Loops over records in batches, allowing you to operate on them. * This method works only with dbCalls. * - * @param int $size Size - * @param Closure $userFunc Callback Function + * @param int $size Size + * @param Closure(array|object): mixed $userFunc Callback Function * * @return void * diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 892dd903b690..e52baa39f570 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -836,7 +836,7 @@ protected function whereHaving(string $qbKey, $key, $value = null, string $type * Generates a WHERE field IN('item', 'item') SQL query, * joined with 'AND' if appropriate. * - * @param array|BaseBuilder|Closure|string $values The values searched on, or anonymous function with subquery + * @param array|BaseBuilder|(Closure(BaseBuilder): BaseBuilder)|null $values The values searched on, or anonymous function with subquery * * @return $this */ @@ -849,7 +849,7 @@ public function whereIn(?string $key = null, $values = null, ?bool $escape = nul * Generates a WHERE field IN('item', 'item') SQL query, * joined with 'OR' if appropriate. * - * @param array|BaseBuilder|Closure|string $values The values searched on, or anonymous function with subquery + * @param array|BaseBuilder|(Closure(BaseBuilder): BaseBuilder)|null $values The values searched on, or anonymous function with subquery * * @return $this */ @@ -862,7 +862,7 @@ public function orWhereIn(?string $key = null, $values = null, ?bool $escape = n * Generates a WHERE field NOT IN('item', 'item') SQL query, * joined with 'AND' if appropriate. * - * @param array|BaseBuilder|Closure|string $values The values searched on, or anonymous function with subquery + * @param array|BaseBuilder|(Closure(BaseBuilder): BaseBuilder)|null $values The values searched on, or anonymous function with subquery * * @return $this */ @@ -875,7 +875,7 @@ public function whereNotIn(?string $key = null, $values = null, ?bool $escape = * Generates a WHERE field NOT IN('item', 'item') SQL query, * joined with 'OR' if appropriate. * - * @param array|BaseBuilder|Closure|string $values The values searched on, or anonymous function with subquery + * @param array|BaseBuilder|(Closure(BaseBuilder): BaseBuilder)|null $values The values searched on, or anonymous function with subquery * * @return $this */ @@ -888,7 +888,7 @@ public function orWhereNotIn(?string $key = null, $values = null, ?bool $escape * Generates a HAVING field IN('item', 'item') SQL query, * joined with 'AND' if appropriate. * - * @param array|BaseBuilder|Closure|string $values The values searched on, or anonymous function with subquery + * @param array|BaseBuilder|(Closure(BaseBuilder): BaseBuilder)|null $values The values searched on, or anonymous function with subquery * * @return $this */ @@ -901,7 +901,7 @@ public function havingIn(?string $key = null, $values = null, ?bool $escape = nu * Generates a HAVING field IN('item', 'item') SQL query, * joined with 'OR' if appropriate. * - * @param array|BaseBuilder|Closure|string $values The values searched on, or anonymous function with subquery + * @param array|BaseBuilder|(Closure(BaseBuilder): BaseBuilder)|null $values The values searched on, or anonymous function with subquery * * @return $this */ @@ -914,7 +914,7 @@ public function orHavingIn(?string $key = null, $values = null, ?bool $escape = * Generates a HAVING field NOT IN('item', 'item') SQL query, * joined with 'AND' if appropriate. * - * @param array|BaseBuilder|Closure|string $values The values searched on, or anonymous function with subquery + * @param array|BaseBuilder|(Closure(BaseBuilder):BaseBuilder)|null $values The values searched on, or anonymous function with subquery * * @return $this */ @@ -927,7 +927,7 @@ public function havingNotIn(?string $key = null, $values = null, ?bool $escape = * Generates a HAVING field NOT IN('item', 'item') SQL query, * joined with 'OR' if appropriate. * - * @param array|BaseBuilder|Closure|string $values The values searched on, or anonymous function with subquery + * @param array|BaseBuilder|(Closure(BaseBuilder): BaseBuilder)|null $values The values searched on, or anonymous function with subquery * * @return $this */ @@ -942,8 +942,8 @@ public function orHavingNotIn(?string $key = null, $values = null, ?bool $escape * @used-by whereNotIn() * @used-by orWhereNotIn() * - * @param non-empty-string|null $key - * @param array|BaseBuilder|Closure|null $values The values searched on, or anonymous function with subquery + * @param non-empty-string|null $key + * @param array|BaseBuilder|(Closure(BaseBuilder): BaseBuilder)|null $values The values searched on, or anonymous function with subquery * * @return $this * @@ -1197,7 +1197,7 @@ protected function _like_statement(?string $prefix, string $column, ?string $not /** * Add UNION statement * - * @param BaseBuilder|Closure $union + * @param BaseBuilder|Closure(BaseBuilder): BaseBuilder $union * * @return $this */ @@ -1209,7 +1209,7 @@ public function union($union) /** * Add UNION ALL statement * - * @param BaseBuilder|Closure $union + * @param BaseBuilder|Closure(BaseBuilder): BaseBuilder $union * * @return $this */ @@ -1222,7 +1222,7 @@ public function unionAll($union) * @used-by union() * @used-by unionAll() * - * @param BaseBuilder|Closure $union + * @param BaseBuilder|Closure(BaseBuilder): BaseBuilder $union * * @return $this */ @@ -3558,9 +3558,9 @@ protected function isSubquery($value): bool } /** - * @param BaseBuilder|Closure $builder - * @param bool $wrapped Wrap the subquery in brackets - * @param string $alias Subquery alias + * @param BaseBuilder|Closure(BaseBuilder): BaseBuilder $builder + * @param bool $wrapped Wrap the subquery in brackets + * @param string $alias Subquery alias */ protected function buildSubquery($builder, bool $wrapped = false, string $alias = ''): string { diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index c60c2e72c680..0a88b00a4445 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -959,6 +959,8 @@ public function newQuery(): BaseBuilder * ->get(); * }) * + * @param Closure(BaseConnection): mixed $func + * * @return BasePreparedQuery|null */ public function prepare(Closure $func, array $options = []) diff --git a/system/Model.php b/system/Model.php index d5df3f861b97..7213189010c8 100644 --- a/system/Model.php +++ b/system/Model.php @@ -623,10 +623,6 @@ public function getIdValue($row) * Works with $this->builder to get the Compiled select to * determine the rows to operate on. * This method works only with dbCalls. - * - * @return void - * - * @throws DataException */ public function chunk(int $size, Closure $userFunc) { diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 74c34d6ad518..ad5c01a4858f 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -1158,6 +1158,8 @@ public function view(string $from, string $view, ?array $options = null): RouteC /** * Limits the routes to a specified ENVIRONMENT or they won't run. + * + * @param Closure(RouteCollection): void $callback */ public function environment(string $env, Closure $callback): RouteCollectionInterface { diff --git a/system/Test/FilterTestTrait.php b/system/Test/FilterTestTrait.php index 93f273a39f1f..5837e6e658a6 100644 --- a/system/Test/FilterTestTrait.php +++ b/system/Test/FilterTestTrait.php @@ -119,6 +119,8 @@ protected function setUpFilterTestTrait(): void * * @param FilterInterface|string $filter The filter instance, class, or alias * @param string $position "before" or "after" + * + * @phpstan-return Closure(list|null=): mixed */ protected function getFilterCaller($filter, string $position): Closure { diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index cd81352eb8c2..a942a32bceea 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -467,7 +467,7 @@ private function processPermitEmpty($value, array $rules, array $data) } /** - * @param Closure|string $rule + * @param Closure(bool|float|int|list|object|string|null, bool|float|int|list|object|string|null, string|null, string|null): (bool|string) $rule */ private function isClosure($rule): bool {