mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-23 12:27:05 +00:00
Fix various phpstan issues.
This commit is contained in:
@@ -77,7 +77,7 @@ class StoreRequest extends FormRequest
|
||||
* Returns the transaction data as it is found in the submitted data. It's a complex method according to code
|
||||
* standards but it just has a lot of ??-statements because of the fields that may or may not exist.
|
||||
*
|
||||
* @return array|null
|
||||
* @return array
|
||||
*/
|
||||
private function getTransactionData(): array
|
||||
{
|
||||
|
@@ -198,6 +198,7 @@ class StoreRequest extends FormRequest
|
||||
protected function atLeastOneActiveTrigger(Validator $validator): void
|
||||
{
|
||||
$data = $validator->getData();
|
||||
/** @var string|int|array|null $triggers */
|
||||
$triggers = $data['triggers'] ?? [];
|
||||
// need at least one trigger
|
||||
if (!is_countable($triggers) || 0 === count($triggers)) {
|
||||
@@ -227,6 +228,7 @@ class StoreRequest extends FormRequest
|
||||
protected function atLeastOneActiveAction(Validator $validator): void
|
||||
{
|
||||
$data = $validator->getData();
|
||||
/** @var string|int|array|null $actions */
|
||||
$actions = $data['actions'] ?? [];
|
||||
// need at least one trigger
|
||||
if (!is_countable($actions) || 0 === count($actions)) {
|
||||
|
@@ -66,7 +66,11 @@ class TestRequest extends FormRequest
|
||||
*/
|
||||
private function getDate(string $field): ?Carbon
|
||||
{
|
||||
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
|
||||
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr((string)$this->query($field), 0, 10));
|
||||
if(false === $result) {
|
||||
return null;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -56,7 +56,11 @@ class TriggerRequest extends FormRequest
|
||||
*/
|
||||
private function getDate(string $field): ?Carbon
|
||||
{
|
||||
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($this->query($field), 0, 10));
|
||||
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr((string)$this->query($field), 0, 10));
|
||||
if(false === $result) {
|
||||
return null;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -56,7 +56,11 @@ class TriggerRequest extends FormRequest
|
||||
*/
|
||||
private function getDate(string $field): ?Carbon
|
||||
{
|
||||
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
|
||||
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr((string)$this->query($field), 0, 10));
|
||||
if(false === $result) {
|
||||
return null;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -159,12 +159,15 @@ class UpdateRequest extends FormRequest
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
$return = [];
|
||||
|
||||
if (!is_countable($this->get('transactions'))) {
|
||||
/** @var array|null $transactions */
|
||||
$transactions = $this->get('transactions');
|
||||
|
||||
if (!is_countable($transactions)) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
/** @var array $transaction */
|
||||
foreach ($this->get('transactions') as $transaction) {
|
||||
foreach ($transactions as $transaction) {
|
||||
if (!is_array($transaction)) {
|
||||
throw new FireflyException('Invalid data submitted: transaction is not array.');
|
||||
}
|
||||
|
Reference in New Issue
Block a user