Add strict types and newlines.

This commit is contained in:
James Cole 2018-05-05 16:51:32 +02:00
parent 3ac240dc1c
commit f74b9ba7ab
29 changed files with 347 additions and 270 deletions

View File

@ -80,4 +80,4 @@ class CurrencyRequest extends Request
return $rules; return $rules;
} }
} }

View File

@ -163,4 +163,4 @@ class FakeJobConfiguration implements JobConfigurationInterface
$this->job = $job; $this->job = $job;
$this->repository->setUser($job->user); $this->repository->setUser($job->user);
} }
} }

View File

@ -0,0 +1,89 @@
<?php
declare(strict_types=1);
/**
* FileJobConfiguration.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
namespace FireflyIII\Import\JobConfiguration;
use FireflyIII\Models\ImportJob;
use Illuminate\Support\MessageBag;
class FileJobConfiguration implements JobConfigurationInterface
{
/**
* ConfiguratorInterface constructor.
*/
public function __construct()
{
}
/**
* Store any data from the $data array into the job. Anything in the message bag will be flashed
* as an error to the user, regardless of its content.
*
* @param array $data
*
* @return MessageBag
*/
public function configureJob(array $data): MessageBag
{
// TODO: Implement configureJob() method.
}
/**
* Return the data required for the next step in the job configuration.
*
* @return array
*/
public function getNextData(): array
{
// TODO: Implement getNextData() method.
}
/**
* Returns the view of the next step in the job configuration.
*
* @return string
*/
public function getNextView(): string
{
// TODO: Implement getNextView() method.
}
/**
* Returns true when the initial configuration for this job is complete.
*
* @return bool
*/
public function configurationComplete(): bool
{
// TODO: Implement configurationComplete() method.
}
/**
* @param ImportJob $job
*/
public function setJob(ImportJob $job): void
{
// TODO: Implement setJob() method.
}
}

View File

@ -36,146 +36,146 @@ use Preferences;
*/ */
class BunqPrerequisites implements PrerequisitesInterface class BunqPrerequisites implements PrerequisitesInterface
{ {
// /** @var User */ /** @var User */
// private $user; private $user;
// //
// /** // /**
// * Returns view name that allows user to fill in prerequisites. Currently asks for the API key. // * Returns view name that allows user to fill in prerequisites. Currently asks for the API key.
// * // *
// * @return string // * @return string
// */ // */
// public function getView(): string // public function getView(): string
// { // {
// Log::debug('Now in BunqPrerequisites::getView()'); // Log::debug('Now in BunqPrerequisites::getView()');
// //
// return 'import.bunq.prerequisites'; // return 'import.bunq.prerequisites';
// } // }
// //
// /** // /**
// * Returns any values required for the prerequisites-view. // * Returns any values required for the prerequisites-view.
// * // *
// * @return array // * @return array
// */ // */
// public function getViewParameters(): array // public function getViewParameters(): array
// { // {
// Log::debug('Now in BunqPrerequisites::getViewParameters()'); // Log::debug('Now in BunqPrerequisites::getViewParameters()');
// $key = ''; // $key = '';
// $serverIP = ''; // $serverIP = '';
// if ($this->hasApiKey()) { // if ($this->hasApiKey()) {
// $key = Preferences::getForUser($this->user, 'bunq_api_key', null)->data; // $key = Preferences::getForUser($this->user, 'bunq_api_key', null)->data;
// } // }
// if ($this->hasServerIP()) { // if ($this->hasServerIP()) {
// $serverIP = Preferences::getForUser($this->user, 'external_ip', null)->data; // $serverIP = Preferences::getForUser($this->user, 'external_ip', null)->data;
// } // }
// if (!$this->hasServerIP()) { // if (!$this->hasServerIP()) {
// /** @var IPRetrievalInterface $service */ // /** @var IPRetrievalInterface $service */
// $service = app(IPRetrievalInterface::class); // $service = app(IPRetrievalInterface::class);
// $serverIP = (string)$service->getIP(); // $serverIP = (string)$service->getIP();
// } // }
// //
// //
// // get IP address // // get IP address
// return ['key' => $key, 'ip' => $serverIP]; // return ['key' => $key, 'ip' => $serverIP];
// } // }
// //
// /** // /**
// * Returns if this import method has any special prerequisites such as config // * Returns if this import method has any special prerequisites such as config
// * variables or other things. The only thing we verify is the presence of the API key. Everything else // * variables or other things. The only thing we verify is the presence of the API key. Everything else
// * tumbles into place: no installation token? Will be requested. No device server? Will be created. Etc. // * tumbles into place: no installation token? Will be requested. No device server? Will be created. Etc.
// * // *
// * @return bool // * @return bool
// */ // */
// public function hasPrerequisites(): bool // public function hasPrerequisites(): bool
// { // {
// $hasApiKey = $this->hasApiKey(); // $hasApiKey = $this->hasApiKey();
// $hasServerIP = $this->hasServerIP(); // $hasServerIP = $this->hasServerIP();
// //
// return !$hasApiKey || !$hasServerIP; // return !$hasApiKey || !$hasServerIP;
// } // }
// //
// /** // /**
// * Indicate if all prerequisites have been met. // * Indicate if all prerequisites have been met.
// * // *
// * @return bool // * @return bool
// */ // */
// public function isComplete(): bool // public function isComplete(): bool
// { // {
// // is complete when user has entered both the API key // // is complete when user has entered both the API key
// // and his IP address. // // and his IP address.
// //
// $hasApiKey = $this->hasApiKey(); // $hasApiKey = $this->hasApiKey();
// $hasServerIP = $this->hasServerIP(); // $hasServerIP = $this->hasServerIP();
// //
// return $hasApiKey && $hasServerIP; // return $hasApiKey && $hasServerIP;
// } // }
// //
// /** // /**
// * Set the user for this Prerequisites-routine. Class is expected to implement and save this. // * Set the user for this Prerequisites-routine. Class is expected to implement and save this.
// * // *
// * @param User $user // * @param User $user
// */ // */
// public function setUser(User $user): void // public function setUser(User $user): void
// { // {
// Log::debug(sprintf('Now in setUser(#%d)', $user->id)); // Log::debug(sprintf('Now in setUser(#%d)', $user->id));
// $this->user = $user; // $this->user = $user;
// } // }
// //
// /** // /**
// * This method responds to the user's submission of an API key. It tries to register this instance as a new Firefly III device. // * This method responds to the user's submission of an API key. It tries to register this instance as a new Firefly III device.
// * If this fails, the error is returned in a message bag and the user is notified (this is fairly friendly). // * If this fails, the error is returned in a message bag and the user is notified (this is fairly friendly).
// * // *
// * @param Request $request // * @param Request $request
// * // *
// * @return MessageBag // * @return MessageBag
// */ // */
// public function storePrerequisites(Request $request): MessageBag // public function storePrerequisites(Request $request): MessageBag
// { // {
// $apiKey = $request->get('api_key'); // $apiKey = $request->get('api_key');
// $serverIP = $request->get('external_ip'); // $serverIP = $request->get('external_ip');
// Log::debug('Storing bunq API key'); // Log::debug('Storing bunq API key');
// Preferences::setForUser($this->user, 'bunq_api_key', $apiKey); // Preferences::setForUser($this->user, 'bunq_api_key', $apiKey);
// Preferences::setForUser($this->user, 'external_ip', $serverIP); // Preferences::setForUser($this->user, 'external_ip', $serverIP);
// //
// return new MessageBag; // return new MessageBag;
// } // }
// //
// /** // /**
// * @return bool // * @return bool
// */ // */
// private function hasApiKey(): bool // private function hasApiKey(): bool
// { // {
// $apiKey = Preferences::getForUser($this->user, 'bunq_api_key', false); // $apiKey = Preferences::getForUser($this->user, 'bunq_api_key', false);
// if (null === $apiKey) { // if (null === $apiKey) {
// return false; // return false;
// } // }
// if (null === $apiKey->data) { // if (null === $apiKey->data) {
// return false; // return false;
// } // }
// if (\strlen((string)$apiKey->data) === 64) { // if (\strlen((string)$apiKey->data) === 64) {
// return true; // return true;
// } // }
// //
// return false; // return false;
// } // }
// //
// /** // /**
// * @return bool // * @return bool
// */ // */
// private function hasServerIP(): bool // private function hasServerIP(): bool
// { // {
// $serverIP = Preferences::getForUser($this->user, 'external_ip', false); // $serverIP = Preferences::getForUser($this->user, 'external_ip', false);
// if (null === $serverIP) { // if (null === $serverIP) {
// return false; // return false;
// } // }
// if (null === $serverIP->data) { // if (null === $serverIP->data) {
// return false; // return false;
// } // }
// if (\strlen((string)$serverIP->data) > 6) { // if (\strlen((string)$serverIP->data) > 6) {
// return true; // return true;
// } // }
// //
// return false; // return false;
// } // }
/** /**
* Returns view name that allows user to fill in prerequisites. * Returns view name that allows user to fill in prerequisites.
* *
@ -183,8 +183,7 @@ class BunqPrerequisites implements PrerequisitesInterface
*/ */
public function getView(): string public function getView(): string
{ {
// TODO: Implement getView() method. return 'todo';
throw new NotImplementedException;
} }
/** /**
@ -194,8 +193,7 @@ class BunqPrerequisites implements PrerequisitesInterface
*/ */
public function getViewParameters(): array public function getViewParameters(): array
{ {
// TODO: Implement getViewParameters() method. return [];
throw new NotImplementedException;
} }
/** /**
@ -205,8 +203,7 @@ class BunqPrerequisites implements PrerequisitesInterface
*/ */
public function isComplete(): bool public function isComplete(): bool
{ {
// TODO: Implement isComplete() method. return false;
throw new NotImplementedException;
} }
/** /**
@ -216,8 +213,7 @@ class BunqPrerequisites implements PrerequisitesInterface
*/ */
public function setUser(User $user): void public function setUser(User $user): void
{ {
// TODO: Implement setUser() method. $this->user = $user;
throw new NotImplementedException;
} }
/** /**
@ -231,7 +227,6 @@ class BunqPrerequisites implements PrerequisitesInterface
*/ */
public function storePrerequisites(array $data): MessageBag public function storePrerequisites(array $data): MessageBag
{ {
// TODO: Implement storePrerequisites() method. return new MessageBag;
throw new NotImplementedException;
} }
} }

View File

@ -34,83 +34,83 @@ use Illuminate\Support\MessageBag;
*/ */
class FilePrerequisites implements PrerequisitesInterface class FilePrerequisites implements PrerequisitesInterface
{ {
// /** @var User */ // /** @var User */
// private $user; // private $user;
// //
// /** // /**
// * Returns view name that allows user to fill in prerequisites. Currently asks for the API key. // * Returns view name that allows user to fill in prerequisites. Currently asks for the API key.
// * // *
// * @return string // * @return string
// */ // */
// public function getView(): string // public function getView(): string
// { // {
// return ''; // return '';
// } // }
// //
// /** // /**
// * Returns any values required for the prerequisites-view. // * Returns any values required for the prerequisites-view.
// * // *
// * @return array // * @return array
// */ // */
// public function getViewParameters(): array // public function getViewParameters(): array
// { // {
// return []; // return [];
// } // }
// //
// /** // /**
// * Returns if this import method has any special prerequisites such as config // * Returns if this import method has any special prerequisites such as config
// * variables or other things. The only thing we verify is the presence of the API key. Everything else // * variables or other things. The only thing we verify is the presence of the API key. Everything else
// * tumbles into place: no installation token? Will be requested. No device server? Will be created. Etc. // * tumbles into place: no installation token? Will be requested. No device server? Will be created. Etc.
// * // *
// * True if prerequisites. False if not. // * True if prerequisites. False if not.
// * // *
// * @return bool // * @return bool
// * // *
// * @throws FireflyException // * @throws FireflyException
// */ // */
// public function hasPrerequisites(): bool // public function hasPrerequisites(): bool
// { // {
// if ($this->user->hasRole('demo')) { // if ($this->user->hasRole('demo')) {
// throw new FireflyException('Apologies, the demo user cannot import files.'); // throw new FireflyException('Apologies, the demo user cannot import files.');
// } // }
// //
// return false; // return false;
// } // }
// //
// /** // /**
// * Indicate if all prerequisites have been met. // * Indicate if all prerequisites have been met.
// * // *
// * @return bool // * @return bool
// */ // */
// public function isComplete(): bool // public function isComplete(): bool
// { // {
// // has no prerequisites, so always return true. // // has no prerequisites, so always return true.
// return true; // return true;
// } // }
// //
// /** // /**
// * Set the user for this Prerequisites-routine. Class is expected to implement and save this. // * Set the user for this Prerequisites-routine. Class is expected to implement and save this.
// * // *
// * @param User $user // * @param User $user
// */ // */
// public function setUser(User $user): void // public function setUser(User $user): void
// { // {
// $this->user = $user; // $this->user = $user;
// //
// } // }
// //
// /** // /**
// * This method responds to the user's submission of an API key. It tries to register this instance as a new Firefly III device. // * This method responds to the user's submission of an API key. It tries to register this instance as a new Firefly III device.
// * If this fails, the error is returned in a message bag and the user is notified (this is fairly friendly). // * If this fails, the error is returned in a message bag and the user is notified (this is fairly friendly).
// * // *
// * @param Request $request // * @param Request $request
// * // *
// * @return MessageBag // * @return MessageBag
// */ // */
// public function storePrerequisites(Request $request): MessageBag // public function storePrerequisites(Request $request): MessageBag
// { // {
// return new MessageBag; // return new MessageBag;
// } // }
/** /**
* Returns view name that allows user to fill in prerequisites. * Returns view name that allows user to fill in prerequisites.
* *
@ -118,8 +118,7 @@ class FilePrerequisites implements PrerequisitesInterface
*/ */
public function getView(): string public function getView(): string
{ {
// TODO: Implement getView() method. return '';
throw new NotImplementedException;
} }
/** /**
@ -129,8 +128,7 @@ class FilePrerequisites implements PrerequisitesInterface
*/ */
public function getViewParameters(): array public function getViewParameters(): array
{ {
// TODO: Implement getViewParameters() method. return [];
throw new NotImplementedException;
} }
/** /**
@ -140,8 +138,7 @@ class FilePrerequisites implements PrerequisitesInterface
*/ */
public function isComplete(): bool public function isComplete(): bool
{ {
// TODO: Implement isComplete() method. return true;
throw new NotImplementedException;
} }
/** /**
@ -151,8 +148,7 @@ class FilePrerequisites implements PrerequisitesInterface
*/ */
public function setUser(User $user): void public function setUser(User $user): void
{ {
// TODO: Implement setUser() method.
throw new NotImplementedException;
} }
/** /**
@ -166,7 +162,6 @@ class FilePrerequisites implements PrerequisitesInterface
*/ */
public function storePrerequisites(array $data): MessageBag public function storePrerequisites(array $data): MessageBag
{ {
// TODO: Implement storePrerequisites() method. return new MessageBag;
throw new NotImplementedException;
} }
} }

