Skip to content

[Crawler] document $default as string|null #33742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Symfony/Component/DomCrawler/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,17 +554,17 @@ public function nodeName()
/**
* 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.');
Expand All @@ -576,17 +576,17 @@ public function text(/* $default = null */)
/**
* 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.');
Expand Down