Skip to content

Commit 8f24248

Browse files
wouterjnicolas-grekas
authored andcommitted
Add void return types
1 parent c2f9688 commit 8f24248

10 files changed

+67
-6
lines changed

Crawler.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public function getBaseHref(): ?string
9191

9292
/**
9393
* Removes all the nodes.
94+
*
95+
* @return void
9496
*/
9597
public function clear()
9698
{
@@ -108,6 +110,8 @@ public function clear()
108110
* @param \DOMNodeList|\DOMNode|\DOMNode[]|string|null $node A node
109111
*
110112
* @throws \InvalidArgumentException when node is not the expected type
113+
*
114+
* @return void
111115
*/
112116
public function add(\DOMNodeList|\DOMNode|array|string|null $node)
113117
{
@@ -130,6 +134,8 @@ public function add(\DOMNodeList|\DOMNode|array|string|null $node)
130134
* If the charset is not set via the content type, it is assumed to be UTF-8,
131135
* or ISO-8859-1 as a fallback, which is the default charset defined by the
132136
* HTTP 1.1 specification.
137+
*
138+
* @return void
133139
*/
134140
public function addContent(string $content, string $type = null)
135141
{
@@ -170,6 +176,8 @@ public function addContent(string $content, string $type = null)
170176
* internal errors via libxml_use_internal_errors(true)
171177
* and then, get the errors via libxml_get_errors(). Be
172178
* sure to clear errors with libxml_clear_errors() afterward.
179+
*
180+
* @return void
173181
*/
174182
public function addHtmlContent(string $content, string $charset = 'UTF-8')
175183
{
@@ -204,6 +212,8 @@ public function addHtmlContent(string $content, string $charset = 'UTF-8')
204212
* @param int $options Bitwise OR of the libxml option constants
205213
* LIBXML_PARSEHUGE is dangerous, see
206214
* http://symfony.com/blog/security-release-symfony-2-0-17-released
215+
*
216+
* @return void
207217
*/
208218
public function addXmlContent(string $content, string $charset = 'UTF-8', int $options = \LIBXML_NONET)
209219
{
@@ -232,6 +242,8 @@ public function addXmlContent(string $content, string $charset = 'UTF-8', int $o
232242
* Adds a \DOMDocument to the list of nodes.
233243
*
234244
* @param \DOMDocument $dom A \DOMDocument instance
245+
*
246+
* @return void
235247
*/
236248
public function addDocument(\DOMDocument $dom)
237249
{
@@ -244,6 +256,8 @@ public function addDocument(\DOMDocument $dom)
244256
* Adds a \DOMNodeList to the list of nodes.
245257
*
246258
* @param \DOMNodeList $nodes A \DOMNodeList instance
259+
*
260+
* @return void
247261
*/
248262
public function addNodeList(\DOMNodeList $nodes)
249263
{
@@ -258,6 +272,8 @@ public function addNodeList(\DOMNodeList $nodes)
258272
* Adds an array of \DOMNode instances to the list of nodes.
259273
*
260274
* @param \DOMNode[] $nodes An array of \DOMNode instances
275+
*
276+
* @return void
261277
*/
262278
public function addNodes(array $nodes)
263279
{
@@ -270,6 +286,8 @@ public function addNodes(array $nodes)
270286
* Adds a \DOMNode instance to the list of nodes.
271287
*
272288
* @param \DOMNode $node A \DOMNode instance
289+
*
290+
* @return void
273291
*/
274292
public function addNode(\DOMNode $node)
275293
{
@@ -862,12 +880,17 @@ public function form(array $values = null, string $method = null): Form
862880

863881
/**
864882
* Overloads a default namespace prefix to be used with XPath and CSS expressions.
883+
*
884+
* @return void
865885
*/
866886
public function setDefaultNamespacePrefix(string $prefix)
867887
{
868888
$this->defaultNamespacePrefix = $prefix;
869889
}
870890

891+
/**
892+
* @return void
893+
*/
871894
public function registerNamespace(string $prefix, string $namespace)
872895
{
873896
$this->namespaces[$prefix] = $namespace;

Field/ChoiceFormField.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public function isDisabled(): bool
6060

6161
/**
6262
* Sets the value of the field.
63+
*
64+
* @return void
6365
*/
6466
public function select(string|array|bool $value)
6567
{
@@ -70,6 +72,8 @@ public function select(string|array|bool $value)
7072
* Ticks a checkbox.
7173
*
7274
* @throws \LogicException When the type provided is not correct
75+
*
76+
* @return void
7377
*/
7478
public function tick()
7579
{
@@ -84,6 +88,8 @@ public function tick()
8488
* Unticks a checkbox.
8589
*
8690
* @throws \LogicException When the type provided is not correct
91+
*
92+
* @return void
8793
*/
8894
public function untick()
8995
{
@@ -98,6 +104,8 @@ public function untick()
98104
* Sets the value of the field.
99105
*
100106
* @throws \InvalidArgumentException When value type provided is not correct
107+
*
108+
* @return void
101109
*/
102110
public function setValue(string|array|bool|null $value)
103111
{
@@ -141,7 +149,7 @@ public function setValue(string|array|bool|null $value)
141149
*
142150
* @internal
143151
*/
144-
public function addChoice(\DOMElement $node)
152+
public function addChoice(\DOMElement $node): void
145153
{
146154
if (!$this->multiple && 'radio' !== $this->type) {
147155
throw new \LogicException(sprintf('Unable to add a choice for "%s" as it is not multiple or is not a radio button.', $this->name));
@@ -175,6 +183,8 @@ public function isMultiple(): bool
175183
* Initializes the form field.
176184
*
177185
* @throws \LogicException When node type is incorrect
186+
*
187+
* @return void
178188
*/
179189
protected function initialize()
180190
{

Field/FileFormField.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class FileFormField extends FormField
2424
* @param int $error The error code (one of UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, or UPLOAD_ERR_EXTENSION)
2525
*
2626
* @throws \InvalidArgumentException When error code doesn't exist
27+
*
28+
* @return void
2729
*/
2830
public function setErrorCode(int $error)
2931
{
@@ -37,6 +39,8 @@ public function setErrorCode(int $error)
3739

3840
/**
3941
* Sets the value of the field.
42+
*
43+
* @return void
4044
*/
4145
public function upload(?string $value)
4246
{
@@ -45,6 +49,8 @@ public function upload(?string $value)
4549

4650
/**
4751
* Sets the value of the field.
52+
*
53+
* @return void
4854
*/
4955
public function setValue(?string $value)
5056
{
@@ -76,6 +82,8 @@ public function setValue(?string $value)
7682

7783
/**
7884
* Sets path to the file as string for simulating HTTP request.
85+
*
86+
* @return void
7987
*/
8088
public function setFilePath(string $path)
8189
{
@@ -86,6 +94,8 @@ public function setFilePath(string $path)
8694
* Initializes the form field.
8795
*
8896
* @throws \LogicException When node type is incorrect
97+
*
98+
* @return void
8999
*/
90100
protected function initialize()
91101
{

Field/FormField.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public function getValue(): string|array|null
9292

9393
/**
9494
* Sets the value of the field.
95+
*
96+
* @return void
9597
*/
9698
public function setValue(?string $value)
9799
{

Field/InputFormField.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class InputFormField extends FormField
2525
* Initializes the form field.
2626
*
2727
* @throws \LogicException When node type is incorrect
28+
*
29+
* @return void
2830
*/
2931
protected function initialize()
3032
{

Field/TextareaFormField.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class TextareaFormField extends FormField
2222
* Initializes the form field.
2323
*
2424
* @throws \LogicException When node type is incorrect
25+
*
26+
* @return void
2527
*/
2628
protected function initialize()
2729
{

Form.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ public function has(string $name): bool
245245

246246
/**
247247
* Removes a field from the form.
248+
*
249+
* @return void
248250
*/
249251
public function remove(string $name)
250252
{
@@ -265,6 +267,8 @@ public function get(string $name): FormField|array
265267

266268
/**
267269
* Sets a named field.
270+
*
271+
* @return void
268272
*/
269273
public function set(FormField $field)
270274
{
@@ -350,6 +354,8 @@ public function disableValidation(): static
350354
* Expects a 'submit' button \DOMElement and finds the corresponding form element, or the form element itself.
351355
*
352356
* @throws \LogicException If given node is not a button or input or does not have a form ancestor
357+
*
358+
* @return void
353359
*/
354360
protected function setNode(\DOMElement $node)
355361
{
@@ -386,7 +392,7 @@ protected function setNode(\DOMElement $node)
386392
* the form node or the entire document depending on whether we need
387393
* to find non-descendant elements through HTML5 'form' attribute.
388394
*/
389-
private function initialize()
395+
private function initialize(): void
390396
{
391397
$this->fields = new FormFieldRegistry();
392398

@@ -436,7 +442,7 @@ private function initialize()
436442
}
437443
}
438444

439-
private function addField(\DOMElement $node)
445+
private function addField(\DOMElement $node): void
440446
{
441447
if (!$node->hasAttribute('name') || !$node->getAttribute('name')) {
442448
return;

FormFieldRegistry.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class FormFieldRegistry
2626
/**
2727
* Adds a field to the registry.
2828
*/
29-
public function add(FormField $field)
29+
public function add(FormField $field): void
3030
{
3131
$segments = $this->getSegments($field->getName());
3232

@@ -48,7 +48,7 @@ public function add(FormField $field)
4848
/**
4949
* Removes a field based on the fully qualified name and its children from the registry.
5050
*/
51-
public function remove(string $name)
51+
public function remove(string $name): void
5252
{
5353
$segments = $this->getSegments($name);
5454
$target = &$this->fields;
@@ -103,7 +103,7 @@ public function has(string $name): bool
103103
*
104104
* @throws \InvalidArgumentException if the field does not exist
105105
*/
106-
public function set(string $name, mixed $value)
106+
public function set(string $name, mixed $value): void
107107
{
108108
$target = &$this->get($name);
109109
if ((!\is_array($value) && $target instanceof Field\FormField) || $target instanceof Field\ChoiceFormField) {

Image.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ protected function getRawUri(): string
2626
return $this->node->getAttribute('src');
2727
}
2828

29+
/**
30+
* @return void
31+
*/
2932
protected function setNode(\DOMElement $node)
3033
{
3134
if ('img' !== $node->nodeName) {

Link.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ protected function getRawUri(): string
2323
return $this->node->getAttribute('href');
2424
}
2525

26+
/**
27+
* @return void
28+
*/
2629
protected function setNode(\DOMElement $node)
2730
{
2831
if ('a' !== $node->nodeName && 'area' !== $node->nodeName && 'link' !== $node->nodeName) {

0 commit comments

Comments
 (0)