diff --git a/tests/system/Models/DataConverterModelTest.php b/tests/system/Models/DataConverterModelTest.php index f243871526f3..7d647790d62b 100644 --- a/tests/system/Models/DataConverterModelTest.php +++ b/tests/system/Models/DataConverterModelTest.php @@ -36,7 +36,7 @@ public function testFindAsArray(): void $user = $this->model->find($id); - $this->assertIsInt($user['id']); + $this->assertIsInt($user['id']); // @phpstan-ignore offsetAccess.notFound $this->assertInstanceOf(Time::class, $user['created_at']); $this->assertSame('John Smith', $user['name']); // `name` is cast by custom CastBase64 handler. @@ -128,9 +128,9 @@ public function testFindAllAsArray(): void $users = $this->model->findAll(); - $this->assertIsInt($users[0]['id']); + $this->assertIsInt($users[0]['id']); // @phpstan-ignore offsetAccess.notFound $this->assertInstanceOf(Time::class, $users[0]['created_at']); - $this->assertIsInt($users[1]['id']); + $this->assertIsInt($users[1]['id']); // @phpstan-ignore offsetAccess.notFound $this->assertInstanceOf(Time::class, $users[1]['created_at']); } @@ -208,7 +208,7 @@ public function testFirstAsArray(): void $user = $this->model->first(); - $this->assertIsInt($user['id']); + $this->assertIsInt($user['id']); // @phpstan-ignore offsetAccess.notFound $this->assertInstanceOf(Time::class, $user['created_at']); } @@ -264,7 +264,8 @@ public function testInsertArray(): void $id = $this->model->insert($data, true); $user = $this->model->find($id); - $this->assertSame(['joe@example.com'], $user['email']); + + $this->assertSame(['joe@example.com'], $user['email']); // @phpstan-ignore offsetAccess.notFound } public function testInsertObject(): void @@ -279,7 +280,8 @@ public function testInsertObject(): void $id = $this->model->insert($data, true); $user = $this->model->find($id); - $this->assertSame(['joe@example.com'], $user['email']); + + $this->assertSame(['joe@example.com'], $user['email']); // @phpstan-ignore offsetAccess.notFound } public function testUpdateArray(): void @@ -288,14 +290,14 @@ public function testUpdateArray(): void $user = $this->model->find($id); $user['email'][] = 'private@example.org'; - $this->model->update($user['id'], $user); + $this->model->update($user['id'], $user); // @phpstan-ignore offsetAccess.notFound $user = $this->model->find($id); $this->assertSame([ 'john@example.com', 'private@example.org', - ], $user['email']); + ], $user['email']); // @phpstan-ignore offsetAccess.notFound } public function testUpdateObject(): void @@ -311,7 +313,7 @@ public function testUpdateObject(): void $this->assertSame([ 'john@example.com', 'private@example.org', - ], $user['email']); + ], $user['email']); // @phpstan-ignore offsetAccess.notFound } public function testUpdateCustomObject(): void @@ -363,7 +365,7 @@ public function testSaveArray(): void $this->assertSame([ 'john@example.com', 'private@example.org', - ], $user['email']); + ], $user['email']); // @phpstan-ignore offsetAccess.notFound } public function testSaveObject(): void @@ -379,7 +381,7 @@ public function testSaveObject(): void $this->assertSame([ 'john@example.com', 'private@example.org', - ], $user['email']); + ], $user['email']); // @phpstan-ignore offsetAccess.notFound } public function testSaveCustomObject(): void diff --git a/tests/system/Models/TimestampModelTest.php b/tests/system/Models/TimestampModelTest.php index 8736691b2d4a..ce2675a2d89d 100644 --- a/tests/system/Models/TimestampModelTest.php +++ b/tests/system/Models/TimestampModelTest.php @@ -93,10 +93,12 @@ public function testDoNotAllowDatesInsertArrayWithoutDatesSetsTimestamp(): void $user = $this->model->find($id); $expected = '2023-11-25 12:00:00'; + if ($this->db->DBDriver === 'SQLSRV') { $expected .= '.000'; } - $this->assertSame($expected, $user['created_at']); + + $this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound $this->assertSame($expected, $user['updated_at']); } @@ -116,10 +118,12 @@ public function testDoNotAllowDatesInsertArrayWithDatesSetsTimestamp(): void $user = $this->model->find($id); $expected = '2023-11-25 12:00:00'; + if ($this->db->DBDriver === 'SQLSRV') { $expected .= '.000'; } - $this->assertSame($expected, $user['created_at']); + + $this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound $this->assertSame($expected, $user['updated_at']); } @@ -139,15 +143,17 @@ public function testDoNotAllowDatesUpdateArrayUpdatesUpdatedAt(): void $user = $this->model->find($id); $user['country'] = 'CA'; - $this->model->update($user['id'], $user); + $this->model->update($user['id'], $user); // @phpstan-ignore offsetAccess.notFound $user = $this->model->find($id); $expected = '2023-11-25 12:00:00'; + if ($this->db->DBDriver === 'SQLSRV') { $expected .= '.000'; } - $this->assertSame($expected, $user['created_at']); + + $this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound $this->assertSame($expected, $user['updated_at']); } @@ -197,10 +203,12 @@ public function testAllowDatesInsertArrayWithoutDatesSetsTimestamp(): void $user = $this->model->find($id); $expected = '2023-11-25 12:00:00'; + if ($this->db->DBDriver === 'SQLSRV') { $expected .= '.000'; } - $this->assertSame($expected, $user['created_at']); + + $this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound $this->assertSame($expected, $user['updated_at']); } @@ -224,10 +232,12 @@ public function testAllowDatesInsertArrayWithDatesSetsTimestamp(): void $user = $this->model->find($id); $expected = '2000-01-01 12:00:00'; + if ($this->db->DBDriver === 'SQLSRV') { $expected .= '.000'; } - $this->assertSame($expected, $user['created_at']); + + $this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound $this->assertSame($expected, $user['updated_at']); } @@ -251,15 +261,17 @@ public function testAllowDatesUpdateArrayUpdatesUpdatedAt(): void $user = $this->model->find($id); $user['country'] = 'CA'; - $this->model->update($user['id'], $user); + $this->model->update($user['id'], $user); // @phpstan-ignore offsetAccess.notFound $user = $this->model->find($id); $expected = '2000-01-01 12:00:00'; + if ($this->db->DBDriver === 'SQLSRV') { $expected .= '.000'; } - $this->assertSame($expected, $user['created_at']); + + $this->assertSame($expected, $user['created_at']); // @phpstan-ignore offsetAccess.notFound $this->assertSame($expected, $user['updated_at']); } diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 61b40215f4f2..24fe8aba136f 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -26,7 +26,6 @@ includes: - notIdentical.alwaysTrue.neon - nullCoalesce.property.neon - nullCoalesce.variable.neon - - offsetAccess.notFound.neon - parameterByRef.unusedType.neon - property.defaultValue.neon - property.nonObject.neon diff --git a/utils/phpstan-baseline/offsetAccess.notFound.neon b/utils/phpstan-baseline/offsetAccess.notFound.neon deleted file mode 100644 index e96706dc1bb5..000000000000 --- a/utils/phpstan-baseline/offsetAccess.notFound.neon +++ /dev/null @@ -1,33 +0,0 @@ -# total 19 errors - -parameters: - ignoreErrors: - - - message: '#^Offset ''email'' does not exist on array\{\}\.$#' - count: 4 - path: ../../tests/system/Models/DataConverterModelTest.php - - - - message: '#^Offset ''email'' does not exist on list\\.$#' - count: 2 - path: ../../tests/system/Models/DataConverterModelTest.php - - - - message: '#^Offset ''id'' does not exist on array\{email\: array\{''private@example\.org''\}\}\.$#' - count: 1 - path: ../../tests/system/Models/DataConverterModelTest.php - - - - message: '#^Offset ''id'' does not exist on array\{\}\.$#' - count: 4 - path: ../../tests/system/Models/DataConverterModelTest.php - - - - message: '#^Offset ''created_at'' does not exist on array\{\}\.$#' - count: 6 - path: ../../tests/system/Models/TimestampModelTest.php - - - - message: '#^Offset ''id'' does not exist on array\{country\: ''CA''\}\.$#' - count: 2 - path: ../../tests/system/Models/TimestampModelTest.php