Skip to content

Commit e9f7b4d

Browse files
[Crawler] document $default as string|null
1 parent fe9ec83 commit e9f7b4d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Crawler.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -554,17 +554,17 @@ public function nodeName()
554554
/**
555555
* Returns the node value of the first node of the list.
556556
*
557-
* @param mixed $default When provided and the current node is empty, this value is returned and no exception is thrown
557+
* @param string|null $default When not null: the value to return when the current node is empty
558558
*
559559
* @return string The node value
560560
*
561561
* @throws \InvalidArgumentException When current node is empty
562562
*/
563-
public function text(/* $default = null */)
563+
public function text(/* string $default = null */)
564564
{
565565
if (!$this->nodes) {
566-
if (0 < \func_num_args()) {
567-
return func_get_arg(0);
566+
if (0 < \func_num_args() && null !== func_get_arg(0)) {
567+
return (string) func_get_arg(0);
568568
}
569569

570570
throw new \InvalidArgumentException('The current node list is empty.');
@@ -576,17 +576,17 @@ public function text(/* $default = null */)
576576
/**
577577
* Returns the first node of the list as HTML.
578578
*
579-
* @param mixed $default When provided and the current node is empty, this value is returned and no exception is thrown
579+
* @param string|null $default When not null: the value to return when the current node is empty
580580
*
581581
* @return string The node html
582582
*
583583
* @throws \InvalidArgumentException When current node is empty
584584
*/
585-
public function html(/* $default = null */)
585+
public function html(/* string $default = null */)
586586
{
587587
if (!$this->nodes) {
588-
if (0 < \func_num_args()) {
589-
return func_get_arg(0);
588+
if (0 < \func_num_args() && null !== func_get_arg(0)) {
589+
return (string) func_get_arg(0);
590590
}
591591

592592
throw new \InvalidArgumentException('The current node list is empty.');

0 commit comments

Comments
 (0)