View File

@ -196,8 +196,7 @@ class SpectrePrerequisites implements PrerequisitesInterface
*/ */
public function getView(): string public function getView(): string
{ {
// TODO: Implement getView() method. return '';
throw new NotImplementedException;
} }
/** /**
@ -207,8 +206,7 @@ class SpectrePrerequisites implements PrerequisitesInterface
*/ */
public function getViewParameters(): array public function getViewParameters(): array
{ {
// TODO: Implement getViewParameters() method. return [];
throw new NotImplementedException;
} }
/** /**
@ -218,8 +216,7 @@ class SpectrePrerequisites implements PrerequisitesInterface
*/ */
public function isComplete(): bool public function isComplete(): bool
{ {
// TODO: Implement isComplete() method. return false;
throw new NotImplementedException;
} }
/** /**
@ -229,8 +226,6 @@ class SpectrePrerequisites implements PrerequisitesInterface
*/ */
public function setUser(User $user): void public function setUser(User $user): void
{ {
// TODO: Implement setUser() method.
throw new NotImplementedException;
} }
/** /**
@ -244,7 +239,6 @@ class SpectrePrerequisites implements PrerequisitesInterface
*/ */
public function storePrerequisites(array $data): MessageBag public function storePrerequisites(array $data): MessageBag
{ {
// TODO: Implement storePrerequisites() method. return new MessageBag;
throw new NotImplementedException;
} }
} }

