Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix EntityTest PHPStan errors #9107

Merged
merged 4 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
204 changes: 0 additions & 204 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -5143,18 +5143,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Entity/Entity.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property CodeIgniter\\\\Entity\\\\Entity\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Entity/Entity.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property CodeIgniter\\\\Entity\\\\Entity\\:\\:\\$original type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Entity/Entity.php',
];
$ignoreErrors[] = [
// identifier: codeigniter.configArgumentInstanceof
'message' => '#^Argument \\#1 \\$name \\(\'Config\\\\\\\\Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#',
Expand Down Expand Up @@ -10987,12 +10975,6 @@
'count' => 1,
'path' => __DIR__ . '/tests/_support/Entity/CustomUser.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property Tests\\\\Support\\\\Entity\\\\User\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/_support/Entity/User.php',
];
$ignoreErrors[] = [
// identifier: missingType.return
'message' => '#^Method Tests\\\\Support\\\\Language\\\\SecondMockLanguage\\:\\:loaded\\(\\) has no return type specified\\.$#',
Expand Down Expand Up @@ -11227,12 +11209,6 @@
'count' => 1,
'path' => __DIR__ . '/tests/_support/Models/UserModel.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property Tests\\\\Support\\\\SomeEntity\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/_support/SomeEntity.php',
];
$ignoreErrors[] = [
// identifier: missingType.return
'message' => '#^Method Tests\\\\Support\\\\Test\\\\TestForReflectionHelper\\:\\:getPrivate\\(\\) has no return type specified\\.$#',
Expand Down Expand Up @@ -13717,180 +13693,6 @@
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.return
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:getBar\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.return
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:getFakeBar\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.return
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:setBar\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.parameter
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:setBar\\(\\) has parameter \\$value with no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.return
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:_getBar\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.return
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:_setBar\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.parameter
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:_setBar\\(\\) has parameter \\$value with no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.return
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:getBar\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.return
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:setBar\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.parameter
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:setBar\\(\\) has parameter \\$value with no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.return
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1162\\:\\:getSimple\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.parameter
'message' => '#^Method class@anonymous/tests/system/Entity/EntityTest\\.php\\:1229\\:\\:setSeventh\\(\\) has parameter \\$seventh with no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1078\\:\\:\\$original type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1116\\:\\:\\$original type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.property
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1162\\:\\:\\$_original has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1162\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.property
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1192\\:\\:\\$_original has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1192\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.property
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1211\\:\\:\\$_original has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1211\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.property
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1229\\:\\:\\$_original has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1229\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.property
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1287\\:\\:\\$_original has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1287\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.property
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1316\\:\\:\\$_original has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:1316\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property class@anonymous/tests/system/Entity/EntityTest\\.php\\:895\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/Entity/EntityTest.php',
];
$ignoreErrors[] = [
// identifier: codeigniter.configArgumentInstanceof
'message' => '#^Argument \\#1 \\$name \\(\'Modules\'\\) passed to function config does not extend CodeIgniter\\\\\\\\Config\\\\\\\\BaseConfig\\.$#',
Expand Down Expand Up @@ -18661,12 +18463,6 @@
'count' => 1,
'path' => __DIR__ . '/tests/system/View/ParserTest.php',
];
$ignoreErrors[] = [
// identifier: missingType.iterableValue
'message' => '#^Property class@anonymous/tests/system/View/ParserTest\\.php\\:370\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/system/View/ParserTest.php',
];
$ignoreErrors[] = [
// identifier: method.notFound
'message' => '#^Call to an undefined method CodeIgniter\\\\View\\\\Table\\:\\:compileTemplate\\(\\)\\.$#',
Expand Down
4 changes: 2 additions & 2 deletions system/Entity/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Entity implements JsonSerializable
/**
* Holds the current values of all class vars.
*
* @var array
* @var array<string, mixed>
*/
protected $attributes = [];

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

Expand Down
30 changes: 15 additions & 15 deletions tests/system/Entity/EntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1092,19 +1092,19 @@ protected function getEntity()
'createdAt' => 'created_at',
];

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

return $this;
}

public function getBar()
public function getBar(): string
{
return "{$this->attributes['bar']}:bar";
}

public function getFakeBar()
public function getFakeBar(): string
{
return "{$this->attributes['bar']}:bar";
}
Expand All @@ -1131,26 +1131,26 @@ protected function getNewSetterGetterEntity()
];
private string $bar;

public function setBar($value)
public function setBar(string $value): self
{
$this->bar = $value;

return $this;
}

public function getBar()
public function getBar(): string
{
return $this->bar;
}

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

return $this;
}

public function _getBar()
public function _getBar(): string
{
return "{$this->attributes['bar']}:bar";
}
Expand All @@ -1164,7 +1164,7 @@ protected function getMappedEntity()
'foo' => null,
'simple' => null,
];
protected $_original = [
protected $original = [
'foo' => null,
'simple' => null,
];
Expand All @@ -1180,7 +1180,7 @@ protected function setSimple(string $val): void
$this->attributes['simple'] = 'oo:' . $val;
}

protected function getSimple()
protected function getSimple(): string
{
return $this->attributes['simple'] . ':oo';
}
Expand All @@ -1194,7 +1194,7 @@ protected function getSwappedEntity()
'foo' => 'foo',
'bar' => 'bar',
];
protected $_original = [
protected $original = [
'foo' => 'foo',
'bar' => 'bar',
];
Expand All @@ -1213,7 +1213,7 @@ protected function getSimpleSwappedEntity()
'foo' => 'foo',
'bar' => 'bar',
];
protected $_original = [
protected $original = [
'foo' => 'foo',
'bar' => 'bar',
];
Expand Down Expand Up @@ -1242,7 +1242,7 @@ protected function getCastEntity($data = null): Entity
'twelfth' => null,
'thirteenth' => null,
];
protected $_original = [
protected $original = [
'first' => null,
'second' => null,
'third' => null,
Expand Down Expand Up @@ -1275,7 +1275,7 @@ protected function getCastEntity($data = null): Entity
'thirteenth' => 'uri',
];

public function setSeventh($seventh): void
public function setSeventh(string $seventh): void
{
$this->attributes['seventh'] = $seventh;
}
Expand All @@ -1292,7 +1292,7 @@ protected function getCastNullableEntity()
'integer_0' => null,
'string_value_not_null' => 'value',
];
protected $_original = [
protected $original = [
'string_null' => null,
'string_empty' => null,
'integer_null' => null,
Expand Down Expand Up @@ -1320,7 +1320,7 @@ protected function getCustomCastEntity()
'third' => null,
'fourth' => null,
];
protected $_original = [
protected $original = [
'first' => null,
'second' => null,
'third' => null,
Expand Down
Loading