refactor: fix phpstan no type specified model tests#10022
Open
adiprsa wants to merge 1 commit intocodeigniter4:developfrom
Open
refactor: fix phpstan no type specified model tests#10022adiprsa wants to merge 1 commit intocodeigniter4:developfrom
adiprsa wants to merge 1 commit intocodeigniter4:developfrom
Conversation
neznaika0
reviewed
Mar 6, 2026
| /** | ||
| * @var array{'datamap': array{}, 'dates': array{string, string, string}, 'casts': array{}} | ||
| */ | ||
| protected $_options = [ |
Contributor
There was a problem hiding this comment.
Stop.
@michalsn @paulbalandan
It all looks like a dead code. Can you tell me where the array is currently being used and how to set the properties in the object?
this is the behavior of v4.0.x only then there was an options array and attributes appeared later.
I assume all Entity tests need to be reviewed again.
@adiprsa right now I'm not sure if the tests are correct, at least we use $attributes instead of object properties. Plus $deleted doesn't seem to exist (deleted_at)
Contributor
There was a problem hiding this comment.
The tests should be similar:
public function testInsertBatchNewEntityWithDateTime(): void
{
$entity = new class () extends Entity {
protected $attributes = [
'id' => null,
'name' => null,
'email' => null,
'country' => null,
'deleted_at' => null,
'created_at' => null,
'updated_at' => null,
];
protected $dates = [
'created_at',
'updated_at',
'deleted_at',
];
};
$entityTwo = clone $entity;
$this->createModel(UserModel::class);
$entity->name = 'Mark One';
$entity->email = 'markone@example.com';
$entity->country = 'India';
$entity->deleted_at = null;
$entity->created_at = new Time('now');
$entityTwo->name = 'Mark Two';
$entityTwo->email = 'marktwo@example.com';
$entityTwo->country = 'India';
$entityTwo->deleted_at = null;
$entityTwo->created_at = $entity->created_at;
$this->setPrivateProperty($this->model, 'useTimestamps', true);
$this->assertSame(2, $this->model->insertBatch([$entity, $entityTwo]));
}
Member
There was a problem hiding this comment.
Seems correct - these tests should be updated. Good catch.
neznaika0
suggested changes
Mar 6, 2026
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
#7731
Checklist: