Skip to content

Commit d69e174

Browse files
Merge branch '4.4'
* 4.4: some backports from master Add return types to internal|final|private methods [HttpFoundation] Precalculate session expiry timestamp
2 parents c0687b0 + 7447f4c commit d69e174

13 files changed

+49
-123
lines changed

Node/ElementNode.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,12 @@ public function __construct(string $namespace = null, string $element = null)
3232
$this->element = $element;
3333
}
3434

35-
/**
36-
* @return string|null
37-
*/
38-
public function getNamespace()
35+
public function getNamespace(): ?string
3936
{
4037
return $this->namespace;
4138
}
4239

43-
/**
44-
* @return string|null
45-
*/
46-
public function getElement()
40+
public function getElement(): ?string
4741
{
4842
return $this->element;
4943
}

Node/FunctionNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getName(): string
5252
/**
5353
* @return Token[]
5454
*/
55-
public function getArguments()
55+
public function getArguments(): array
5656
{
5757
return $this->arguments;
5858
}

Node/NegationNode.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,12 @@ public function __construct(NodeInterface $selector, NodeInterface $subSelector)
3232
$this->subSelector = $subSelector;
3333
}
3434

35-
/**
36-
* @return NodeInterface
37-
*/
38-
public function getSelector()
35+
public function getSelector(): NodeInterface
3936
{
4037
return $this->selector;
4138
}
4239

43-
/**
44-
* @return NodeInterface
45-
*/
46-
public function getSubSelector()
40+
public function getSubSelector(): NodeInterface
4741
{
4842
return $this->subSelector;
4943
}

