Fixes for PHP 8

This commit is contained in:
= 2021-02-20 21:51:33 +11:00
parent 087129788b
commit 633210e281
2 changed files with 8 additions and 4 deletions

View File

@ -49,7 +49,7 @@ class Helpers
* *
* @return null|string * @return null|string
*/ */
public function formatCustomFieldValue($custom_fields = null, $field, $value, Client $client = null): ?string public function formatCustomFieldValue($custom_fields, $field, $value, Client $client = null): ?string
{ {
$custom_field = ''; $custom_field = '';
@ -84,7 +84,7 @@ class Helpers
* *
* @return string * @return string
*/ */
public function makeCustomField($custom_fields = null, $field): string public function makeCustomField($custom_fields, $field): string
{ {
if ($custom_fields && property_exists($custom_fields, $field)) { if ($custom_fields && property_exists($custom_fields, $field)) {
$custom_field = $custom_fields->{$field}; $custom_field = $custom_fields->{$field};

View File

@ -217,13 +217,17 @@ trait CompanySettingsSaver
switch ($key) { switch ($key) {
case 'int': case 'int':
case 'integer': case 'integer':
return ctype_digit(strval(abs($value))); if(is_string($value))
return false;
return is_int($value) || ctype_digit(strval(abs($value)));
case 'real': case 'real':
case 'float': case 'float':
case 'double': case 'double':
return is_float($value) || is_numeric(strval($value)); return is_float($value) || is_numeric(strval($value));
case 'string': case 'string':
return method_exists($value, '__toString') || is_null($value) || is_string($value); // return method_exists($value, '__toString') || is_null($value) || is_string($value);
return is_null($value) || is_string($value);
case 'bool': case 'bool':
case 'boolean': case 'boolean':
return is_bool($value) || (int) filter_var($value, FILTER_VALIDATE_BOOLEAN); return is_bool($value) || (int) filter_var($value, FILTER_VALIDATE_BOOLEAN);