Add annotated methods.

This commit is contained in:
James Cole 2018-07-15 10:00:08 +02:00
parent 7b41c5b301
commit ac8776aea4
13 changed files with 63 additions and 14 deletions

View File

@ -71,7 +71,6 @@ class LinkTypeRequest extends Request
'outward' => 'required|unique:link_types,outward|min:1|different:inward',
'inward' => 'required|unique:link_types,inward|min:1|different:outward',
];
// Rule::unique('users')->ignore($user->id),
switch ($this->method()) {

View File

@ -31,7 +31,7 @@ use Exception;
use FireflyIII\Jobs\MailError;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Validation\ValidationException;
use Illuminate\Validation\ValidationException as LaravelValidationException;
use League\OAuth2\Server\Exception\OAuthServerException;
use Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -54,7 +54,7 @@ class Handler extends ExceptionHandler
*/
public function render($request, Exception $exception)
{
if ($exception instanceof ValidationException && $request->expectsJson()) {
if ($exception instanceof LaravelValidationException && $request->expectsJson()) {
// ignore it: controller will handle it.
return parent::render($request, $exception);
}

View File

@ -29,6 +29,8 @@ use Illuminate\Support\Collection;
/**
* Class Support.
* @method Collection getExpenses()
* @method Collection getIncome()
*/
class Support
{

View File

@ -64,6 +64,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property string $transaction_journal_category_name
* @property int $bill_id
* @property string $bill_name
* @property string $bill_name_encrypted
* @property string $notes
* @property string $tags
* @property string $transaction_currency_symbol
@ -87,7 +88,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property string $after // used in audit reports.
* @property int $opposing_id // ID of the opposing transaction, used in collector
* @property bool $encrypted // is the journal encrypted
* @property $bill_name_encrypted
*/
class Transaction extends Model
{

View File

@ -43,6 +43,7 @@ use Session;
/**
* Class ExpandedForm.
*
*/
class ExpandedForm
{

View File

@ -24,13 +24,20 @@ namespace FireflyIII\Support\Facades;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\User;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Facade;
/**
* @codeCoverageIgnore
* Class Amount.
*
* @method string formatAnything(TransactionCurrency $format, string $amount, bool $coloured = true)
* @method Collection getAllCurrencies()
* @method string getCurrencyCode()
* @method string getCurrencySymbol()
* @method TransactionCurrency getDefaultCurrency()
* @method TransactionCurrency getDefaultCurrencyByUser(User $user)
* @method array getJsConfig(array $config)
*/
class Amount extends Facade
{

View File

@ -22,11 +22,15 @@ declare(strict_types=1);
namespace FireflyIII\Support\Facades;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Facade;
/**
* @codeCoverageIgnore
* Class ExpandedForm.
*
* @method array makeSelectList(Collection $set)
* @method array makeSelectListWithEmpty(Collection $set)
*/
class ExpandedForm extends Facade
{

View File

@ -22,14 +22,28 @@ declare(strict_types=1);
namespace FireflyIII\Support\Facades;
use Carbon\Carbon;
use Illuminate\Support\Facades\Facade;
/**
* @codeCoverageIgnore
* Class Navigation.
*
* @method array blockPeriods(\Carbon\Carbon $start, \Carbon\Carbon $end, string $range)
* @method string periodShow(\Carbon\Carbon $theDate, string $repeatFrequency)
* @method Carbon addPeriod(Carbon $theDate, string $repeatFreq, int $skip)
* @method array blockPeriods(Carbon $start, Carbon $end, string $range)
* @method Carbon endOfPeriod(Carbon $end, string $repeatFreq)
* @method Carbon endOfX(Carbon $theCurrentEnd, string $repeatFreq, Carbon $maxDate = null)
* @method array listOfPeriods(Carbon $start, Carbon $end)
* @method string periodShow(Carbon $theDate, string $repeatFrequency)
* @method string preferredCarbonFormat(Carbon $start, Carbon $end)
* @method string preferredCarbonLocalizedFormat(Carbon $start, Carbon $end)
* @method string preferredEndOfPeriod(Carbon $start, Carbon $end)
* @method string preferredRangeFormat(Carbon $start, Carbon $end)
* @method string preferredSqlFormat(Carbon $start, Carbon $end)
* @method Carbon startOfPeriod(Carbon $theDate, string $repeatFreq)
* @method Carbon subtractPeriod(Carbon $theDate, string $repeatFreq, int $subtract = 1)
* @method Carbon updateEndDate(string $range, Carbon $start)
* @method Carbon updateStartDate(string $range, Carbon $start)
*/
class Navigation extends Facade
{

View File

@ -24,16 +24,23 @@ namespace FireflyIII\Support\Facades;
use FireflyIII\Models\Preference;
use FireflyIII\User;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Facade;
/**
* @codeCoverageIgnore
* Class Preferences.
*
* @method Preference set(string $name, $value)
* @method Collection beginsWith(User $user, string $search)
* @method bool delete(string $name)
* @method Collection findByName(string $name)
* @method Preference get(string $name, $value)
* @method array getArrayForUser(User $user, array $list)
* @method Preference|null getForUser(User $user, string $name, $default = null)
* @method string lastActivity()
* @method void mark()
* @method Preference set(string $name, $value)
* @method Preference setForUser(User $user, string $name, $value)
*/
class Preferences extends Facade
{

View File

@ -22,12 +22,26 @@ declare(strict_types=1);
namespace FireflyIII\Support\Facades;
use Carbon\Carbon;
use FireflyIII\Models\Account;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Facade;
/**
* @codeCoverageIgnore
* Class Steam.
* @method string balance(Account $account, Carbon $date)
* @method string balanceIgnoreVirtual(Account $account, Carbon $date)
* @method array balanceInRange(Account $account, Carbon $start, Carbon $end)
* @method array balancesByAccounts(Collection $accounts, Carbon $date)
* @method decrypt(int $isEncrypted, string $value)
* @method array getLastActivities(array $accounts)
* @method string negative(string $amount)
* @method string|null opposite(string $amount = null)
* @method int phpBytes(string $string)
* @method tryDecrypt($value)
* @method string positive(string $amount)
*
*/
class Steam extends Facade
{

View File

@ -505,9 +505,10 @@ class Navigation
*
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function subtractPeriod(Carbon $theDate, string $repeatFreq, int $subtract = 1): Carbon
public function subtractPeriod(Carbon $theDate, string $repeatFreq, int $subtract = null): Carbon
{
$date = clone $theDate;
$subtract = $subtract ?? 1;
$date = clone $theDate;
// 1D 1W 1M 3M 6M 1Y
Log::debug(sprintf('subtractPeriod: date is %s, repeat frequency is %s and subtract is %d', $date->format('Y-m-d'), $repeatFreq, $subtract));
$functionMap = [

View File

@ -302,11 +302,11 @@ class Steam
}
/**
* @param $string
* @param string $string
*
* @return int
*/
public function phpBytes($string): int
public function phpBytes(string $string): int
{
$string = strtolower($string);

View File

@ -123,7 +123,7 @@ trait TransactionValidation
}
// no valid descriptions and empty journal description? error.
if ($validDescriptions === 0 && '' === $journalDescription) {
if (0 === $validDescriptions && '' === $journalDescription) {
$validator->errors()->add('description', (string)trans('validation.filled', ['attribute' => (string)trans('validation.attributes.description')]));
}
}
@ -179,7 +179,7 @@ trait TransactionValidation
$data = $validator->getData();
$transactions = $data['transactions'] ?? [];
// need at least one transaction
if (\count($transactions) === 0) {
if (0 === \count($transactions)) {
$validator->errors()->add('description', (string)trans('validation.at_least_one_transaction'));
}
}
@ -293,7 +293,7 @@ trait TransactionValidation
$repository->setUser($admin);
$set = $repository->getAccountsById([$accountId]);
Log::debug(sprintf('Count of accounts found by ID %d is: %d', $accountId, $set->count()));
if ($set->count() === 1) {
if (1 === $set->count()) {
/** @var Account $first */
$first = $set->first();
if ($first->accountType->type !== AccountType::ASSET) {