You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just noticed the same issue. The problem appears to be that parse_url returns the port as an int, not a string, at least in PHP 7.3 and 7.4 - did this behavior change at any time? There is some mention in the PHP core changelog of a bug where port is 0, maybe the extra check was meant to address that?
The docs for parse_url say:
If the component parameter is specified, parse_url() returns a string (or an integer, in the case of PHP_URL_PORT) instead of an array.
It says nothing about the components of the array, but it's reasonable to expect that the type will still be an integer when asking for all components instead of only the port. I think the breaking array check can be safely removed.
This appear similar to #143 which is said to be fixed with 3.0,5 or dev-master, but a) composer cannot find a 3.0.5, and b) dev-master still fails, and looks unchanged.
encodeUrl breaks in
with "Notice: Trying to access array offset on value of type int".
Modifying the if query to honor the variable type seems to help.
if ($port && ((gettype($port) == "string" && $port[0] !== ':') || gettype($port) == "integer")) {
$port = ':' . $port;
}
I don't have cloned the project and I am currently very short in time, can someone please fix this issue and make an update available to composer?
Kind regards and have a nice Xmas.
Reproduce:
`<?php
$url_parsed = array (
'scheme' => 'http',
'host' => 'localhost',
'port' => 10003,
'path' => '/some/path',
);
$port = (isset($url_parsed['port']) ? $url_parsed['port'] : null);
// breaks
if ($port && $port[0] !== ':') {
$port = ':' . $port;
}
// seems to work
if ($port && ((gettype($port) == "string" && $port[0] !== ':') || gettype($port) == "integer")) {
$port = ':' . $port;
}
var_export($port);
`
The text was updated successfully, but these errors were encountered: