Skip to content

Firefly III: a personal finances manager

Add some method annotators, see if this helps with Scrutinizer issues.

James Cole5dad569d6296
diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php
index 849705f2da..12c61e22b5 100644
--- a/app/Helpers/Attachments/AttachmentHelper.php
+++ b/app/Helpers/Attachments/AttachmentHelper.php
@@ -166,7 +166,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$attachment->md5 = md5_file($path);
$attachment->mime = $mime;
$attachment->size = \strlen($content);
- $attachment->uploaded = 1;
+ $attachment->uploaded = true;
$attachment->save();
return true;
diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.php
index a7c79b891a..117bcaa6e9 100644
--- a/app/Repositories/LinkType/LinkTypeRepository.php
+++ b/app/Repositories/LinkType/LinkTypeRepository.php
@@ -210,7 +210,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
/**
* @param User $user
*/
- public function setUser(User $user)
+ public function setUser(User $user): void
{
$this->user = $user;
}
diff --git a/app/Repositories/LinkType/LinkTypeRepositoryInterface.php b/app/Repositories/LinkType/LinkTypeRepositoryInterface.php
index 617cb45b59..eb584560dc 100644
--- a/app/Repositories/LinkType/LinkTypeRepositoryInterface.php
+++ b/app/Repositories/LinkType/LinkTypeRepositoryInterface.php
@@ -25,6 +25,7 @@ namespace FireflyIII\Repositories\LinkType;
use FireflyIII\Models\LinkType;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionJournalLink;
+use FireflyIII\User;
use Illuminate\Support\Collection;
/**
@@ -62,6 +63,13 @@ interface LinkTypeRepositoryInterface
*/
public function find(int $id): LinkType;
+ /**
+ * Set the user for this instance.
+ *
+ * @param User $user
+ */
+ public function setUser(User $user): void;
+
/**
* Find link type by name.
*
diff --git a/app/Support/Facades/Amount.php b/app/Support/Facades/Amount.php
index 24bb3d89c6..f575f3ac01 100644
--- a/app/Support/Facades/Amount.php
+++ b/app/Support/Facades/Amount.php
@@ -22,11 +22,15 @@ declare(strict_types=1);
namespace FireflyIII\Support\Facades;
+use FireflyIII\Models\TransactionCurrency;
+use FireflyIII\User;
use Illuminate\Support\Facades\Facade;
/**
* @codeCoverageIgnore
* Class Amount.
+ *
+ * @method TransactionCurrency getDefaultCurrencyByUser(User $user)
*/
class Amount extends Facade
{
diff --git a/app/Support/Facades/Navigation.php b/app/Support/Facades/Navigation.php
index f54c32e414..2b2fe45e7d 100644
--- a/app/Support/Facades/Navigation.php
+++ b/app/Support/Facades/Navigation.php
@@ -27,6 +27,9 @@ use Illuminate\Support\Facades\Facade;
/**
* @codeCoverageIgnore
* Class Navigation.
+ *
+ * @method array blockPeriods(\Carbon\Carbon $start, \Carbon\Carbon $end, string $range)
+ * @method string periodShow(\Carbon\Carbon $theDate, string $repeatFrequency)
*/
class Navigation extends Facade
{
diff --git a/app/Support/Facades/Preferences.php b/app/Support/Facades/Preferences.php
index a166989cbb..d438f999f8 100644
--- a/app/Support/Facades/Preferences.php
+++ b/app/Support/Facades/Preferences.php
@@ -22,11 +22,18 @@ declare(strict_types=1);
namespace FireflyIII\Support\Facades;
+use FireflyIII\Models\Preference;
+use FireflyIII\User;
use Illuminate\Support\Facades\Facade;
/**
* @codeCoverageIgnore
* Class Preferences.
+ *
+ * @method Preference set(string $name, $value)
+ * @method Preference get(string $name, $value)
+ * @method Preference|null getForUser(User $user, string $name, $default)
+ * @method void mark()
*/
class Preferences extends Facade
{
diff --git a/app/Support/Facades/Steam.php b/app/Support/Facades/Steam.php
index d59b93b9b8..33b8c847df 100644
--- a/app/Support/Facades/Steam.php
+++ b/app/Support/Facades/Steam.php
@@ -27,6 +27,7 @@ use Illuminate\Support\Facades\Facade;
/**
* @codeCoverageIgnore
* Class Steam.
+ * @method string positive(string $amount)
*/
class Steam extends Facade
{
diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php
index af6392144a..0a3a5caadd 100644
--- a/app/Support/Navigation.php
+++ b/app/Support/Navigation.php
@@ -298,7 +298,7 @@ class Navigation
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
- public function periodShow(Carbon $theDate, string $repeatFrequency): string
+ public function periodShow(\Carbon\Carbon $theDate, string $repeatFrequency): string
{
$date = clone $theDate;
$formatMap = [
diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php
index 8774c29d6e..e57cb53b3f 100644
--- a/app/Support/Preferences.php
+++ b/app/Support/Preferences.php
@@ -79,12 +79,12 @@ class Preferences
}
/**
- * @param $name
- * @param null $default
+ * @param string $name
+ * @param null $default
*
* @return \FireflyIII\Models\Preference|null
*/
- public function get($name, $default = null)
+ public function get(string $name, $default = null): ?Preference
{
/** @var User $user */
$user = auth()->user();
@@ -125,7 +125,7 @@ class Preferences
*
* @return \FireflyIII\Models\Preference|null
*/
- public function getForUser(User $user, $name, $default = null): ?Preference
+ public function getForUser(User $user, string $name, $default = null): ?Preference
{
$fullName = sprintf('preference%s%s', $user->id, $name);
if (Cache::has($fullName)) {
@@ -177,23 +177,21 @@ class Preferences
}
/**
- * @return bool
+ *
*/
- public function mark(): bool
+ public function mark(): void
{
$this->set('lastActivity', microtime());
Session::forget('first');
-
- return true;
}
/**
- * @param $name
- * @param $value
+ * @param string $name
+ * @param mixed $value
*
- * @return Preference
+ * @return \FireflyIII\Models\Preference
*/
- public function set($name, $value): Preference
+ public function set(string $name, $value): Preference
{
$user = auth()->user();
if (null === $user) {
@@ -210,12 +208,12 @@ class Preferences
/**
* @param \FireflyIII\User $user
- * @param $name
+ * @param string $name
* @param mixed $value
*
* @return Preference
*/
- public function setForUser(User $user, $name, $value): Preference
+ public function setForUser(User $user, string $name, $value): Preference
{
$fullName = sprintf('preference%s%s', $user->id, $name);
Cache::forget($fullName);