From faa74867f8c2201e08a09f1757131f3033e60b43 Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 18 Jan 2024 19:53:15 -0600 Subject: [PATCH] Fixed Psalm errors (#45) --- src/Users/SqlUserService.php | 2 +- tests/Integration/IntegrationTestCase.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Users/SqlUserService.php b/src/Users/SqlUserService.php index 2aef194..bfeeac3 100644 --- a/src/Users/SqlUserService.php +++ b/src/Users/SqlUserService.php @@ -161,7 +161,7 @@ public function getUserById(int $id): User $statement->execute(['id' => $id]); $row = $statement->fetch(PDO::FETCH_ASSOC); - if (empty($row)) { + if ($row === false || \count($row) === 0) { throw new UserNotFoundException("No user found with ID $id"); } diff --git a/tests/Integration/IntegrationTestCase.php b/tests/Integration/IntegrationTestCase.php index f82a329..7e8233e 100644 --- a/tests/Integration/IntegrationTestCase.php +++ b/tests/Integration/IntegrationTestCase.php @@ -21,7 +21,8 @@ protected function setUp(): void parent::setUp(); // Auto-call certain trait methods if the test case uses them - $traits = \class_uses($this) ?: []; + $traits = \class_uses($this); + $traits = $traits === false ? [] : $traits; if (isset($traits[MigratesDatabase::class])) { /** @psalm-suppress UndefinedMethod This method will exist because it uses the migration trait */