Skip to content

Commit a5c7f77

Browse files
authored
Merge pull request #9107 from kenjis/fix-EntityTest
test: fix EntityTest PHPStan errors
2 parents 5a340d0 + 820aaec commit a5c7f77

File tree

3 files changed

+17
-221
lines changed

3 files changed

+17
-221
lines changed

phpstan-baseline.php

Lines changed: 0 additions & 204 deletions
Original file line numberDiff line numberDiff line change
@@ -5143,18 +5143,6 @@
51435143
'count' => 1,
51445144
'path' => __DIR__ . '/system/Entity/Entity.php',
51455145
];
5146-
$ignoreErrors[] = [
5147-
// identifier: missingType.iterableValue
5148-
'message' => '#^Property CodeIgniter\\\\Entity\\\\Entity\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
5149-
'count' => 1,
5150-
'path' => __DIR__ . '/system/Entity/Entity.php',
5151-
];
5152-
$ignoreErrors[] = [
5153-
// identifier: missingType.iterableValue
5154-
'message' => '#^Property CodeIgniter\\\\Entity\\\\Entity\\:\\:\\$original type has no value type specified in iterable type array\\.$#',
5155-
'count' => 1,
5156-
'path' => __DIR__ . '/system/Entity/Entity.php',
5157-
];
51585146
$ignoreErrors[] = [
51595147
// identifier: codeigniter.configArgumentInstanceof
51605148
'message' => '#^Argument \\#1 \\$name \\(\'Config\\\\\\\\Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#',
@@ -10987,12 +10975,6 @@
1098710975
'count' => 1,
1098810976
'path' => __DIR__ . '/tests/_support/Entity/CustomUser.php',
1098910977
];
10990-
$ignoreErrors[] = [
10991-
// identifier: missingType.iterableValue
10992-
'message' => '#^Property Tests\\\\Support\\\\Entity\\\\User\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
10993-
'count' => 1,
10994-
'path' => __DIR__ . '/tests/_support/Entity/User.php',
10995-
];
1099610978
$ignoreErrors[] = [
1099710979
// identifier: missingType.return
1099810980
'message' => '#^Method Tests\\\\Support\\\\Language\\\\SecondMockLanguage\\:\\:loaded\\(\\) has no return type specified\\.$#',
@@ -11227,12 +11209,6 @@
1122711209
'count' => 1,
1122811210
'path' => __DIR__ . '/tests/_support/Models/UserModel.php',
1122911211
];
11230-
$ignoreErrors[] = [
11231-
// identifier: missingType.iterableValue
11232-
'message' => '#^Property Tests\\\\Support\\\\SomeEntity\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
11233-
'count' => 1,
11234-
'path' => __DIR__ . '/tests/_support/SomeEntity.php',
11235-
];
1123611212
$ignoreErrors[] = [
1123711213
// identifier: missingType.return
1123811214
'message' => '#^Method Tests\\\\Support\\\\Test\\\\TestForReflectionHelper\\:\\:getPrivate\\(\\) has no return type specified\\.$#',
@@ -13717,180 +13693,6 @@
1371713693
'count' => 1,
1371813694
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
1371913695
];
13720-
$ignoreErrors[] = [
13721-
// identifier: missingType.return
13722-
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:getBar\\(\\) has no return type specified\\.$#',
13723-
'count' => 1,
13724-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13725-
];
13726-
$ignoreErrors[] = [
13727-
// identifier: missingType.return
13728-
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:getFakeBar\\(\\) has no return type specified\\.$#',
13729-
'count' => 1,
13730-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13731-
];
13732-
$ignoreErrors[] = [
13733-
// identifier: missingType.return
13734-
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:setBar\\(\\) has no return type specified\\.$#',
13735-
'count' => 1,
13736-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13737-
];
13738-
$ignoreErrors[] = [
13739-
// identifier: missingType.parameter
13740-
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:setBar\\(\\) has parameter \\$value with no type specified\\.$#',
13741-
'count' => 1,
13742-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13743-
];
13744-
$ignoreErrors[] = [
13745-
// identifier: missingType.return
13746-
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:_getBar\\(\\) has no return type specified\\.$#',
13747-
'count' => 1,
13748-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13749-
];
13750-
$ignoreErrors[] = [
13751-
// identifier: missingType.return
13752-
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:_setBar\\(\\) has no return type specified\\.$#',
13753-
'count' => 1,
13754-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13755-
];
13756-
$ignoreErrors[] = [
13757-
// identifier: missingType.parameter
13758-
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:_setBar\\(\\) has parameter \\$value with no type specified\\.$#',
13759-
'count' => 1,
13760-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13761-
];
13762-
$ignoreErrors[] = [
13763-
// identifier: missingType.return
13764-
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:getBar\\(\\) has no return type specified\\.$#',
13765-
'count' => 1,
13766-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13767-
];
13768-
$ignoreErrors[] = [
13769-
// identifier: missingType.return
13770-
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:setBar\\(\\) has no return type specified\\.$#',
13771-
'count' => 1,
13772-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13773-
];
13774-
$ignoreErrors[] = [
13775-
// identifier: missingType.parameter
13776-
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:setBar\\(\\) has parameter \\$value with no type specified\\.$#',
13777-
'count' => 1,
13778-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13779-
];
13780-
$ignoreErrors[] = [
13781-
// identifier: missingType.return
13782-
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1162\\:\\:getSimple\\(\\) has no return type specified\\.$#',
13783-
'count' => 1,
13784-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13785-
];
13786-
$ignoreErrors[] = [
13787-
// identifier: missingType.parameter
13788-
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1229\\:\\:setSeventh\\(\\) has parameter \\$seventh with no type specified\\.$#',
13789-
'count' => 1,
13790-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13791-
];
13792-
$ignoreErrors[] = [
13793-
// identifier: missingType.iterableValue
13794-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
13795-
'count' => 1,
13796-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13797-
];
13798-
$ignoreErrors[] = [
13799-
// identifier: missingType.iterableValue
13800-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:\\$original type has no value type specified in iterable type array\\.$#',
13801-
'count' => 1,
13802-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13803-
];
13804-
$ignoreErrors[] = [
13805-
// identifier: missingType.iterableValue
13806-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
13807-
'count' => 1,
13808-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13809-
];
13810-
$ignoreErrors[] = [
13811-
// identifier: missingType.iterableValue
13812-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:\\$original type has no value type specified in iterable type array\\.$#',
13813-
'count' => 1,
13814-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13815-
];
13816-
$ignoreErrors[] = [
13817-
// identifier: missingType.property
13818-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1162\\:\\:\\$_original has no type specified\\.$#',
13819-
'count' => 1,
13820-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13821-
];
13822-
$ignoreErrors[] = [
13823-
// identifier: missingType.iterableValue
13824-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1162\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
13825-
'count' => 1,
13826-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13827-
];
13828-
$ignoreErrors[] = [
13829-
// identifier: missingType.property
13830-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1192\\:\\:\\$_original has no type specified\\.$#',
13831-
'count' => 1,
13832-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13833-
];
13834-
$ignoreErrors[] = [
13835-
// identifier: missingType.iterableValue
13836-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1192\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
13837-
'count' => 1,
13838-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13839-
];
13840-
$ignoreErrors[] = [
13841-
// identifier: missingType.property
13842-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1211\\:\\:\\$_original has no type specified\\.$#',
13843-
'count' => 1,
13844-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13845-
];
13846-
$ignoreErrors[] = [
13847-
// identifier: missingType.iterableValue
13848-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1211\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
13849-
'count' => 1,
13850-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13851-
];
13852-
$ignoreErrors[] = [
13853-
// identifier: missingType.property
13854-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1229\\:\\:\\$_original has no type specified\\.$#',
13855-
'count' => 1,
13856-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13857-
];
13858-
$ignoreErrors[] = [
13859-
// identifier: missingType.iterableValue
13860-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1229\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
13861-
'count' => 1,
13862-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13863-
];
13864-
$ignoreErrors[] = [
13865-
// identifier: missingType.property
13866-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1287\\:\\:\\$_original has no type specified\\.$#',
13867-
'count' => 1,
13868-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13869-
];
13870-
$ignoreErrors[] = [
13871-
// identifier: missingType.iterableValue
13872-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1287\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
13873-
'count' => 1,
13874-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13875-
];
13876-
$ignoreErrors[] = [
13877-
// identifier: missingType.property
13878-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1316\\:\\:\\$_original has no type specified\\.$#',
13879-
'count' => 1,
13880-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13881-
];
13882-
$ignoreErrors[] = [
13883-
// identifier: missingType.iterableValue
13884-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1316\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
13885-
'count' => 1,
13886-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13887-
];
13888-
$ignoreErrors[] = [
13889-
// identifier: missingType.iterableValue
13890-
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:895\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
13891-
'count' => 1,
13892-
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
13893-
];
1389413696
$ignoreErrors[] = [
1389513697
// identifier: codeigniter.configArgumentInstanceof
1389613698
'message' => '#^Argument \\#1 \\$name \\(\'Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#',
@@ -18661,12 +18463,6 @@
1866118463
'count' => 1,
1866218464
'path' => __DIR__ . '/tests/system/View/ParserTest.php',
1866318465
];
18664-
$ignoreErrors[] = [
18665-
// identifier: missingType.iterableValue
18666-
'message' => '#^Property class@anonymous/tests/system/View/ParserTest\\.php\\:370\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
18667-
'count' => 1,
18668-
'path' => __DIR__ . '/tests/system/View/ParserTest.php',
18669-
];
1867018466
$ignoreErrors[] = [
1867118467
// identifier: method.notFound
1867218468
'message' => '#^Call to an undefined method CodeIgniter\\\\View\\\\Table\\:\\:compileTemplate\\(\\)\\.$#',

system/Entity/Entity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Entity implements JsonSerializable
106106
/**
107107
* Holds the current values of all class vars.
108108
*
109-
* @var array
109+
* @var array<string, mixed>
110110
*/
111111
protected $attributes = [];
112112

@@ -115,7 +115,7 @@ class Entity implements JsonSerializable
115115
* what's actually been changed and not accidentally write
116116
* nulls where we shouldn't.
117117
*
118-
* @var array
118+
* @var array<string, mixed>
119119
*/
120120
protected $original = [];
121121

tests/system/Entity/EntityTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,19 +1092,19 @@ protected function getEntity()
10921092
'createdAt' => 'created_at',
10931093
];
10941094

