In CurlFormatter::extractUrlArgument, calling withFragment with null throws an exception because the PSR-7 Uri implementation of Guzzle immediatly calls filterQueryAndFragment which checks if the fragment is a string :
// Uri.php
public function withFragment($fragment)
{
$fragment = $this->filterQueryAndFragment($fragment); /// <----------------
if ($this->fragment === $fragment) {
return $this;
}
$new = clone $this;
$new->fragment = $fragment;
return $new;
}
private function filterQueryAndFragment($str)
{
if (!is_string($str)) { /// <----------------
throw new \InvalidArgumentException('Query and fragment must be a string');
}
return preg_replace_callback(
'/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/',
[$this, 'rawurlencodeMatchZero'],
$str
);
}
Should an empty string be passed instead ? Or not be called at all (depending if the string representation of the Uri holds the fragment, as it's the case for Guzzle) ?
In
CurlFormatter::extractUrlArgument
, callingwithFragment
withnull
throws an exception because the PSR-7 Uri implementation of Guzzle immediatly callsfilterQueryAndFragment
which checks if the fragment is a string :Should an empty string be passed instead ? Or not be called at all (depending if the string representation of the Uri holds the fragment, as it's the case for Guzzle) ?
Brice