Skip to content

Commit

Permalink
Use get_debug_type() instead of gettype()
Browse files Browse the repository at this point in the history
  • Loading branch information
the-djmaze committed Feb 26, 2024
1 parent 044b0dc commit 9ef11db
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public function getMainAccountFromToken(bool $bThrowExceptionOnFalse = true): ?M
$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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ public function Set(string $sSectionKey, string $sParamKey, $mParamValue) : void
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':
Expand Down Expand Up @@ -289,13 +289,13 @@ public function Save() : bool
$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':
Expand Down
8 changes: 1 addition & 7 deletions snappymail/v/0.0.0/app/libraries/Sabre/Xml/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,6 @@ public function getDeserializerForElementName(string $name): callable
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

0 comments on commit 9ef11db

Please sign in to comment.