1095-
public function setBar($value)
1095+
public function setBar(int|string $value): self
10961096
{
10971097
$this->attributes['bar'] = "bar:{$value}";
10981098

10991099
return $this;
11001100
}
11011101

1102-
public function getBar()
1102+
public function getBar(): string
11031103
{
11041104
return "{$this->attributes['bar']}:bar";
11051105
}
11061106

1107-
public function getFakeBar()
1107+
public function getFakeBar(): string
11081108
{
11091109
return "{$this->attributes['bar']}:bar";
11101110
}
@@ -1131,26 +1131,26 @@ protected function getNewSetterGetterEntity()
11311131
];
11321132
private string $bar;
11331133

1134-
public function setBar($value)
1134+
public function setBar(string $value): self
11351135
{
11361136
$this->bar = $value;
11371137

11381138
return $this;
11391139
}
11401140

1141-
public function getBar()
1141+
public function getBar(): string
11421142
{
11431143
return $this->bar;
11441144
}
11451145

1146-
public function _setBar($value)
1146+
public function _setBar(string $value): self
11471147
{
11481148
$this->attributes['bar'] = "bar:{$value}";
11491149

11501150
return $this;
11511151
}
11521152

1153-
public function _getBar()
1153+
public function _getBar(): string
11541154
{
11551155
return "{$this->attributes['bar']}:bar";
11561156
}
@@ -1164,7 +1164,7 @@ protected function getMappedEntity()
11641164
'foo' => null,
11651165
'simple' => null,
11661166
];
1167-
protected $_original = [
1167+
protected $original = [
11681168
'foo' => null,
11691169
'simple' => null,
11701170
];
@@ -1180,7 +1180,7 @@ protected function setSimple(string $val): void
11801180
$this->attributes['simple'] = 'oo:' . $val;
11811181
}
11821182