Parser/TokenStream.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,9 @@ public function freeze()
7676
/**
7777
* Returns next token.
7878
*
79-
* @return Token
80-
*
8179
* @throws InternalErrorException If there is no more token
8280
*/
83-
public function getNext()
81+
public function getNext(): Token
8482
{
8583
if ($this->peeking) {
8684
$this->peeking = false;
@@ -98,10 +96,8 @@ public function getNext()
9896

9997
/**
10098
* Returns peeked token.
101-
*
102-
* @return Token
10399
*/
104-
public function getPeek()
100+
public function getPeek(): Token
105101
{
106102
if (!$this->peeking) {
107103
$this->peeked = $this->getNext();
@@ -116,7 +112,7 @@ public function getPeek()
116112
*
117113
* @return Token[]
118114
*/
119-
public function getUsed()
115+
public function getUsed(): array
120116
{
121117
return $this->used;
122118
}
@@ -128,7 +124,7 @@ public function getUsed()
128124
*
129125
* @throws SyntaxErrorException If next token is not an identifier
130126
*/
131-
public function getNextIdentifier()
127+
public function getNextIdentifier(): string
132128
{
133129
$next = $this->getNext();
134130

@@ -146,7 +142,7 @@ public function getNextIdentifier()
146142
*
147143
* @throws SyntaxErrorException If next token is not an identifier or a star delimiter
148144
*/
149-
public function getNextIdentifierOrStar()
145+
public function getNextIdentifierOrStar(): ?string
150146
{
151147
$next = $this->getNext();
152148

Parser/Tokenizer/Tokenizer.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ public function __construct()
5050

5151
/**
5252
* Tokenize selector source code.
53-
*
54-
* @return TokenStream
5553
*/
56-
public function tokenize(Reader $reader)
54+
public function tokenize(Reader $reader): TokenStream
5755
{
5856
$stream = new TokenStream();
5957

XPath/Extension/AbstractExtension.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,39 @@ abstract class AbstractExtension implements ExtensionInterface
2626
/**
2727
* {@inheritdoc}
2828
*/
29-
public function getNodeTranslators()
29+
public function getNodeTranslators(): array
3030
{
3131
return [];
3232
}
3333

3434
/**
3535
* {@inheritdoc}
3636
*/
37-
public function getCombinationTranslators()
37+
public function getCombinationTranslators(): array
3838
{
3939
return [];
4040
}
4141

4242
/**
4343
* {@inheritdoc}
4444
*/
45-
public function getFunctionTranslators()
45+
public function getFunctionTranslators(): array
4646
{
4747
return [];
4848
}
4949

5050
/**
5151
* {@inheritdoc}
5252
*/
53-
public function getPseudoClassTranslators()
53+
public function getPseudoClassTranslators(): array
5454
{
5555
return [];
5656
}
5757

5858
/**
5959
* {@inheritdoc}
6060
*/
61-
public function getAttributeMatchingTranslators()
61+
public function getAttributeMatchingTranslators(): array
6262
{
6363
return [];
6464
}

XPath/Extension/AttributeMatchingExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class AttributeMatchingExtension extends AbstractExtension
2929
/**
3030
* {@inheritdoc}
3131
*/
32-
public function getAttributeMatchingTranslators()
32+
public function getAttributeMatchingTranslators(): array
3333
{
3434
return [
3535
'exists' => [$this, 'translateExists'],
@@ -112,7 +112,7 @@ public function translateDifferent(XPathExpr $xpath, string $attribute, ?string
112112
/**
113113
* {@inheritdoc}
114114
*/
115-
public function getName()
115+
public function getName(): string
116116
{
117117
return 'attribute-matching';
118118
}

XPath/Extension/CombinationExtension.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,37 +43,28 @@ public function translateDescendant(XPathExpr $xpath, XPathExpr $combinedXpath):
4343
return $xpath->join('/descendant-or-self::*/', $combinedXpath);
4444
}
4545

46-
/**
47-
* @return XPathExpr
48-
*/
49-
public function translateChild(XPathExpr $xpath, XPathExpr $combinedXpath)
46+
public function translateChild(XPathExpr $xpath, XPathExpr $combinedXpath): XPathExpr
5047
{
5148
return $xpath->join('/', $combinedXpath);
5249
}
5350

54-
/**
55-
* @return XPathExpr
56-
*/
57-
public function translateDirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath)
51+
public function translateDirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath): XPathExpr
5852
{
5953
return $xpath
6054
->join('/following-sibling::', $combinedXpath)
6155
->addNameTest()
6256
->addCondition('position() = 1');
6357
}
6458

65-
/**
66-
* @return XPathExpr
67-
*/
68-
public function translateIndirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath)
59+
public function translateIndirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath): XPathExpr
6960
{
7061
return $xpath->join('/following-sibling::', $combinedXpath);
7162
}
7263

7364
/**
7465
* {@inheritdoc}
7566
*/
76-
public function getName()
67+
public function getName(): string
7768
{
7869
return 'combination';
7970
}

XPath/Extension/FunctionExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class FunctionExtension extends AbstractExtension
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
public function getFunctionTranslators()
36+
public function getFunctionTranslators(): array
3737
{
3838
return [
3939
'nth-child' => [$this, 'translateNthChild'],
@@ -164,7 +164,7 @@ public function translateLang(XPathExpr $xpath, FunctionNode $function): XPathEx
164164
/**
165165
* {@inheritdoc}
166166
*/
167-
public function getName()
167+
public function getName(): string
168168
{
169169
return 'function';
170170
}

XPath/Extension/HtmlExtension.php

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(Translator $translator)
3939
/**
4040
* {@inheritdoc}
4141
*/
42-
public function getPseudoClassTranslators()
42+
public function getPseudoClassTranslators(): array
4343
{
4444
return [
4545
'checked' => [$this, 'translateChecked'],
@@ -56,17 +56,14 @@ public function getPseudoClassTranslators()
5656
/**
5757
* {@inheritdoc}
5858
*/
59-
public function getFunctionTranslators()
59+
public function getFunctionTranslators(): array
6060
{
6161
return [
6262
'lang' => [$this, 'translateLang'],
6363
];
6464
}
6565

66-
/**
67-
* @return XPathExpr
68-
*/
69-
public function translateChecked(XPathExpr $xpath)
66+
public function translateChecked(XPathExpr $xpath): XPathExpr
7067
{
7168
return $xpath->addCondition(
7269
'(@checked '
@@ -75,18 +72,12 @@ public function translateChecked(XPathExpr $xpath)
7572
);
7673
}
7774

78-
/**
79-
* @return XPathExpr
80-
*/
81-
public function translateLink(XPathExpr $xpath)
75+
public function translateLink(XPathExpr $xpath): XPathExpr
8276
{
8377
return $xpath->addCondition("@href and (name(.) = 'a' or name(.) = 'link' or name(.) = 'area')");
8478
}
8579

86-
/**
87-
* @return XPathExpr
88-
*/
89-
public function translateDisabled(XPathExpr $xpath)
80+
public function translateDisabled(XPathExpr $xpath): XPathExpr
9081
{
9182
return $xpath->addCondition(
9283
'('
@@ -112,10 +103,7 @@ public function translateDisabled(XPathExpr $xpath)
112103
// todo: in the second half, add "and is not a descendant of that fieldset element's first legend element child, if any."
113104
}
114105

115-
/**
116-
* @return XPathExpr
117-
*/
118-
public function translateEnabled(XPathExpr $xpath)
106+
public function translateEnabled(XPathExpr $xpath): XPathExpr
119107
{
120108
return $xpath->addCondition(
121109
'('
@@ -149,11 +137,9 @@ public function translateEnabled(XPathExpr $xpath)
149137
}
150138

151139
/**
152-
* @return XPathExpr
153-
*
154140
* @throws ExpressionErrorException
155141
*/
156-
public function translateLang(XPathExpr $xpath, FunctionNode $function)
142+
public function translateLang(XPathExpr $xpath, FunctionNode $function): XPathExpr
157143
{
158144
$arguments = $function->getArguments();
159145
foreach ($arguments as $token) {
@@ -171,42 +157,30 @@ public function translateLang(XPathExpr $xpath, FunctionNode $function)
171157
));
172158
}
173159

174-
/**
175-
* @return XPathExpr
176-
*/
177-
public function translateSelected(XPathExpr $xpath)
160+
public function translateSelected(XPathExpr $xpath): XPathExpr
178161
{
179162
return $xpath->addCondition("(@selected and name(.) = 'option')");
180163
}
181164

182-
/**
183-
* @return XPathExpr
184-
*/
185-
public function translateInvalid(XPathExpr $xpath)
165+
public function translateInvalid(XPathExpr $xpath): XPathExpr
186166
{
187167
return $xpath->addCondition('0');
188168
}
189169

190-
/**
191-
* @return XPathExpr
192-
*/
193-
public function translateHover(XPathExpr $xpath)
170+
public function translateHover(XPathExpr $xpath): XPathExpr
194171
{
195172
return $xpath->addCondition('0');
196173
}
197174

198-
/**
199-
* @return XPathExpr
200-
*/
201-
public function translateVisited(XPathExpr $xpath)
175+
public function translateVisited(XPathExpr $xpath): XPathExpr
202176
{
203177
return $xpath->addCondition('0');
204178
}
205179

206180
/**
207181
* {@inheritdoc}
208182
*/
209-
public function getName()
183+
public function getName(): string
210184
{
211185
return 'html';
212186
}

XPath/Extension/NodeExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function hasFlag(int $flag): bool
6262
/**
6363
* {@inheritdoc}
6464
*/
65-
public function getNodeTranslators()
65+
public function getNodeTranslators(): array
6666
{
6767
return [
6868
'Selector' => [$this, 'translateSelector'],
@@ -185,7 +185,7 @@ public function translateElement(Node\ElementNode $node): XPathExpr
185185
/**
186186
* {@inheritdoc}
187187
*/
188-
public function getName()
188+
public function getName(): string
189189
{
190190
return 'node';
191191
}

0 commit comments

Comments
 (0)