com web/bugs: Fix strict types issues: src/Repository/BugRepository.php src/Repository/VoteRepository.php

From: Date: Mon, 24 Dec 2018 02:00:41 +0000
Subject: com web/bugs: Fix strict types issues: src/Repository/BugRepository.php src/Repository/VoteRepository.php
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-27608@lists.php.net to get a copy of this message
Commit: 402a43856329884eae5b58e83b656b08a6c2ab01 Author: Peter Kokot <peterkokot@gmail.com> Mon, 24 Dec 2018 03:00:41 +0100 Parents: fe4c5e81f570c4dfb9c0bc4530bc3d955ab579d4 Branches: master Link: http://git.php.net/?p=web/bugs.git;a=commitdiff;h=402a43856329884eae5b58e83b656b08a6c2ab01 Log: Fix strict types issues This makes sure arrays are always returned when calling PDOStatement::fetch() in current repository classes. Changed paths: M src/Repository/BugRepository.php M src/Repository/VoteRepository.php Diff: diff --git a/src/Repository/BugRepository.php b/src/Repository/BugRepository.php index 5ef08f3..d47f0c3 100644 --- a/src/Repository/BugRepository.php +++ b/src/Repository/BugRepository.php @@ -51,7 +51,9 @@ class BugRepository $statement = $this->dbh->prepare($sql); $statement->execute([$id]); - return $statement->fetch(); + $result = $statement->fetch(); + + return $result === false ? [] : $result; } /** diff --git a/src/Repository/VoteRepository.php b/src/Repository/VoteRepository.php index e832e7c..1b2aecc 100644 --- a/src/Repository/VoteRepository.php +++ b/src/Repository/VoteRepository.php @@ -33,10 +33,6 @@ class VoteRepository $result = $statement->fetch(); - if ($result === false) { - return []; - } - - return $result; + return $result === false ? [] : $result; } }

« previous php.webmaster (#27608) next »