chore: major code cleanup and type safety using phpstan
This commit is contained in:
1 parent
060cbea9da
commit
3da73d626b
103 files changed
+976
-1192
No files matched your search
@@ -130,7 +130,7 @@ abstract class AbstractParticipantFieldHandler implements ParticipantFieldHandle
|
||||
*/
|
||||
protected function normalizeEmptyValue(mixed $value): mixed
|
||||
{
|
||||
return empty($value) ? null : $value;
|
||||
return $this->isEmptyValue($value) ? null : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,13 +146,24 @@ abstract class AbstractParticipantFieldHandler implements ParticipantFieldHandle
|
||||
*/
|
||||
protected function normalizeIntValue(mixed $value): ?int
|
||||
{
|
||||
if (empty($value)) {
|
||||
if ($this->isEmptyValue($value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return is_numeric($value) ? (int) $value : null;
|
||||
}
|
||||
|
||||
private function isEmptyValue(mixed $value): bool
|
||||
{
|
||||
return null === $value
|
||||
|| false === $value
|
||||
|| 0 === $value
|
||||
|| 0.0 === $value
|
||||
|| '' === $value
|
||||
|| '0' === $value
|
||||
|| [] === $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a checkbox/form toggle value to a boolean.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user