Remove inspection, add TODO's, make code a bit simpler.

This commit is contained in:
James Cole 2019-08-16 21:38:35 +02:00
parent 820358af73
commit f09d0e87e4
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
23 changed files with 79 additions and 90 deletions

View File

@ -73,7 +73,7 @@ class ShowController extends Controller
);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Show an account.
*

View File

@ -65,7 +65,7 @@ class ShowController extends Controller
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Show a single category.
*

View File

@ -382,7 +382,7 @@ class BudgetController extends Controller
return response()->json($data);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Shows a budget overview chart (spent and budgeted).
*

View File

@ -66,7 +66,7 @@ class BudgetReportController extends Controller
);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Chart that groups expenses by the account.
*
@ -97,7 +97,7 @@ class BudgetReportController extends Controller
return response()->json($data);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Chart that groups the expenses by budget.
*
@ -128,7 +128,7 @@ class BudgetReportController extends Controller
return response()->json($data);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Main overview of a budget in the budget report.
*

View File

@ -260,7 +260,7 @@ class CategoryController extends Controller
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Chart for period for transactions without a category.

View File

@ -61,7 +61,7 @@ class CategoryReportController extends Controller
);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Chart for expenses grouped by expense account.
*
@ -89,7 +89,7 @@ class CategoryReportController extends Controller
return response()->json($data);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Chart for income grouped by revenue account.
*
@ -120,7 +120,7 @@ class CategoryReportController extends Controller
return response()->json($data);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Chart for expenses grouped by expense account.
*
@ -151,7 +151,7 @@ class CategoryReportController extends Controller
return response()->json($data);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Piechart for income grouped by account.
*
@ -182,7 +182,7 @@ class CategoryReportController extends Controller
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Main report category chart.
*

View File

@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
/** @noinspection MoreThanThreeArgumentsInspection */
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart;
@ -64,7 +64,7 @@ class ExpenseReportController extends Controller
);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Main chart that shows income and expense for a combination of expense/revenue accounts.
*

View File

@ -53,7 +53,7 @@ class TagReportController extends Controller
$this->generator = app(GeneratorInterface::class);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Generate expenses for tags grouped on account.
*
@ -84,7 +84,7 @@ class TagReportController extends Controller
return response()->json($data);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Generate income for tag grouped by account.
*
@ -115,7 +115,7 @@ class TagReportController extends Controller
return response()->json($data);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Generate expense for tag grouped on budget.
*
@ -145,7 +145,7 @@ class TagReportController extends Controller
return response()->json($data);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Generate expense for tag grouped on category.
*
@ -175,7 +175,7 @@ class TagReportController extends Controller
return response()->json($data);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Generate main tag overview chart.
*
@ -292,7 +292,7 @@ class TagReportController extends Controller
return response()->json($data);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Show expense grouped by expense account.
*
@ -323,7 +323,7 @@ class TagReportController extends Controller
return response()->json($data);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Show income grouped by tag.
*

View File

@ -37,7 +37,7 @@ use Log;
*/
class ExchangeController extends Controller
{
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Returns an exchange rate.
*

View File

@ -63,7 +63,7 @@ class ExpenseController extends Controller
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Generates the overview per budget.
*
@ -117,7 +117,7 @@ class ExpenseController extends Controller
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Generates the overview per category (spent and earned).
*
@ -179,7 +179,7 @@ class ExpenseController extends Controller
return $result;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Overview of spending.
*
@ -232,7 +232,7 @@ class ExpenseController extends Controller
// for period, get spent and earned for each account (by name)
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* List of top expenses.
*
@ -284,7 +284,7 @@ class ExpenseController extends Controller
return $result;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* List of top income.
*

View File

@ -69,7 +69,7 @@ class ReportController extends Controller
}
);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Show account report.
*
@ -138,7 +138,7 @@ class ReportController extends Controller
return $generator->generate();
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Show budget report.
*
@ -176,7 +176,7 @@ class ReportController extends Controller
return $generator->generate();
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Show category report.
*
@ -386,7 +386,7 @@ class ReportController extends Controller
return redirect($uri);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Get a tag report.
*

