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; $this->oMainAuthAccount = $oMainAuthAccount;
} else { } else {
$this->StorageProvider()->Clear($oMainAuthAccount, StorageType::SESSION, $sToken); $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 { } else {
\SnappyMail\Log::notice('TOKENS', 'AUTH_SPEC_TOKEN_KEY invalid'); \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)) { if (!\is_scalar($mParamValue)) {
$mParamValue = null; $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; $this->aData[$sSectionKey][$sParamKey][0] = (bool) $mParamValue;
break; break;
case 'double': case 'float':
$this->aData[$sSectionKey][$sParamKey][0] = (float) $mParamValue; $this->aData[$sSectionKey][$sParamKey][0] = (float) $mParamValue;
break; break;
case 'integer': case 'int':
$this->aData[$sSectionKey][$sParamKey][0] = (int) $mParamValue; $this->aData[$sSectionKey][$sParamKey][0] = (int) $mParamValue;
break; break;
case 'string': case 'string':
@ -289,13 +289,13 @@ abstract class AbstractConfig implements \ArrayAccess, \JsonSerializable
$bFirst = false; $bFirst = false;
$sValue = '""'; $sValue = '""';
switch (\gettype($mParamValue[0])) switch (\get_debug_type($mParamValue[0]))
{ {
case 'boolean': case 'bool':
$sValue = $mParamValue[0] ? 'On' : 'Off'; $sValue = $mParamValue[0] ? 'On' : 'Off';
break; break;
case 'double': case 'float':
case 'integer': case 'int':
$sValue = $mParamValue[0]; $sValue = $mParamValue[0];
break; break;
case 'string': case 'string':

View file

@ -306,12 +306,6 @@ class Reader extends \XMLReader
return [$deserializer, 'xmlDeserialize']; return [$deserializer, 'xmlDeserialize'];
} }
$type = gettype($deserializer); throw new \LogicException('Could not use this type as a deserializer: '.get_debug_type($deserializer).' for element: '.$name);
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);
} }
} }

View file

@ -172,12 +172,12 @@ function standardSerializer(Writer $writer, $value): void
$writer->write($item); $writer->write($item);
$writer->endElement(); $writer->endElement();
} else { } 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)) { } elseif (is_object($value)) {
throw new \InvalidArgumentException('The writer cannot serialize objects of class: '.get_class($value)); throw new \InvalidArgumentException('The writer cannot serialize objects of class: '.get_class($value));
} elseif (!is_null($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));
} }
} }