mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
Make sure phpcs and rector agree on styles.
This commit is contained in:
@@ -64,6 +64,7 @@ return $config->setRules(
|
||||
'global_namespace_import' => true, // matches with rector.
|
||||
|
||||
// complex rules
|
||||
'phpdoc_to_comment' => ['ignored_tags' => ['var']],
|
||||
'php_unit_test_case_static_method_calls' => [
|
||||
'call_type' => 'this',
|
||||
],
|
||||
|
@@ -28,7 +28,8 @@ composer update --quiet
|
||||
rm -f .php-cs-fixer.cache
|
||||
PHP_CS_FIXER_IGNORE_ENV=true ./vendor/bin/php-cs-fixer fix \
|
||||
--config $SCRIPT_DIR/php-cs-fixer/.php-cs-fixer.php \
|
||||
--format=txt -v \
|
||||
--format=txt \
|
||||
-v \
|
||||
--allow-risky=yes
|
||||
|
||||
EXIT_CODE=$?
|
||||
|
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
|
||||
use Rector\Php80\Rector\ClassMethod\AddParamBasedOnParentClassMethodRector;
|
||||
use Rector\Transform\Rector\String_\StringToClassConstantRector;
|
||||
use RectorLaravel\Set\LaravelLevelSetList;
|
||||
|
||||
@@ -32,6 +33,7 @@ use RectorLaravel\Set\LaravelLevelSetList;
|
||||
return RectorConfig::configure()
|
||||
->withSkip([
|
||||
ChangeOrIfContinueToMultiContinueRector::class,
|
||||
AddParamBasedOnParentClassMethodRector::class,
|
||||
StringToClassConstantRector::class => [
|
||||
__DIR__ . '/../app/Http/Controllers/Auth/LoginController.php',
|
||||
],
|
||||
|
@@ -82,7 +82,7 @@ class NetWorth implements NetWorthInterface
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
// Log::debug(sprintf('Now at account #%d ("%s")', $account->id, $account->name));
|
||||
// Log::debug(sprintf('Now at account #%d ("%s")', $account->id, $account->name));
|
||||
$currency = $this->accountRepository->getAccountCurrency($account) ?? $default;
|
||||
$useNative = $convertToNative && $default->id !== $currency->id;
|
||||
$currency = $useNative ? $default : $currency;
|
||||
@@ -93,12 +93,12 @@ class NetWorth implements NetWorthInterface
|
||||
$balance = $balances[$account->id]['balance'] ?? '0';
|
||||
$nativeBalance = $balances[$account->id]['native_balance'] ?? '0';
|
||||
}
|
||||
// Log::debug(sprintf('Balance is %s, native balance is %s', $balance, $nativeBalance));
|
||||
// Log::debug(sprintf('Balance is %s, native balance is %s', $balance, $nativeBalance));
|
||||
// always subtract virtual balance again.
|
||||
$balance = '' !== (string) $account->virtual_balance ? bcsub($balance, (string) $account->virtual_balance) : $balance;
|
||||
$nativeBalance = '' !== (string) $account->native_virtual_balance ? bcsub($nativeBalance, (string) $account->native_virtual_balance) : $nativeBalance;
|
||||
$amountToUse = $useNative ? $nativeBalance : $balance;
|
||||
// Log::debug(sprintf('Will use %s %s', $currencyCode, $amountToUse));
|
||||
// Log::debug(sprintf('Will use %s %s', $currencyCode, $amountToUse));
|
||||
|
||||
$netWorth[$currencyCode] ??= [
|
||||
'balance' => '0',
|
||||
|
@@ -71,12 +71,12 @@ class TransactionSummarizer
|
||||
$foreignCurrencyDecimalPlaces = null;
|
||||
|
||||
if ($this->convertToNative) {
|
||||
// Log::debug('convertToNative is true.');
|
||||
// Log::debug('convertToNative is true.');
|
||||
// if convert to native, use the native amount yes or no?
|
||||
$useNative = $this->default->id !== (int) $journal['currency_id'];
|
||||
$useForeign = $this->default->id === (int) $journal['foreign_currency_id'];
|
||||
if ($useNative) {
|
||||
// Log::debug(sprintf('Journal #%d switches to native amount (original is %s)', $journal['transaction_journal_id'], $journal['currency_code']));
|
||||
// Log::debug(sprintf('Journal #%d switches to native amount (original is %s)', $journal['transaction_journal_id'], $journal['currency_code']));
|
||||
$field = 'native_amount';
|
||||
$currencyId = $this->default->id;
|
||||
$currencyName = $this->default->name;
|
||||
@@ -85,7 +85,7 @@ class TransactionSummarizer
|
||||
$currencyDecimalPlaces = $this->default->decimal_places;
|
||||
}
|
||||
if ($useForeign) {
|
||||
// Log::debug(sprintf('Journal #%d switches to foreign amount (foreign is %s)', $journal['transaction_journal_id'], $journal['foreign_currency_code']));
|
||||
// Log::debug(sprintf('Journal #%d switches to foreign amount (foreign is %s)', $journal['transaction_journal_id'], $journal['foreign_currency_code']));
|
||||
$field = 'foreign_amount';
|
||||
$currencyId = (int) $journal['foreign_currency_id'];
|
||||
$currencyName = $journal['foreign_currency_name'];
|
||||
@@ -95,7 +95,7 @@ class TransactionSummarizer
|
||||
}
|
||||
}
|
||||
if (!$this->convertToNative) {
|
||||
// Log::debug('convertToNative is false.');
|
||||
// Log::debug('convertToNative is false.');
|
||||
// use foreign amount?
|
||||
$foreignCurrencyId = (int) $journal['foreign_currency_id'];
|
||||
if (0 !== $foreignCurrencyId) {
|
||||
|
@@ -260,8 +260,6 @@ return [
|
||||
'destination_balance_lt' => ['alias' => false, 'needs_context' => true],
|
||||
'destination_balance_is' => ['alias' => false, 'needs_context' => true],
|
||||
],
|
||||
/**
|
||||
* Which query parser to use - 'new' or 'legacy'
|
||||
*/
|
||||
// Which query parser to use - 'new' or 'legacy'
|
||||
'query_parser' => env('QUERY_PARSER_IMPLEMENTATION', 'legacy'),
|
||||
];
|
||||
|
@@ -56,7 +56,7 @@ final class BillDateCalculatorTest extends TestCase
|
||||
public function testGivenSomeDataItWorks(Carbon $earliest, Carbon $latest, Carbon $billStart, string $period, int $skip, ?Carbon $lastPaid, array $expected): void
|
||||
{
|
||||
$result = $this->calculator->getPayDates($earliest, $latest, $billStart, $period, $skip, $lastPaid);
|
||||
self::assertSame($expected, $result);
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
public static function provideDates(): Iterator
|
||||
|
@@ -45,6 +45,6 @@ final class NavigationCustomEndOfPeriodTest extends TestCase
|
||||
$navigation = new Navigation();
|
||||
|
||||
$period = $navigation->endOfPeriod($from, 'custom');
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
$this->assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ final class CalculatorTest extends TestCase
|
||||
{
|
||||
$calculator = new Calculator();
|
||||
$period = $calculator->nextDateByInterval($provider->epoch(), $provider->periodicity);
|
||||
self::assertSame($provider->expected()->toDateString(), $period->toDateString());
|
||||
$this->assertSame($provider->expected()->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function provideAllPeriodicity(): iterable
|
||||
@@ -102,7 +102,7 @@ final class CalculatorTest extends TestCase
|
||||
{
|
||||
$calculator = new Calculator();
|
||||
$period = $calculator->nextDateByInterval($provider->epoch(), $provider->periodicity, $provider->skip);
|
||||
self::assertSame($provider->expected()->toDateString(), $period->toDateString());
|
||||
$this->assertSame($provider->expected()->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function provideSkippedIntervals(): iterable
|
||||
|
@@ -36,7 +36,7 @@ abstract class IntervalTestCase extends TestCase
|
||||
public function testGivenAnEpochWhenCallTheNextDateThenReturnsTheExpectedDateSuccessful(IntervalProvider $provider): void
|
||||
{
|
||||
$period = static::factory()->nextDate($provider->epoch);
|
||||
self::assertSame($provider->expected->toDateString(), $period->toDateString());
|
||||
$this->assertSame($provider->expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function provider(): iterable
|
||||
|
@@ -56,7 +56,7 @@ final class NavigationAddPeriodTest extends TestCase
|
||||
public function testGivenAFrequencyAndSkipIntervalWhenCalculateTheDateThenReturnsTheSkippedDateSuccessful(int $skip, string $frequency, Carbon $from, Carbon $expected): void
|
||||
{
|
||||
$period = $this->navigation->addPeriod($from, $frequency, $skip);
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
$this->assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function providePeriodsWithSkippingParam(): iterable
|
||||
@@ -108,7 +108,7 @@ final class NavigationAddPeriodTest extends TestCase
|
||||
public function testGivenAFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
|
||||
{
|
||||
$period = $this->navigation->addPeriod($from, $frequency, 0);
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
$this->assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function providePeriods(): Iterator
|
||||
@@ -158,7 +158,7 @@ final class NavigationAddPeriodTest extends TestCase
|
||||
public function testGivenAIntervalWhenCallTheNextDateByIntervalMethodThenReturnsTheExpectedDateSuccessful(Periodicity $periodicity, Carbon $from, Carbon $expected): void
|
||||
{
|
||||
$period = $this->navigation->nextDateByInterval($from, $periodicity);
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
$this->assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function provideFrequencies(): Iterator
|
||||
@@ -212,7 +212,7 @@ final class NavigationAddPeriodTest extends TestCase
|
||||
public function testGivenAMonthFrequencyWhenCalculateTheDateThenReturnsTheLastDayOfMonthSuccessful(string $frequency, Carbon $from, Carbon $expected): void
|
||||
{
|
||||
$period = $this->navigation->addPeriod($from, $frequency, 0);
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
$this->assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function provideMonthPeriods(): Iterator
|
||||
|
@@ -55,7 +55,7 @@ final class NavigationEndOfPeriodTest extends TestCase
|
||||
public function testGivenADateAndFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
|
||||
{
|
||||
$period = clone $this->navigation->endOfPeriod($from, $frequency);
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
$this->assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function provideDates(): Iterator
|
||||
@@ -116,7 +116,7 @@ final class NavigationEndOfPeriodTest extends TestCase
|
||||
Log::spy();
|
||||
|
||||
$period = $this->navigation->endOfPeriod($from, $frequency);
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
$this->assertSame($expected->toDateString(), $period->toDateString());
|
||||
$expectedMessage = sprintf('Cannot do endOfPeriod for $repeat_freq "%s"', $frequency);
|
||||
|
||||
Log::shouldHaveReceived('error', [$expectedMessage]);
|
||||
|
@@ -54,7 +54,7 @@ final class NavigationPreferredCarbonFormatByPeriodTest extends TestCase
|
||||
public function testGivenAPeriodWhenCallPreferredCarbonFormatByPeriodThenReturnsExpectedFormat(string $period, string $expected): void
|
||||
{
|
||||
$formatPeriod = $this->navigation->preferredCarbonFormatByPeriod($period);
|
||||
self::assertSame($expected, $formatPeriod);
|
||||
$this->assertSame($expected, $formatPeriod);
|
||||
}
|
||||
|
||||
public static function providePeriods(): Iterator
|
||||
|
@@ -55,7 +55,7 @@ final class NavigationPreferredCarbonFormatTest extends TestCase
|
||||
public function testGivenStartAndEndDatesWhenCallPreferredCarbonFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void
|
||||
{
|
||||
$carbonFormat = $this->navigation->preferredCarbonFormat($start, $end);
|
||||
self::assertSame($expected, $carbonFormat);
|
||||
$this->assertSame($expected, $carbonFormat);
|
||||
}
|
||||
|
||||
public static function providePeriods(): Iterator
|
||||
|
@@ -55,7 +55,7 @@ final class NavigationPreferredEndOfPeriodTest extends TestCase
|
||||
public function testGivenStartAndEndDatesWhenCallPreferredEndOfPeriodThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void
|
||||
{
|
||||
$formatPeriod = $this->navigation->preferredEndOfPeriod($start, $end);
|
||||
self::assertSame($expected, $formatPeriod);
|
||||
$this->assertSame($expected, $formatPeriod);
|
||||
}
|
||||
|
||||
public static function providePeriods(): Iterator
|
||||
|
@@ -55,7 +55,7 @@ final class NavigationPreferredRangeFormatTest extends TestCase
|
||||
public function testGivenStartAndEndDatesWhenCallPreferredRangeFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void
|
||||
{
|
||||
$formatPeriod = $this->navigation->preferredRangeFormat($start, $end);
|
||||
self::assertSame($expected, $formatPeriod);
|
||||
$this->assertSame($expected, $formatPeriod);
|
||||
}
|
||||
|
||||
public static function providePeriods(): Iterator
|
||||
|
@@ -55,7 +55,7 @@ final class NavigationPreferredSqlFormatTest extends TestCase
|
||||
public function testGivenStartAndEndDatesWhenCallPreferredSqlFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void
|
||||
{
|
||||
$formatPeriod = $this->navigation->preferredSqlFormat($start, $end);
|
||||
self::assertSame($expected, $formatPeriod);
|
||||
$this->assertSame($expected, $formatPeriod);
|
||||
}
|
||||
|
||||
public static function provideDates(): Iterator
|
||||
|
@@ -56,7 +56,7 @@ final class NavigationStartOfPeriodTest extends TestCase
|
||||
public function testGivenADateAndFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
|
||||
{
|
||||
$period = $this->navigation->startOfPeriod($from, $frequency);
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
$this->assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function provideDates(): Iterator
|
||||
@@ -121,7 +121,7 @@ final class NavigationStartOfPeriodTest extends TestCase
|
||||
;
|
||||
|
||||
$period = $this->navigation->startOfPeriod($from, $frequency);
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
$this->assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function provideUnknownFrequencies(): Iterator
|
||||
|
@@ -26,7 +26,7 @@ abstract class AbstractQueryParserInterfaceParseQueryTester extends TestCase
|
||||
{
|
||||
$actual = $this->createParser()->parse($query);
|
||||
|
||||
self::assertObjectEquals($expected, $actual);
|
||||
$this->assertObjectEquals($expected, $actual);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user