-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Fix some return type annotations #33007
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,7 +334,7 @@ public function addNode(\DOMNode $node) | |
* | ||
* @param int $position The position | ||
* | ||
* @return self | ||
* @return static | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Most methods in this class return the result of |
||
*/ | ||
public function eq($position) | ||
{ | ||
|
@@ -377,7 +377,7 @@ public function each(\Closure $closure) | |
* @param int $offset | ||
* @param int $length | ||
* | ||
* @return self | ||
* @return static | ||
*/ | ||
public function slice($offset = 0, $length = null) | ||
{ | ||
|
@@ -391,7 +391,7 @@ public function slice($offset = 0, $length = null) | |
* | ||
* @param \Closure $closure An anonymous function | ||
* | ||
* @return self | ||
* @return static | ||
*/ | ||
public function reduce(\Closure $closure) | ||
{ | ||
|
@@ -408,7 +408,7 @@ public function reduce(\Closure $closure) | |
/** | ||
* Returns the first node of the current selection. | ||
* | ||
* @return self | ||
* @return static | ||
*/ | ||
public function first() | ||
{ | ||
|
@@ -418,7 +418,7 @@ public function first() | |
/** | ||
* Returns the last node of the current selection. | ||
* | ||
* @return self | ||
* @return static | ||
*/ | ||
public function last() | ||
{ | ||
|
@@ -428,7 +428,7 @@ public function last() | |
/** | ||
* Returns the siblings nodes of the current selection. | ||
* | ||
* @return self | ||
* @return static | ||
* | ||
* @throws \InvalidArgumentException When current node is empty | ||
*/ | ||
|
@@ -444,7 +444,7 @@ public function siblings() | |
/** | ||
* Returns the next siblings nodes of the current selection. | ||
* | ||
* @return self | ||
* @return static | ||
* | ||
* @throws \InvalidArgumentException When current node is empty | ||
*/ | ||
|
@@ -460,7 +460,7 @@ public function nextAll() | |
/** | ||
* Returns the previous sibling nodes of the current selection. | ||
* | ||
* @return self | ||
* @return static | ||
* | ||
* @throws \InvalidArgumentException | ||
*/ | ||
|
@@ -476,7 +476,7 @@ public function previousAll() | |
/** | ||
* Returns the parents nodes of the current selection. | ||
* | ||
* @return self | ||
* @return static | ||
* | ||
* @throws \InvalidArgumentException When current node is empty | ||
*/ | ||
|
@@ -501,7 +501,7 @@ public function parents() | |
/** | ||
* Returns the children nodes of the current selection. | ||
* | ||
* @return self | ||
* @return static | ||
* | ||
* @throws \InvalidArgumentException When current node is empty | ||
*/ | ||
|
@@ -664,7 +664,7 @@ public function extract($attributes) | |
* | ||
* @param string $xpath An XPath expression | ||
* | ||
* @return self | ||
* @return static | ||
*/ | ||
public function filterXPath($xpath) | ||
{ | ||
|
@@ -685,7 +685,7 @@ public function filterXPath($xpath) | |
* | ||
* @param string $selector A CSS selector | ||
* | ||
* @return self | ||
* @return static | ||
* | ||
* @throws \RuntimeException if the CssSelector Component is not available | ||
*/ | ||
|
@@ -706,7 +706,7 @@ public function filter($selector) | |
* | ||
* @param string $value The link text | ||
* | ||
* @return self | ||
* @return static | ||
*/ | ||
public function selectLink($value) | ||
{ | ||
|
@@ -721,7 +721,7 @@ public function selectLink($value) | |
* | ||
* @param string $value The image alt | ||
* | ||
* @return self A new instance of Crawler with the filtered list of nodes | ||
* @return static A new instance of Crawler with the filtered list of nodes | ||
*/ | ||
public function selectImage($value) | ||
{ | ||
|
@@ -735,7 +735,7 @@ public function selectImage($value) | |
* | ||
* @param string $value The button text | ||
* | ||
* @return self | ||
* @return static | ||
*/ | ||
public function selectButton($value) | ||
{ | ||
|
@@ -937,7 +937,7 @@ public static function xpathLiteral($s) | |
* | ||
* @param string $xpath | ||
* | ||
* @return self | ||
* @return static | ||
*/ | ||
private function filterRelativeXPath($xpath) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -350,13 +350,13 @@ private function doPurge($url) | |
* | ||
* @param string $key The store key | ||
* | ||
* @return string The data associated with the key | ||
* @return string|null The data associated with the key | ||
*/ | ||
private function load($key) | ||
{ | ||
$path = $this->getPath($key); | ||
|
||
return file_exists($path) ? file_get_contents($path) : false; | ||
return file_exists($path) ? file_get_contents($path) : null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As suggested by @Tobion in #32993 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. file_get_contents can also return false that we should cast to null. this will otherwise break the type hints later There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we talking about the file behind There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. permissions, race conditions and more probably There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, something like that? return file_exists($path) && false !== $contents = file_get_contents($path) ? $contents : null; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lgtm There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 This method does not return anything.