1183-
protected function getSimple()
1183+
protected function getSimple(): string
11841184
{
11851185
return $this->attributes['simple'] . ':oo';
11861186
}
@@ -1194,7 +1194,7 @@ protected function getSwappedEntity()
11941194
'foo' => 'foo',
11951195
'bar' => 'bar',
11961196
];
1197-
protected $_original = [
1197+
protected $original = [
11981198
'foo' => 'foo',
11991199
'bar' => 'bar',
12001200
];
@@ -1213,7 +1213,7 @@ protected function getSimpleSwappedEntity()
12131213
'foo' => 'foo',
12141214
'bar' => 'bar',
12151215
];
1216-
protected $_original = [
1216+
protected $original = [
12171217
'foo' => 'foo',
12181218
'bar' => 'bar',
12191219
];
@@ -1242,7 +1242,7 @@ protected function getCastEntity($data = null): Entity
12421242
'twelfth' => null,
12431243
'thirteenth' => null,
12441244
];
1245-
protected $_original = [
1245+
protected $original = [
12461246
'first' => null,
12471247
'second' => null,
12481248
'third' => null,
@@ -1275,7 +1275,7 @@ protected function getCastEntity($data = null): Entity
12751275
'thirteenth' => 'uri',
12761276
];
12771277

1278-
public function setSeventh($seventh): void
1278+
public function setSeventh(string $seventh): void
12791279
{
12801280
$this->attributes['seventh'] = $seventh;
12811281
}
@@ -1292,7 +1292,7 @@ protected function getCastNullableEntity()
12921292
'integer_0' => null,
12931293
'string_value_not_null' => 'value',
12941294
];
1295-
protected $_original = [
1295+
protected $original = [
12961296
'string_null' => null,
12971297
'string_empty' => null,
12981298
'integer_null' => null,
@@ -1320,7 +1320,7 @@ protected function getCustomCastEntity()
13201320
'third' => null,
13211321
'fourth' => null,
13221322
];
1323-
protected $_original = [
1323+
protected $original = [
13241324
'first' => null,
13251325
'second' => null,
13261326
'third' => null,

0 commit comments

Comments
 (0)