AnrDaemon / net-url

A class to simplify handling of the various URL's (and some URI's)
Do What The F*ck You Want To Public License
0 stars 0 forks source link

`Url::fromHttp()` global state dependency #4

Open AnrDaemon opened 4 years ago

AnrDaemon commented 4 years ago

Url::fromHttp() rely on the $_SERVER superglobal variable to provide request information.

It should either receive the provider array as part of the arguments or rely on the filter_input_array(INPUT_SERVER) as being authoritative.

Perhaps, change signature to

function fromHttp(array $overrides = [], $trust_x_forwarded_headers = true, array $src = []) 
{
  $src = $src ?: \filter_input_array(INPUT_SERVER);
  //…
}