Fix some issues that triggered in scrutinizer.

This commit is contained in:
James Cole 2018-07-22 21:32:58 +02:00
parent 67ea825d4a
commit 4fa5f4e5a3
42 changed files with 81 additions and 80 deletions

View File

@ -249,7 +249,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$attachment->filename = $file->getClientOriginalName();
$attachment->mime = $file->getMimeType();
$attachment->size = $file->getSize();
$attachment->uploaded = 0;
$attachment->uploaded = false;
$attachment->save();
Log::debug('Created attachment:', $attachment->toArray());

View File

@ -22,6 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Crypt;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;

View File

@ -300,7 +300,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
$attachment->filename = $name;
$attachment->mime = 'plain/txt';
$attachment->size = \strlen($content);
$attachment->uploaded = 0;
$attachment->uploaded = false;
$attachment->save();
$encrypted = Crypt::encrypt($content);
@ -351,7 +351,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
$attachment->filename = $name;
$attachment->mime = $file->getMimeType();
$attachment->size = $file->getSize();
$attachment->uploaded = 0;
$attachment->uploaded = false;
$attachment->save();
$fileObject = $file->openFile('r');
$fileObject->rewind();

View File

@ -288,7 +288,7 @@ class RuleRepository implements RuleRepositoryInterface
$rule->rule_group_id = $data['rule_group_id'];
$rule->order = ($order + 1);
$rule->active = 1;
$rule->active = true;
$rule->strict = $data['strict'] ?? false;
$rule->stop_processing = 1 === (int)$data['stop-processing'];
$rule->title = $data['title'];
@ -316,7 +316,7 @@ class RuleRepository implements RuleRepositoryInterface
$ruleAction = new RuleAction;
$ruleAction->rule()->associate($rule);
$ruleAction->order = $values['order'];
$ruleAction->active = 1;
$ruleAction->active = true;
$ruleAction->stop_processing = $values['stopProcessing'];
$ruleAction->action_type = $values['action'];
$ruleAction->action_value = $values['value'] ?? '';
@ -336,7 +336,7 @@ class RuleRepository implements RuleRepositoryInterface
$ruleTrigger = new RuleTrigger;
$ruleTrigger->rule()->associate($rule);
$ruleTrigger->order = $values['order'];
$ruleTrigger->active = 1;
$ruleTrigger->active = true;
$ruleTrigger->stop_processing = $values['stopProcessing'];
$ruleTrigger->trigger_type = $values['action'];
$ruleTrigger->trigger_value = $values['value'] ?? '';

View File

@ -52,7 +52,7 @@ class BelongsUser implements Rule
*
* @return string
*/
public function message()
public function message(): string
{
return (string)trans('validation.belongs_user');
}

View File

@ -51,7 +51,7 @@ class FireflyConfig
/**
* @param string $name
* @param null $default
* @param mixed $default
*
* @return \FireflyIII\Models\Configuration|null
*/
@ -79,7 +79,7 @@ class FireflyConfig
/**
* @param string $name
* @param null $default
* @param mixed $default
*
* @return \FireflyIII\Models\Configuration|null
*/

View File

@ -80,7 +80,7 @@ class Preferences
/**
* @param string $name
* @param null $default
* @param mixed $default
*
* @return \FireflyIII\Models\Preference|null
*/

View File

@ -43,11 +43,11 @@ final class AmountExactly extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
return false;

View File

@ -43,11 +43,11 @@ final class AmountLess extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
return false;

View File

@ -43,11 +43,11 @@ final class AmountMore extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
$res = 0 === bccomp('0', (string)$value);

View File

@ -43,11 +43,11 @@ final class BudgetIs extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
return false;

View File

@ -43,11 +43,11 @@ final class CategoryIs extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
return false;

View File

@ -44,11 +44,11 @@ final class CurrencyIs extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
return false;

View File

@ -42,11 +42,11 @@ final class DescriptionContains extends AbstractTrigger implements TriggerInterf
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
$res = '' === (string)$value;

View File

@ -42,11 +42,11 @@ final class DescriptionEnds extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
$res = '' === (string)$value;

View File

@ -42,11 +42,11 @@ final class DescriptionIs extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
return false;

View File

@ -42,11 +42,11 @@ final class DescriptionStarts extends AbstractTrigger implements TriggerInterfac
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
$res = '' === (string)$value;

View File

@ -43,11 +43,11 @@ final class FromAccountContains extends AbstractTrigger implements TriggerInterf
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
$res = '' === (string)$value;

View File

@ -43,11 +43,11 @@ final class FromAccountEnds extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
$res = '' === (string)$value;

View File

@ -43,11 +43,11 @@ final class FromAccountIs extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
$res = '' === (string)$value;

View File

@ -43,11 +43,11 @@ final class FromAccountStarts extends AbstractTrigger implements TriggerInterfac
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
$res = '' === (string)$value;

View File

@ -43,11 +43,11 @@ final class HasAnyBudget extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
return false;
}

View File

@ -43,11 +43,11 @@ final class HasAnyCategory extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
return false;
}

View File

@ -42,11 +42,11 @@ final class HasAnyTag extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
return false;
}

View File

@ -42,11 +42,11 @@ class HasAttachment extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
$value = (int)$value;

View File

@ -43,11 +43,11 @@ final class HasNoBudget extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
return false;
}

View File

@ -43,11 +43,11 @@ final class HasNoCategory extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
return false;
}

View File

@ -42,11 +42,11 @@ final class HasNoTag extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
return false;
}

View File

@ -43,11 +43,11 @@ final class NotesAny extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
return false;
}

View File

@ -43,11 +43,11 @@ final class NotesAre extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
return false;

View File

@ -43,11 +43,11 @@ final class NotesContain extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
$res = '' === (string)$value;

View File

@ -43,11 +43,11 @@ final class NotesEmpty extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
return false;
}

View File

@ -43,11 +43,11 @@ final class NotesEnd extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
$res = '' === (string)$value;

View File

@ -43,11 +43,11 @@ final class NotesStart extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
$res = '' === (string)$value;

View File

@ -43,11 +43,11 @@ final class TagIs extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
return false;

View File

@ -43,11 +43,11 @@ final class ToAccountContains extends AbstractTrigger implements TriggerInterfac
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
$res = '' === (string)$value;

View File

@ -43,11 +43,11 @@ final class ToAccountEnds extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
$res = '' === (string)$value;

View File

@ -43,11 +43,11 @@ final class ToAccountIs extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
$res = '' === (string)$value;

View File

@ -43,11 +43,11 @@ final class ToAccountStarts extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
$res = '' === (string)$value;

View File

@ -42,11 +42,11 @@ final class TransactionType extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
if (null !== $value) {
return false;

View File

@ -41,11 +41,11 @@ interface TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @return bool
*/
public static function willMatchEverything($value = null);
public static function willMatchEverything($value = null): bool;
/**
* Triggers on a value and journal.

View File

@ -42,13 +42,13 @@ final class UserAction extends AbstractTrigger implements TriggerInterface
* (even if it will still include 99.9% of the users transactions), this method MUST return
* false.
*
* @param null $value
* @param mixed $value
*
* @codeCoverageIgnore
*
* @return bool
*/
public static function willMatchEverything($value = null)
public static function willMatchEverything($value = null): bool
{
return true;
}