[Crawler] document $default as string|null

This commit is contained in:
Nicolas Grekas 2019-09-27 19:18:47 +02:00
parent fbfdebc487
commit e96add4787

View File

@ -554,17 +554,17 @@ class Crawler implements \Countable, \IteratorAggregate
/**
* Returns the node value of the first node of the list.
*
* @param mixed $default When provided and the current node is empty, this value is returned and no exception is thrown
* @param string|null $default When not null: the value to return when the current node is empty
*
* @return string The node value
*
* @throws \InvalidArgumentException When current node is empty
*/
public function text(/* $default = null */)
public function text(/* string $default = null */)
{
if (!$this->nodes) {
if (0 < \func_num_args()) {
return func_get_arg(0);
if (0 < \func_num_args() && null !== func_get_arg(0)) {
return (string) func_get_arg(0);
}
throw new \InvalidArgumentException('The current node list is empty.');
@ -576,17 +576,17 @@ class Crawler implements \Countable, \IteratorAggregate
/**
* Returns the first node of the list as HTML.
*
* @param mixed $default When provided and the current node is empty, this value is returned and no exception is thrown
* @param string|null $default When not null: the value to return when the current node is empty
*
* @return string The node html
*
* @throws \InvalidArgumentException When current node is empty
*/
public function html(/* $default = null */)
public function html(/* string $default = null */)
{
if (!$this->nodes) {
if (0 < \func_num_args()) {
return func_get_arg(0);
if (0 < \func_num_args() && null !== func_get_arg(0)) {
return (string) func_get_arg(0);
}
throw new \InvalidArgumentException('The current node list is empty.');