protected function typeToString($type)
    {

        if (is_object($type)) {
            return sprintf('Object::%s', get_class($type));
        }

        if (is_array($type)) {
            $types = [];

            /** @noinspection ForeachSourceInspection */
            foreach ($type as $key => $item) {
                $types[] = sprintf('%s => %s', $key, $this->typeToString($item));
            }

            return 'Array(' . implode(', ', $types) . ')';
        }

        if (is_bool($type)) {
            return sprintf('Boolean::%s', $type ? 'True' : 'False');
        }

        if (is_int($type) || is_float($type)) {
            return sprintf('Integer::%s', (string) $type);
        }

        if ($type === null) {
            return 'null';
        }

        return "'$type'";
    }