View File

@ -90,7 +90,7 @@ class FireflyServiceProvider extends ServiceProvider
public function boot(): void
{
Validator::resolver(
/** @noinspection MoreThanThreeArgumentsInspection */
function ($translator, $data, $rules, $messages) {
return new FireflyValidator($translator, $data, $rules, $messages);
}

View File

@ -467,7 +467,7 @@ class BudgetRepository implements BudgetRepositoryInterface
return $amount;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Carbon $start
@ -544,7 +544,7 @@ class BudgetRepository implements BudgetRepositoryInterface
return $set;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Get all budgets with these ID's.
@ -570,7 +570,7 @@ class BudgetRepository implements BudgetRepositoryInterface
return $set;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $accounts
@ -822,7 +822,7 @@ class BudgetRepository implements BudgetRepositoryInterface
return $newBudget;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param array $data

View File

@ -147,6 +147,8 @@ interface BudgetRepositoryInterface
public function getAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end): string;
/**
* TODO only used in API
*
* @param Carbon $start
* @param Carbon $end
*
@ -165,6 +167,8 @@ interface BudgetRepositoryInterface
public function getAvailableBudgetsByDate(?Carbon $start, ?Carbon $end): Collection;
/**
* TODO only used in API
*
* Returns all available budget objects.
*
* @param TransactionCurrency $currency
@ -205,7 +209,7 @@ interface BudgetRepositoryInterface
*/
public function getByIds(array $budgetIds): Collection;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @return Collection
@ -244,7 +248,7 @@ interface BudgetRepositoryInterface
*/
public function setBudgetOrder(Budget $budget, int $order): void;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param User $user
@ -252,6 +256,7 @@ interface BudgetRepositoryInterface
public function setUser(User $user);
/**
* TODO this method is not multi-currency aware.
* @param Collection $budgets
* @param Collection $accounts
* @param Carbon $start
@ -261,7 +266,7 @@ interface BudgetRepositoryInterface
*/
public function spentInPeriod(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): string;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Return multi-currency spent information.
@ -332,7 +337,7 @@ interface BudgetRepositoryInterface
*/
public function updateBudgetLimit(BudgetLimit $budgetLimit, array $data): BudgetLimit;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Budget $budget
* @param Carbon $start

View File

@ -279,7 +279,7 @@ class CategoryRepository implements CategoryRepositoryInterface
return $this->user->categories()->find($categoryId);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Find a category.
@ -317,7 +317,7 @@ class CategoryRepository implements CategoryRepositoryInterface
return $factory->findOrCreate(null, $data['name']);
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Category $category
@ -389,7 +389,7 @@ class CategoryRepository implements CategoryRepositoryInterface
return $lastJournalDate;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $categories
@ -433,7 +433,7 @@ class CategoryRepository implements CategoryRepositoryInterface
return $data;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $accounts
@ -472,7 +472,7 @@ class CategoryRepository implements CategoryRepositoryInterface
return $result;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $categories

View File

@ -124,7 +124,7 @@ interface CategoryRepositoryInterface
*/
public function getCategories(): Collection;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Return most recent transaction(journal) date or null when never used before.
@ -146,7 +146,7 @@ interface CategoryRepositoryInterface
*/
public function periodExpenses(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param Collection $accounts
@ -176,7 +176,7 @@ interface CategoryRepositoryInterface
*/
public function periodIncomeNoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param string $query
@ -185,7 +185,7 @@ interface CategoryRepositoryInterface
*/
public function searchCategory(string $query): Collection;
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param User $user

View File

@ -39,7 +39,7 @@ use Tests\Object\FakeApiContext;
*/
class ApiContext
{
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param BunqEnumApiEnvironmentType $environmentType
* @param string $apiKey

View File

@ -36,7 +36,7 @@ use Preferences as Prefs;
*/
class Amount
{
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* bool $sepBySpace is $localeconv['n_sep_by_space']
* int $signPosn = $localeconv['n_sign_posn']

View File

@ -575,7 +575,7 @@ trait AugumentData
return $grouped;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Spent by budget.
@ -635,7 +635,7 @@ trait AugumentData
return $sum;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Spent by category.
@ -696,7 +696,7 @@ trait AugumentData
return $sum;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Spent in a period.
@ -744,7 +744,7 @@ trait AugumentData
return $sum;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Returns an array with the following values:

View File

@ -32,7 +32,7 @@ use Illuminate\Support\Facades\Log;
*/
trait CalculateRangeOccurrences
{
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.
*
@ -60,7 +60,7 @@ trait CalculateRangeOccurrences
return $return;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.
*
@ -107,7 +107,7 @@ trait CalculateRangeOccurrences
return $return;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Get the number of daily occurrences for a recurring transaction until date $end is reached. Will skip every $skipMod-1 occurrences.

View File

@ -32,7 +32,7 @@ use Carbon\Carbon;
*/
trait CalculateXOccurrences
{
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Calculates the number of daily occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences.
@ -61,7 +61,7 @@ trait CalculateXOccurrences
return $return;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Calculates the number of monthly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
@ -100,7 +100,7 @@ trait CalculateXOccurrences
return $return;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Calculates the number of NDOM occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
* over $skipMod -1 recurrences.
@ -139,7 +139,7 @@ trait CalculateXOccurrences
return $return;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Calculates the number of weekly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip
@ -183,7 +183,7 @@ trait CalculateXOccurrences
return $return;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* Calculates the number of yearly occurrences for a recurring transaction, starting at the date, until $count is reached. It will skip

View File

@ -122,7 +122,7 @@ class AmountFormat extends Twig_Extension
{
return new Twig_SimpleFunction(
'formatAmountBySymbol',
/** @noinspection MoreThanThreeArgumentsInspection */
static function (string $amount, string $symbol, int $decimalPlaces = null, bool $coloured = null): string {
$decimalPlaces = $decimalPlaces ?? 2;
$coloured = $coloured ?? true;

View File

@ -63,8 +63,10 @@ class AccountValidator
$this->destError = 'No error yet.';
$this->sourceError = 'No error yet.';
$this->combinations = config('firefly.source_dests');
/** @var AccountRepositoryInterface accountRepository */
$this->accountRepository = app(AccountRepositoryInterface::class);
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
@ -174,25 +176,12 @@ class AccountValidator
*/
private function canCreateType(string $accountType): bool
{
$result = false;
switch ($accountType) {
default:
Log::error(sprintf('AccountValidator::validateSource cannot handle "%s".', $this->transactionType));
break;
case AccountType::ASSET:
case AccountType::LOAN:
case AccountType::MORTGAGE:
case AccountType::DEBT:
$result = false;
break;
case AccountType::EXPENSE:
case AccountType::REVENUE:
case AccountType::INITIAL_BALANCE:
$result = true;
break;
$canCreate = [AccountType::EXPENSE, AccountType::REVENUE, AccountType::INITIAL_BALANCE];
if (in_array($accountType, $canCreate, true)) {
return true;
}
return $result;
return false;
}
/**
@ -225,25 +214,20 @@ class AccountValidator
*/
private function findExistingAccount(array $validTypes, int $accountId, string $accountName): ?Account
{
$result = null;
// find by ID
if ($accountId > 0) {
$first = $this->accountRepository->findNull($accountId);
if ((null !== $first) && in_array($first->accountType->type, $validTypes, true)) {
$result = $first;
return $first;
}
}
// find by name:
if (null === $result && '' !== $accountName) {
$second = $this->accountRepository->findByName($accountName, $validTypes);
if (null !== $second) {
$result = $second;
}
if ('' !== $accountName) {
return $this->accountRepository->findByName($accountName, $validTypes);
}
return $result;
return null;
}
/**