private static function processTypeErrorOnSetValue($message, $trace, $i): void
    {
        if (0 !== strpos($message, 'Argument ')) {
            return;
        }

        if (isset($trace[$i]['file']) && __FILE__ === $trace[$i]['file'] && array_key_exists(0, $trace[$i]['args'])) {
            $pos = strpos($message, $delim = 'must be of the type ') ?: (strpos($message, $delim = 'must be an instance of ') ?: strpos($message, $delim = 'must implement interface '));
            if (false !== $pos) {
                $pos += \strlen($delim);
                $type = $trace[$i]['args'][0];
                $type = \is_object($type) ? \get_class($type) : \gettype($type);

                throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given.', substr($message, $pos, (int) strpos($message, ',', $pos) - $pos), $type));
            }
        }
    }