Various PSR12 code cleanup

This commit is contained in:
James Cole
2022-12-29 19:42:26 +01:00
parent dbf3e76ecc
commit 6cfdc58cb1
415 changed files with 7462 additions and 6874 deletions

View File

@@ -42,9 +42,9 @@ trait AppendsLocationData
/**
* Read the submitted Request data and add new or updated Location data to the array.
*
* @param array $data
* @param array $data
*
* @param string|null $prefix
* @param string|null $prefix
*
* @return array
*/
@@ -100,8 +100,8 @@ trait AppendsLocationData
}
/**
* @param string|null $prefix
* @param string $key
* @param string|null $prefix
* @param string $key
*
* @return string
*/
@@ -115,7 +115,7 @@ trait AppendsLocationData
}
/**
* @param string|null $prefix
* @param string|null $prefix
*
* @return bool
*/
@@ -167,7 +167,7 @@ trait AppendsLocationData
/**
* Abstract method.
*
* @param mixed ...$patterns
* @param mixed ...$patterns
*
* @return mixed
*/
@@ -176,15 +176,15 @@ trait AppendsLocationData
/**
* Abstract method stolen from "InteractsWithInput".
*
* @param null $key
* @param bool $default
* @param null $key
* @param bool $default
*
* @return mixed
*/
abstract public function boolean($key = null, $default = false);
/**
* @param string|null $prefix
* @param string|null $prefix
*
* @return bool
*/
@@ -229,7 +229,7 @@ trait AppendsLocationData
}
/**
* @param string|null $prefix
* @param string|null $prefix
*
* @return bool
*/
@@ -245,7 +245,7 @@ trait AppendsLocationData
&& null === $this->get($zoomLevelKey))
&& (
'PUT' === $this->method()
|| ('POST' === $this->method() && $this->routeIs('*.update'))
|| ('POST' === $this->method() && $this->routeIs('*.update'))
);
}
}

View File

@@ -35,30 +35,30 @@ trait ConvertsDataTypes
/**
* Return integer value.
*
* @param string $field
* @param string $field
*
* @return int
*/
public function convertInteger(string $field): int
{
return (int) $this->get($field);
return (int)$this->get($field);
}
/**
* Return string value.
*
* @param string $field
* @param string $field
*
* @return string
*/
public function convertString(string $field): string
{
return $this->clearString((string) ($this->get($field) ?? ''), false);
return $this->clearString((string)($this->get($field) ?? ''), false);
}
/**
* @param string|null $string
* @param bool $keepNewlines
* @param string|null $string
* @param bool $keepNewlines
*
* @return string|null
*/
@@ -131,17 +131,17 @@ trait ConvertsDataTypes
/**
* Return string value with newlines.
*
* @param string $field
* @param string $field
*
* @return string
*/
public function stringWithNewlines(string $field): string
{
return $this->clearString((string) ($this->get($field) ?? ''));
return $this->clearString((string)($this->get($field) ?? ''));
}
/**
* @param mixed $array
* @param mixed $array
*
* @return array|null
*/
@@ -161,7 +161,7 @@ trait ConvertsDataTypes
}
/**
* @param string|null $value
* @param string|null $value
*
* @return bool
*/
@@ -187,7 +187,24 @@ trait ConvertsDataTypes
}
/**
* @param string|null $string
* Return floating value.
*
* @param string $field
*
* @return float|null
*/
protected function convertFloat(string $field): ?float
{
$res = $this->get($field);
if (null === $res) {
return null;
}
return (float)$res;
}
/**
* @param string|null $string
*
* @return Carbon|null
*/
@@ -215,28 +232,11 @@ trait ConvertsDataTypes
return $carbon;
}
/**
* Return floating value.
*
* @param string $field
*
* @return float|null
*/
protected function convertFloat(string $field): ?float
{
$res = $this->get($field);
if (null === $res) {
return null;
}
return (float) $res;
}
/**
* Returns all data in the request, or omits the field if not set,
* according to the config from the request. This is the way.
*
* @param array $fields
* @param array $fields
*
* @return array
*/
@@ -256,7 +256,7 @@ trait ConvertsDataTypes
/**
* Return date or NULL.
*
* @param string $field
* @param string $field
*
* @return Carbon|null
*/
@@ -278,7 +278,7 @@ trait ConvertsDataTypes
/**
* Parse to integer
*
* @param string|null $string
* @param string|null $string
*
* @return int|null
*/
@@ -291,13 +291,13 @@ trait ConvertsDataTypes
return null;
}
return (int) $string;
return (int)$string;
}
/**
* Return integer value, or NULL when it's not set.
*
* @param string $field
* @param string $field
*
* @return int|null
*/
@@ -307,11 +307,11 @@ trait ConvertsDataTypes
return null;
}
$value = (string) $this->get($field);
$value = (string)$this->get($field);
if ('' === $value) {
return null;
}
return (int) $value;
return (int)$value;
}
}

View File

@@ -29,7 +29,7 @@ namespace FireflyIII\Support\Request;
trait GetRecurrenceData
{
/**
* @param array $transaction
* @param array $transaction
*
* @return array
*/
@@ -42,7 +42,7 @@ trait GetRecurrenceData
$return['amount'] = $transaction['amount'];
}
if (array_key_exists('currency_id', $transaction)) {
$return['currency_id'] = (int) $transaction['currency_id'];
$return['currency_id'] = (int)$transaction['currency_id'];
}
if (array_key_exists('currency_code', $transaction)) {
$return['currency_code'] = $transaction['currency_code'];
@@ -53,17 +53,17 @@ trait GetRecurrenceData
$return['foreign_amount'] = $transaction['foreign_amount'];
}
if (array_key_exists('foreign_currency_id', $transaction)) {
$return['foreign_currency_id'] = (int) $transaction['foreign_currency_id'];
$return['foreign_currency_id'] = (int)$transaction['foreign_currency_id'];
}
if (array_key_exists('foreign_currency_code', $transaction)) {
$return['foreign_currency_code'] = $transaction['foreign_currency_code'];
}
// source + dest
if (array_key_exists('source_id', $transaction)) {
$return['source_id'] = (int) $transaction['source_id'];
$return['source_id'] = (int)$transaction['source_id'];
}
if (array_key_exists('destination_id', $transaction)) {
$return['destination_id'] = (int) $transaction['destination_id'];
$return['destination_id'] = (int)$transaction['destination_id'];
}
// description
if (array_key_exists('description', $transaction)) {
@@ -71,17 +71,17 @@ trait GetRecurrenceData
}
if (array_key_exists('piggy_bank_id', $transaction)) {
$return['piggy_bank_id'] = (int) $transaction['piggy_bank_id'];
$return['piggy_bank_id'] = (int)$transaction['piggy_bank_id'];
}
if (array_key_exists('tags', $transaction)) {
$return['tags'] = $transaction['tags'];
}
if (array_key_exists('budget_id', $transaction)) {
$return['budget_id'] = (int) $transaction['budget_id'];
$return['budget_id'] = (int)$transaction['budget_id'];
}
if (array_key_exists('category_id', $transaction)) {
$return['category_id'] = (int) $transaction['category_id'];
$return['category_id'] = (int)$transaction['category_id'];
}
return $return;