Use get_debug_type() instead of gettype()

This commit is contained in:
the-djmaze 2024-02-26 04:20:28 +01:00
parent 044b0dcde6
commit 9ef11db895
4 changed files with 12 additions and 18 deletions

View file

@ -261,7 +261,7 @@ trait UserAuth
$this->oMainAuthAccount = $oMainAuthAccount;
} else {
$this->StorageProvider()->Clear($oMainAuthAccount, StorageType::SESSION, $sToken);
\SnappyMail\Log::notice('TOKENS', 'SESSION_TOKEN value invalid: ' . \gettype($sTokenValue));
\SnappyMail\Log::notice('TOKENS', 'SESSION_TOKEN value invalid: ' . \get_debug_type($sTokenValue));
}
} else {
\SnappyMail\Log::notice('TOKENS', 'AUTH_SPEC_TOKEN_KEY invalid');

View file

@ -88,15 +88,15 @@ abstract class AbstractConfig implements \ArrayAccess, \JsonSerializable
if (!\is_scalar($mParamValue)) {
$mParamValue = null;
}
switch (\gettype($this->aData[$sSectionKey][$sParamKey][0]))
switch (\get_debug_type($this->aData[$sSectionKey][$sParamKey][0]))
{
case 'boolean':
case 'bool':
$this->aData[$sSectionKey][$sParamKey][0] = (bool) $mParamValue;
break;
case 'double':
case 'float':
$this->aData[$sSectionKey][$sParamKey][0] = (float) $mParamValue;
break;
case 'integer':
case 'int':
$this->aData[$sSectionKey][$sParamKey][0] = (int) $mParamValue;
break;
case 'string':
@ -289,13 +289,13 @@ abstract class AbstractConfig implements \ArrayAccess, \JsonSerializable
$bFirst = false;
$sValue = '""';
switch (\gettype($mParamValue[0]))
switch (\get_debug_type($mParamValue[0]))
{
case 'boolean':
case 'bool':
$sValue = $mParamValue[0] ? 'On' : 'Off';
break;
case 'double':
case 'integer':
case 'float':
case 'int':
$sValue = $mParamValue[0];
break;
case 'string':

View file

@ -306,12 +306,6 @@ class Reader extends \XMLReader
return [$deserializer, 'xmlDeserialize'];
}
$type = gettype($deserializer);
if (is_string($deserializer)) {
$type .= ' ('.$deserializer.')';
} elseif (is_object($deserializer)) {
$type .= ' ('.get_class($deserializer).')';
}
throw new \LogicException('Could not use this type as a deserializer: '.$type.' for element: '.$name);
throw new \LogicException('Could not use this type as a deserializer: '.get_debug_type($deserializer).' for element: '.$name);
}
}

View file

@ -172,12 +172,12 @@ function standardSerializer(Writer $writer, $value): void
$writer->write($item);
$writer->endElement();
} else {
throw new \InvalidArgumentException('The writer does not know how to serialize arrays with keys of type: '.gettype($name));
throw new \InvalidArgumentException('The writer does not know how to serialize arrays with keys of type: '.get_debug_type($name));
}
}
} elseif (is_object($value)) {
throw new \InvalidArgumentException('The writer cannot serialize objects of class: '.get_class($value));
} elseif (!is_null($value)) {
throw new \InvalidArgumentException('The writer cannot serialize values of type: '.gettype($value));
throw new \InvalidArgumentException('The writer cannot serialize values of type: '.get_debug_type($value));
}
}