mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-07-28 00:09:56 -07:00
Fix various phpstan issues.
This commit is contained in:
@@ -34,10 +34,6 @@ parameters:
|
||||
reportUnmatchedIgnoredErrors: true
|
||||
ignoreErrors:
|
||||
# these are actually interesting but not right now:
|
||||
- identifier: larastan.noUnnecessaryCollectionCall
|
||||
- identifier: varTag.differentVariable
|
||||
- identifier: identical.alwaysTrue
|
||||
- identifier: assign.propertyReadOnly
|
||||
- identifier: varTag.nativeType
|
||||
- identifier: property.onlyWritten
|
||||
- identifier: parameter.phpDocType
|
||||
|
||||
@@ -224,7 +224,8 @@ abstract class Controller extends BaseController
|
||||
$value = min(max(1, $value), 2 ** 16);
|
||||
$bag->set($integer, $value);
|
||||
}
|
||||
if (null === $value && 'limit' === $integer && auth()->check()) {
|
||||
// && 'limit' === $integer
|
||||
if (null === $value && auth()->check()) {
|
||||
// set default for user:
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
@@ -48,6 +48,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
final class UpdateController extends Controller
|
||||
{
|
||||
private TransactionGroupRepositoryInterface $groupRepository;
|
||||
protected array $acceptedRoles = [];
|
||||
|
||||
/**
|
||||
* TransactionController constructor.
|
||||
|
||||
@@ -64,10 +64,6 @@ class RemovesDatabaseDecryption extends Command
|
||||
'journal_links' => ['comment'],
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string $table
|
||||
* @var array $fields
|
||||
*/
|
||||
foreach ($tables as $table => $fields) {
|
||||
$this->decryptTable($table, $fields);
|
||||
}
|
||||
|
||||
@@ -50,15 +50,15 @@ class DeletedAccountObserver
|
||||
}
|
||||
|
||||
$journalIds = Transaction::where('account_id', $account->id)
|
||||
->get(['transactions.transaction_journal_id'])
|
||||
->pluck('transaction_journal_id')
|
||||
->toArray()
|
||||
;
|
||||
$groupIds = TransactionJournal::whereIn('id', $journalIds)
|
||||
->get(['transaction_journals.transaction_group_id'])
|
||||
->pluck('transaction_group_id')
|
||||
->toArray()
|
||||
;
|
||||
->get(['transactions.transaction_journal_id'])
|
||||
->pluck('transaction_journal_id')
|
||||
->toArray();
|
||||
|
||||
$groupIds = array_map(function (array $item) {
|
||||
return $item['transaction_group_id'];
|
||||
}, TransactionJournal::whereIn('id', $journalIds)
|
||||
->get(['transaction_journals.transaction_group_id'])
|
||||
->toArray());
|
||||
|
||||
if (count($journalIds) > 0) {
|
||||
Transaction::whereIn('transaction_journal_id', $journalIds)->delete();
|
||||
|
||||
@@ -224,7 +224,7 @@ final class IndexController extends Controller
|
||||
Log::debug(sprintf('(getAllBudgets) Start is "%s", end is "%s"', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
|
||||
// complement budget with budget limits in range, and expenses in currency X in range.
|
||||
/** @var Budget $current */
|
||||
/** @var Budget $budget */
|
||||
foreach ($collection as $budget) {
|
||||
Log::debug(sprintf('Working on budget #%d ("%s")', $budget->id, $budget->name));
|
||||
$array = $budget->toArray();
|
||||
|
||||
@@ -31,6 +31,7 @@ use FireflyIII\Events\Security\System\SystemRequestedVersionCheck;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Middleware\Installer;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Support\Facades\Preferences;
|
||||
|
||||
@@ -42,6 +42,9 @@ use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* @property AccountType $accountType
|
||||
*/
|
||||
#[ObservedBy([DeletedAccountObserver::class])]
|
||||
class Account extends Model
|
||||
{
|
||||
|
||||
@@ -34,6 +34,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* @property Carbon $date
|
||||
* @property PiggyBank $piggyBank
|
||||
*/
|
||||
#[ObservedBy([PiggyBankEventObserver::class])]
|
||||
class PiggyBankEvent extends Model
|
||||
|
||||
@@ -33,10 +33,12 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Collection;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* @property User $user
|
||||
* @property Collection<RuleTrigger> $ruleTriggers
|
||||
*/
|
||||
#[ObservedBy([DeletedRuleObserver::class])]
|
||||
class Rule extends Model
|
||||
|
||||
@@ -30,7 +30,6 @@ use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Override;
|
||||
|
||||
use function Safe\file_get_contents;
|
||||
use function Safe\json_decode;
|
||||
|
||||
@@ -49,9 +48,9 @@ class GitHubUpdateRequest implements UpdateRequestInterface
|
||||
$this->currentBuild = $currentBuild;
|
||||
Log::debug(sprintf('Now in getUpdateInformation(%s, %s)', $currentVersion, $channel));
|
||||
|
||||
$response = new UpdateResponse();
|
||||
$releases = $this->getReleases();
|
||||
$filtered = $this->filterReleases($releases);
|
||||
$response = new UpdateResponse();
|
||||
$releases = $this->getReleases();
|
||||
$filtered = $this->filterReleases($releases);
|
||||
|
||||
Log::debug(sprintf('Left with %d release(s) to compare', count($filtered)));
|
||||
|
||||
@@ -61,7 +60,7 @@ class GitHubUpdateRequest implements UpdateRequestInterface
|
||||
return $response;
|
||||
}
|
||||
|
||||
$newest = $this->getNewest($filtered);
|
||||
$newest = $this->getNewest($filtered);
|
||||
|
||||
Log::debug(sprintf('Newest release is "%s" released on %s', $newest['version'], $newest['published_at']->format('Y-m-d H:i')));
|
||||
|
||||
@@ -74,20 +73,20 @@ class GitHubUpdateRequest implements UpdateRequestInterface
|
||||
Log::debug(sprintf('Compare with current version "%s", built on %s', $currentVersion, $currentBuild->format('Y-m-d H:i')));
|
||||
if ($currentBuild->lt($newest['published_at']) && $currentBuild->diffInMinutes($newest['published_at']) > 10) {
|
||||
Log::debug(sprintf(
|
||||
'Current build %s is older than newest build %s, so a new release is available.',
|
||||
$currentBuild->format('Y-m-d H:i:s e'),
|
||||
$newest['published_at']->format('Y-m-d H:i:s e')
|
||||
));
|
||||
'Current build %s is older than newest build %s, so a new release is available.',
|
||||
$currentBuild->format('Y-m-d H:i:s e'),
|
||||
$newest['published_at']->format('Y-m-d H:i:s e')
|
||||
));
|
||||
$response->setNewVersionAvailable(true);
|
||||
|
||||
return $response;
|
||||
}
|
||||
if ($currentBuild->gt($newest['published_at'])) {
|
||||
Log::debug(sprintf(
|
||||
'Current build %s is newer than newest build %s, so NO new release is available.',
|
||||
$currentBuild->format('Y-m-d H:i'),
|
||||
$newest['published_at']->format('Y-m-d H:i')
|
||||
));
|
||||
'Current build %s is newer than newest build %s, so NO new release is available.',
|
||||
$currentBuild->format('Y-m-d H:i'),
|
||||
$newest['published_at']->format('Y-m-d H:i')
|
||||
));
|
||||
$response->setNewVersionAvailable(false);
|
||||
|
||||
return $response;
|
||||
@@ -97,19 +96,15 @@ class GitHubUpdateRequest implements UpdateRequestInterface
|
||||
}
|
||||
|
||||
// if not, compare version.
|
||||
$res = version_compare($newest['version'], $currentVersion);
|
||||
$res = version_compare($newest['version'], $currentVersion);
|
||||
if ($res < 1) {
|
||||
$response->setNewVersionAvailable(false);
|
||||
|
||||
return $response;
|
||||
}
|
||||
if (1 === $res) {
|
||||
$response->setNewVersionAvailable(true);
|
||||
$response->setNewVersionAvailable(true);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
// return $response;
|
||||
return $response;
|
||||
}
|
||||
|
||||
private function filterReleases(array $releases): array
|
||||
@@ -151,7 +146,7 @@ class GitHubUpdateRequest implements UpdateRequestInterface
|
||||
|
||||
private function getNewest(array $releases): array
|
||||
{
|
||||
$latest = ['version' => '1.0.0', 'published_at' => now(config('app.timezone'))->startOfYear()];
|
||||
$latest = ['version' => '1.0.0', 'published_at' => now(config('app.timezone'))->startOfYear()];
|
||||
foreach ($releases as $release) {
|
||||
Log::debug(sprintf('Comparing current version "%s" with latest version "%s"', $release['version'], $latest['version']));
|
||||
if (str_contains($release['version'], 'develop') || str_contains($latest['version'], 'develop')) {
|
||||
@@ -159,10 +154,10 @@ class GitHubUpdateRequest implements UpdateRequestInterface
|
||||
// compare build times.
|
||||
if ($latest['published_at']->lt($release['published_at'])) {
|
||||
Log::debug(sprintf(
|
||||
'Current date "%s" is newer than latest date "%s"',
|
||||
$release['published_at']->format('Y-m-d H:i'),
|
||||
$latest['published_at']->format('Y-m-d H:i')
|
||||
));
|
||||
'Current date "%s" is newer than latest date "%s"',
|
||||
$release['published_at']->format('Y-m-d H:i'),
|
||||
$latest['published_at']->format('Y-m-d H:i')
|
||||
));
|
||||
$latest = $release;
|
||||
}
|
||||
}
|
||||
@@ -184,7 +179,7 @@ class GitHubUpdateRequest implements UpdateRequestInterface
|
||||
private function getReleases(): array
|
||||
{
|
||||
$client = new Client();
|
||||
$opts = ['timeout' => 5.0, 'headers' => ['User-Agent' => 'FireflyIII/'.config('firefly.version')]];
|
||||
$opts = ['timeout' => 5.0, 'headers' => ['User-Agent' => 'FireflyIII/' . config('firefly.version')]];
|
||||
$return = [];
|
||||
$body = '';
|
||||
if ($this->localDebug && file_exists('json.json')) {
|
||||
@@ -193,13 +188,13 @@ class GitHubUpdateRequest implements UpdateRequestInterface
|
||||
if (!$this->localDebug) {
|
||||
try {
|
||||
$res = $client->get('https://api.github.com/repos/firefly-iii/firefly-iii/releases', $opts);
|
||||
} catch (ClientException|Exception $e) {
|
||||
} catch (ClientException | Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
|
||||
return [];
|
||||
}
|
||||
Log::debug('Successfully contacted GitHub');
|
||||
$body = (string) $res->getBody();
|
||||
$body = (string)$res->getBody();
|
||||
}
|
||||
|
||||
if (!json_validate($body)) {
|
||||
@@ -207,7 +202,7 @@ class GitHubUpdateRequest implements UpdateRequestInterface
|
||||
|
||||
return [];
|
||||
}
|
||||
$json = json_decode($body, true);
|
||||
$json = json_decode($body, true);
|
||||
|
||||
/** @var array $release */
|
||||
foreach ($json as $release) {
|
||||
@@ -222,7 +217,7 @@ class GitHubUpdateRequest implements UpdateRequestInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
$return[] = ['version' => $version, 'published_at' => $published];
|
||||
$return[] = ['version' => $version, 'published_at' => $published];
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
||||
Reference in New Issue
Block a user