View File

@ -108,4 +108,4 @@ class FakeRoutine implements RoutineInterface
$this->job = $job; $this->job = $job;
$this->repository->setUser($job->user); $this->repository->setUser($job->user);
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
namespace FireflyIII\Import\Storage; namespace FireflyIII\Import\Storage;
@ -458,4 +459,4 @@ class ImportArrayStorage
return $totalHits >= $requiredHits; return $totalHits >= $requiredHits;
} }
} }

View File

@ -37,4 +37,4 @@ interface IPRetrievalInterface
* @return null|string * @return null|string
*/ */
public function getIP(): ?string; public function getIP(): ?string;
} }

View File

@ -57,4 +57,4 @@ class IpifyOrg implements IPRetrievalInterface
return (string)$response->body; return (string)$response->body;
} }
} }

View File

@ -29,4 +29,4 @@ namespace FireflyIII\Services\Spectre\Exception;
class WrongRequestFormatException extends SpectreException class WrongRequestFormatException extends SpectreException
{ {
} }

View File

@ -108,4 +108,4 @@ class SimpleJournalList implements BinderInterface
} }
throw new NotFoundHttpException; throw new NotFoundHttpException;
} }
} }

View File

@ -43,4 +43,4 @@ class StageAhoyHandler
} }
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
namespace FireflyIII\Support\Import\Routine\Fake; namespace FireflyIII\Support\Import\Routine\Fake;
@ -123,4 +124,4 @@ class StageFinalHandler
} }
} }

View File

@ -43,4 +43,4 @@ class StageNewHandler
} }
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;

View File

@ -1,4 +1,5 @@
<?php <?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;

View File

@ -272,4 +272,4 @@ class CurrencyControllerTest extends TestCase
$response->assertHeader('Content-Type', 'application/vnd.api+json'); $response->assertHeader('Content-Type', 'application/vnd.api+json');
$response->assertSee($currency->name); $response->assertSee($currency->name);
} }
} }

View File

@ -225,4 +225,4 @@ class JobConfigurationControllerTest extends TestCase
} }
} }

View File

@ -169,4 +169,4 @@ class VersionCheckEventHandlerTest extends TestCase
$handler->checkForUpdates($event); $handler->checkForUpdates($event);
} }
} }

View File

@ -590,4 +590,4 @@ class FakeJobConfigurationTest extends TestCase
$view = $configurator->getNextView(); $view = $configurator->getNextView();
$this->assertEquals('import.fake.enter-song', $view); $this->assertEquals('import.fake.enter-song', $view);
} }
} }

View File

@ -171,4 +171,4 @@ class FakePrerequisitesTest extends TestCase
$this->assertCount(0, $messages); $this->assertCount(0, $messages);
} }
} }

View File

@ -144,4 +144,4 @@ class FakeRoutineTest extends TestCase
} }
} }
} }

View File

@ -165,4 +165,4 @@ class AbnAmroDescriptionTest extends TestCase
} }
} }

View File

@ -135,4 +135,4 @@ class IngDescriptionTest extends TestCase
$this->assertEquals($row, $result); $this->assertEquals($row, $result);
} }
} }

View File

@ -58,4 +58,4 @@ class PresidentsChoiceTest extends TestCase
} }
} }

View File

@ -72,4 +72,4 @@ class RabobankDescriptionTest extends TestCase
$this->assertEquals($row, $result); $this->assertEquals($row, $result);
} }
} }

View File

@ -69,4 +69,4 @@ class SnsDescriptionTest extends TestCase
$this->assertEquals('Some text', $result[17]); $this->assertEquals('Some text', $result[17]);
} }
} }

View File

@ -632,4 +632,4 @@ class ImportArrayStorageTest extends TestCase
], ],
]; ];
} }
} }