@@ -40,20 +40,27 @@ |
||
40 | 40 | |
41 | 41 | private function getFuncParts($tokens) { |
42 | 42 | $parts = []; |
43 | - if ($tokens[0]['type'] === Tokenizer::NAME) $parts['name'] = $tokens[0]['value']; |
|
44 | - else $parts['name'] = null; |
|
43 | + if ($tokens[0]['type'] === Tokenizer::NAME) { |
|
44 | + $parts['name'] = $tokens[0]['value']; |
|
45 | + } else { |
|
46 | + $parts['name'] = null; |
|
47 | + } |
|
45 | 48 | if ($parts['name'] === null || (isset($tokens[1]) && $tokens[1]['type'] === Tokenizer::OPEN_SQUARE_BRACKET)) { |
46 | 49 | $parts['name'] = null; |
47 | 50 | $parts['args'] = $this->valueParser->parseTokens($tokens, $this->functionSet); |
51 | + } elseif (isset($tokens[1])) { |
|
52 | + $parts['args'] = $this->valueParser->parseTokens($tokens[1]['value'], $this->functionSet); |
|
53 | + } else { |
|
54 | + $parts['args'] = []; |
|
48 | 55 | } |
49 | - elseif (isset($tokens[1])) $parts['args'] = $this->valueParser->parseTokens($tokens[1]['value'], $this->functionSet); |
|
50 | - else $parts['args'] = []; |
|
51 | 56 | return $parts; |
52 | 57 | } |
53 | 58 | |
54 | 59 | public function hasFunction($name) { |
55 | 60 | foreach ($this->pseudo as $pseudo) { |
56 | - if (strpos($pseudo, $name) === 0) return true; |
|
61 | + if (strpos($pseudo, $name) === 0) { |
|
62 | + return true; |
|
63 | + } |
|
57 | 64 | } |
58 | 65 | } |
59 | 66 |
@@ -14,7 +14,9 @@ |
||
14 | 14 | } |
15 | 15 | |
16 | 16 | public function match($name, $args, \DomElement $element) { |
17 | - if ($name !== null) return true; |
|
17 | + if ($name !== null) { |
|
18 | + return true; |
|
19 | + } |
|
18 | 20 | return $args[0]; |
19 | 21 | } |
20 | 22 | } |
@@ -9,7 +9,9 @@ discard block |
||
9 | 9 | class Nth implements \Transphporm\Pseudo { |
10 | 10 | |
11 | 11 | public function match($name, $args, \DomElement $element) { |
12 | - if ($name !== 'nth-child') return true; |
|
12 | + if ($name !== 'nth-child') { |
|
13 | + return true; |
|
14 | + } |
|
13 | 15 | |
14 | 16 | $criteria = $args[0]; |
15 | 17 | |
@@ -18,8 +20,11 @@ discard block |
||
18 | 20 | $pseudo = $tokenizer->getTokens(); |
19 | 21 | $num = end($pseudo)['value'][0]['value']; |
20 | 22 | |
21 | - if (is_callable([$this, $criteria])) return $this->$criteria($num); |
|
22 | - else return $num == $criteria; |
|
23 | + if (is_callable([$this, $criteria])) { |
|
24 | + return $this->$criteria($num); |
|
25 | + } else { |
|
26 | + return $num == $criteria; |
|
27 | + } |
|
23 | 28 | } |
24 | 29 | |
25 | 30 | private function odd($num) { |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | } |
17 | 17 | |
18 | 18 | public function match($name, $args, \DomElement $element) { |
19 | - if ($name !== 'not') return true; |
|
19 | + if ($name !== 'not') { |
|
20 | + return true; |
|
21 | + } |
|
20 | 22 | |
21 | 23 | $xpath = new \DomXpath($element->ownerDocument); |
22 | 24 | return $this->notElement($args, $xpath, $element); |
@@ -29,7 +31,9 @@ discard block |
||
29 | 31 | //Find all nodes matched by the expressions in the brackets :not(EXPR) |
30 | 32 | foreach ($xpath->query($xpathString) as $matchedElement) { |
31 | 33 | //Check to see whether this node was matched by the not query |
32 | - if ($element->isSameNode($matchedElement)) return false; |
|
34 | + if ($element->isSameNode($matchedElement)) { |
|
35 | + return false; |
|
36 | + } |
|
33 | 37 | } |
34 | 38 | } |
35 | 39 | return true; |