Skip to content

Commit 2c829f3

Browse files
authored
Merge pull request #8645 from kenjis/fix-phpstan-errors-in-app-and-tests
docs: fix phpstan ignored errors in app/ and admin/starter/tests/
2 parents 1c1aefd + 02b0ac8 commit 2c829f3

23 files changed

+92
-347
lines changed

admin/starter/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ExampleMigration extends Migration
88
{
99
protected $DBGroup = 'tests';
1010

11-
public function up()
11+
public function up(): void
1212
{
1313
$this->forge->addField('id');
1414
$this->forge->addField([
@@ -30,7 +30,7 @@ public function up()
3030
$this->forge->createTable('factories');
3131
}
3232

33-
public function down()
33+
public function down(): void
3434
{
3535
$this->forge->dropTable('factories');
3636
}

admin/starter/tests/_support/Database/Seeds/ExampleSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class ExampleSeeder extends Seeder
88
{
9-
public function run()
9+
public function run(): void
1010
{
1111
$factories = [
1212
[

admin/starter/tests/database/ExampleDatabaseTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class ExampleDatabaseTest extends CIUnitTestCase
1414

1515
protected $seed = ExampleSeeder::class;
1616

17-
public function testModelFindAll()
17+
public function testModelFindAll(): void
1818
{
1919
$model = new ExampleModel();
2020

@@ -25,7 +25,7 @@ public function testModelFindAll()
2525
$this->assertCount(3, $objects);
2626
}
2727

28-
public function testSoftDeleteLeavesRow()
28+
public function testSoftDeleteLeavesRow(): void
2929
{
3030
$model = new ExampleModel();
3131
$this->setPrivateProperty($model, 'useSoftDeletes', true);

admin/starter/tests/session/ExampleSessionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
final class ExampleSessionTest extends CIUnitTestCase
1010
{
11-
public function testSessionSimple()
11+
public function testSessionSimple(): void
1212
{
1313
$session = Services::session();
1414

admin/starter/tests/unit/HealthTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
*/
1111
final class HealthTest extends CIUnitTestCase
1212
{
13-
public function testIsDefinedAppPath()
13+
public function testIsDefinedAppPath(): void
1414
{
1515
$this->assertTrue(defined('APPPATH'));
1616
}
1717

18-
public function testBaseUrlHasBeenSet()
18+
public function testBaseUrlHasBeenSet(): void
1919
{
2020
$validation = Services::validation();
2121

app/Config/ContentSecurityPolicy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class ContentSecurityPolicy extends BaseConfig
122122
* The frame-src directive restricts the URLs which may
123123
* be loaded into nested browsing contexts.
124124
*
125-
* @var array|string|null
125+
* @var list<string>|string|null
126126
*/
127127
public $frameSrc;
128128

app/Config/Database.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class Database extends Config
2323

2424
/**
2525
* The default database connection.
26+
*
27+
* @var array<string, mixed>
2628
*/
2729
public array $default = [
2830
'DSN' => '',
@@ -48,6 +50,8 @@ class Database extends Config
4850
/**
4951
* This database connection is used when
5052
* running PHPUnit database tests.
53+
*
54+
* @var array<string, mixed>
5155
*/
5256
public array $tests = [
5357
'DSN' => '',

app/Config/Exceptions.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class Exceptions extends BaseConfig
3030
* --------------------------------------------------------------------------
3131
* Any status codes here will NOT be logged if logging is turned on.
3232
* By default, only 404 (Page Not Found) exceptions are ignored.
33+
*
34+
* @var list<int>
3335
*/
3436
public array $ignoreCodes = [404];
3537

@@ -51,6 +53,8 @@ class Exceptions extends BaseConfig
5153
* Any data that you would like to hide from the debug trace.
5254
* In order to specify 2 levels, use "/" to separate.
5355
* ex. ['server', 'setup/password', 'secret_token']
56+
*
57+
* @var list<string>
5458
*/
5559
public array $sensitiveDataInTrace = [];
5660

app/Config/Filters.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class Filters extends BaseConfig
5555
* If you use this, you should disable auto-routing because auto-routing
5656
* permits any HTTP method to access a controller. Accessing the controller
5757
* with a method you don't expect could bypass the filter.
58+
*
59+
* @var array<string, list<string>>
5860
*/
5961
public array $methods = [];
6062

@@ -64,6 +66,8 @@ class Filters extends BaseConfig
6466
*
6567
* Example:
6668
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
69+
*
70+
* @var array<string, array<string, list<string>>>
6771
*/
6872
public array $filters = [];
6973
}

app/Config/Logger.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Logger extends BaseConfig
3636
* For a live site you'll usually enable Critical or higher (3) to be logged otherwise
3737
* your log files will fill up very fast.
3838
*
39-
* @var array|int
39+
* @var int|list<int>
4040
*/
4141
public $threshold = (ENVIRONMENT === 'production') ? 4 : 9;
4242

@@ -72,6 +72,8 @@ class Logger extends BaseConfig
7272
*
7373
* Handlers are executed in the order defined in this array, starting with
7474
* the handler on top and continuing down.
75+
*
76+
* @var array<class-string, array<string, int|list<string>|string>>
7577
*/
7678
public array $handlers = [
7779
/*

app/Config/Mimes.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class Mimes
2222
{
2323
/**
2424
* Map of extensions to mime types.
25+
*
26+
* @var array<string, list<string>|string>
2527
*/
2628
public static array $mimes = [
2729
'hqx' => [

app/Config/Routing.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class Routing extends BaseRouting
2424
* found taking precedence.
2525
*
2626
* Default: APPPATH . 'Config/Routes.php'
27+
*
28+
* @var list<string>
2729
*/
2830
public array $routeFiles = [
2931
APPPATH . 'Config/Routes.php',
@@ -106,7 +108,7 @@ class Routing extends BaseRouting
106108
* 'blog' => 'Acme\Blog\Controllers',
107109
* ]
108110
*
109-
* @var array [ uri_segment => namespace ]
111+
* @var array<string, string>
110112
*/
111113
public array $moduleRoutes = [];
112114
}

app/Config/Toolbar.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Toolbar extends BaseConfig
3131
* List of toolbar collectors that will be called when Debug Toolbar
3232
* fires up and collects data from.
3333
*
34-
* @var list<string>
34+
* @var list<class-string>
3535
*/
3636
public array $collectors = [
3737
Timers::class,
@@ -99,6 +99,8 @@ class Toolbar extends BaseConfig
9999
* We restrict the values to keep performance as high as possible.
100100
*
101101
* NOTE: The ROOTPATH will be prepended to all values.
102+
*
103+
* @var list<string>
102104
*/
103105
public array $watchedDirectories = [
104106
'app',
@@ -111,6 +113,8 @@ class Toolbar extends BaseConfig
111113
*
112114
* Contains an array of file extensions that will be watched for changes and
113115
* used to determine if the hot-reload feature should reload the page or not.
116+
*
117+
* @var list<string>
114118
*/
115119
public array $watchedExtensions = [
116120
'php', 'css', 'js', 'html', 'svg', 'json', 'env',

app/Controllers/BaseController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class BaseController extends Controller
3333
* class instantiation. These helpers will be available
3434
* to all other controllers that extend BaseController.
3535
*
36-
* @var array
36+
* @var list<string>
3737
*/
3838
protected $helpers = [];
3939

0 commit comments

Comments
 (0)