Skip to content

Commit d14dce8

Browse files
authored
Merge pull request #9008 from samsonasik/refactor-closure-void
refactor: enable AddClosureVoidReturnTypeWhereNoReturnRector to add void return on closure
2 parents fc5dd88 + 9e4777a commit d14dce8

File tree

14 files changed

+18
-16
lines changed

14 files changed

+18
-16
lines changed

app/Config/Events.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Events::on('create', [$myInstance, 'myMethod']);
2424
*/
2525

26-
Events::on('pre_system', static function () {
26+
Events::on('pre_system', static function (): void {
2727
if (ENVIRONMENT !== 'testing') {
2828
if (ini_get('zlib.output_compression')) {
2929
throw FrameworkException::forEnabledZlibOutputCompression();
@@ -47,7 +47,7 @@
4747
Services::toolbar()->respond();
4848
// Hot Reload route - for framework use on the hot reloader.
4949
if (ENVIRONMENT === 'development') {
50-
Services::routes()->get('__hot-reload', static function () {
50+
Services::routes()->get('__hot-reload', static function (): void {
5151
(new HotReloader())->run();
5252
});
5353
}

rector.php

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
5757
use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector;
5858
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
59+
use Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector;
5960
use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector;
6061
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
6162
use Utils\Rector\PassStrictParameterToFunctionParameterRector;
@@ -217,6 +218,7 @@
217218
SingleInArrayToCompareRector::class,
218219
VersionCompareFuncCallToConstantRector::class,
219220
ExplicitBoolCompareRector::class,
221+
AddClosureVoidReturnTypeWhereNoReturnRector::class,
220222
])
221223
->withConfiguredRule(StringClassNameToClassConstantRector::class, [
222224
// keep '\\' prefix string on string '\Foo\Bar'

system/Autoloader/Autoloader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ private function autoloadKint(): void
507507
{
508508
// If we have KINT_DIR it means it's already loaded via composer
509509
if (! defined('KINT_DIR')) {
510-
spl_autoload_register(function ($class) {
510+
spl_autoload_register(function ($class): void {
511511
$class = explode('\\', $class);
512512

513513
if (array_shift($class) !== 'Kint') {

system/CLI/CLI.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ public static function wrap(?string $string = null, int $max = 0, int $padLeft =
857857

858858
$first = true;
859859

860-
array_walk($lines, static function (&$line) use ($padLeft, &$first) {
860+
array_walk($lines, static function (&$line) use ($padLeft, &$first): void {
861861
if (! $first) {
862862
$line = str_repeat(' ', $padLeft) . $line;
863863
} else {

system/CodeIgniter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ private function autoloadKint(): void
253253
{
254254
// If we have KINT_DIR it means it's already loaded via composer
255255
if (! defined('KINT_DIR')) {
256-
spl_autoload_register(function ($class) {
256+
spl_autoload_register(function ($class): void {
257257
$class = explode('\\', $class);
258258

259259
if (array_shift($class) !== 'Kint') {

system/DataConverter/DataConverter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function reconstruct(string $classname, array $row): object
140140
return $classObj;
141141
}
142142

143-
$classSet = Closure::bind(function ($key, $value) {
143+
$classSet = Closure::bind(function ($key, $value): void {
144144
$this->{$key} = $value;
145145
}, $classObj, $classname);
146146

system/Database/Postgre/Builder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function replace(?array $set = null)
159159
$table = $this->QBFrom[0];
160160
$set = $this->binds;
161161

162-
array_walk($set, static function (array &$item) {
162+
array_walk($set, static function (array &$item): void {
163163
$item = $item[0];
164164
});
165165

system/Database/Query.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function setQuery(string $sql, $binds = null, bool $setEscape = true)
118118
}
119119

120120
if ($setEscape) {
121-
array_walk($binds, static function (&$item) {
121+
array_walk($binds, static function (&$item): void {
122122
$item = [
123123
$item,
124124
true,
@@ -141,7 +141,7 @@ public function setQuery(string $sql, $binds = null, bool $setEscape = true)
141141
public function setBinds(array $binds, bool $setEscape = true)
142142
{
143143
if ($setEscape) {
144-
array_walk($binds, static function (&$item) {
144+
array_walk($binds, static function (&$item): void {
145145
$item = [$item, true];
146146
});
147147
}

system/Database/SQLSRV/Builder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ protected function _replace(string $table, array $keys, array $values): string
420420

421421
// Get the binds
422422
$binds = $this->binds;
423-
array_walk($binds, static function (&$item) {
423+
array_walk($binds, static function (&$item): void {
424424
$item = $item[0];
425425
});
426426

system/Database/SQLite3/Result.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ protected function fetchObject(string $className = 'stdClass')
147147
return $classObj->injectRawData($row);
148148
}
149149

150-
$classSet = Closure::bind(function ($key, $value) {
150+
$classSet = Closure::bind(function ($key, $value): void {
151151
$this->{$key} = $value;
152152
}, $classObj, $className);
153153

system/Debug/Toolbar.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ protected function collectTimelineData($collectors): array
294294
array_multisort(...$sortArray);
295295

296296
// Add end time to each element
297-
array_walk($data, static function (&$row) {
297+
array_walk($data, static function (&$row): void {
298298
$row['end'] = $row['start'] + $row['duration'];
299299
});
300300

system/Filters/Filters.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ private function getCleanName(string $name): array
522522
[$name, $arguments] = explode(':', $name);
523523

524524
$arguments = explode(',', $arguments);
525-
array_walk($arguments, static function (&$item) {
525+
array_walk($arguments, static function (&$item): void {
526526
$item = trim($item);
527527
});
528528
}

system/HTTP/IncomingRequest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ public function getJsonVar($index = null, bool $assoc = false, ?int $filter = nu
586586
) {
587587
if (is_array($data)) {
588588
// Iterate over array and append filter and flags
589-
array_walk_recursive($data, static function (&$val) use ($filter, $flags) {
589+
array_walk_recursive($data, static function (&$val) use ($filter, $flags): void {
590590
$valType = gettype($val);
591591
$val = filter_var($val, $filter, $flags);
592592

@@ -672,7 +672,7 @@ public function getRawInputVar($index = null, ?int $filter = null, $flags = null
672672
)
673673
) {
674674
// Iterate over array and append filter and flags
675-
array_walk_recursive($output, static function (&$val) use ($filter, $flags) {
675+
array_walk_recursive($output, static function (&$val) use ($filter, $flags): void {
676676
$val = filter_var($val, $filter, $flags);
677677
});
678678

system/HTTP/RequestTrait.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public function fetchGlobal(string $name, $index = null, ?int $filter = null, $f
322322
)
323323
) {
324324
// Iterate over array and append filter and flags
325-
array_walk_recursive($value, static function (&$val) use ($filter, $flags) {
325+
array_walk_recursive($value, static function (&$val) use ($filter, $flags): void {
326326
$val = filter_var($val, $filter, $flags);
327327
});
328328

0 commit comments

Comments
 (0)