Skip to content

Commit 4d00726

Browse files
Replace more docblocks by type-hints
1 parent 7b8e4b9 commit 4d00726

20 files changed

+76
-370
lines changed

CssSelectorConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CssSelectorConverter
3131
/**
3232
* @param bool $html Whether HTML support should be enabled. Disable it for XML documents
3333
*/
34-
public function __construct($html = true)
34+
public function __construct(bool $html = true)
3535
{
3636
$this->translator = new Translator();
3737

Node/AttributeNode.php

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,7 @@ class AttributeNode extends AbstractNode
2929
private $operator;
3030
private $value;
3131

32-
/**
33-
* @param NodeInterface $selector
34-
* @param string $namespace
35-
* @param string $attribute
36-
* @param string $operator
37-
* @param string $value
38-
*/
39-
public function __construct(NodeInterface $selector, $namespace, $attribute, $operator, $value)
32+
public function __construct(NodeInterface $selector, ?string $namespace, string $attribute, string $operator, ?string $value)
4033
{
4134
$this->selector = $selector;
4235
$this->namespace = $namespace;
@@ -45,42 +38,27 @@ public function __construct(NodeInterface $selector, $namespace, $attribute, $op
4538
$this->value = $value;
4639
}
4740

48-
/**
49-
* @return NodeInterface
50-
*/
51-
public function getSelector()
41+
public function getSelector(): NodeInterface
5242
{
5343
return $this->selector;
5444
}
5545

56-
/**
57-
* @return string
58-
*/
59-
public function getNamespace()
46+
public function getNamespace(): ?string
6047
{
6148
return $this->namespace;
6249
}
6350

64-
/**
65-
* @return string
66-
*/
67-
public function getAttribute()
51+
public function getAttribute(): string
6852
{
6953
return $this->attribute;
7054
}
7155

72-
/**
73-
* @return string
74-
*/
75-
public function getOperator()
56+
public function getOperator(): string
7657
{
7758
return $this->operator;
7859
}
7960

80-
/**
81-
* @return string
82-
*/
83-
public function getValue()
61+
public function getValue(): ?string
8462
{
8563
return $this->value;
8664
}

Node/ClassNode.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,18 @@ class ClassNode extends AbstractNode
2626
private $selector;
2727
private $name;
2828

29-
/**
30-
* @param NodeInterface $selector
31-
* @param string $name
32-
*/
33-
public function __construct(NodeInterface $selector, $name)
29+
public function __construct(NodeInterface $selector, string $name)
3430
{
3531
$this->selector = $selector;
3632
$this->name = $name;
3733
}
3834

39-
/**
40-
* @return NodeInterface
41-
*/
42-
public function getSelector()
35+
public function getSelector(): NodeInterface
4336
{
4437
return $this->selector;
4538
}
4639

47-
/**
48-
* @return string
49-
*/
50-
public function getName()
40+
public function getName(): string
5141
{
5242
return $this->name;
5343
}

Node/CombinedSelectorNode.php

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,38 +27,24 @@ class CombinedSelectorNode extends AbstractNode
2727
private $combinator;
2828
private $subSelector;
2929

30-
/**
31-
* @param NodeInterface $selector
32-
* @param string $combinator
33-
* @param NodeInterface $subSelector
34-
*/
35-
public function __construct(NodeInterface $selector, $combinator, NodeInterface $subSelector)
30+
public function __construct(NodeInterface $selector, string $combinator, NodeInterface $subSelector)
3631
{
3732
$this->selector = $selector;
3833
$this->combinator = $combinator;
3934
$this->subSelector = $subSelector;
4035
}
4136

42-
/**
43-
* @return NodeInterface
44-
*/
45-
public function getSelector()
37+
public function getSelector(): NodeInterface
4638
{
4739
return $this->selector;
4840
}
4941

50-
/**
51-
* @return string
52-
*/
53-
public function getCombinator()
42+
public function getCombinator(): string
5443
{
5544
return $this->combinator;
5645
}
5746

58-
/**
59-
* @return NodeInterface
60-
*/
61-
public function getSubSelector()
47+
public function getSubSelector(): NodeInterface
6248
{
6349
return $this->subSelector;
6450
}

Node/ElementNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ElementNode extends AbstractNode
3030
* @param string|null $namespace
3131
* @param string|null $element
3232
*/
33-
public function __construct($namespace = null, $element = null)
33+
public function __construct(string $namespace = null, string $element = null)
3434
{
3535
$this->namespace = $namespace;
3636
$this->element = $element;

Node/FunctionNode.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,19 @@ class FunctionNode extends AbstractNode
3434
* @param string $name
3535
* @param Token[] $arguments
3636
*/
37-
public function __construct(NodeInterface $selector, $name, array $arguments = array())
37+
public function __construct(NodeInterface $selector, string $name, array $arguments = array())
3838
{
3939
$this->selector = $selector;
4040
$this->name = strtolower($name);
4141
$this->arguments = $arguments;
4242
}
4343

44-
/**
45-
* @return NodeInterface
46-
*/
47-
public function getSelector()
44+
public function getSelector(): NodeInterface
4845
{
4946
return $this->selector;
5047
}
5148

52-
/**
53-
* @return string
54-
*/
55-
public function getName()
49+
public function getName(): string
5650
{
5751
return $this->name;
5852
}

Node/HashNode.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,18 @@ class HashNode extends AbstractNode
2626
private $selector;
2727
private $id;
2828

29-
/**
30-
* @param NodeInterface $selector
31-
* @param string $id
32-
*/
33-
public function __construct(NodeInterface $selector, $id)
29+
public function __construct(NodeInterface $selector, string $id)
3430
{
3531
$this->selector = $selector;
3632
$this->id = $id;
3733
}
3834

39-
/**
40-
* @return NodeInterface
41-
*/
42-
public function getSelector()
35+
public function getSelector(): NodeInterface
4336
{
4437
return $this->selector;
4538
}
4639

47-
/**
48-
* @return string
49-
*/
50-
public function getId()
40+
public function getId(): string
5141
{
5242
return $this->id;
5343
}

Node/PseudoNode.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,18 @@ class PseudoNode extends AbstractNode
2626
private $selector;
2727
private $identifier;
2828

29-
/**
30-
* @param NodeInterface $selector
31-
* @param string $identifier
32-
*/
33-
public function __construct(NodeInterface $selector, $identifier)
29+
public function __construct(NodeInterface $selector, string $identifier)
3430
{
3531
$this->selector = $selector;
3632
$this->identifier = strtolower($identifier);
3733
}
3834

39-
/**
40-
* @return NodeInterface
41-
*/
42-
public function getSelector()
35+
public function getSelector(): NodeInterface
4336
{
4437
return $this->selector;
4538
}
4639

47-
/**
48-
* @return string
49-
*/
50-
public function getIdentifier()
40+
public function getIdentifier(): string
5141
{
5242
return $this->identifier;
5343
}

Node/SelectorNode.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,18 @@ class SelectorNode extends AbstractNode
2626
private $tree;
2727
private $pseudoElement;
2828

29-
/**
30-
* @param NodeInterface $tree
31-
* @param null|string $pseudoElement
32-
*/
33-
public function __construct(NodeInterface $tree, $pseudoElement = null)
29+
public function __construct(NodeInterface $tree, string $pseudoElement = null)
3430
{
3531
$this->tree = $tree;
3632
$this->pseudoElement = $pseudoElement ? strtolower($pseudoElement) : null;
3733
}
3834

39-
/**
40-
* @return NodeInterface
41-
*/
42-
public function getTree()
35+
public function getTree(): NodeInterface
4336
{
4437
return $this->tree;
4538
}
4639

47-
/**
48-
* @return null|string
49-
*/
50-
public function getPseudoElement()
40+
public function getPseudoElement(): ?string
5141
{
5242
return $this->pseudoElement;
5343
}

Parser/Parser.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ public function parse(string $source): array
5050
*
5151
* @param Token[] $tokens
5252
*
53-
* @return array
54-
*
5553
* @throws SyntaxErrorException
5654
*/
57-
public static function parseSeries(array $tokens)
55+
public static function parseSeries(array $tokens): array
5856
{
5957
foreach ($tokens as $token) {
6058
if ($token->isString()) {
@@ -146,14 +144,9 @@ private function parserSelectorNode(TokenStream $stream): Node\SelectorNode
146144
/**
147145
* Parses next simple node (hash, class, pseudo, negation).
148146
*
149-
* @param TokenStream $stream
150-
* @param bool $insideNegation
151-
*
152-
* @return array
153-
*
154147
* @throws SyntaxErrorException
155148
*/
156-
private function parseSimpleSelector(TokenStream $stream, $insideNegation = false)
149+
private function parseSimpleSelector(TokenStream $stream, bool $insideNegation = false): array
157150
{
158151
$stream->skipWhitespace();
159152

0 commit comments

Comments
 (0)