Skip to content

Commit

Permalink
Fix omissions in dfd4901
Browse files Browse the repository at this point in the history
  • Loading branch information
esperecyan committed Feb 15, 2023
1 parent dfd4901 commit 1ad5ae4
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/URLSearchParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class URLSearchParams implements \IteratorAggregate
* @link https://url.spec.whatwg.org/#concept-urlsearchparams-list URL Standard
*/
private $list = [];

/**
* @var URL|null
* @link https://url.spec.whatwg.org/#concept-urlsearchparams-url-object URL Standard
*/
private $urlObject = null;

/**
* @link https://url.spec.whatwg.org/#concept-urlsearchparams-new URL Standard
* @param string[][]|string[]|string|URLSearchParams $init
Expand All @@ -39,13 +39,13 @@ public function __construct($init = '')
. ' or esperecyan\url\URLSearchParams)',
$init
);

static::createNewURLSearchParamsObject(
$this,
is_string($initValue) ? preg_replace('/^\\?/u', '', $initValue) : $initValue
);
}

/**
* Creates a new URLSearchParams object.
* @link https://url.spec.whatwg.org/#concept-urlsearchparams-new URL Standard
Expand Down Expand Up @@ -79,7 +79,7 @@ private static function createNewURLSearchParamsObject($query, $init)
}
return $query;
}

/**
* A URLSearchParams object’s update steps.
* @link https://url.spec.whatwg.org/#concept-urlsearchparams-update URL Standard
Expand All @@ -92,7 +92,7 @@ private function update()
}, null, $this->urlObject)->__invoke($this->urlObject, lib\URLencoding::serializeURLencoded($this->list));
}
}

/**
* Appends a new name-value pair whose name is name and value is value, to the list of name-value pairs.
* @link https://url.spec.whatwg.org/#dom-urlsearchparams-appendname-value URL Standard
Expand All @@ -104,7 +104,7 @@ public function append($name, $value)
$this->list[] = [TypeHinter::to('USVString', $name, 0), TypeHinter::to('USVString', $value, 1)];
$this->update();
}

/**
* Removes all name-value pairs whose name is name.
* @link https://url.spec.whatwg.org/#dom-urlsearchparams-deletename URL Standard
Expand All @@ -118,7 +118,7 @@ public function delete($name)
}));
$this->update();
}

/**
* Returns the value of the first name-value pair whose name is name, and null if there is no such pair.
* @link https://url.spec.whatwg.org/#dom-urlsearchparams-getname URL Standard
Expand All @@ -137,7 +137,7 @@ public function get($name)
}
return $value;
}

/**
* Returns the values of all name-value pairs whose name is name, in list order, and the empty sequence otherwise.
* @link https://url.spec.whatwg.org/#dom-urlsearchparams-getallname URL Standard
Expand All @@ -155,7 +155,7 @@ public function getAll($name)
}
return $values;
}

/**
* Returns true if there is a name-value pair whose name is name, and false otherwise.
* @link https://url.spec.whatwg.org/#dom-urlsearchparams-hasname URL Standard
Expand All @@ -166,7 +166,7 @@ public function has($name)
{
return !is_null($this->get(TypeHinter::to('USVString', $name)));
}

/**
* If there are any name-value pairs whose name is name, set the value of the first such name-value pair to value and remove the others.
* Otherwise, append a new name-value pair whose name is name and value is value, to the list of name-value pairs.
Expand Down Expand Up @@ -198,7 +198,7 @@ public function set($name, $value)
}
$this->update();
}

/**
* Sorts all name-value pair by their names and comparing JavaScript strings (UTF-16).
* @link https://url.spec.whatwg.org/#dom-urlsearchparams-sort URL Standard
Expand All @@ -211,15 +211,16 @@ public function sort()
return mb_convert_encoding($pair[0], 'UTF-16BE', 'UTF-8');
}, $this->list), SORT_STRING, range(1, count($this->list)), $this->list);
}

/**
* @uses lib\URLSearchParamsIterator
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new lib\URLSearchParamsIterator($this->list, $this);
}

/**
* Returns the serialization of the URLSearchParams object's associated list of name-value pairs.
* @link https://url.spec.whatwg.org/#stringification-behavior URL Standard
Expand Down

0 comments on commit 1ad5ae4

Please sign in to comment.