WIP [HttpFoundation] fix detection of request uri, base url, base path, path info

WIP
BC break: no
Tests pass: no
Fixes: #7329 (not yet)

I synchronized the code with the changes done upstream in ZF: https://github.com/zendframework/zf2/blob/master/library/Zend/Http/PhpEnvironment/Request.php

I also added tests from ZF and #7329.

I also rewrote the `preparePathInfo` slightly because there were some strange things.