diff --git a/app/Views/errors/cli/error_exception.php b/app/Views/errors/cli/error_exception.php
index 2bf1459d4094..d551b3317c89 100644
--- a/app/Views/errors/cli/error_exception.php
+++ b/app/Views/errors/cli/error_exception.php
@@ -50,7 +50,7 @@
$function .= $padClass . $error['function'];
}
- $args = implode(', ', array_map(static fn ($value) => match (true) {
+ $args = implode(', ', array_map(static fn ($value): ?string => match (true) {
is_object($value) => 'Object(' . $value::class . ')',
is_array($value) => $value !== [] ? '[...]' : '[]',
$value === null => 'null', // return the lowercased version
diff --git a/rector.php b/rector.php
index ee8621691862..486685959c70 100644
--- a/rector.php
+++ b/rector.php
@@ -41,6 +41,7 @@
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector;
+use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
use Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector;
@@ -201,6 +202,7 @@
TypedPropertyFromAssignsRector::class,
ClosureReturnTypeRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
+ AddArrowFunctionReturnTypeRector::class,
])
->withConfiguredRule(StringClassNameToClassConstantRector::class, [
// keep '\\' prefix string on string '\Foo\Bar'
diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php
index 0b5b01b179aa..9a7e1459e40f 100644
--- a/system/CLI/CLI.php
+++ b/system/CLI/CLI.php
@@ -339,7 +339,7 @@ public static function promptByMultipleKeys(string $text, array $options): array
$pattern = preg_match_all('/^\d+(,\d+)*$/', trim($input));
// separate input by comma and convert all to an int[]
- $inputToArray = array_map(static fn ($value) => (int) $value, explode(',', $input));
+ $inputToArray = array_map(static fn ($value): int => (int) $value, explode(',', $input));
// find max from key of $options
$maxOptions = array_key_last($options);
// find max from input
diff --git a/system/Commands/Utilities/Routes.php b/system/Commands/Utilities/Routes.php
index a0f81f6b42a0..d7a6c0b55744 100644
--- a/system/Commands/Utilities/Routes.php
+++ b/system/Commands/Utilities/Routes.php
@@ -187,7 +187,7 @@ public function run(array $params)
// Sort by Handler.
if ($sortByHandler) {
- usort($tbody, static fn ($handler1, $handler2) => strcmp($handler1[3], $handler2[3]));
+ usort($tbody, static fn ($handler1, $handler2): int => strcmp($handler1[3], $handler2[3]));
}
if ($host !== null) {
diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php
index e738a331d608..54d9a8980f44 100644
--- a/system/Database/BaseBuilder.php
+++ b/system/Database/BaseBuilder.php
@@ -2018,7 +2018,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
$sql = 'INSERT INTO ' . $table . ' (' . implode(', ', $keys) . ")\n{:_table_:}ON DUPLICATE KEY UPDATE\n" . implode(
",\n",
array_map(
- static fn ($key, $value) => $table . '.' . $key . ($value instanceof RawSql ?
+ static fn ($key, $value): string => $table . '.' . $key . ($value instanceof RawSql ?
' = ' . $value :
' = VALUES(' . $value . ')'),
array_keys($updateFields),
@@ -2108,7 +2108,7 @@ public function onConstraint($set)
if (is_string($set)) {
$set = explode(',', $set);
- $set = array_map(static fn ($key) => trim($key), $set);
+ $set = array_map(static fn ($key): string => trim($key), $set);
}
if ($set instanceof RawSql) {
@@ -2152,7 +2152,7 @@ public function setQueryAsData($query, ?string $alias = null, $columns = null):
if (is_string($query)) {
if ($columns !== null && is_string($columns)) {
$columns = explode(',', $columns);
- $columns = array_map(static fn ($key) => trim($key), $columns);
+ $columns = array_map(static fn ($key): string => trim($key), $columns);
}
$columns = (array) $columns;
@@ -2190,7 +2190,7 @@ protected function fieldsFromQuery(string $sql): array
*/
protected function formatValues(array $values): array
{
- return array_map(static fn ($index) => '(' . implode(',', $index) . ')', $values);
+ return array_map(static fn ($index): string => '(' . implode(',', $index) . ')', $values);
}
/**
@@ -2649,7 +2649,7 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
$sql .= implode(
",\n",
array_map(
- static fn ($key, $value) => $key . ($value instanceof RawSql ?
+ static fn ($key, $value): string => $key . ($value instanceof RawSql ?
' = ' . $value :
' = ' . $alias . '.' . $value),
array_keys($updateFields),
@@ -2691,8 +2691,8 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
$data = implode(
" UNION ALL\n",
array_map(
- static fn ($value) => 'SELECT ' . implode(', ', array_map(
- static fn ($key, $index) => $index . ' ' . $key,
+ static fn ($value): string => 'SELECT ' . implode(', ', array_map(
+ static fn ($key, $index): string => $index . ' ' . $key,
$keys,
$value
)),
@@ -2946,8 +2946,8 @@ protected function _deleteBatch(string $table, array $keys, array $values): stri
$data = implode(
" UNION ALL\n",
array_map(
- static fn ($value) => 'SELECT ' . implode(', ', array_map(
- static fn ($key, $index) => $index . ' ' . $key,
+ static fn ($value): string => 'SELECT ' . implode(', ', array_map(
+ static fn ($key, $index): string => $index . ' ' . $key,
$keys,
$value
)),
diff --git a/system/Database/Forge.php b/system/Database/Forge.php
index fc9aa54ec169..b41b8f34f8c8 100644
--- a/system/Database/Forge.php
+++ b/system/Database/Forge.php
@@ -861,7 +861,7 @@ protected function _alterTable(string $alterType, string $table, $processedField
$columnNamesToDrop = explode(',', $columnNamesToDrop);
}
- $columnNamesToDrop = array_map(fn ($field) => 'DROP COLUMN ' . $this->db->escapeIdentifiers(trim($field)), $columnNamesToDrop);
+ $columnNamesToDrop = array_map(fn ($field): string => 'DROP COLUMN ' . $this->db->escapeIdentifiers(trim($field)), $columnNamesToDrop);
return $sql . implode(', ', $columnNamesToDrop);
}
diff --git a/system/Database/MySQLi/Builder.php b/system/Database/MySQLi/Builder.php
index 81434bc3645d..8c1de9d9f987 100644
--- a/system/Database/MySQLi/Builder.php
+++ b/system/Database/MySQLi/Builder.php
@@ -115,7 +115,7 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
$sql .= implode(
",\n",
array_map(
- static fn ($key, $value) => $table . '.' . $key . ($value instanceof RawSql ?
+ static fn ($key, $value): string => $table . '.' . $key . ($value instanceof RawSql ?
' = ' . $value :
' = ' . $alias . '.' . $value),
array_keys($updateFields),
@@ -132,8 +132,8 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
$data = implode(
" UNION ALL\n",
array_map(
- static fn ($value) => 'SELECT ' . implode(', ', array_map(
- static fn ($key, $index) => $index . ' ' . $key,
+ static fn ($value): string => 'SELECT ' . implode(', ', array_map(
+ static fn ($key, $index): string => $index . ' ' . $key,
$keys,
$value
)),
diff --git a/system/Database/OCI8/Builder.php b/system/Database/OCI8/Builder.php
index 24a6bb53b07c..5a65ffe9b75d 100644
--- a/system/Database/OCI8/Builder.php
+++ b/system/Database/OCI8/Builder.php
@@ -89,8 +89,8 @@ protected function _insertBatch(string $table, array $keys, array $values): stri
$data = implode(
" FROM DUAL UNION ALL\n",
array_map(
- static fn ($value) => 'SELECT ' . implode(', ', array_map(
- static fn ($key, $index) => $index . ' ' . $key,
+ static fn ($value): string => 'SELECT ' . implode(', ', array_map(
+ static fn ($key, $index): string => $index . ' ' . $key,
$keys,
$value
)),
@@ -107,7 +107,7 @@ protected function _insertBatch(string $table, array $keys, array $values): stri
*/
protected function _replace(string $table, array $keys, array $values): string
{
- $fieldNames = array_map(static fn ($columnName) => trim($columnName, '"'), $keys);
+ $fieldNames = array_map(static fn ($columnName): string => trim($columnName, '"'), $keys);
$uniqueIndexes = array_filter($this->db->getIndexData($table), static function ($index) use ($fieldNames): bool {
$hasAllFields = count(array_intersect($index->fields, $fieldNames)) === count($index->fields);
@@ -126,7 +126,7 @@ protected function _replace(string $table, array $keys, array $values): string
$sql = 'MERGE INTO ' . $table . "\n USING (SELECT ";
- $sql .= implode(', ', array_map(static fn ($columnName, $value) => $value . ' ' . $columnName, $keys, $values));
+ $sql .= implode(', ', array_map(static fn ($columnName, $value): string => $value . ' ' . $columnName, $keys, $values));
$sql .= ' FROM DUAL) "_replace" ON ( ';
@@ -134,16 +134,16 @@ protected function _replace(string $table, array $keys, array $values): string
$onList[] = '1 != 1';
foreach ($uniqueIndexes as $index) {
- $onList[] = '(' . implode(' AND ', array_map(static fn ($columnName) => $table . '."' . $columnName . '" = "_replace"."' . $columnName . '"', $index->fields)) . ')';
+ $onList[] = '(' . implode(' AND ', array_map(static fn ($columnName): string => $table . '."' . $columnName . '" = "_replace"."' . $columnName . '"', $index->fields)) . ')';
}
$sql .= implode(' OR ', $onList) . ') WHEN MATCHED THEN UPDATE SET ';
- $sql .= implode(', ', array_map(static fn ($columnName) => $columnName . ' = "_replace".' . $columnName, $replaceableFields));
+ $sql .= implode(', ', array_map(static fn ($columnName): string => $columnName . ' = "_replace".' . $columnName, $replaceableFields));
$sql .= ' WHEN NOT MATCHED THEN INSERT (' . implode(', ', $replaceableFields) . ') VALUES ';
- return $sql . (' (' . implode(', ', array_map(static fn ($columnName) => '"_replace".' . $columnName, $replaceableFields)) . ')');
+ return $sql . (' (' . implode(', ', array_map(static fn ($columnName): string => '"_replace".' . $columnName, $replaceableFields)) . ')');
}
/**
@@ -298,7 +298,7 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
$sql .= implode(
",\n",
array_map(
- static fn ($key, $value) => $table . '.' . $key . ($value instanceof RawSql ?
+ static fn ($key, $value): string => $table . '.' . $key . ($value instanceof RawSql ?
' = ' . $value :
' = ' . $alias . '.' . $value),
array_keys($updateFields),
@@ -315,8 +315,8 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
$data = implode(
" UNION ALL\n",
array_map(
- static fn ($value) => 'SELECT ' . implode(', ', array_map(
- static fn ($key, $index) => $index . ' ' . $key,
+ static fn ($value): string => 'SELECT ' . implode(', ', array_map(
+ static fn ($key, $index): string => $index . ' ' . $key,
$keys,
$value
)) . ' FROM DUAL',
@@ -342,7 +342,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
$constraints = $this->QBOptions['constraints'] ?? [];
if (empty($constraints)) {
- $fieldNames = array_map(static fn ($columnName) => trim($columnName, '"'), $keys);
+ $fieldNames = array_map(static fn ($columnName): string => trim($columnName, '"'), $keys);
$uniqueIndexes = array_filter($this->db->getIndexData($table), static function ($index) use ($fieldNames): bool {
$hasAllFields = count(array_intersect($index->fields, $fieldNames)) === count($index->fields);
@@ -401,7 +401,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
$sql .= implode(
",\n",
array_map(
- static fn ($key, $value) => $key . ($value instanceof RawSql ?
+ static fn ($key, $value): string => $key . ($value instanceof RawSql ?
" = {$value}" :
" = {$alias}.{$value}"),
array_keys($updateFields),
@@ -412,7 +412,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
$sql .= "\nWHEN NOT MATCHED THEN INSERT (" . implode(', ', $keys) . ")\nVALUES ";
$sql .= (' ('
- . implode(', ', array_map(static fn ($columnName) => "{$alias}.{$columnName}", $keys))
+ . implode(', ', array_map(static fn ($columnName): string => "{$alias}.{$columnName}", $keys))
. ')');
$this->QBOptions['sql'] = $sql;
@@ -424,8 +424,8 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
$data = implode(
" FROM DUAL UNION ALL\n",
array_map(
- static fn ($value) => 'SELECT ' . implode(', ', array_map(
- static fn ($key, $index) => $index . ' ' . $key,
+ static fn ($value): string => 'SELECT ' . implode(', ', array_map(
+ static fn ($key, $index): string => $index . ' ' . $key,
$keys,
$value
)),
@@ -503,8 +503,8 @@ protected function _deleteBatch(string $table, array $keys, array $values): stri
$data = implode(
" FROM DUAL UNION ALL\n",
array_map(
- static fn ($value) => 'SELECT ' . implode(', ', array_map(
- static fn ($key, $index) => $index . ' ' . $key,
+ static fn ($value): string => 'SELECT ' . implode(', ', array_map(
+ static fn ($key, $index): string => $index . ' ' . $key,
$keys,
$value
)),
diff --git a/system/Database/OCI8/Result.php b/system/Database/OCI8/Result.php
index 0039e90ae9b4..1049847b7af0 100644
--- a/system/Database/OCI8/Result.php
+++ b/system/Database/OCI8/Result.php
@@ -37,7 +37,7 @@ public function getFieldCount(): int
*/
public function getFieldNames(): array
{
- return array_map(fn ($fieldIndex) => oci_field_name($this->resultID, $fieldIndex), range(1, $this->getFieldCount()));
+ return array_map(fn ($fieldIndex): false|string => oci_field_name($this->resultID, $fieldIndex), range(1, $this->getFieldCount()));
}
/**
diff --git a/system/Database/Postgre/Builder.php b/system/Database/Postgre/Builder.php
index faae0eda8a9b..21fa222c7544 100644
--- a/system/Database/Postgre/Builder.php
+++ b/system/Database/Postgre/Builder.php
@@ -353,7 +353,7 @@ protected function _updateBatch(string $table, array $keys, array $values): stri
$sql .= implode(
",\n",
array_map(
- static fn ($key, $value) => $key . ($value instanceof RawSql ?
+ static fn ($key, $value): string => $key . ($value instanceof RawSql ?
' = ' . $value :
' = ' . $that->cast($alias . '.' . $value, $that->getFieldType($table, $key))),
array_keys($updateFields),
@@ -394,8 +394,8 @@ static function ($key, $value) use ($table, $alias, $that): string|RawSql {
$data = implode(
" UNION ALL\n",
array_map(
- static fn ($value) => 'SELECT ' . implode(', ', array_map(
- static fn ($key, $index) => $index . ' ' . $key,
+ static fn ($value): string => 'SELECT ' . implode(', ', array_map(
+ static fn ($key, $index): string => $index . ' ' . $key,
$keys,
$value
)),
@@ -458,7 +458,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
// if this is the first iteration of batch then we need to build skeleton sql
if ($sql === '') {
- $fieldNames = array_map(static fn ($columnName) => trim($columnName, '"'), $keys);
+ $fieldNames = array_map(static fn ($columnName): string => trim($columnName, '"'), $keys);
$constraints = $this->QBOptions['constraints'] ?? [];
@@ -524,7 +524,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
$sql .= implode(
",\n",
array_map(
- static fn ($key, $value) => $key . ($value instanceof RawSql ?
+ static fn ($key, $value): string => $key . ($value instanceof RawSql ?
" = {$value}" :
" = {$alias}.{$value}"),
array_keys($updateFields),
@@ -617,8 +617,8 @@ static function ($key, $value) use ($table, $alias, $that): RawSql|string {
$data = implode(
" UNION ALL\n",
array_map(
- static fn ($value) => 'SELECT ' . implode(', ', array_map(
- static fn ($key, $index) => $index . ' ' . $key,
+ static fn ($value): string => 'SELECT ' . implode(', ', array_map(
+ static fn ($key, $index): string => $index . ' ' . $key,
$keys,
$value
)),
diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php
index 4ce2b0763536..ad278145afef 100644
--- a/system/Database/Postgre/Connection.php
+++ b/system/Database/Postgre/Connection.php
@@ -371,7 +371,7 @@ protected function _indexData(string $table): array
$obj = new stdClass();
$obj->name = $row->indexname;
$_fields = explode(',', preg_replace('/^.*\((.+?)\)$/', '$1', trim($row->indexdef)));
- $obj->fields = array_map(static fn ($v) => trim($v), $_fields);
+ $obj->fields = array_map(static fn ($v): string => trim($v), $_fields);
if (str_starts_with($row->indexdef, 'CREATE UNIQUE INDEX pk')) {
$obj->type = 'PRIMARY';
diff --git a/system/Database/Query.php b/system/Database/Query.php
index ba8e9066063f..36026817d4d1 100644
--- a/system/Database/Query.php
+++ b/system/Database/Query.php
@@ -418,7 +418,7 @@ public function debugToolbarDisplay(): string
*/
$search = '/\b(?:' . implode('|', $highlight) . ')\b(?![^(')]*'(?:(?:[^(')]*'){2})*[^(')]*$)/';
- return preg_replace_callback($search, static fn ($matches) => '' . str_replace(' ', ' ', $matches[0]) . '', $sql);
+ return preg_replace_callback($search, static fn ($matches): string => '' . str_replace(' ', ' ', $matches[0]) . '', $sql);
}
/**
diff --git a/system/Database/SQLSRV/Builder.php b/system/Database/SQLSRV/Builder.php
index c1272cdcf326..e320069e80bf 100644
--- a/system/Database/SQLSRV/Builder.php
+++ b/system/Database/SQLSRV/Builder.php
@@ -694,7 +694,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
$identityInFields = in_array($tableIdentity, $keys, true);
- $fieldNames = array_map(static fn ($columnName) => trim($columnName, '"'), $keys);
+ $fieldNames = array_map(static fn ($columnName): string => trim($columnName, '"'), $keys);
if (empty($constraints)) {
$tableIndexes = $this->db->getIndexData($table);
@@ -773,7 +773,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
$sql .= implode(
",\n",
array_map(
- static fn ($key, $value) => $key . ($value instanceof RawSql ?
+ static fn ($key, $value): string => $key . ($value instanceof RawSql ?
' = ' . $value :
" = {$alias}.{$value}"),
array_keys($updateFields),
@@ -787,7 +787,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
'(' . implode(
', ',
array_map(
- static fn ($columnName) => $columnName === $tableIdentity
+ static fn ($columnName): string => $columnName === $tableIdentity
? "CASE WHEN {$alias}.{$columnName} IS NULL THEN (SELECT "
. 'isnull(IDENT_CURRENT(\'' . $fullTableName . '\')+IDENT_INCR(\''
. $fullTableName . "'),1)) ELSE {$alias}.{$columnName} END"
diff --git a/system/Database/SQLSRV/Connection.php b/system/Database/SQLSRV/Connection.php
index 8ded4cd02098..6903f42eebac 100644
--- a/system/Database/SQLSRV/Connection.php
+++ b/system/Database/SQLSRV/Connection.php
@@ -257,7 +257,7 @@ protected function _indexData(string $table): array
$obj->name = $row->index_name;
$_fields = explode(',', trim($row->index_keys));
- $obj->fields = array_map(static fn ($v) => trim($v), $_fields);
+ $obj->fields = array_map(static fn ($v): string => trim($v), $_fields);
if (str_contains($row->index_description, 'primary key located on')) {
$obj->type = 'PRIMARY';
diff --git a/system/Database/SQLSRV/Forge.php b/system/Database/SQLSRV/Forge.php
index df3d55c779c4..18d792a6eea8 100644
--- a/system/Database/SQLSRV/Forge.php
+++ b/system/Database/SQLSRV/Forge.php
@@ -225,7 +225,7 @@ protected function _alterTable(string $alterType, string $table, $processedField
$sql = 'ALTER TABLE ' . $fullTable . ' DROP ';
- $fields = array_map(static fn ($item) => 'COLUMN [' . trim($item) . ']', (array) $columnNamesToDrop);
+ $fields = array_map(static fn ($item): string => 'COLUMN [' . trim($item) . ']', (array) $columnNamesToDrop);
return $sql . implode(',', $fields);
}
@@ -380,7 +380,7 @@ protected function _attributeType(array &$attributes)
// https://learn.microsoft.com/en-us/sql/t-sql/data-types/char-and-varchar-transact-sql?view=sql-server-ver16#remarks
$maxLength = max(
array_map(
- static fn ($value) => strlen($value),
+ static fn ($value): int => strlen($value),
$attributes['CONSTRAINT']
)
);
diff --git a/system/Database/SQLite3/Builder.php b/system/Database/SQLite3/Builder.php
index 15fc2529aa0d..744b64448fc6 100644
--- a/system/Database/SQLite3/Builder.php
+++ b/system/Database/SQLite3/Builder.php
@@ -143,7 +143,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
$constraints = $this->QBOptions['constraints'] ?? [];
if (empty($constraints)) {
- $fieldNames = array_map(static fn ($columnName) => trim($columnName, '`'), $keys);
+ $fieldNames = array_map(static fn ($columnName): string => trim($columnName, '`'), $keys);
$allIndexes = array_filter($this->db->getIndexData($table), static function ($index) use ($fieldNames): bool {
$hasAllFields = count(array_intersect($index->fields, $fieldNames)) === count($index->fields);
@@ -179,7 +179,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
$sql = 'INSERT INTO ' . $table . ' (';
- $sql .= implode(', ', array_map(static fn ($columnName) => $columnName, $keys));
+ $sql .= implode(', ', array_map(static fn ($columnName): string => $columnName, $keys));
$sql .= ")\n";
@@ -192,7 +192,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
$sql .= implode(
",\n",
array_map(
- static fn ($key, $value) => $key . ($value instanceof RawSql ?
+ static fn ($key, $value): string => $key . ($value instanceof RawSql ?
" = {$value}" :
" = {$alias}.{$value}"),
array_keys($updateFields),
@@ -265,8 +265,8 @@ protected function _deleteBatch(string $table, array $keys, array $values): stri
$data = implode(
" UNION ALL\n",
array_map(
- static fn ($value) => 'SELECT ' . implode(', ', array_map(
- static fn ($key, $index) => $index . ' ' . $key,
+ static fn ($value): string => 'SELECT ' . implode(', ', array_map(
+ static fn ($key, $index): string => $index . ' ' . $key,
$keys,
$value
)),
diff --git a/system/Database/SQLite3/Table.php b/system/Database/SQLite3/Table.php
index 5db002a1060b..61d4aee7535b 100644
--- a/system/Database/SQLite3/Table.php
+++ b/system/Database/SQLite3/Table.php
@@ -113,7 +113,7 @@ public function fromTable(string $table)
$this->keys = array_merge($this->keys, $this->formatKeys($this->db->getIndexData($table)));
// if primary key index exists twice then remove psuedo index name 'primary'.
- $primaryIndexes = array_filter($this->keys, static fn ($index) => $index['type'] === 'primary');
+ $primaryIndexes = array_filter($this->keys, static fn ($index): bool => $index['type'] === 'primary');
if ($primaryIndexes !== [] && count($primaryIndexes) > 1 && array_key_exists('primary', $this->keys)) {
unset($this->keys['primary']);
@@ -202,7 +202,7 @@ public function modifyColumn(array $fieldsToModify)
*/
public function dropPrimaryKey(): Table
{
- $primaryIndexes = array_filter($this->keys, static fn ($index) => strtolower($index['type']) === 'primary');
+ $primaryIndexes = array_filter($this->keys, static fn ($index): bool => strtolower($index['type']) === 'primary');
foreach (array_keys($primaryIndexes) as $key) {
unset($this->keys[$key]);
@@ -235,7 +235,7 @@ public function dropForeignKey(string $foreignName)
*/
public function addPrimaryKey(array $fields): Table
{
- $primaryIndexes = array_filter($this->keys, static fn ($index) => strtolower($index['type']) === 'primary');
+ $primaryIndexes = array_filter($this->keys, static fn ($index): bool => strtolower($index['type']) === 'primary');
// if primary key already exists we can't add another one
if ($primaryIndexes !== []) {
@@ -308,7 +308,7 @@ protected function createTable()
$this->keys = array_filter(
$this->keys,
- static fn ($index) => count(array_intersect($index['fields'], $fieldNames)) === count($index['fields'])
+ static fn ($index): bool => count(array_intersect($index['fields'], $fieldNames)) === count($index['fields'])
);
// Unique/Index keys
diff --git a/system/Debug/Toolbar/Collectors/Database.php b/system/Debug/Toolbar/Collectors/Database.php
index 1a923a35516b..32f7f07091b3 100644
--- a/system/Debug/Toolbar/Collectors/Database.php
+++ b/system/Debug/Toolbar/Collectors/Database.php
@@ -218,7 +218,7 @@ public function getTitleDetails(): string
$this->getConnections();
$queryCount = count(static::$queries);
- $uniqueCount = count(array_filter(static::$queries, static fn ($query) => $query['duplicate'] === false));
+ $uniqueCount = count(array_filter(static::$queries, static fn ($query): bool => $query['duplicate'] === false));
$connectionCount = count($this->connections);
return sprintf(
diff --git a/system/Entity/Entity.php b/system/Entity/Entity.php
index 464992af6251..ff2fba1f7062 100644
--- a/system/Entity/Entity.php
+++ b/system/Entity/Entity.php
@@ -181,7 +181,7 @@ public function toArray(bool $onlyChanged = false, bool $cast = true, bool $recu
{
$this->_cast = $cast;
- $keys = array_filter(array_keys($this->attributes), static fn ($key) => ! str_starts_with($key, '_'));
+ $keys = array_filter(array_keys($this->attributes), static fn ($key): bool => ! str_starts_with($key, '_'));
if (is_array($this->datamap)) {
$keys = array_unique(
diff --git a/system/Files/FileCollection.php b/system/Files/FileCollection.php
index f1310795867d..179bbc1d4997 100644
--- a/system/Files/FileCollection.php
+++ b/system/Files/FileCollection.php
@@ -108,7 +108,7 @@ final protected static function matchFiles(array $files, string $pattern): array
$pattern = "#\\A{$pattern}\\z#";
}
- return array_filter($files, static fn ($value) => (bool) preg_match($pattern, basename($value)));
+ return array_filter($files, static fn ($value): bool => (bool) preg_match($pattern, basename($value)));
}
// --------------------------------------------------------------------
diff --git a/system/HTTP/URI.php b/system/HTTP/URI.php
index d0d23a3d26ee..2b386797fecd 100644
--- a/system/HTTP/URI.php
+++ b/system/HTTP/URI.php
@@ -1021,7 +1021,7 @@ protected function filterPath(?string $path = null): string
// Encode characters
$path = preg_replace_callback(
'/(?:[^' . static::CHAR_UNRESERVED . ':@&=\+\$,\/;%]+|%(?![A-Fa-f0-9]{2}))/',
- static fn (array $matches) => rawurlencode($matches[0]),
+ static fn (array $matches): string => rawurlencode($matches[0]),
$path
);
@@ -1167,9 +1167,9 @@ protected function parseStr(string $query): array
$return = [];
$query = explode('&', $query);
- $params = array_map(static fn (string $chunk) => preg_replace_callback(
+ $params = array_map(static fn (string $chunk): ?string => preg_replace_callback(
'/^(?[^&=]+?)(?:\[[^&=]*\])?=(?[^&=]+)/',
- static fn (array $match) => str_replace($match['key'], bin2hex($match['key']), $match[0]),
+ static fn (array $match): string => str_replace($match['key'], bin2hex($match['key']), $match[0]),
urldecode($chunk)
), $query);
diff --git a/system/Helpers/Array/ArrayHelper.php b/system/Helpers/Array/ArrayHelper.php
index 4bbd34427fa1..fc5bc462956e 100644
--- a/system/Helpers/Array/ArrayHelper.php
+++ b/system/Helpers/Array/ArrayHelper.php
@@ -58,7 +58,7 @@ private static function convertToArray(string $index): array
);
return array_map(
- static fn ($key) => str_replace('\.', '.', $key),
+ static fn ($key): string => str_replace('\.', '.', $key),
$segments
);
}
@@ -96,7 +96,7 @@ private static function arraySearchDot(array $indexes, array $array)
$answer[] = self::arraySearchDot($indexes, $value);
}
- $answer = array_filter($answer, static fn ($value) => $value !== null);
+ $answer = array_filter($answer, static fn ($value): bool => $value !== null);
if ($answer !== []) {
// If array only has one element, we return that element for BC.
diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php
index 7e11388841f4..6e77a1f36b0c 100644
--- a/system/Helpers/form_helper.php
+++ b/system/Helpers/form_helper.php
@@ -739,7 +739,7 @@ function validation_show_error(string $field, string $template = 'single'): stri
$config = config(Validation::class);
$view = service('renderer');
- $errors = array_filter(validation_errors(), static fn ($key) => preg_match(
+ $errors = array_filter(validation_errors(), static fn ($key): false|int => preg_match(
'/^' . str_replace(['\.\*', '\*\.'], ['\..+', '.+\.'], preg_quote($field, '/')) . '$/',
$key
), ARRAY_FILTER_USE_KEY);
diff --git a/system/Language/Language.php b/system/Language/Language.php
index 1ab2c5269195..cbea4a53324e 100644
--- a/system/Language/Language.php
+++ b/system/Language/Language.php
@@ -206,11 +206,11 @@ protected function formatMessage($message, array $args = [])
$argsString = implode(
', ',
- array_map(static fn ($element) => '"' . $element . '"', $args)
+ array_map(static fn ($element): string => '"' . $element . '"', $args)
);
$argsUrlEncoded = implode(
', ',
- array_map(static fn ($element) => '"' . rawurlencode($element) . '"', $args)
+ array_map(static fn ($element): string => '"' . rawurlencode($element) . '"', $args)
);
log_message(
diff --git a/system/Router/AutoRouter.php b/system/Router/AutoRouter.php
index ce40f5cdc406..cad9ecbc1746 100644
--- a/system/Router/AutoRouter.php
+++ b/system/Router/AutoRouter.php
@@ -184,7 +184,7 @@ public function setTranslateURIDashes(bool $val = false): self
*/
private function scanControllers(array $segments): array
{
- $segments = array_filter($segments, static fn ($segment) => $segment !== '');
+ $segments = array_filter($segments, static fn ($segment): bool => $segment !== '');
// numerically reindex the array, removing gaps
$segments = array_values($segments);
diff --git a/system/Router/AutoRouterImproved.php b/system/Router/AutoRouterImproved.php
index 63cdd7702635..6160c0555dae 100644
--- a/system/Router/AutoRouterImproved.php
+++ b/system/Router/AutoRouterImproved.php
@@ -136,7 +136,7 @@ public function __construct(
private function createSegments(string $uri): array
{
$segments = explode('/', $uri);
- $segments = array_filter($segments, static fn ($segment) => $segment !== '');
+ $segments = array_filter($segments, static fn ($segment): bool => $segment !== '');
// numerically reindex the array, removing gaps
return array_values($segments);
@@ -209,7 +209,7 @@ private function searchLastDefaultController(): bool
}
$namespaces = array_map(
- fn ($segment) => $this->translateURI($segment),
+ fn ($segment): string => $this->translateURI($segment),
$segments
);
diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php
index 13cbba449989..faee291a8213 100644
--- a/system/Router/RouteCollection.php
+++ b/system/Router/RouteCollection.php
@@ -1504,7 +1504,7 @@ protected function create(string $verb, string $from, $to, ?array $options = nul
for ($i = (int) $options['offset'] + 1; $i < (int) $options['offset'] + 7; $i++) {
$to = preg_replace_callback(
'/\$X/',
- static fn ($m) => '$' . $i,
+ static fn ($m): string => '$' . $i,
$to,
1
);
diff --git a/system/Router/Router.php b/system/Router/Router.php
index 0cd1614991ee..4e8c08852f79 100644
--- a/system/Router/Router.php
+++ b/system/Router/Router.php
@@ -590,7 +590,7 @@ protected function validateRequest(array $segments): array
*/
protected function scanControllers(array $segments): array
{
- $segments = array_filter($segments, static fn ($segment) => $segment !== '');
+ $segments = array_filter($segments, static fn ($segment): bool => $segment !== '');
// numerically reindex the array, removing gaps
$segments = array_values($segments);
diff --git a/system/Test/ReflectionHelper.php b/system/Test/ReflectionHelper.php
index a1b7ee99c67f..988fe949004c 100644
--- a/system/Test/ReflectionHelper.php
+++ b/system/Test/ReflectionHelper.php
@@ -41,7 +41,7 @@ public static function getPrivateMethodInvoker($obj, $method)
$refMethod = new ReflectionMethod($obj, $method);
$obj = (gettype($obj) === 'object') ? $obj : null;
- return static fn (...$args) => $refMethod->invokeArgs($obj, $args);
+ return static fn (...$args): mixed => $refMethod->invokeArgs($obj, $args);
}
/**
diff --git a/system/Validation/DotArrayFilter.php b/system/Validation/DotArrayFilter.php
index c7a401e1589a..62da95cb61c7 100644
--- a/system/Validation/DotArrayFilter.php
+++ b/system/Validation/DotArrayFilter.php
@@ -32,7 +32,7 @@ public static function run(array $indexes, array $array): array
foreach ($indexes as $index) {
$segments = preg_split('/(? str_replace('\.', '.', $key), $segments);
+ $segments = array_map(static fn ($key): string => str_replace('\.', '.', $key), $segments);
$filteredArray = self::filter($segments, $array);
diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php
index c00329d670bb..93524663947e 100644
--- a/system/Validation/Validation.php
+++ b/system/Validation/Validation.php
@@ -176,7 +176,7 @@ public function run(?array $data = null, ?string $group = null, $dbGroup = null)
$values = array_filter(
$flattenedArray,
- static fn ($key) => preg_match(self::getRegex($field), $key),
+ static fn ($key): false|int => preg_match(self::getRegex($field), $key),
ARRAY_FILTER_USE_KEY
);
@@ -413,7 +413,7 @@ private function processIfExist(string $field, array $rules, array $data)
}
// Otherwise remove the if_exist rule and continue the process
- $rules = array_filter($rules, static fn ($rule) => $rule instanceof Closure || $rule !== 'if_exist');
+ $rules = array_filter($rules, static fn ($rule): bool => $rule instanceof Closure || $rule !== 'if_exist');
}
return $rules;
@@ -460,7 +460,7 @@ private function processPermitEmpty($value, array $rules, array $data)
}
}
- $rules = array_filter($rules, static fn ($rule) => $rule instanceof Closure || $rule !== 'permit_empty');
+ $rules = array_filter($rules, static fn ($rule): bool => $rule instanceof Closure || $rule !== 'permit_empty');
}
return $rules;
@@ -867,7 +867,7 @@ public function getError(?string $field = null): string
$errors = array_filter(
$this->getErrors(),
- static fn ($key) => preg_match(self::getRegex($field), $key),
+ static fn ($key): false|int => preg_match(self::getRegex($field), $key),
ARRAY_FILTER_USE_KEY
);
diff --git a/system/View/Table.php b/system/View/Table.php
index 9eb29578a6da..a063e71c5a85 100644
--- a/system/View/Table.php
+++ b/system/View/Table.php
@@ -228,13 +228,13 @@ public function addRow()
$missingKeys = array_diff_key($keyIndex, $tmpRow);
// Remove all keys which don't exist in $keyIndex
- $tmpRow = array_filter($tmpRow, static fn ($k) => array_key_exists($k, $keyIndex), ARRAY_FILTER_USE_KEY);
+ $tmpRow = array_filter($tmpRow, static fn ($k): bool => array_key_exists($k, $keyIndex), ARRAY_FILTER_USE_KEY);
// add missing keys to row, but use $this->emptyCells
- $tmpRow = array_merge($tmpRow, array_map(fn ($v) => ['data' => $this->emptyCells], $missingKeys));
+ $tmpRow = array_merge($tmpRow, array_map(fn ($v): array => ['data' => $this->emptyCells], $missingKeys));
// order keys by $keyIndex values
- uksort($tmpRow, static fn ($k1, $k2) => $keyIndex[$k1] <=> $keyIndex[$k2]);
+ uksort($tmpRow, static fn ($k1, $k2): int => $keyIndex[$k1] <=> $keyIndex[$k2]);
}
$this->rows[] = $tmpRow;
diff --git a/tests/_support/Config/Routes.php b/tests/_support/Config/Routes.php
index 9b3ead4fd65f..c6286056e017 100644
--- a/tests/_support/Config/Routes.php
+++ b/tests/_support/Config/Routes.php
@@ -15,7 +15,7 @@
// This is a simple file to include for testing the RouteCollection class.
$routes->add('testing', 'TestController::index', ['as' => 'testing-index']);
-$routes->get('closure', static fn () => 'closure test');
+$routes->get('closure', static fn (): string => 'closure test');
$routes->get('/', 'Blog::index', ['hostname' => 'blog.example.com']);
$routes->get('/', 'Sub::index', ['subdomain' => 'sub']);
$routes->get('/all', 'AllDomain::index', ['subdomain' => '*']);
diff --git a/tests/system/AutoReview/FrameworkCodeTest.php b/tests/system/AutoReview/FrameworkCodeTest.php
index b8b155bbbf28..7473d26e5880 100644
--- a/tests/system/AutoReview/FrameworkCodeTest.php
+++ b/tests/system/AutoReview/FrameworkCodeTest.php
@@ -136,7 +136,7 @@ static function (SplFileInfo $file) use ($directory): string {
$testClasses = array_filter(
$testClasses,
- static fn (string $class) => is_subclass_of($class, TestCase::class)
+ static fn (string $class): bool => is_subclass_of($class, TestCase::class)
);
sort($testClasses);
diff --git a/tests/system/Cache/Handlers/DummyHandlerTest.php b/tests/system/Cache/Handlers/DummyHandlerTest.php
index 1b6fa3aa773a..c9c8a0fa0937 100644
--- a/tests/system/Cache/Handlers/DummyHandlerTest.php
+++ b/tests/system/Cache/Handlers/DummyHandlerTest.php
@@ -42,7 +42,7 @@ public function testGet(): void
public function testRemember(): void
{
- $dummyHandler = $this->handler->remember('key', 2, static fn () => 'value');
+ $dummyHandler = $this->handler->remember('key', 2, static fn (): string => 'value');
$this->assertNull($dummyHandler);
}
diff --git a/tests/system/Cache/Handlers/FileHandlerTest.php b/tests/system/Cache/Handlers/FileHandlerTest.php
index 9a7213374dd2..47223198caad 100644
--- a/tests/system/Cache/Handlers/FileHandlerTest.php
+++ b/tests/system/Cache/Handlers/FileHandlerTest.php
@@ -135,7 +135,7 @@ public function testGet(): void
*/
public function testRemember(): void
{
- $this->handler->remember(self::$key1, 2, static fn () => 'value');
+ $this->handler->remember(self::$key1, 2, static fn (): string => 'value');
$this->assertSame('value', $this->handler->get(self::$key1));
$this->assertNull($this->handler->get(self::$dummy));
diff --git a/tests/system/Cache/Handlers/MemcachedHandlerTest.php b/tests/system/Cache/Handlers/MemcachedHandlerTest.php
index 45a44b64feff..36c8c220aa31 100644
--- a/tests/system/Cache/Handlers/MemcachedHandlerTest.php
+++ b/tests/system/Cache/Handlers/MemcachedHandlerTest.php
@@ -86,7 +86,7 @@ public function testGet(): void
*/
public function testRemember(): void
{
- $this->handler->remember(self::$key1, 2, static fn () => 'value');
+ $this->handler->remember(self::$key1, 2, static fn (): string => 'value');
$this->assertSame('value', $this->handler->get(self::$key1));
$this->assertNull($this->handler->get(self::$dummy));
diff --git a/tests/system/Cache/Handlers/PredisHandlerTest.php b/tests/system/Cache/Handlers/PredisHandlerTest.php
index 6d88d6e3f609..9b11c23b0683 100644
--- a/tests/system/Cache/Handlers/PredisHandlerTest.php
+++ b/tests/system/Cache/Handlers/PredisHandlerTest.php
@@ -91,7 +91,7 @@ public function testGet(): void
*/
public function testRemember(): void
{
- $this->handler->remember(self::$key1, 2, static fn () => 'value');
+ $this->handler->remember(self::$key1, 2, static fn (): string => 'value');
$this->assertSame('value', $this->handler->get(self::$key1));
$this->assertNull($this->handler->get(self::$dummy));
diff --git a/tests/system/Cache/Handlers/RedisHandlerTest.php b/tests/system/Cache/Handlers/RedisHandlerTest.php
index 8aa2339b06f8..0eee45f5704f 100644
--- a/tests/system/Cache/Handlers/RedisHandlerTest.php
+++ b/tests/system/Cache/Handlers/RedisHandlerTest.php
@@ -97,7 +97,7 @@ public function testGet(): void
*/
public function testRemember(): void
{
- $this->handler->remember(self::$key1, 2, static fn () => 'value');
+ $this->handler->remember(self::$key1, 2, static fn (): string => 'value');
$this->assertSame('value', $this->handler->get(self::$key1));
$this->assertNull($this->handler->get(self::$dummy));
diff --git a/tests/system/CodeIgniterTest.php b/tests/system/CodeIgniterTest.php
index 735aed389552..afddc7dbb30e 100644
--- a/tests/system/CodeIgniterTest.php
+++ b/tests/system/CodeIgniterTest.php
@@ -214,7 +214,7 @@ public function testControllersCanReturnString(): void
$routes = service('routes');
$routes->add(
'pages/(:segment)',
- static fn ($segment) => 'You want to see "' . esc($segment) . '" page.'
+ static fn ($segment): string => 'You want to see "' . esc($segment) . '" page.'
);
$router = service('router', $routes, service('incomingrequest'));
Services::injectMock('router', $router);
diff --git a/tests/system/Database/Builder/UnionTest.php b/tests/system/Database/Builder/UnionTest.php
index bd498e2e2cab..5711c6c3cbf7 100644
--- a/tests/system/Database/Builder/UnionTest.php
+++ b/tests/system/Database/Builder/UnionTest.php
@@ -47,7 +47,7 @@ public function testUnion(): void
$builder = $this->db->table('test');
- $builder->union(static fn ($builder) => $builder->from('test'));
+ $builder->union(static fn ($builder): BaseBuilder => $builder->from('test'));
$this->assertSame($expected, $this->buildSelect($builder));
}
@@ -85,7 +85,7 @@ public function testUnionSQLSRV(): void
$builder = $db->table('users');
- $builder->union(static fn ($builder) => $builder->from('users'));
+ $builder->union(static fn ($builder): BaseBuilder => $builder->from('users'));
$this->assertSame($expected, $this->buildSelect($builder));
}
diff --git a/tests/system/Database/Live/ForgeTest.php b/tests/system/Database/Live/ForgeTest.php
index 16ea6b528c89..8f76efd12b42 100644
--- a/tests/system/Database/Live/ForgeTest.php
+++ b/tests/system/Database/Live/ForgeTest.php
@@ -1707,7 +1707,7 @@ public function testProcessIndexes(): void
// check that db_actions_name key exists
$indexes = array_filter(
$allIndexes,
- static fn ($index) => ($index->name === 'db_actions_name')
+ static fn ($index): bool => ($index->name === 'db_actions_name')
&& ($index->fields === [0 => 'name'])
);
$this->assertCount(1, $indexes);
@@ -1715,7 +1715,7 @@ public function testProcessIndexes(): void
// check that db_actions_category_name key exists
$indexes = array_filter(
$allIndexes,
- static fn ($index) => ($index->name === 'db_actions_category_name')
+ static fn ($index): bool => ($index->name === 'db_actions_category_name')
&& ($index->fields === [0 => 'category', 1 => 'name'])
);
$this->assertCount(1, $indexes);
@@ -1723,7 +1723,7 @@ public function testProcessIndexes(): void
// check that the primary key exists
$indexes = array_filter(
$allIndexes,
- static fn ($index) => $index->type === 'PRIMARY'
+ static fn ($index): bool => $index->type === 'PRIMARY'
);
$this->assertCount(1, $indexes);
@@ -1755,7 +1755,7 @@ public function testProcessIndexesWithKeyOnly(): void
// check that db_actions_name key exists
$indexes = array_filter(
$allIndexes,
- static fn ($index) => ($index->name === 'db_actions_name')
+ static fn ($index): bool => ($index->name === 'db_actions_name')
&& ($index->fields === [0 => 'name'])
);
$this->assertCount(1, $indexes);
@@ -1781,7 +1781,7 @@ public function testProcessIndexesWithPrimaryKeyOnly(): void
// check that the primary key exists
$indexes = array_filter(
$allIndexes,
- static fn ($index) => $index->type === 'PRIMARY'
+ static fn ($index): bool => $index->type === 'PRIMARY'
);
$this->assertCount(1, $indexes);
diff --git a/tests/system/Debug/TimerTest.php b/tests/system/Debug/TimerTest.php
index 09bf0d535bee..c7b02678e4fd 100644
--- a/tests/system/Debug/TimerTest.php
+++ b/tests/system/Debug/TimerTest.php
@@ -157,7 +157,7 @@ public function testRecordFunctionWithReturn(): void
public function testRecordArrowFunction(): void
{
$timer = new Timer();
- $returnValue = $timer->record('longjohn', static fn () => strlen('CI4'));
+ $returnValue = $timer->record('longjohn', static fn (): int => strlen('CI4'));
$this->assertLessThan(0.1, $timer->getElapsedTime('longjohn'));
$this->assertSame(3, $returnValue);
@@ -196,7 +196,7 @@ public function testCommonWithNameExpectTimer(): void
public function testCommonNoNameCallableExpectTimer(): void
{
- $returnValue = timer(null, static fn () => strlen('CI4'));
+ $returnValue = timer(null, static fn (): int => strlen('CI4'));
$this->assertInstanceOf(Timer::class, $returnValue);
}
@@ -212,7 +212,7 @@ public function testCommonCallableExpectNoReturn(): void
public function testCommonCallableExpectWithReturn(): void
{
- $returnValue = timer('common', static fn () => strlen('CI4'));
+ $returnValue = timer('common', static fn (): int => strlen('CI4'));
$this->assertNotInstanceOf(Timer::class, $returnValue);
$this->assertSame(3, $returnValue);
diff --git a/tests/system/HTTP/ContentSecurityPolicyTest.php b/tests/system/HTTP/ContentSecurityPolicyTest.php
index 596fbfcf0b24..c1d90554fc7c 100644
--- a/tests/system/HTTP/ContentSecurityPolicyTest.php
+++ b/tests/system/HTTP/ContentSecurityPolicyTest.php
@@ -441,7 +441,7 @@ public function testBodyScriptNonce(): void
$result = $this->work($body);
$nonceStyle = array_filter(
$this->getPrivateProperty($this->csp, 'styleSrc'),
- static fn ($value) => str_starts_with($value, 'nonce-')
+ static fn ($value): bool => str_starts_with($value, 'nonce-')
);
$this->assertStringContainsString('nonce=', $this->response->getBody());
@@ -516,7 +516,7 @@ public function testBodyStyleNonce(): void
$result = $this->work($body);
$nonceScript = array_filter(
$this->getPrivateProperty($this->csp, 'scriptSrc'),
- static fn ($value) => str_starts_with($value, 'nonce-')
+ static fn ($value): bool => str_starts_with($value, 'nonce-')
);
$this->assertStringContainsString('nonce=', $this->response->getBody());
diff --git a/tests/system/Router/DefinedRouteCollectorTest.php b/tests/system/Router/DefinedRouteCollectorTest.php
index 3c1d29abc023..2ec354c88893 100644
--- a/tests/system/Router/DefinedRouteCollectorTest.php
+++ b/tests/system/Router/DefinedRouteCollectorTest.php
@@ -51,8 +51,8 @@ public function testCollect(): void
$routes->get('journals', 'Blogs');
$routes->get('100', 'Home::index');
$routes->get('product/(:num)', 'Catalog::productLookupByID/$1');
- $routes->get('feed', static fn () => 'A Closure route.');
- $routes->get('200', static fn () => 'A Closure route.');
+ $routes->get('feed', static fn (): string => 'A Closure route.');
+ $routes->get('200', static fn (): string => 'A Closure route.');
$routes->view('about', 'pages/about');
$collector = new DefinedRouteCollector($routes);
diff --git a/tests/system/Router/RouterTest.php b/tests/system/Router/RouterTest.php
index 5ce347e07f4c..4ad823dda8c3 100644
--- a/tests/system/Router/RouterTest.php
+++ b/tests/system/Router/RouterTest.php
@@ -68,8 +68,8 @@ private function createRouteCollection(?Routing $routingConfig = null): void
'posts/(:num)' => 'Blog::show/$1',
'posts/(:num)/edit' => 'Blog::edit/$1',
'books/(:num)/(:alpha)/(:num)' => 'Blog::show/$3/$1',
- 'closure/(:num)/(:alpha)' => static fn ($num, $str) => $num . '-' . $str,
- 'closure-dash/(:num)/(:alpha)' => static fn ($num, $str) => $num . '-' . $str,
+ 'closure/(:num)/(:alpha)' => static fn ($num, $str): string => $num . '-' . $str,
+ 'closure-dash/(:num)/(:alpha)' => static fn ($num, $str): string => $num . '-' . $str,
'{locale}/pages' => 'App\Pages::list_all',
'test/(:any)/lang/{locale}' => 'App\Pages::list_all',
'admin/admins' => 'App\Admin\Admins::list_all',
diff --git a/tests/system/Test/FeatureTestTraitTest.php b/tests/system/Test/FeatureTestTraitTest.php
index 47aaea07d1d6..349d1af233b9 100644
--- a/tests/system/Test/FeatureTestTraitTest.php
+++ b/tests/system/Test/FeatureTestTraitTest.php
@@ -54,7 +54,7 @@ public function testCallGet(): void
[
'GET',
'home',
- static fn () => 'Hello World',
+ static fn (): string => 'Hello World',
],
]);
$response = $this->get('home');
@@ -74,7 +74,7 @@ public function testCallGetAndUriString(): void
[
'GET',
'foo/bar/1/2/3',
- static fn () => 'Hello World',
+ static fn (): string => 'Hello World',
],
]);
$response = $this->get('foo/bar/1/2/3');
@@ -90,7 +90,7 @@ public function testCallGetAndFilterReturnsResponse(): void
[
'GET',
'admin',
- static fn () => 'Admin Area',
+ static fn (): string => 'Admin Area',
['filter' => 'test-redirectfilter'],
],
]);
@@ -123,7 +123,7 @@ public function testCallPost(): void
[
'POST',
'home',
- static fn () => 'Hello Mars',
+ static fn (): string => 'Hello Mars',
],
]);
$response = $this->post('home');
@@ -137,7 +137,7 @@ public function testCallPostWithBody(): void
[
'POST',
'home',
- static fn () => 'Hello ' . service('request')->getPost('foo') . '!',
+ static fn (): string => 'Hello ' . service('request')->getPost('foo') . '!',
],
]);
$response = $this->post('home', ['foo' => 'Mars']);
@@ -181,7 +181,7 @@ public function testCallPut(): void
[
'PUT',
'home',
- static fn () => 'Hello Pluto',
+ static fn (): string => 'Hello Pluto',
],
]);
$response = $this->put('home');
@@ -195,7 +195,7 @@ public function testCallPatch(): void
[
'PATCH',
'home',
- static fn () => 'Hello Jupiter',
+ static fn (): string => 'Hello Jupiter',
],
]);
$response = $this->patch('home');
@@ -209,7 +209,7 @@ public function testCallOptions(): void
[
'OPTIONS',
'home',
- static fn () => 'Hello George',
+ static fn (): string => 'Hello George',
],
]);
$response = $this->options('home');
@@ -223,7 +223,7 @@ public function testCallDelete(): void
[
'DELETE',
'home',
- static fn () => 'Hello Wonka',
+ static fn (): string => 'Hello Wonka',
],
]);
$response = $this->delete('home');
@@ -237,7 +237,7 @@ public function testSession(): void
[
'GET',
'home',
- static fn () => 'Home',
+ static fn (): string => 'Home',
],
])->withSession([
'fruit' => 'apple',
@@ -259,7 +259,7 @@ public function testWithSessionNull(): void
[
'GET',
'home',
- static fn () => 'Home',
+ static fn (): string => 'Home',
],
])->withSession()->get('home');
diff --git a/tests/system/Validation/RulesTest.php b/tests/system/Validation/RulesTest.php
index a7e3e985de87..b0b23c00f686 100644
--- a/tests/system/Validation/RulesTest.php
+++ b/tests/system/Validation/RulesTest.php
@@ -119,7 +119,7 @@ public static function provideIfExist(): iterable
],
// Testing with closure
[
- ['foo' => ['if_exist', static fn ($value) => true]],
+ ['foo' => ['if_exist', static fn ($value): bool => true]],
['foo' => []],
true,
],
@@ -299,7 +299,7 @@ public static function providePermitEmpty(): iterable
],
[
// Testing with closure
- ['foo' => ['permit_empty', static fn ($value) => true]],
+ ['foo' => ['permit_empty', static fn ($value): bool => true]],
['foo' => ''],
true,
],
diff --git a/tests/system/Validation/StrictRules/RulesTest.php b/tests/system/Validation/StrictRules/RulesTest.php
index 7589360d0efe..de06bfe576ec 100644
--- a/tests/system/Validation/StrictRules/RulesTest.php
+++ b/tests/system/Validation/StrictRules/RulesTest.php
@@ -91,7 +91,7 @@ public static function providePermitEmptyStrict(): iterable
],
// Testing with closure
[
- ['foo' => ['permit_empty', static fn ($value) => true]],
+ ['foo' => ['permit_empty', static fn ($value): bool => true]],
['foo' => ''],
true,
],
diff --git a/tests/system/Validation/ValidationTest.php b/tests/system/Validation/ValidationTest.php
index 5906e2ac5465..f6d7252dc1ff 100644
--- a/tests/system/Validation/ValidationTest.php
+++ b/tests/system/Validation/ValidationTest.php
@@ -284,7 +284,7 @@ public function testClosureRule(): void
{
$this->validation->setRules(
[
- 'foo' => ['required', static fn ($value) => $value === 'abc'],
+ 'foo' => ['required', static fn ($value): bool => $value === 'abc'],
],
[
// Errors
@@ -339,7 +339,7 @@ public function testClosureRuleWithLabel(): void
$this->validation->setRules([
'secret' => [
'label' => 'シークレット',
- 'rules' => ['required', static fn ($value) => $value === 'abc'],
+ 'rules' => ['required', static fn ($value): bool => $value === 'abc'],
'errors' => [
// Specify the array key for the closure rule.
1 => 'The {field} is invalid',
diff --git a/tests/system/View/ParserTest.php b/tests/system/View/ParserTest.php
index 33ff7880f893..27a3100ce862 100644
--- a/tests/system/View/ParserTest.php
+++ b/tests/system/View/ParserTest.php
@@ -797,7 +797,7 @@ public function testParserPluginNoParams(): void
public function testParserPluginClosure(): void
{
$config = $this->config;
- $config->plugins['hello'] = static fn (array $params = []) => 'Hello, ' . trim($params[0]);
+ $config->plugins['hello'] = static fn (array $params = []): string => 'Hello, ' . trim($params[0]);
$this->parser = new Parser($config, $this->viewsDir, $this->loader);
@@ -828,7 +828,7 @@ public function testParserPluginParams(): void
public function testParserSingleTag(): void
{
- $this->parser->addPlugin('hit:it', static fn () => 'Hip to the Hop', false);
+ $this->parser->addPlugin('hit:it', static fn (): string => 'Hip to the Hop', false);
$template = '{+ hit:it +}';
@@ -837,7 +837,7 @@ public function testParserSingleTag(): void
public function testParserSingleTagWithParams(): void
{
- $this->parser->addPlugin('hit:it', static fn (array $params = []) => "{$params['first']} to the {$params['last']}", false);
+ $this->parser->addPlugin('hit:it', static fn (array $params = []): string => "{$params['first']} to the {$params['last']}", false);
$template = '{+ hit:it first=foo last=bar +}';
@@ -846,7 +846,7 @@ public function testParserSingleTagWithParams(): void
public function testParserSingleTagWithSingleParams(): void
{
- $this->parser->addPlugin('hit:it', static fn (array $params = []) => "{$params[0]} to the {$params[1]}", false);
+ $this->parser->addPlugin('hit:it', static fn (array $params = []): string => "{$params[0]} to the {$params[1]}", false);
$template = '{+ hit:it foo bar +}';