Skip to content

Commit 7548764

Browse files
committed
[DomCrawler] Add types to private properties
1 parent 6d1375c commit 7548764

8 files changed

+25
-67
lines changed

Crawler.php

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,53 +28,35 @@ class Crawler implements \Countable, \IteratorAggregate
2828

2929
/**
3030
* The default namespace prefix to be used with XPath and CSS expressions.
31-
*
32-
* @var string
3331
*/
34-
private $defaultNamespacePrefix = 'default';
32+
private string $defaultNamespacePrefix = 'default';
3533

3634
/**
3735
* A map of manually registered namespaces.
3836
*
3937
* @var array<string, string>
4038
*/
41-
private $namespaces = [];
39+
private array $namespaces = [];
4240

4341
/**
4442
* A map of cached namespaces.
45-
*
46-
* @var \ArrayObject
47-
*/
48-
private $cachedNamespaces;
49-
50-
/**
51-
* The base href value.
52-
*
53-
* @var string|null
5443
*/
55-
private $baseHref;
44+
private \ArrayObject $cachedNamespaces;
5645

57-
/**
58-
* @var \DOMDocument|null
59-
*/
60-
private $document;
46+
private ?string $baseHref;
47+
private ?\DOMDocument $document = null;
6148

6249
/**
6350
* @var \DOMNode[]
6451
*/
65-
private $nodes = [];
52+
private array $nodes = [];
6653

6754
/**
6855
* Whether the Crawler contains HTML or XML content (used when converting CSS to XPath).
69-
*
70-
* @var bool
7156
*/
72-
private $isHtml = true;
57+
private bool $isHtml = true;
7358

74-
/**
75-
* @var HTML5|null
76-
*/
77-
private $html5Parser;
59+
private ?HTML5 $html5Parser;
7860

7961
/**
8062
* @param \DOMNodeList|\DOMNode|\DOMNode[]|string|null $node A Node to use as the base for the crawling

Field/ChoiceFormField.php

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,10 @@
2020
*/
2121
class ChoiceFormField extends FormField
2222
{
23-
/**
24-
* @var string
25-
*/
26-
private $type;
27-
/**
28-
* @var bool
29-
*/
30-
private $multiple;
31-
/**
32-
* @var array
33-
*/
34-
private $options;
35-
/**
36-
* @var bool
37-
*/
38-
private $validationDisabled = false;
23+
private string $type;
24+
private bool $multiple;
25+
private array $options;
26+
private bool $validationDisabled = false;
3927

4028
/**
4129
* Returns true if the field should be included in the submitted values.

Form.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,9 @@
2121
*/
2222
class Form extends Link implements \ArrayAccess
2323
{
24-
/**
25-
* @var \DOMElement
26-
*/
27-
private $button;
28-
29-
/**
30-
* @var FormFieldRegistry
31-
*/
32-
private $fields;
33-
34-
/**
35-
* @var string
36-
*/
37-
private $baseHref;
24+
private \DOMElement $button;
25+
private FormFieldRegistry $fields;
26+
private ?string $baseHref;
3827

3928
/**
4029
* @param \DOMElement $node A \DOMElement instance

FormFieldRegistry.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
*/
2121
class FormFieldRegistry
2222
{
23-
private $fields = [];
24-
25-
private $base = '';
23+
private array $fields = [];
24+
private string $base = '';
2625

2726
/**
2827
* Adds a field to the registry.

Test/Constraint/CrawlerSelectorAttributeValueSame.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
final class CrawlerSelectorAttributeValueSame extends Constraint
1818
{
19-
private $selector;
20-
private $attribute;
21-
private $expectedText;
19+
private string $selector;
20+
private string $attribute;
21+
private string $expectedText;
2222

2323
public function __construct(string $selector, string $attribute, string $expectedText)
2424
{

Test/Constraint/CrawlerSelectorExists.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
final class CrawlerSelectorExists extends Constraint
1818
{
19-
private $selector;
19+
private string $selector;
2020

2121
public function __construct(string $selector)
2222
{

Test/Constraint/CrawlerSelectorTextContains.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
final class CrawlerSelectorTextContains extends Constraint
1818
{
19-
private $selector;
20-
private $expectedText;
19+
private string $selector;
20+
private string $expectedText;
2121

2222
public function __construct(string $selector, string $expectedText)
2323
{

Test/Constraint/CrawlerSelectorTextSame.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
final class CrawlerSelectorTextSame extends Constraint
1818
{
19-
private $selector;
20-
private $expectedText;
19+
private string $selector;
20+
private string $expectedText;
2121

2222
public function __construct(string $selector, string $expectedText)
2323
{

0 commit comments

Comments
 (0)