Skip to content

Commit eea72bb

Browse files
committed
refactor: fix missingType.property errors
1 parent c42ffa8 commit eea72bb

10 files changed

Lines changed: 103 additions & 282 deletions

File tree

system/Database/OCI8/Connection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ class Connection extends BaseConnection
5353
'rownum',
5454
];
5555

56+
/**
57+
* @var array<string, string>
58+
*/
5659
protected $validDSNs = [
5760
// TNS
5861
'tns' => '/^\(DESCRIPTION=(\(.+\)){2,}\)$/',
@@ -79,6 +82,8 @@ class Connection extends BaseConnection
7982
*
8083
* Used by storedProcedure() to prevent execute() from
8184
* re-setting the statement ID.
85+
*
86+
* @var bool
8287
*/
8388
protected $resetStmtId = true;
8489

system/Database/Postgre/Connection.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,24 @@ class Connection extends BaseConnection
5151
*/
5252
public $escapeChar = '"';
5353

54+
/**
55+
* @var string|null
56+
*/
5457
protected $connect_timeout;
58+
59+
/**
60+
* @var string|null
61+
*/
5562
protected $options;
63+
64+
/**
65+
* @var string|null
66+
*/
5667
protected $sslmode;
68+
69+
/**
70+
* @var string|null
71+
*/
5772
protected $service;
5873

5974
/**

tests/system/Config/FactoriesTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ public function testUsesConfigOptions(): void
8787
{
8888
// Simulate having a $widgets property in App\Config\Factory
8989
$config = new class () extends Factory {
90-
public $widgets = ['bar' => 'bam'];
90+
/**
91+
* @var array<string, string>
92+
*/
93+
public array $widgets = ['bar' => 'bam'];
9194
};
9295
Factories::injectMock('config', Factory::class, $config);
9396

tests/system/Config/fixtures/RegistrarConfig.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@
1515

1616
class RegistrarConfig extends BaseConfig
1717
{
18-
public $foo = 'bar';
19-
public $bar = [
18+
public string $foo = 'bar';
19+
20+
/**
21+
* @var list<string>
22+
*/
23+
public array $bar = [
2024
'baz',
2125
];
2226
}

tests/system/Config/fixtures/SimpleConfig.php

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,63 @@
1515

1616
class SimpleConfig extends BaseConfig
1717
{
18-
public $QZERO;
19-
public $QZEROSTR;
20-
public $QEMPTYSTR;
21-
public $QFALSE;
22-
public $first = 'foo';
23-
public $second = 'bar';
24-
public $FOO;
25-
public $onedeep;
26-
public $default = [
18+
public ?string $QZERO = null;
19+
public ?string $QZEROSTR = null;
20+
public ?string $QEMPTYSTR = null;
21+
public bool|string|null $QFALSE = null;
22+
public string $first = 'foo';
23+
public string $second = 'bar';
24+
public ?string $FOO = null;
25+
public ?string $onedeep = null;
26+
27+
/**
28+
* @var array<string, string|null>
29+
*/
30+
public array $default = [
2731
'name' => null,
2832
];
29-
public $simple = [
33+
34+
/**
35+
* @var array<string, string|null>
36+
*/
37+
public array $simple = [
3038
'name' => null,
3139
];
3240

3341
// properties for environment override testing
34-
public $alpha = 'one';
35-
public $bravo = 'two';
36-
public $charlie = 'three';
37-
public $delta = 'four';
38-
public $echo = '';
39-
public $foxtrot = 'false';
40-
public $fruit = 'pineapple';
41-
public $dessert = '';
42-
public $golf = 18;
43-
public $crew = [
42+
public string $alpha = 'one';
43+
public string $bravo = 'two';
44+
public string $charlie = 'three';
45+
public string $delta = 'four';
46+
public string $echo = '';
47+
public bool|string $foxtrot = 'false';
48+
public string $fruit = 'pineapple';
49+
public string $dessert = '';
50+
public int $golf = 18;
51+
52+
/**
53+
* @var array<string, bool|string>
54+
*/
55+
public array $crew = [
4456
'captain' => 'Kirk',
4557
'science' => 'Spock',
4658
'doctor' => 'Bones',
4759
'comms' => 'Uhuru',
4860
];
49-
public $shortie;
50-
public $longie;
51-
public $onedeep_value;
52-
public $one_deep = [
61+
62+
public ?string $shortie = null;
63+
public ?string $longie = null;
64+
public ?string $onedeep_value = null;
65+
66+
/**
67+
* @var array<string, string|null>
68+
*/
69+
public array $one_deep = [
5370
'under_deep' => null,
5471
];
55-
public $float = 12.34;
56-
public $int = 1234;
57-
public $password = 'secret';
58-
public ?int $size = null;
72+
73+
public float $float = 12.34;
74+
public int $int = 1234;
75+
public string $password = 'secret';
76+
public ?int $size = null;
5977
}

tests/system/Database/Live/ConnectTest.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,20 @@ final class ConnectTest extends CIUnitTestCase
2828
{
2929
use DatabaseTestTrait;
3030

31-
private $group1;
32-
private $group2;
33-
private $tests;
31+
/**
32+
* @var array<string, mixed>
33+
*/
34+
private array $group1 = [];
35+
36+
/**
37+
* @var array<string, mixed>
38+
*/
39+
private array $group2 = [];
40+
41+
/**
42+
* @var array<string, mixed>
43+
*/
44+
private array $tests = [];
3445

3546
protected function setUp(): void
3647
{

tests/system/Database/Live/GetTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,13 @@ public function testGetRowWithReturnType(): void
254254
public function testGetRowWithCustomReturnType(): void
255255
{
256256
$testClass = new class () {
257-
public $id;
258-
public $name;
259-
public $email;
260-
public $country;
261-
public $created_at;
262-
public $updated_at;
263-
public $deleted_at;
257+
public mixed $id = null;
258+
public mixed $name = null;
259+
public mixed $email = null;
260+
public mixed $country = null;
261+
public mixed $created_at = null;
262+
public mixed $updated_at = null;
263+
public mixed $deleted_at = null;
264264
};
265265

266266
$user = $this->db->table('user')->get()->getRow(0, $testClass::class);

tests/system/Database/Live/MySQLi/NumberNativeTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ final class NumberNativeTest extends CIUnitTestCase
2727
{
2828
use DatabaseTestTrait;
2929

30-
private $tests;
30+
/**
31+
* @var array<string, mixed>
32+
*/
33+
private array $tests = [];
34+
3135
protected $refresh = true;
3236
protected $seed = CITestSeeder::class;
3337

utils/phpstan-baseline/loader.neon

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 1527 errors
1+
# total 1480 errors
22

33
includes:
44
- argument.type.neon
@@ -12,7 +12,6 @@ includes:
1212
- method.notFound.neon
1313
- missingType.iterableValue.neon
1414
- missingType.parameter.neon
15-
- missingType.property.neon
1615
- nullCoalesce.property.neon
1716
- property.defaultValue.neon
1817
- property.nonObject.neon

0 commit comments

Comments
 (0)