diff --git a/app/Config/Events.php b/app/Config/Events.php index 993abd24ebc7..62a7b86d46c8 100644 --- a/app/Config/Events.php +++ b/app/Config/Events.php @@ -23,7 +23,7 @@ * Events::on('create', [$myInstance, 'myMethod']); */ -Events::on('pre_system', static function () { +Events::on('pre_system', static function (): void { if (ENVIRONMENT !== 'testing') { if (ini_get('zlib.output_compression')) { throw FrameworkException::forEnabledZlibOutputCompression(); @@ -47,7 +47,7 @@ Services::toolbar()->respond(); // Hot Reload route - for framework use on the hot reloader. if (ENVIRONMENT === 'development') { - Services::routes()->get('__hot-reload', static function () { + Services::routes()->get('__hot-reload', static function (): void { (new HotReloader())->run(); }); } diff --git a/rector.php b/rector.php index 6eeabe396a04..c3c43879019d 100644 --- a/rector.php +++ b/rector.php @@ -56,6 +56,7 @@ use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector; use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector; +use Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector; use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector; use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector; use Utils\Rector\PassStrictParameterToFunctionParameterRector; @@ -217,6 +218,7 @@ SingleInArrayToCompareRector::class, VersionCompareFuncCallToConstantRector::class, ExplicitBoolCompareRector::class, + AddClosureVoidReturnTypeWhereNoReturnRector::class, ]) ->withConfiguredRule(StringClassNameToClassConstantRector::class, [ // keep '\\' prefix string on string '\Foo\Bar' diff --git a/system/Autoloader/Autoloader.php b/system/Autoloader/Autoloader.php index 78d31eae0d7f..28c183f12552 100644 --- a/system/Autoloader/Autoloader.php +++ b/system/Autoloader/Autoloader.php @@ -507,7 +507,7 @@ private function autoloadKint(): void { // If we have KINT_DIR it means it's already loaded via composer if (! defined('KINT_DIR')) { - spl_autoload_register(function ($class) { + spl_autoload_register(function ($class): void { $class = explode('\\', $class); if (array_shift($class) !== 'Kint') { diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index 6adc9f839367..bfe1511eed02 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -857,7 +857,7 @@ public static function wrap(?string $string = null, int $max = 0, int $padLeft = $first = true; - array_walk($lines, static function (&$line) use ($padLeft, &$first) { + array_walk($lines, static function (&$line) use ($padLeft, &$first): void { if (! $first) { $line = str_repeat(' ', $padLeft) . $line; } else { diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index 95feae8160a1..0bb101cc7990 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -253,7 +253,7 @@ private function autoloadKint(): void { // If we have KINT_DIR it means it's already loaded via composer if (! defined('KINT_DIR')) { - spl_autoload_register(function ($class) { + spl_autoload_register(function ($class): void { $class = explode('\\', $class); if (array_shift($class) !== 'Kint') { diff --git a/system/DataConverter/DataConverter.php b/system/DataConverter/DataConverter.php index b79ede5b08ff..43b42a08bbdf 100644 --- a/system/DataConverter/DataConverter.php +++ b/system/DataConverter/DataConverter.php @@ -140,7 +140,7 @@ public function reconstruct(string $classname, array $row): object return $classObj; } - $classSet = Closure::bind(function ($key, $value) { + $classSet = Closure::bind(function ($key, $value): void { $this->{$key} = $value; }, $classObj, $classname); diff --git a/system/Database/Postgre/Builder.php b/system/Database/Postgre/Builder.php index 857760930275..1071dfedf06b 100644 --- a/system/Database/Postgre/Builder.php +++ b/system/Database/Postgre/Builder.php @@ -159,7 +159,7 @@ public function replace(?array $set = null) $table = $this->QBFrom[0]; $set = $this->binds; - array_walk($set, static function (array &$item) { + array_walk($set, static function (array &$item): void { $item = $item[0]; }); diff --git a/system/Database/Query.php b/system/Database/Query.php index 11085a91f6a0..ba8e9066063f 100644 --- a/system/Database/Query.php +++ b/system/Database/Query.php @@ -118,7 +118,7 @@ public function setQuery(string $sql, $binds = null, bool $setEscape = true) } if ($setEscape) { - array_walk($binds, static function (&$item) { + array_walk($binds, static function (&$item): void { $item = [ $item, true, @@ -141,7 +141,7 @@ public function setQuery(string $sql, $binds = null, bool $setEscape = true) public function setBinds(array $binds, bool $setEscape = true) { if ($setEscape) { - array_walk($binds, static function (&$item) { + array_walk($binds, static function (&$item): void { $item = [$item, true]; }); } diff --git a/system/Database/SQLSRV/Builder.php b/system/Database/SQLSRV/Builder.php index e2301f7ee2ab..a6d0b8e85ccd 100644 --- a/system/Database/SQLSRV/Builder.php +++ b/system/Database/SQLSRV/Builder.php @@ -420,7 +420,7 @@ protected function _replace(string $table, array $keys, array $values): string // Get the binds $binds = $this->binds; - array_walk($binds, static function (&$item) { + array_walk($binds, static function (&$item): void { $item = $item[0]; }); diff --git a/system/Database/SQLite3/Result.php b/system/Database/SQLite3/Result.php index 70d8dc47d2b6..aa5abf28682a 100644 --- a/system/Database/SQLite3/Result.php +++ b/system/Database/SQLite3/Result.php @@ -147,7 +147,7 @@ protected function fetchObject(string $className = 'stdClass') return $classObj->injectRawData($row); } - $classSet = Closure::bind(function ($key, $value) { + $classSet = Closure::bind(function ($key, $value): void { $this->{$key} = $value; }, $classObj, $className); diff --git a/system/Debug/Toolbar.php b/system/Debug/Toolbar.php index 115016225062..9f20f987f59c 100644 --- a/system/Debug/Toolbar.php +++ b/system/Debug/Toolbar.php @@ -294,7 +294,7 @@ protected function collectTimelineData($collectors): array array_multisort(...$sortArray); // Add end time to each element - array_walk($data, static function (&$row) { + array_walk($data, static function (&$row): void { $row['end'] = $row['start'] + $row['duration']; }); diff --git a/system/Filters/Filters.php b/system/Filters/Filters.php index d8e22835e2ed..1255e0c4055d 100644 --- a/system/Filters/Filters.php +++ b/system/Filters/Filters.php @@ -522,7 +522,7 @@ private function getCleanName(string $name): array [$name, $arguments] = explode(':', $name); $arguments = explode(',', $arguments); - array_walk($arguments, static function (&$item) { + array_walk($arguments, static function (&$item): void { $item = trim($item); }); } diff --git a/system/HTTP/IncomingRequest.php b/system/HTTP/IncomingRequest.php index ec13e40f6ff5..c905de0a3ae3 100644 --- a/system/HTTP/IncomingRequest.php +++ b/system/HTTP/IncomingRequest.php @@ -586,7 +586,7 @@ public function getJsonVar($index = null, bool $assoc = false, ?int $filter = nu ) { if (is_array($data)) { // Iterate over array and append filter and flags - array_walk_recursive($data, static function (&$val) use ($filter, $flags) { + array_walk_recursive($data, static function (&$val) use ($filter, $flags): void { $valType = gettype($val); $val = filter_var($val, $filter, $flags); @@ -672,7 +672,7 @@ public function getRawInputVar($index = null, ?int $filter = null, $flags = null ) ) { // Iterate over array and append filter and flags - array_walk_recursive($output, static function (&$val) use ($filter, $flags) { + array_walk_recursive($output, static function (&$val) use ($filter, $flags): void { $val = filter_var($val, $filter, $flags); }); diff --git a/system/HTTP/RequestTrait.php b/system/HTTP/RequestTrait.php index cfdc52b55f69..43a4f23a0e87 100644 --- a/system/HTTP/RequestTrait.php +++ b/system/HTTP/RequestTrait.php @@ -322,7 +322,7 @@ public function fetchGlobal(string $name, $index = null, ?int $filter = null, $f ) ) { // Iterate over array and append filter and flags - array_walk_recursive($value, static function (&$val) use ($filter, $flags) { + array_walk_recursive($value, static function (&$val) use ($filter, $flags): void { $val = filter_var($val, $filter, $flags); });