Skip to content

Commit 105c98b

Browse files
committed
Merge branch '4.2' into short-array-master
* 4.2: fixed CS fixed CS fixed tests fixed CS fixed CS fixed CS fixed short array CS in comments fixed CS in ExpressionLanguage fixtures fixed CS in generated files fixed CS on generated container files fixed CS on Form PHP templates fixed CS on YAML fixtures fixed fixtures switched array() to []
2 parents 2fd9a08 + 48eddf6 commit 105c98b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+698
-698
lines changed

Node/FunctionNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class FunctionNode extends AbstractNode
3434
* @param string $name
3535
* @param Token[] $arguments
3636
*/
37-
public function __construct(NodeInterface $selector, string $name, array $arguments = array())
37+
public function __construct(NodeInterface $selector, string $name, array $arguments = [])
3838
{
3939
$this->selector = $selector;
4040
$this->name = strtolower($name);

Parser/Handler/StringHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function handle(Reader $reader, TokenStream $stream): bool
4747
{
4848
$quote = $reader->getSubstring(1);
4949

50-
if (!\in_array($quote, array("'", '"'))) {
50+
if (!\in_array($quote, ["'", '"'])) {
5151
return false;
5252
}
5353

Parser/Parser.php

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -74,33 +74,33 @@ public static function parseSeries(array $tokens): array
7474

7575
switch (true) {
7676
case 'odd' === $joined:
77-
return array(2, 1);
77+
return [2, 1];
7878
case 'even' === $joined:
79-
return array(2, 0);
79+
return [2, 0];
8080
case 'n' === $joined:
81-
return array(1, 0);
81+
return [1, 0];
8282
case false === strpos($joined, 'n'):
83-
return array(0, $int($joined));
83+
return [0, $int($joined)];
8484
}
8585

8686
$split = explode('n', $joined);
8787
$first = isset($split[0]) ? $split[0] : null;
8888

89-
return array(
89+
return [
9090
$first ? ('-' === $first || '+' === $first ? $int($first.'1') : $int($first)) : 1,
9191
isset($split[1]) && $split[1] ? $int($split[1]) : 0,
92-
);
92+
];
9393
}
9494

9595
private function parseSelectorList(TokenStream $stream): array
9696
{
9797
$stream->skipWhitespace();
98-
$selectors = array();
98+
$selectors = [];
9999

100100
while (true) {
101101
$selectors[] = $this->parserSelectorNode($stream);
102102

103-
if ($stream->getPeek()->isDelimiter(array(','))) {
103+
if ($stream->getPeek()->isDelimiter([','])) {
104104
$stream->getNext();
105105
$stream->skipWhitespace();
106106
} else {
@@ -119,15 +119,15 @@ private function parserSelectorNode(TokenStream $stream): Node\SelectorNode
119119
$stream->skipWhitespace();
120120
$peek = $stream->getPeek();
121121

122-
if ($peek->isFileEnd() || $peek->isDelimiter(array(','))) {
122+
if ($peek->isFileEnd() || $peek->isDelimiter([','])) {
123123
break;
124124
}
125125

126126
if (null !== $pseudoElement) {
127127
throw SyntaxErrorException::pseudoElementFound($pseudoElement, 'not at the end of a selector');
128128
}
129129

130-
if ($peek->isDelimiter(array('+', '>', '~'))) {
130+
if ($peek->isDelimiter(['+', '>', '~'])) {
131131
$combinator = $stream->getNext()->getValue();
132132
$stream->skipWhitespace();
133133
} else {
@@ -158,8 +158,8 @@ private function parseSimpleSelector(TokenStream $stream, bool $insideNegation =
158158
$peek = $stream->getPeek();
159159
if ($peek->isWhitespace()
160160
|| $peek->isFileEnd()
161-
|| $peek->isDelimiter(array(',', '+', '>', '~'))
162-
|| ($insideNegation && $peek->isDelimiter(array(')')))
161+
|| $peek->isDelimiter([',', '+', '>', '~'])
162+
|| ($insideNegation && $peek->isDelimiter([')']))
163163
) {
164164
break;
165165
}
@@ -170,32 +170,32 @@ private function parseSimpleSelector(TokenStream $stream, bool $insideNegation =
170170

171171
if ($peek->isHash()) {
172172
$result = new Node\HashNode($result, $stream->getNext()->getValue());
173-
} elseif ($peek->isDelimiter(array('.'))) {
173+
} elseif ($peek->isDelimiter(['.'])) {
174174
$stream->getNext();
175175
$result = new Node\ClassNode($result, $stream->getNextIdentifier());
176-
} elseif ($peek->isDelimiter(array('['))) {
176+
} elseif ($peek->isDelimiter(['['])) {
177177
$stream->getNext();
178178
$result = $this->parseAttributeNode($result, $stream);
179-
} elseif ($peek->isDelimiter(array(':'))) {
179+
} elseif ($peek->isDelimiter([':'])) {
180180
$stream->getNext();
181181

182-
if ($stream->getPeek()->isDelimiter(array(':'))) {
182+
if ($stream->getPeek()->isDelimiter([':'])) {
183183
$stream->getNext();
184184
$pseudoElement = $stream->getNextIdentifier();
185185

186186
continue;
187187
}
188188

189189
$identifier = $stream->getNextIdentifier();
190-
if (\in_array(strtolower($identifier), array('first-line', 'first-letter', 'before', 'after'))) {
190+
if (\in_array(strtolower($identifier), ['first-line', 'first-letter', 'before', 'after'])) {
191191
// Special case: CSS 2.1 pseudo-elements can have a single ':'.
192192
// Any new pseudo-element must have two.
193193
$pseudoElement = $identifier;
194194

195195
continue;
196196
}
197197

198-
if (!$stream->getPeek()->isDelimiter(array('('))) {
198+
if (!$stream->getPeek()->isDelimiter(['('])) {
199199
$result = new Node\PseudoNode($result, $identifier);
200200

201201
continue;
@@ -216,13 +216,13 @@ private function parseSimpleSelector(TokenStream $stream, bool $insideNegation =
216216
throw SyntaxErrorException::pseudoElementFound($argumentPseudoElement, 'inside ::not()');
217217
}
218218

219-
if (!$next->isDelimiter(array(')'))) {
219+
if (!$next->isDelimiter([')'])) {
220220
throw SyntaxErrorException::unexpectedToken('")"', $next);
221221
}
222222

223223
$result = new Node\NegationNode($result, $argument);
224224
} else {
225-
$arguments = array();
225+
$arguments = [];
226226
$next = null;
227227

228228
while (true) {
@@ -232,10 +232,10 @@ private function parseSimpleSelector(TokenStream $stream, bool $insideNegation =
232232
if ($next->isIdentifier()
233233
|| $next->isString()
234234
|| $next->isNumber()
235-
|| $next->isDelimiter(array('+', '-'))
235+
|| $next->isDelimiter(['+', '-'])
236236
) {
237237
$arguments[] = $next;
238-
} elseif ($next->isDelimiter(array(')'))) {
238+
} elseif ($next->isDelimiter([')'])) {
239239
break;
240240
} else {
241241
throw SyntaxErrorException::unexpectedToken('an argument', $next);
@@ -257,22 +257,22 @@ private function parseSimpleSelector(TokenStream $stream, bool $insideNegation =
257257
throw SyntaxErrorException::unexpectedToken('selector', $stream->getPeek());
258258
}
259259

260-
return array($result, $pseudoElement);
260+
return [$result, $pseudoElement];
261261
}
262262

263263
private function parseElementNode(TokenStream $stream): Node\ElementNode
264264
{
265265
$peek = $stream->getPeek();
266266

267-
if ($peek->isIdentifier() || $peek->isDelimiter(array('*'))) {
267+
if ($peek->isIdentifier() || $peek->isDelimiter(['*'])) {
268268
if ($peek->isIdentifier()) {
269269
$namespace = $stream->getNext()->getValue();
270270
} else {
271271
$stream->getNext();
272272
$namespace = null;
273273
}
274274

275-
if ($stream->getPeek()->isDelimiter(array('|'))) {
275+
if ($stream->getPeek()->isDelimiter(['|'])) {
276276
$stream->getNext();
277277
$element = $stream->getNextIdentifierOrStar();
278278
} else {
@@ -291,14 +291,14 @@ private function parseAttributeNode(Node\NodeInterface $selector, TokenStream $s
291291
$stream->skipWhitespace();
292292
$attribute = $stream->getNextIdentifierOrStar();
293293

294-
if (null === $attribute && !$stream->getPeek()->isDelimiter(array('|'))) {
294+
if (null === $attribute && !$stream->getPeek()->isDelimiter(['|'])) {
295295
throw SyntaxErrorException::unexpectedToken('"|"', $stream->getPeek());
296296
}
297297

298-
if ($stream->getPeek()->isDelimiter(array('|'))) {
298+
if ($stream->getPeek()->isDelimiter(['|'])) {
299299
$stream->getNext();
300300

301-
if ($stream->getPeek()->isDelimiter(array('='))) {
301+
if ($stream->getPeek()->isDelimiter(['='])) {
302302
$namespace = null;
303303
$stream->getNext();
304304
$operator = '|=';
@@ -315,12 +315,12 @@ private function parseAttributeNode(Node\NodeInterface $selector, TokenStream $s
315315
$stream->skipWhitespace();
316316
$next = $stream->getNext();
317317

318-
if ($next->isDelimiter(array(']'))) {
318+
if ($next->isDelimiter([']'])) {
319319
return new Node\AttributeNode($selector, $namespace, $attribute, 'exists', null);
320-
} elseif ($next->isDelimiter(array('='))) {
320+
} elseif ($next->isDelimiter(['='])) {
321321
$operator = '=';
322-
} elseif ($next->isDelimiter(array('^', '$', '*', '~', '|', '!'))
323-
&& $stream->getPeek()->isDelimiter(array('='))
322+
} elseif ($next->isDelimiter(['^', '$', '*', '~', '|', '!'])
323+
&& $stream->getPeek()->isDelimiter(['='])
324324
) {
325325
$operator = $next->getValue().'=';
326326
$stream->getNext();
@@ -344,7 +344,7 @@ private function parseAttributeNode(Node\NodeInterface $selector, TokenStream $s
344344
$stream->skipWhitespace();
345345
$next = $stream->getNext();
346346

347-
if (!$next->isDelimiter(array(']'))) {
347+
if (!$next->isDelimiter([']'])) {
348348
throw SyntaxErrorException::unexpectedToken('"]"', $next);
349349
}
350350

Parser/Shortcut/ClassParser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public function parse(string $source): array
4141
// 2 => string 'input' (length=5)
4242
// 3 => string 'ab6bd_field' (length=11)
4343
if (preg_match('/^(?:([a-z]++)\|)?+([\w-]++|\*)?+\.([\w-]++)$/i', trim($source), $matches)) {
44-
return array(
44+
return [
4545
new SelectorNode(new ClassNode(new ElementNode($matches[1] ?: null, $matches[2] ?: null), $matches[3])),
46-
);
46+
];
4747
}
4848

49-
return array();
49+
return [];
5050
}
5151
}

Parser/Shortcut/ElementParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public function parse(string $source): array
3939
// 1 => string 'testns' (length=6)
4040
// 2 => string 'testel' (length=6)
4141
if (preg_match('/^(?:([a-z]++)\|)?([\w-]++|\*)$/i', trim($source), $matches)) {
42-
return array(new SelectorNode(new ElementNode($matches[1] ?: null, $matches[2])));
42+
return [new SelectorNode(new ElementNode($matches[1] ?: null, $matches[2]))];
4343
}
4444

45-
return array();
45+
return [];
4646
}
4747
}

Parser/Shortcut/EmptyStringParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public function parse(string $source): array
3838
{
3939
// Matches an empty string
4040
if ('' == $source) {
41-
return array(new SelectorNode(new ElementNode(null, '*')));
41+
return [new SelectorNode(new ElementNode(null, '*'))];
4242
}
4343

44-
return array();
44+
return [];
4545
}
4646
}

Parser/Shortcut/HashParser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public function parse(string $source): array
4141
// 2 => string 'input' (length=5)
4242
// 3 => string 'ab6bd_field' (length=11)
4343
if (preg_match('/^(?:([a-z]++)\|)?+([\w-]++|\*)?+#([\w-]++)$/i', trim($source), $matches)) {
44-
return array(
44+
return [
4545
new SelectorNode(new HashNode(new ElementNode($matches[1] ?: null, $matches[2] ?: null), $matches[3])),
46-
);
46+
];
4747
}
4848

49-
return array();
49+
return [];
5050
}
5151
}

Parser/Token.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function isFileEnd(): bool
6262
return self::TYPE_FILE_END === $this->type;
6363
}
6464

65-
public function isDelimiter(array $values = array()): bool
65+
public function isDelimiter(array $values = []): bool
6666
{
6767
if (self::TYPE_DELIMITER !== $this->type) {
6868
return false;

Parser/TokenStream.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ class TokenStream
2929
/**
3030
* @var Token[]
3131
*/
32-
private $tokens = array();
32+
private $tokens = [];
3333

3434
/**
3535
* @var Token[]
3636
*/
37-
private $used = array();
37+
private $used = [];
3838

3939
/**
4040
* @var int
@@ -154,7 +154,7 @@ public function getNextIdentifierOrStar()
154154
return $next->getValue();
155155
}
156156

157-
if ($next->isDelimiter(array('*'))) {
157+
if ($next->isDelimiter(['*'])) {
158158
return;
159159
}
160160

Parser/Tokenizer/Tokenizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ public function __construct()
3838
$patterns = new TokenizerPatterns();
3939
$escaping = new TokenizerEscaping($patterns);
4040

41-
$this->handlers = array(
41+
$this->handlers = [
4242
new Handler\WhitespaceHandler(),
4343
new Handler\IdentifierHandler($patterns, $escaping),
4444
new Handler\HashHandler($patterns, $escaping),
4545
new Handler\StringHandler($patterns, $escaping),
4646
new Handler\NumberHandler($patterns),
4747
new Handler\CommentHandler(),
48-
);
48+
];
4949
}
5050

5151
/**

Tests/CssSelectorConverterTest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@ public function testCssToXPathWithoutPrefix($css, $xpath)
5555

5656
public function getCssToXPathWithoutPrefixTestData()
5757
{
58-
return array(
59-
array('h1', 'h1'),
60-
array('foo|h1', 'foo:h1'),
61-
array('h1, h2, h3', 'h1 | h2 | h3'),
62-
array('h1:nth-child(3n+1)', "*/*[(name() = 'h1') and (position() - 1 >= 0 and (position() - 1) mod 3 = 0)]"),
63-
array('h1 > p', 'h1/p'),
64-
array('h1#foo', "h1[@id = 'foo']"),
65-
array('h1.foo', "h1[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"),
66-
array('h1[class*="foo bar"]', "h1[@class and contains(@class, 'foo bar')]"),
67-
array('h1[foo|class*="foo bar"]', "h1[@foo:class and contains(@foo:class, 'foo bar')]"),
68-
array('h1[class]', 'h1[@class]'),
69-
array('h1 .foo', "h1/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"),
70-
array('h1 #foo', "h1/descendant-or-self::*/*[@id = 'foo']"),
71-
array('h1 [class*=foo]', "h1/descendant-or-self::*/*[@class and contains(@class, 'foo')]"),
72-
array('div>.foo', "div/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"),
73-
array('div > .foo', "div/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"),
74-
);
58+
return [
59+
['h1', 'h1'],
60+
['foo|h1', 'foo:h1'],
61+
['h1, h2, h3', 'h1 | h2 | h3'],
62+
['h1:nth-child(3n+1)', "*/*[(name() = 'h1') and (position() - 1 >= 0 and (position() - 1) mod 3 = 0)]"],
63+
['h1 > p', 'h1/p'],
64+
['h1#foo', "h1[@id = 'foo']"],
65+
['h1.foo', "h1[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"],
66+
['h1[class*="foo bar"]', "h1[@class and contains(@class, 'foo bar')]"],
67+
['h1[foo|class*="foo bar"]', "h1[@foo:class and contains(@foo:class, 'foo bar')]"],
68+
['h1[class]', 'h1[@class]'],
69+
['h1 .foo', "h1/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"],
70+
['h1 #foo', "h1/descendant-or-self::*/*[@id = 'foo']"],
71+
['h1 [class*=foo]', "h1/descendant-or-self::*/*[@class and contains(@class, 'foo')]"],
72+
['div>.foo', "div/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"],
73+
['div > .foo', "div/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"],
74+
];
7575
}
7676
}

0 commit comments

Comments
 (0)