Skip to content

Commit 25b8720

Browse files
Replace more docblocks by type-hints
1 parent b5b5337 commit 25b8720

File tree

5 files changed

+13
-48
lines changed

5 files changed

+13
-48
lines changed

AbstractUriElement.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ abstract class AbstractUriElement
3636
/**
3737
* @param \DOMElement $node A \DOMElement instance
3838
* @param string $currentUri The URI of the page where the link is embedded (or the base href)
39-
* @param string $method The method to use for the link (get by default)
39+
* @param string $method The method to use for the link (GET by default)
4040
*
4141
* @throws \InvalidArgumentException if the node is not a link
4242
*/
43-
public function __construct(\DOMElement $node, $currentUri, $method = 'GET')
43+
public function __construct(\DOMElement $node, string $currentUri, ?string $method = 'GET')
4444
{
4545
if (!in_array(strtolower(substr($currentUri, 0, 4)), array('http', 'file'))) {
4646
throw new \InvalidArgumentException(sprintf('Current URI must be an absolute URL ("%s").', $currentUri));
@@ -168,24 +168,16 @@ abstract protected function setNode(\DOMElement $node);
168168

169169
/**
170170
* Removes the query string and the anchor from the given uri.
171-
*
172-
* @param string $uri The uri to clean
173-
*
174-
* @return string
175171
*/
176-
private function cleanupUri($uri)
172+
private function cleanupUri(string $uri): string
177173
{
178174
return $this->cleanupQuery($this->cleanupAnchor($uri));
179175
}
180176

181177
/**
182178
* Remove the query string from the uri.
183-
*
184-
* @param string $uri
185-
*
186-
* @return string
187179
*/
188-
private function cleanupQuery($uri)
180+
private function cleanupQuery(string $uri): string
189181
{
190182
if (false !== $pos = strpos($uri, '?')) {
191183
return substr($uri, 0, $pos);
@@ -196,12 +188,8 @@ private function cleanupQuery($uri)
196188

197189
/**
198190
* Remove the anchor from the uri.
199-
*
200-
* @param string $uri
201-
*
202-
* @return string
203191
*/
204-
private function cleanupAnchor($uri)
192+
private function cleanupAnchor(string $uri): string
205193
{
206194
if (false !== $pos = strpos($uri, '#')) {
207195
return substr($uri, 0, $pos);

Crawler.php

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Crawler implements \Countable, \IteratorAggregate
5959
* @param string $uri The current URI
6060
* @param string $baseHref The base href value
6161
*/
62-
public function __construct($node = null, $uri = null, $baseHref = null)
62+
public function __construct($node = null, string $uri = null, string $baseHref = null)
6363
{
6464
$this->uri = $uri;
6565
$this->baseHref = $baseHref ?: $uri;
@@ -958,12 +958,8 @@ private function filterRelativeXPath($xpath)
958958
*
959959
* The returned XPath will match elements matching the XPath inside the current crawler
960960
* when running in the context of a node of the crawler.
961-
*
962-
* @param string $xpath
963-
*
964-
* @return string
965961
*/
966-
private function relativize($xpath)
962+
private function relativize(string $xpath): string
967963
{
968964
$expressions = array();
969965

@@ -1095,14 +1091,9 @@ protected function sibling($node, $siblingDir = 'nextSibling')
10951091
}
10961092

10971093
/**
1098-
* @param \DOMDocument $document
1099-
* @param array $prefixes
1100-
*
1101-
* @return \DOMXPath
1102-
*
11031094
* @throws \InvalidArgumentException
11041095
*/
1105-
private function createDOMXPath(\DOMDocument $document, array $prefixes = array())
1096+
private function createDOMXPath(\DOMDocument $document, array $prefixes = array()): \DOMXPath
11061097
{
11071098
$domxpath = new \DOMXPath($document);
11081099

@@ -1117,14 +1108,9 @@ private function createDOMXPath(\DOMDocument $document, array $prefixes = array(
11171108
}
11181109

11191110
/**
1120-
* @param \DOMXPath $domxpath
1121-
* @param string $prefix
1122-
*
1123-
* @return string
1124-
*
11251111
* @throws \InvalidArgumentException
11261112
*/
1127-
private function discoverNamespace(\DOMXPath $domxpath, $prefix)
1113+
private function discoverNamespace(\DOMXPath $domxpath, string $prefix): string
11281114
{
11291115
if (isset($this->namespaces[$prefix])) {
11301116
return $this->namespaces[$prefix];
@@ -1138,12 +1124,7 @@ private function discoverNamespace(\DOMXPath $domxpath, $prefix)
11381124
}
11391125
}
11401126

1141-
/**
1142-
* @param string $xpath
1143-
*
1144-
* @return array
1145-
*/
1146-
private function findNamespacePrefixes($xpath)
1127+
private function findNamespacePrefixes(string $xpath): array
11471128
{
11481129
if (preg_match_all('/(?P<prefix>[a-z_][a-z_0-9\-\.]*+):[^"\/:]/i', $xpath, $matches)) {
11491130
return array_unique($matches['prefix']);

Field/ChoiceFormField.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,8 @@ protected function initialize()
254254

255255
/**
256256
* Returns option value with associated disabled flag.
257-
*
258-
* @param \DOMElement $node
259-
*
260-
* @return array
261257
*/
262-
private function buildOptionValue(\DOMElement $node)
258+
private function buildOptionValue(\DOMElement $node): array
263259
{
264260
$option = array();
265261

Form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Form extends Link implements \ArrayAccess
4444
*
4545
* @throws \LogicException if the node is not a button inside a form tag
4646
*/
47-
public function __construct(\DOMElement $node, $currentUri, $method = null, $baseHref = null)
47+
public function __construct(\DOMElement $node, string $currentUri, string $method = null, string $baseHref = null)
4848
{
4949
parent::__construct($node, $currentUri, $method);
5050
$this->baseHref = $baseHref;

Image.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
class Image extends AbstractUriElement
1818
{
19-
public function __construct(\DOMElement $node, $currentUri)
19+
public function __construct(\DOMElement $node, string $currentUri)
2020
{
2121
parent::__construct($node, $currentUri, 'GET');
2222
}

0 commit comments

Comments
 (0)