Automattic\WooCommerce\Vendor\GraphQL\Error
FormattedError::printVar
Method of the class: FormattedError{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = FormattedError::printVar( $var ): string;
- $var(mixed) (required)
- .
FormattedError::printVar() FormattedError::printVar code WC 10.9.1
public static function printVar($var): string
{
if ($var instanceof Type) {
return 'GraphQLType: ' . $var->toString();
}
if (is_object($var)) {
// Calling `count` on instances of `PHPUnit\Framework\Test` triggers an unintended side effect - see https://github.com/sebastianbergmann/phpunit/issues/5866#issuecomment-2172429263
$count = ! $var instanceof Test && $var instanceof \Countable
? '(' . count($var) . ')'
: '';
return 'instance of ' . get_class($var) . $count;
}
if (is_array($var)) {
return 'array(' . count($var) . ')';
}
if ($var === '') {
return '(empty string)';
}
if (is_string($var)) {
return "'" . addcslashes($var, "'") . "'";
}
if (is_bool($var)) {
return $var ? 'true' : 'false';
}
if (is_scalar($var)) {
return (string) $var;
}
if ($var === null) {
return 'null';
}
return gettype($var);
}