public static function getPhpValue($val, $default = null, ParserInterface $parser = null)
    {
        if ($val instanceof DOMElement) {
            $parser = $parser ?: new static;

            return $parser->parseDomElement($val);
        }

        if (0 === strlen($val)) {
            return $default;
        }

        if (0 === strpos($val, '0x') && preg_match('#^[[:xdigit:]]+$#', substr($val, 2))) {
            return hexdec($val);
        }

        if (is_numeric($val)) {
            return ctype_digit($val) ? intval($val) : floatval($val);
        }

        if (in_array($lval = strtolower($val), ['true', 'false'])) {
            return $lval === 'true' ? true : false;
        }

        return $val;
    }