Skip to content

Commit d61e33e

Browse files
authored
Merge pull request #8072 from kenjis/declare_strict_types
refactor: add `declare(strict_types=1)`
2 parents f9679ec + 5307da0 commit d61e33e

File tree

845 files changed

+1708
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

845 files changed

+1708
-24
lines changed

contributing/internals.md

Lines changed: 3 additions & 4 deletions

rector.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*
@@ -43,6 +45,7 @@
4345
use Rector\Set\ValueObject\LevelSetList;
4446
use Rector\Set\ValueObject\SetList;
4547
use Rector\Strict\Rector\If_\BooleanInIfConditionRuleFixerRector;
48+
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
4649
use Utils\Rector\PassStrictParameterToFunctionParameterRector;
4750
use Utils\Rector\RemoveErrorSuppressInTryCatchStmtsRector;
4851
use Utils\Rector\UnderscoreToCamelCaseVariableNameRector;
@@ -106,6 +109,19 @@
106109
__DIR__ . '/system/Session/Handlers',
107110
],
108111

112+
DeclareStrictTypesRector::class => [
113+
__DIR__ . '/app',
114+
__DIR__ . '/system/CodeIgniter.php',
115+
__DIR__ . '/system/Config/BaseConfig.php',
116+
__DIR__ . '/system/Commands/Generators/Views',
117+
__DIR__ . '/system/Pager/Views',
118+
__DIR__ . '/system/Test/ControllerTestTrait.php',
119+
__DIR__ . '/system/Validation/Views',
120+
__DIR__ . '/system/View/Parser.php',
121+
__DIR__ . '/tests/system/Debug/ExceptionsTest.php',
122+
__DIR__ . '/tests/system/View/Views',
123+
],
124+
109125
// use mt_rand instead of random_int on purpose on non-cryptographically random
110126
RandomFunctionRector::class,
111127

@@ -116,6 +132,7 @@
116132
$rectorConfig->importNames();
117133
$rectorConfig->removeUnusedImports();
118134

135+
$rectorConfig->rule(DeclareStrictTypesRector::class);
119136
$rectorConfig->rule(UnderscoreToCamelCaseVariableNameRector::class);
120137
$rectorConfig->rule(SimplifyUselessVariableRector::class);
121138
$rectorConfig->rule(RemoveAlwaysElseRector::class);

system/API/ResponseTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Autoloader/Autoloader.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Autoloader/FileLocator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Autoloader/FileLocatorCached.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Autoloader/FileLocatorInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/BaseModel.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/CLI/BaseCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/CLI/CLI.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/CLI/Commands.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/CLI/Console.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/CLI/Exceptions/CLIException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/CLI/GeneratorTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Cache/CacheFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Cache/CacheInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Cache/Exceptions/CacheException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Cache/Exceptions/ExceptionInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Cache/FactoriesCache.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Cache/FactoriesCache/FileVarExportHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Cache/Handlers/BaseHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Cache/Handlers/DummyHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Cache/Handlers/FileHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Cache/Handlers/MemcachedHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Cache/Handlers/PredisHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Cache/Handlers/RedisHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Cache/Handlers/WincacheHandler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Cache/ResponseCache.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/CodeIgniter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,8 @@ protected function runController($class)
919919
// This is a Web request or PHP CLI request
920920
$params = $this->router->params();
921921

922+
// The controller method param types may not be string.
923+
// So cannot set `declare(strict_types=1)` in this file.
922924
$output = method_exists($class, '_remap')
923925
? $class->_remap($this->method, ...$params)
924926
: $class->{$this->method}(...$params);

system/Commands/Cache/ClearCache.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Commands/Cache/InfoCache.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Commands/Database/CreateDatabase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Commands/Database/Migrate.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Commands/Database/MigrateRefresh.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Commands/Database/MigrateRollback.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Commands/Database/MigrateStatus.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Commands/Database/Seed.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Commands/Database/ShowTableInfo.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Commands/Encryption/GenerateKey.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Commands/Generators/CellGenerator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Commands/Generators/CommandGenerator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Commands/Generators/ConfigGenerator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Commands/Generators/ControllerGenerator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

system/Commands/Generators/EntityGenerator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This file is part of CodeIgniter 4 framework.
57
*

0 commit comments

Comments
 (0)