Not sure why I keep calling this tool nestor, it's called rector

This commit is contained in:
James Cole
2025-05-24 05:52:31 +02:00
parent 1c33be4828
commit b8e33201bd
8 changed files with 25 additions and 14 deletions

View File

@@ -24,8 +24,12 @@
declare(strict_types=1); declare(strict_types=1);
use Rector\Config\RectorConfig; use Rector\Config\RectorConfig;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
return RectorConfig::configure() return RectorConfig::configure()
->withSkip([
ChangeOrIfContinueToMultiContinueRector::class,
])
->withPaths([ ->withPaths([
// __DIR__ . '/../app', // __DIR__ . '/../app',
__DIR__ . '/../app/Http', __DIR__ . '/../app/Http',
@@ -43,9 +47,9 @@ __DIR__ . '/../app/Http',
privatization: false, // leave false. privatization: false, // leave false.
naming : false, // leave false naming : false, // leave false
instanceOf : true, instanceOf : true,
earlyReturn : false, earlyReturn : true,
strictBooleans : false, strictBooleans : true,
carbon : false, carbon : true,
rectorPreset : false, rectorPreset : false,
phpunitCodeQuality : false, phpunitCodeQuality : false,
doctrineCodeQuality: false, doctrineCodeQuality: false,
@@ -61,4 +65,5 @@ __DIR__ . '/../app/Http',
->withTypeCoverageLevel(0) ->withTypeCoverageLevel(0)
->withDeadCodeLevel(0) ->withDeadCodeLevel(0)
->withCodeQualityLevel(0) ->withCodeQualityLevel(0)
->withImportNames(removeUnusedImports: true);// import statements instead of full classes. ->withImportNames(removeUnusedImports: true);// import statements instead of full classes.

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin; namespace FireflyIII\Http\Controllers\Admin;
use Carbon\Carbon;
use FireflyIII\Helpers\Update\UpdateTrait; use FireflyIII\Helpers\Update\UpdateTrait;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser; use FireflyIII\Http\Middleware\IsDemoUser;
@@ -96,7 +97,7 @@ class UpdateController extends Controller
$channel = in_array($channel, ['stable', 'beta', 'alpha'], true) ? $channel : 'stable'; $channel = in_array($channel, ['stable', 'beta', 'alpha'], true) ? $channel : 'stable';
app('fireflyconfig')->set('permission_update_check', $checkForUpdates); app('fireflyconfig')->set('permission_update_check', $checkForUpdates);
app('fireflyconfig')->set('last_update_check', time()); app('fireflyconfig')->set('last_update_check', Carbon::now()->getTimestamp());
app('fireflyconfig')->set('update_channel', $channel); app('fireflyconfig')->set('update_channel', $channel);
session()->flash('success', (string) trans('firefly.configuration_updated')); session()->flash('success', (string) trans('firefly.configuration_updated'));

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Auth; namespace FireflyIII\Http\Controllers\Auth;
use Carbon\Carbon;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Support\Facades\Cookie; use Illuminate\Support\Facades\Cookie;
use FireflyIII\Events\ActuallyLoggedIn; use FireflyIII\Events\ActuallyLoggedIn;
@@ -253,7 +254,7 @@ class LoginController extends Controller
$storeInCookie = config('google2fa.store_in_cookie', false); $storeInCookie = config('google2fa.store_in_cookie', false);
if (false !== $storeInCookie) { if (false !== $storeInCookie) {
$cookieName = config('google2fa.cookie_name', 'google2fa_token'); $cookieName = config('google2fa.cookie_name', 'google2fa_token');
Cookie::queue(Cookie::make($cookieName, 'invalid-'.time())); Cookie::queue(Cookie::make($cookieName, 'invalid-'.Carbon::now()->getTimestamp()));
} }
$usernameField = $this->username(); $usernameField = $this->username();

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Auth; namespace FireflyIII\Http\Controllers\Auth;
use Carbon\Carbon;
use FireflyIII\Events\Security\MFABackupFewLeft; use FireflyIII\Events\Security\MFABackupFewLeft;
use FireflyIII\Events\Security\MFABackupNoLeft; use FireflyIII\Events\Security\MFABackupNoLeft;
use FireflyIII\Events\Security\MFAManyFailedAttempts; use FireflyIII\Events\Security\MFAManyFailedAttempts;
@@ -129,7 +130,7 @@ class TwoFactorController extends Controller
*/ */
private function inMFAHistory(string $mfaCode, array $mfaHistory): bool private function inMFAHistory(string $mfaCode, array $mfaHistory): bool
{ {
$now = time(); $now = Carbon::now()->getTimestamp();
foreach ($mfaHistory as $entry) { foreach ($mfaHistory as $entry) {
$time = $entry['time']; $time = $entry['time'];
$code = $entry['code']; $code = $entry['code'];
@@ -149,7 +150,7 @@ class TwoFactorController extends Controller
/** @var array $mfaHistory */ /** @var array $mfaHistory */
$mfaHistory = app('preferences')->get('mfa_history', [])->data; $mfaHistory = app('preferences')->get('mfa_history', [])->data;
$newHistory = []; $newHistory = [];
$now = time(); $now = Carbon::now()->getTimestamp();
foreach ($mfaHistory as $entry) { foreach ($mfaHistory as $entry) {
$time = $entry['time']; $time = $entry['time'];
$code = $entry['code']; $code = $entry['code'];
@@ -184,7 +185,7 @@ class TwoFactorController extends Controller
/** @var array $mfaHistory */ /** @var array $mfaHistory */
$mfaHistory = app('preferences')->get('mfa_history', [])->data; $mfaHistory = app('preferences')->get('mfa_history', [])->data;
$entry = [ $entry = [
'time' => time(), 'time' => Carbon::now()->getTimestamp(),
'code' => $mfaCode, 'code' => $mfaCode,
]; ];
$mfaHistory[] = $entry; $mfaHistory[] = $entry;

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Export; namespace FireflyIII\Http\Controllers\Export;
use Carbon\Carbon;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@@ -92,7 +93,7 @@ class IndexController extends Controller
$generator->setStart($firstDate); $generator->setStart($firstDate);
$result = $generator->export(); $result = $generator->export();
$name = sprintf('%s_transaction_export.csv', date('Y_m_d')); $name = sprintf('%s_transaction_export.csv', Carbon::now()->format('Y_m_d'));
$quoted = sprintf('"%s"', addcslashes($name, '"\\')); $quoted = sprintf('"%s"', addcslashes($name, '"\\'));
// headers for CSV file. // headers for CSV file.

View File

@@ -153,7 +153,7 @@ class RecurrenceController extends Controller
*/ */
public function suggest(Request $request): JsonResponse public function suggest(Request $request): JsonResponse
{ {
$string = '' === (string) $request->get('date') ? date('Y-m-d') : (string) $request->get('date'); $string = '' === (string) $request->get('date') ? Carbon::now()->format('Y-m-d') : (string) $request->get('date');
$today = today(config('app.timezone'))->startOfDay(); $today = today(config('app.timezone'))->startOfDay();
try { try {

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers; namespace FireflyIII\Http\Controllers;
use Carbon\Carbon;
use JsonException; use JsonException;
use function Safe\json_decode; use function Safe\json_decode;
use function Safe\file_get_contents; use function Safe\file_get_contents;
@@ -114,7 +115,7 @@ class PreferencesController extends Controller
if (is_array($fiscalYearStartStr)) { if (is_array($fiscalYearStartStr)) {
$fiscalYearStartStr = '01-01'; $fiscalYearStartStr = '01-01';
} }
$fiscalYearStart = sprintf('%s-%s', date('Y'), (string) $fiscalYearStartStr); $fiscalYearStart = sprintf('%s-%s', Carbon::now()->format('Y'), (string) $fiscalYearStartStr);
$tjOptionalFields = Preferences::get('transaction_journal_optional_fields', [])->data; $tjOptionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
$availableDarkModes = config('firefly.available_dark_modes'); $availableDarkModes = config('firefly.available_dark_modes');
@@ -277,7 +278,7 @@ class PreferencesController extends Controller
$customFiscalYear = 1 === (int) $request->get('customFiscalYear'); $customFiscalYear = 1 === (int) $request->get('customFiscalYear');
$string = strtotime((string) $request->get('fiscalYearStart')); $string = strtotime((string) $request->get('fiscalYearStart'));
if (false !== $string) { if (false !== $string) {
$fiscalYearStart = date('m-d', $string); $fiscalYearStart = Carbon::createFromTimestamp($string)->format('m-d');
Preferences::set('customFiscalYear', $customFiscalYear); Preferences::set('customFiscalYear', $customFiscalYear);
Preferences::set('fiscalYearStart', $fiscalYearStart); Preferences::set('fiscalYearStart', $fiscalYearStart);
} }

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Profile; namespace FireflyIII\Http\Controllers\Profile;
use Carbon\Carbon;
use Cookie; use Cookie;
use Google2FA; use Google2FA;
use FireflyIII\Events\Security\DisabledMFA; use FireflyIII\Events\Security\DisabledMFA;
@@ -296,7 +297,7 @@ class MfaController extends Controller
/** @var array $mfaHistory */ /** @var array $mfaHistory */
$mfaHistory = app('preferences')->get('mfa_history', [])->data; $mfaHistory = app('preferences')->get('mfa_history', [])->data;
$entry = [ $entry = [
'time' => time(), 'time' => Carbon::now()->getTimestamp(),
'code' => $mfaCode, 'code' => $mfaCode,
]; ];
$mfaHistory[] = $entry; $mfaHistory[] = $entry;
@@ -313,7 +314,7 @@ class MfaController extends Controller
/** @var array $mfaHistory */ /** @var array $mfaHistory */
$mfaHistory = app('preferences')->get('mfa_history', [])->data; $mfaHistory = app('preferences')->get('mfa_history', [])->data;
$newHistory = []; $newHistory = [];
$now = time(); $now = Carbon::now()->getTimestamp();
foreach ($mfaHistory as $entry) { foreach ($mfaHistory as $entry) {
$time = $entry['time']; $time = $entry['time'];
$code = $entry['code']; $code = $entry['code'];