From efac62f0e40a5e565c3105bfc6ba13e9e3f836bd Mon Sep 17 00:00:00 2001 From: "J. King" Date: Fri, 2 Nov 2018 11:47:10 -0400 Subject: [PATCH] Add missing return type hints where possible --- lib/Db/PDOError.php | 2 +- lib/Db/PDOResult.php | 4 ++-- lib/Db/Result.php | 4 ++-- lib/Db/ResultAggregate.php | 4 ++-- lib/Db/ResultEmpty.php | 4 ++-- lib/Db/SQLite3/ExceptionBuilder.php | 2 +- lib/Db/SQLite3/Result.php | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/Db/PDOError.php b/lib/Db/PDOError.php index 37341e4..03e1f89 100644 --- a/lib/Db/PDOError.php +++ b/lib/Db/PDOError.php @@ -7,7 +7,7 @@ declare(strict_types=1); namespace JKingWeb\Arsse\Db; trait PDOError { - public function exceptionBuild() { + public function exceptionBuild(): array { if ($this instanceof Statement) { $err = $this->st->errorInfo(); } else { diff --git a/lib/Db/PDOResult.php b/lib/Db/PDOResult.php index 32400e9..8889511 100644 --- a/lib/Db/PDOResult.php +++ b/lib/Db/PDOResult.php @@ -16,11 +16,11 @@ class PDOResult extends AbstractResult { // actual public methods - public function changes() { + public function changes(): int { return $this->rows; } - public function lastId() { + public function lastId(): int { return $this->id; } diff --git a/lib/Db/Result.php b/lib/Db/Result.php index 91d0b42..88c908b 100644 --- a/lib/Db/Result.php +++ b/lib/Db/Result.php @@ -17,6 +17,6 @@ interface Result extends \Iterator { public function getAll(): array; public function getValue(); - public function changes(); - public function lastId(); + public function changes(): int; + public function lastId(): int; } diff --git a/lib/Db/ResultAggregate.php b/lib/Db/ResultAggregate.php index 84fb282..4f53b9d 100644 --- a/lib/Db/ResultAggregate.php +++ b/lib/Db/ResultAggregate.php @@ -15,13 +15,13 @@ class ResultAggregate extends AbstractResult { // actual public methods - public function changes() { + public function changes(): int { return array_reduce($this->data, function ($sum, $value) { return $sum + $value->changes(); }, 0); } - public function lastId() { + public function lastId(): int { return $this->data[sizeof($this->data) - 1]->lastId(); } diff --git a/lib/Db/ResultEmpty.php b/lib/Db/ResultEmpty.php index f11d75e..60478b2 100644 --- a/lib/Db/ResultEmpty.php +++ b/lib/Db/ResultEmpty.php @@ -9,11 +9,11 @@ namespace JKingWeb\Arsse\Db; use JKingWeb\Arsse\Db\Exception; class ResultEmpty extends AbstractResult { - public function changes() { + public function changes(): int { return 0; } - public function lastId() { + public function lastId(): int { return 0; } diff --git a/lib/Db/SQLite3/ExceptionBuilder.php b/lib/Db/SQLite3/ExceptionBuilder.php index 6d5bee0..4e63163 100644 --- a/lib/Db/SQLite3/ExceptionBuilder.php +++ b/lib/Db/SQLite3/ExceptionBuilder.php @@ -11,7 +11,7 @@ use JKingWeb\Arsse\Db\ExceptionInput; use JKingWeb\Arsse\Db\ExceptionTimeout; trait ExceptionBuilder { - public function exceptionBuild() { + public function exceptionBuild(): array { switch ($this->db->lastErrorCode()) { case self::SQLITE_BUSY: return [ExceptionTimeout::class, 'general', $this->db->lastErrorMsg()]; diff --git a/lib/Db/SQLite3/Result.php b/lib/Db/SQLite3/Result.php index 853a4bf..d5e652f 100644 --- a/lib/Db/SQLite3/Result.php +++ b/lib/Db/SQLite3/Result.php @@ -17,11 +17,11 @@ class Result extends \JKingWeb\Arsse\Db\AbstractResult { // actual public methods - public function changes() { + public function changes(): int { return $this->rows; } - public function lastId() { + public function lastId(): int { return $this->id; }