Various code cleanup.

This commit is contained in:
James Cole
2018-08-04 17:30:06 +02:00
parent 5af026674f
commit f0d3ca5d53
88 changed files with 552 additions and 311 deletions

View File

@@ -267,6 +267,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface
* - Add the value to the list of "values" that the user must map.
*
* @param Reader $reader
* @param array $config
* @param array $columnConfig
*
* @return array

View File

@@ -101,7 +101,7 @@ class NewFileJobHandler implements FileConfigurationInterface
}
/**
* @param ImportJob $job
* @param ImportJob $importJob
*/
public function setImportJob(ImportJob $importJob): void
{
@@ -114,7 +114,6 @@ class NewFileJobHandler implements FileConfigurationInterface
/**
* Store config from job.
*
* @throws FireflyException
*/
public function storeConfiguration(): void
{

View File

@@ -87,6 +87,8 @@ class NewYnabJobHandler implements YnabJobConfigurationInterface
* Get data for config view.
*
* @return array
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Psr\Container\ContainerExceptionInterface
*/
public function getNextData(): array
{
@@ -134,6 +136,8 @@ class NewYnabJobHandler implements YnabJobConfigurationInterface
/**
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws FireflyException
*/
private function getAccessToken(): void
@@ -231,6 +235,8 @@ class NewYnabJobHandler implements YnabJobConfigurationInterface
/**
* @return bool
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Psr\Container\ContainerExceptionInterface
*/
private function hasRefreshToken(): bool
{

View File

@@ -218,7 +218,7 @@ class SelectAccountsHandler implements YnabJobConfigurationInterface
}
/**
* @param int $accountId
* @param string $accountId
*
* @return string
*/

View File

@@ -111,6 +111,7 @@ class StageImportDataHandler
* @param LocalAccount $source
*
* @return array
* @throws FireflyException
*/
private function convertPayment(BunqPayment $payment, LocalAccount $source): array
{

View File

@@ -47,7 +47,7 @@ class StageFinalHandler
for ($i = 0; $i < 5; $i++) {
$transaction = [
'type' => 'withdrawal',
'date' => Carbon::create()->format('Y-m-d'),
'date' => Carbon::now()->format('Y-m-d'),
'tags' => '',
'user' => $this->importJob->user_id,

View File

@@ -71,7 +71,7 @@ class CurrencyMapper
return $result;
}
}
if (!isset($data['code']) || null === $data['code']) {
if (!isset($data['code'])) {
return null;
}

View File

@@ -212,7 +212,7 @@ class ImportableConverter
return [
'type' => $transactionType,
'date' => $this->convertDateValue($importable->date) ?? Carbon::create()->format('Y-m-d'),
'date' => $this->convertDateValue($importable->date) ?? Carbon::now()->format('Y-m-d'),
'tags' => $importable->tags,
'user' => $this->importJob->user_id,
'notes' => $importable->note,

View File

@@ -64,7 +64,7 @@ class ImportDataHandler
/**
* @var string $ynabId
* @var int $localId
* @var string $localId
*/
foreach ($mapping as $ynabId => $localId) {
$localAccount = $this->getLocalAccount((int)$localId);
@@ -252,7 +252,6 @@ class ImportDataHandler
/**
* @param string $token
* @param string $budget
* @param string $account
*
* @return array

View File

@@ -45,6 +45,8 @@ class StageGetAccessHandler
/**
* Send a token request to YNAB. Return with access token (if all goes well).
*
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws FireflyException
*/
public function run(): void

View File

@@ -171,10 +171,7 @@ class Preferences
if (\is_array($lastActivity)) {
$lastActivity = implode(',', $lastActivity);
}
$hash = md5($lastActivity);
//Log::debug(sprintf('Value of last activity is %s, hash is %s', $lastActivity, $hash));
return $hash;
return md5($lastActivity);
}
/**

View File

@@ -246,7 +246,7 @@ class Search implements SearchInterface
private function extractModifier(string $string): void
{
$parts = explode(':', $string);
if (2 === \count($parts) && \strlen(trim((string)$parts[0])) > 0 && '' !== trim((string)$parts[1])) {
if (2 === \count($parts) && '' !== trim((string)$parts[1]) && \strlen(trim((string)$parts[0])) > 0) {
$type = trim((string)$parts[0]);
$value = trim((string)$parts[1]);
if (\in_array($type, $this->validModifiers, true)) {

View File

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

View File

@@ -136,7 +136,7 @@ class TransactionJournal extends Twig_Extension
/**
* @param JournalModel $journal
*
* @return string
* @return array
*/
private function getTotalAmount(JournalModel $journal): array
{

View File

@@ -103,9 +103,7 @@ class General extends Twig_Extension
return new Twig_SimpleFunction(
'activeRoutePartialWhat',
function ($context): string {
$args = \func_get_args();
$route = $args[1]; // name of the route.
$what = $args[2]; // name of the route.
[, $route, $what] = \func_get_args();
$activeWhat = $context['what'] ?? false;
if ($what === $activeWhat && !(false === stripos(Route::getCurrentRoute()->getName(), $route))) {