Completed
Push — master ( 0ada29...ecc437 )
by Richard
03:53 queued 11s
created
src/Hook/PropertyHook.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,11 +20,15 @@  discard block
 block discarded – undo
20 20
 
21 21
 	public function run(\DomElement $element) {	
22 22
 		//Don't run if there's a pseudo element like nth-child() and this element doesn't match it
23
-		if (!$this->pseudoMatcher->matches($element)) return;
23
+		if (!$this->pseudoMatcher->matches($element)) {
24
+			return;
25
+		}
24 26
 
25 27
 		foreach ($this->rules as $name => $value) {
26 28
 			$result = $this->callProperty($name, $element, $this->valueParser->parse(trim($value), $element));
27
-			if ($result === false) break;
29
+			if ($result === false) {
30
+				break;
31
+			}
28 32
 		}
29 33
 	}
30 34
 
@@ -45,7 +49,9 @@  discard block
 block discarded – undo
45 49
 	}
46 50
 
47 51
 	private function callProperty($name, $element, $value) {
48
-		if (isset($this->properties[$name])) return $this->properties[$name]->run($value, $element, $this->rules, $this->pseudoMatcher, $this->properties);
52
+		if (isset($this->properties[$name])) {
53
+			return $this->properties[$name]->run($value, $element, $this->rules, $this->pseudoMatcher, $this->properties);
54
+		}
49 55
 		return false;
50 56
 	}
51 57
 }
Please login to merge, or discard this patch.
src/Parser/Sheet.php 3 patches
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -13,6 +13,9 @@  discard block
 block discarded – undo
13 13
 	private $xPath;
14 14
 	private $tokenizer; 
15 15
 
16
+	/**
17
+	 * @param string $tss
18
+	 */
16 19
 	public function __construct($tss, $baseDir, CssToXpath $xPath, Value $valueParser) {
17 20
 		$this->tss = $this->stripComments($tss, '//', "\n");
18 21
 		$this->tss = $this->stripComments($this->tss, '/*', '*/');
@@ -44,6 +47,9 @@  discard block
 block discarded – undo
44 47
 		return $rules;
45 48
 	}
46 49
 
50
+	/**
51
+	 * @param integer $index
52
+	 */
47 53
 	private function CssToRules($selector, $index, $properties) {
48 54
 		$parts = $selector->trim()->splitOnToken(Tokenizer::ARG);
49 55
 		$rules = [];
@@ -67,6 +73,9 @@  discard block
 block discarded – undo
67 73
 		return $rules;
68 74
 	}
69 75
 
76
+	/**
77
+	 * @param integer $indexStart
78
+	 */
70 79
 	private function processingInstructions($token, $indexStart) {
71 80
 		if ($token['type'] !== Tokenizer::AT_SIGN) return false;
72 81
 		$tokens = $this->tss->from(Tokenizer::AT_SIGN, false)->to(Tokenizer::SEMI_COLON, false);
@@ -90,6 +99,10 @@  discard block
 block discarded – undo
90 99
 		return ($a->depth < $b->depth) ? -1 : 1;
91 100
 	}
92 101
 
102
+	/**
103
+	 * @param string $open
104
+	 * @param string $close
105
+	 */
93 106
 	private function stripComments($str, $open, $close) {
94 107
 		$pos = 0;
95 108
 		while (($pos = strpos($str, $open, $pos)) !== false) {
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -102,14 +102,14 @@
 block discarded – undo
102 102
 	}
103 103
 
104 104
 	private function getProperties($tokens) {
105
-        $rules = $tokens->splitOnToken(Tokenizer::SEMI_COLON);
105
+		$rules = $tokens->splitOnToken(Tokenizer::SEMI_COLON);
106 106
 
107
-        $return = [];
108
-        foreach ($rules as $rule) {
109
-            $name = $rule->from(Tokenizer::NAME, true)->to(Tokenizer::COLON)->read();
110
-            $return[$name] = $rule->from(Tokenizer::COLON)->trim();
111
-        }
107
+		$return = [];
108
+		foreach ($rules as $rule) {
109
+			$name = $rule->from(Tokenizer::NAME, true)->to(Tokenizer::COLON)->read();
110
+			$return[$name] = $rule->from(Tokenizer::COLON)->trim();
111
+		}
112 112
 
113
-        return $return;
114
-    }
113
+		return $return;
114
+	}
115 115
 }
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@  discard block
 block discarded – undo
33 33
 			}
34 34
 			$selector = $this->tss->from($token['type'], true)->to(Tokenizer::OPEN_BRACE);
35 35
 			$this->tss->skip(count($selector));
36
-			if (count($selector) === 0) break;
36
+			if (count($selector) === 0) {
37
+				break;
38
+			}
37 39
 
38 40
 			$newRules = $this->cssToRules($selector, count($rules)+$indexStart, $this->getProperties($this->tss->current()['value']));
39 41
 			$rules = $this->writeRule($rules, $newRules);
@@ -44,7 +46,9 @@  discard block
 block discarded – undo
44 46
 	}
45 47
 
46 48
 	private function checkError($rules) {
47
-		if (empty($rules) && count($this->tss) > 0) throw new \Exception('No TSS rules parsed');
49
+		if (empty($rules) && count($this->tss) > 0) {
50
+			throw new \Exception('No TSS rules parsed');
51
+		}
48 52
 	}
49 53
 
50 54
 	private function CssToRules($selector, $index, $properties) {
@@ -71,7 +75,9 @@  discard block
 block discarded – undo
71 75
 	}
72 76
 
73 77
 	private function processingInstructions($token, $indexStart) {
74
-		if ($token['type'] !== Tokenizer::AT_SIGN) return false;
78
+		if ($token['type'] !== Tokenizer::AT_SIGN) {
79
+			return false;
80
+		}
75 81
 		$tokens = $this->tss->from(Tokenizer::AT_SIGN, false)->to(Tokenizer::SEMI_COLON, false);
76 82
 		$funcName = $tokens->from(Tokenizer::NAME, true)->read();
77 83
 		$args = $this->valueParser->parseTokens($tokens->from(Tokenizer::NAME));
@@ -88,7 +94,9 @@  discard block
 block discarded – undo
88 94
 
89 95
 	private function sortRules($a, $b) {
90 96
 		//If they have the same depth, compare on index
91
-		if ($a->depth === $b->depth) return $a->index < $b->index ? -1 : 1;
97
+		if ($a->depth === $b->depth) {
98
+			return $a->index < $b->index ? -1 : 1;
99
+		}
92 100
 
93 101
 		return ($a->depth < $b->depth) ? -1 : 1;
94 102
 	}
@@ -97,7 +105,9 @@  discard block
 block discarded – undo
97 105
 		$pos = 0;
98 106
 		while (($pos = strpos($str, $open, $pos)) !== false) {
99 107
 			$end = strpos($str, $close, $pos);
100
-			if ($end === false) break;
108
+			if ($end === false) {
109
+				break;
110
+			}
101 111
 			$str = substr_replace($str, '', $pos, $end-$pos+strlen($close));
102 112
 		}
103 113
 
Please login to merge, or discard this patch.
src/Hook/Formatter.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	public function format($value, $rules) {
17
-		if (!isset($rules['format'])) return $value;
17
+		if (!isset($rules['format'])) {
18
+			return $value;
19
+		}
18 20
 		$tokens = $rules['format'];
19 21
 		
20 22
 		$functionName = $tokens->from(\Transphporm\Parser\Tokenizer::NAME, true)->read();
Please login to merge, or discard this patch.
src/Hook/PseudoMatcher.php 1 patch
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,31 +39,37 @@
 block discarded – undo
39 39
 		$parts['name'] = $this->getFuncName($tokens);
40 40
 		if ($parts['name'] === null || in_array($parts['name'], ['data', 'iteration', 'root'])) {
41 41
 			$parts['args'] = $this->valueParser->parseTokens($tokens);
42
-		}
43
-		else if (count($tokens) > 1) {
42
+		} else if (count($tokens) > 1) {
44 43
 			$tokens->rewind();
45 44
 			$tokens->next();
46 45
 			$parts['args'] = $this->valueParser->parseTokens($tokens->current()['value']);
46
+		} else {
47
+			$parts['args'] = [['']];
47 48
 		}
48
-		else $parts['args'] = [['']];
49 49
 		return $parts;
50 50
 	}
51 51
 
52 52
 	private function getFuncName($tokens) {
53
-		if ($tokens->type() === Tokenizer::NAME) return $tokens->read();
53
+		if ($tokens->type() === Tokenizer::NAME) {
54
+			return $tokens->read();
55
+		}
54 56
 		return null;
55 57
 	}
56 58
 
57 59
 	public function hasFunction($name) {
58 60
 		foreach ($this->pseudo as $tokens) {
59
-			if ($name === $this->getFuncName($tokens)) return true;
61
+			if ($name === $this->getFuncName($tokens)) {
62
+				return true;
63
+			}
60 64
 		}
61 65
 	}
62 66
 
63 67
 	public function getFuncArgs($name) {
64 68
 		foreach ($this->pseudo as $tokens) {
65 69
 			$parts = $this->getFuncParts($tokens);
66
-			if ($name === $parts['name']) return $parts['args'];
70
+			if ($name === $parts['name']) {
71
+				return $parts['args'];
72
+			}
67 73
 		}
68 74
 	}
69 75
 }
Please login to merge, or discard this patch.
src/FunctionSet.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,7 @@
 block discarded – undo
20 20
 			$tokens = $args[0];
21 21
 			$parser = new \Transphporm\Parser\Value($this);
22 22
 			$args[0] = $parser->parseTokens($tokens, $this->elementData->getData($this->element));
23
-		}
24
-		else if ($args[0] instanceof Parser\Tokens) {
23
+		} else if ($args[0] instanceof Parser\Tokens) {
25 24
 			$args[0] = iterator_to_array($args[0]);
26 25
 		}
27 26
 		if (isset($this->functions[$name])) {
Please login to merge, or discard this patch.
src/Parser/Tokens.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
 			if ($token['type'] === $tokenType) $i++;
79 79
 			else $splitTokens[$i][] = $token;
80 80
 		}
81
-        return array_map(function ($tokens) {
81
+        return array_map(function($tokens) {
82 82
             return new Tokens($tokens);
83 83
         }, $splitTokens);
84 84
 		//return $splitTokens;
Please login to merge, or discard this patch.
Braces   +23 added lines, -8 removed lines patch added patch discarded remove patch
@@ -51,19 +51,31 @@  discard block
 block discarded – undo
51 51
 
52 52
     public function from($tokenType, $inclusive = false) {
53 53
         $keys = $this->getKeysOfTokenType($tokenType);
54
-        if (count($keys) === 0) return new Tokens([]);
54
+        if (count($keys) === 0) {
55
+        	return new Tokens([]);
56
+        }
55 57
         $key = $keys[0];
56
-        for ($i = 0; $key < $this->iterator; $i++) $key = $keys[$i];
57
-        if (!$inclusive) $key++;
58
+        for ($i = 0; $key < $this->iterator; $i++) {
59
+        	$key = $keys[$i];
60
+        }
61
+        if (!$inclusive) {
62
+        	$key++;
63
+        }
58 64
         return new Tokens(array_slice($this->tokens, $key));
59 65
     }
60 66
 
61 67
     public function to($tokenType, $inclusive = false) {
62 68
         $keys = $this->getKeysOfTokenType($tokenType);
63
-        if (empty($keys)) return new Tokens([]);
69
+        if (empty($keys)) {
70
+        	return new Tokens([]);
71
+        }
64 72
         $key = $keys[0];
65
-        for ($i = 0; $key < $this->iterator; $i++) $key = $keys[$i];
66
-        if ($inclusive) $key++;
73
+        for ($i = 0; $key < $this->iterator; $i++) {
74
+        	$key = $keys[$i];
75
+        }
76
+        if ($inclusive) {
77
+        	$key++;
78
+        }
67 79
         return new Tokens(array_slice($this->tokens, 0, $key));
68 80
     }
69 81
 
@@ -75,8 +87,11 @@  discard block
 block discarded – undo
75 87
         $splitTokens = [];
76 88
 		$i = 0;
77 89
 		foreach ($this->tokens as $token) {
78
-			if ($token['type'] === $tokenType) $i++;
79
-			else $splitTokens[$i][] = $token;
90
+			if ($token['type'] === $tokenType) {
91
+				$i++;
92
+			} else {
93
+				$splitTokens[$i][] = $token;
94
+			}
80 95
 		}
81 96
         return array_map(function ($tokens) {
82 97
             return new Tokens($tokens);
Please login to merge, or discard this patch.
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -6,28 +6,28 @@  discard block
 block discarded – undo
6 6
  * @version         1.0                                                             */
7 7
 namespace Transphporm\Parser;
8 8
 class Tokens implements \Iterator, \Countable {
9
-    private $tokens;
10
-    private $iterator = 0;
9
+	private $tokens;
10
+	private $iterator = 0;
11 11
 
12
-    public function __construct(array $tokens) {
13
-        $this->tokens = $tokens;
14
-    }
12
+	public function __construct(array $tokens) {
13
+		$this->tokens = $tokens;
14
+	}
15 15
 
16
-    public function count() {
17
-        return count($this->tokens);
18
-    }
16
+	public function count() {
17
+		return count($this->tokens);
18
+	}
19 19
 
20
-    // Iterator Functions
21
-    public function current() {
22
-        return $this->tokens[$this->iterator];
23
-    }
20
+	// Iterator Functions
21
+	public function current() {
22
+		return $this->tokens[$this->iterator];
23
+	}
24 24
 
25
-    public function key() {
26
-        return $this->iterator;
27
-    }
25
+	public function key() {
26
+		return $this->iterator;
27
+	}
28 28
 
29
-    public function next() {
30
-        ++$this->iterator;
29
+	public function next() {
30
+		++$this->iterator;
31 31
 	}
32 32
 
33 33
 	public function valid() {
@@ -38,63 +38,63 @@  discard block
 block discarded – undo
38 38
 		$this->iterator = 0;
39 39
 	}
40 40
 
41
-    private function getKeysOfTokenType($tokenType) {
42
-        return array_keys(array_column($this->tokens, 'type'), $tokenType);
43
-    }
41
+	private function getKeysOfTokenType($tokenType) {
42
+		return array_keys(array_column($this->tokens, 'type'), $tokenType);
43
+	}
44 44
 
45
-    public function from($tokenType, $inclusive = false) {
46
-        $keys = $this->getKeysOfTokenType($tokenType);
47
-        if (count($keys) === 0) return new Tokens([]);
48
-        $key = $keys[0];
49
-        for ($i = 0; $key < $this->iterator; $i++) $key = $keys[$i];
50
-        if (!$inclusive) $key++;
51
-        return new Tokens(array_slice($this->tokens, $key));
52
-    }
45
+	public function from($tokenType, $inclusive = false) {
46
+		$keys = $this->getKeysOfTokenType($tokenType);
47
+		if (count($keys) === 0) return new Tokens([]);
48
+		$key = $keys[0];
49
+		for ($i = 0; $key < $this->iterator; $i++) $key = $keys[$i];
50
+		if (!$inclusive) $key++;
51
+		return new Tokens(array_slice($this->tokens, $key));
52
+	}
53 53
 
54
-    public function to($tokenType, $inclusive = false) {
55
-        $keys = $this->getKeysOfTokenType($tokenType);
56
-        if (empty($keys)) return new Tokens([]);
57
-        $key = $keys[0];
58
-        for ($i = 0; $key < $this->iterator; $i++) $key = $keys[$i];
59
-        if ($inclusive) $key++;
60
-        return new Tokens(array_slice($this->tokens, 0, $key));
61
-    }
54
+	public function to($tokenType, $inclusive = false) {
55
+		$keys = $this->getKeysOfTokenType($tokenType);
56
+		if (empty($keys)) return new Tokens([]);
57
+		$key = $keys[0];
58
+		for ($i = 0; $key < $this->iterator; $i++) $key = $keys[$i];
59
+		if ($inclusive) $key++;
60
+		return new Tokens(array_slice($this->tokens, 0, $key));
61
+	}
62 62
 
63
-    public function skip($count) {
64
-        $this->iterator += $count;
65
-    }
63
+	public function skip($count) {
64
+		$this->iterator += $count;
65
+	}
66 66
 
67
-    public function splitOnToken($tokenType) {
68
-        $splitTokens = [];
67
+	public function splitOnToken($tokenType) {
68
+		$splitTokens = [];
69 69
 		$i = 0;
70 70
 		foreach ($this->tokens as $token) {
71 71
 			if ($token['type'] === $tokenType) $i++;
72 72
 			else $splitTokens[$i][] = $token;
73 73
 		}
74
-        return array_map(function ($tokens) {
75
-            return new Tokens($tokens);
76
-        }, $splitTokens);
74
+		return array_map(function ($tokens) {
75
+			return new Tokens($tokens);
76
+		}, $splitTokens);
77 77
 		//return $splitTokens;
78
-    }
78
+	}
79 79
 
80
-    public function trim() {
81
-        $tokens = $this->tokens;
82
-        // Remove end whitespace
83
-        while (end($tokens)['type'] === Tokenizer::WHITESPACE) {
84
-            array_pop($tokens);
85
-        }
86
-        // Remove begining whitespace
87
-        while (isset($tokens[0]) && $tokens[0]['type'] === Tokenizer::WHITESPACE) {
88
-            array_shift($tokens);
89
-        }
90
-        return new Tokens($tokens);
91
-    }
80
+	public function trim() {
81
+		$tokens = $this->tokens;
82
+		// Remove end whitespace
83
+		while (end($tokens)['type'] === Tokenizer::WHITESPACE) {
84
+			array_pop($tokens);
85
+		}
86
+		// Remove begining whitespace
87
+		while (isset($tokens[0]) && $tokens[0]['type'] === Tokenizer::WHITESPACE) {
88
+			array_shift($tokens);
89
+		}
90
+		return new Tokens($tokens);
91
+	}
92 92
 
93
-    public function read($offset = 0) {
94
-        return isset($this->tokens[$offset]) ? $this->tokens[$offset]['value'] : false;
95
-    }
93
+	public function read($offset = 0) {
94
+		return isset($this->tokens[$offset]) ? $this->tokens[$offset]['value'] : false;
95
+	}
96 96
 
97
-    public function type($offset = 0) {
98
-        return isset($this->tokens[$offset]) ? $this->tokens[$offset]['type'] : false;   
99
-    }
97
+	public function type($offset = 0) {
98
+		return isset($this->tokens[$offset]) ? $this->tokens[$offset]['type'] : false;   
99
+	}
100 100
 }
Please login to merge, or discard this patch.
src/Parser/TokenFilterIterator.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -6,35 +6,35 @@
 block discarded – undo
6 6
  * @version         1.0                                                             */
7 7
 namespace Transphporm\Parser;
8 8
 class TokenFilterIterator implements \Iterator {
9
-    private $ignore;
10
-    private $tokens;
9
+	private $ignore;
10
+	private $tokens;
11 11
 
12
-    public function __construct(Tokens $tokens, array $ignore) {
13
-        $this->ignore = $ignore;
14
-        $this->tokens = $tokens;
15
-    }
12
+	public function __construct(Tokens $tokens, array $ignore) {
13
+		$this->ignore = $ignore;
14
+		$this->tokens = $tokens;
15
+	}
16 16
 
17
-    public function current() {
18
-        return $this->tokens->current();
19
-    }
17
+	public function current() {
18
+		return $this->tokens->current();
19
+	}
20 20
 
21
-    public function key() {
22
-        return $this->tokens->key();
23
-    }
21
+	public function key() {
22
+		return $this->tokens->key();
23
+	}
24 24
 
25
-    public function valid() {
26
-        return $this->tokens->valid();
27
-    }
25
+	public function valid() {
26
+		return $this->tokens->valid();
27
+	}
28 28
 
29
-    public function next() {
30
-        do {
31
-            $this->tokens->next();
32
-        }
33
-        while ($this->tokens->valid() && in_array($this->tokens->current()['type'], $this->ignore));
34
-    }
29
+	public function next() {
30
+		do {
31
+			$this->tokens->next();
32
+		}
33
+		while ($this->tokens->valid() && in_array($this->tokens->current()['type'], $this->ignore));
34
+	}
35 35
 
36
-    public function rewind() {
37
-        $this->tokens->rewind();
38
-        while ($this->tokens->valid() && in_array($this->tokens->current()['type'], $this->ignore)) $this->tokens->next();
39
-    }
36
+	public function rewind() {
37
+		$this->tokens->rewind();
38
+		while ($this->tokens->valid() && in_array($this->tokens->current()['type'], $this->ignore)) $this->tokens->next();
39
+	}
40 40
 }
41 41
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,6 +35,8 @@
 block discarded – undo
35 35
 
36 36
     public function rewind() {
37 37
         $this->tokens->rewind();
38
-        while ($this->tokens->valid() && in_array($this->tokens->current()['type'], $this->ignore)) $this->tokens->next();
38
+        while ($this->tokens->valid() && in_array($this->tokens->current()['type'], $this->ignore)) {
39
+        	$this->tokens->next();
40
+        }
39 41
     }
40 42
 }
41 43
\ No newline at end of file
Please login to merge, or discard this patch.
src/Parser/CssToXpath.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 		$this->functionSet = $functionSet;
19 19
 
20 20
 		$this->translators = [
21
-			Tokenizer::WHITESPACE => function($string) use ($prefix) { return '//' . $prefix . $string;	},
22
-			'' => function($string) use ($prefix) { return '/' . $prefix . $string;	},
23
-			Tokenizer::GREATER_THAN => function($string) use ($prefix) { return '/' . $prefix  . $string; },
24
-			Tokenizer::NUM_SIGN => function($string) { return '[@id=\'' . $string . '\']'; },
25
-			Tokenizer::DOT => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' ' . $string . ' \')]'; },
26
-			Tokenizer::OPEN_SQUARE_BRACKET => function($string) use ($hash) { return '[' .'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \'' . base64_encode(serialize($string)) . '\', ., "' . $hash . '")' . ']';	}
21
+			Tokenizer::WHITESPACE => function($string) use ($prefix) { return '//'.$prefix.$string; },
22
+			'' => function($string) use ($prefix) { return '/'.$prefix.$string; },
23
+			Tokenizer::GREATER_THAN => function($string) use ($prefix) { return '/'.$prefix.$string; },
24
+			Tokenizer::NUM_SIGN => function($string) { return '[@id=\''.$string.'\']'; },
25
+			Tokenizer::DOT => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' '.$string.' \')]'; },
26
+			Tokenizer::OPEN_SQUARE_BRACKET => function($string) use ($hash) { return '['.'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \''.base64_encode(serialize($string)).'\', ., "'.$hash.'")'.']'; }
27 27
 		];
28 28
 	}
29 29
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		$functionSet->setElement($element[0]);
48 48
 
49 49
 		$attributes = array();
50
-        foreach($element[0]->attributes as $attribute_name => $attribute_node) {
50
+        foreach ($element[0]->attributes as $attribute_name => $attribute_node) {
51 51
             $attributes[$attribute_name] = $attribute_node->nodeValue;
52 52
         }
53 53
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		$tokens = [];
79 79
 
80 80
 		foreach ($css->splitOnToken(Tokenizer::GREATER_THAN) as $token) {
81
-			foreach ($token->trim() as $t) $tokens[]  = $t;
81
+			foreach ($token->trim() as $t) $tokens[] = $t;
82 82
 			$tokens[] = ['type' => Tokenizer::GREATER_THAN];
83 83
 		}
84 84
 		$tokens = new Tokens(array_slice($tokens, 0, -1));
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -69,7 +69,9 @@  discard block
 block discarded – undo
69 69
 				$selector->type = $token['type'];
70 70
 				$selectors[] = $selector;
71 71
 			}
72
-			if (isset($token['value'])) $selectors[count($selectors)-1]->string = $token['value'];
72
+			if (isset($token['value'])) {
73
+				$selectors[count($selectors)-1]->string = $token['value'];
74
+			}
73 75
 		}
74 76
 		return $selectors;
75 77
 	}
@@ -79,7 +81,9 @@  discard block
 block discarded – undo
79 81
 		$selectors = $this->split($css);
80 82
 		$xpath = '/';
81 83
 		foreach ($selectors as $selector) {
82
-			if (isset($this->translators[$selector->type])) $xpath .= $this->translators[$selector->type]($selector->string, $xpath);
84
+			if (isset($this->translators[$selector->type])) {
85
+				$xpath .= $this->translators[$selector->type]($selector->string, $xpath);
86
+			}
83 87
 		}
84 88
 
85 89
 		$xpath = str_replace('/[', '/*[', $xpath);
@@ -90,7 +94,9 @@  discard block
 block discarded – undo
90 94
 	private function removeSpacesFromDirectDecend($css) {
91 95
 		$tokens = [];
92 96
 		foreach ($css->splitOnToken(Tokenizer::GREATER_THAN) as $token) {
93
-			foreach ($token->trim() as $t) $tokens[]  = $t;
97
+			foreach ($token->trim() as $t) {
98
+				$tokens[]  = $t;
99
+			}
94 100
 			$tokens[] = ['type' => Tokenizer::GREATER_THAN];
95 101
 		}
96 102
 		return new Tokens(array_slice($tokens, 0, -1));
Please login to merge, or discard this patch.
src/Parser/Value.php 1 patch
Braces   +19 added lines, -15 removed lines patch added patch discarded remove patch
@@ -49,7 +49,9 @@  discard block
 block discarded – undo
49 49
 		$this->data = new ValueData($data ? $data : $this->baseData);
50 50
 		$this->last = null;
51 51
 
52
-		if (count($tokens) <= 0) return [$data];
52
+		if (count($tokens) <= 0) {
53
+			return [$data];
54
+		}
53 55
 
54 56
 		foreach (new TokenFilterIterator($tokens, [Tokenizer::WHITESPACE]) as $token) {
55 57
 			$this->{$this->tokenFuncs[$token['type']]}($token);
@@ -71,13 +73,15 @@  discard block
 block discarded – undo
71 73
 	//Reads the last selected value from $data regardless if it's an array or object and overrides $this->data with the new value
72 74
 	//Dot moves $data to the next object in $data foo.bar moves the $data pointer from `foo` to `bar`
73 75
 	private function processDot($token) {
74
-		if ($this->last !== null) $this->data->traverse($this->last);
75
-		else {
76
+		if ($this->last !== null) {
77
+			$this->data->traverse($this->last);
78
+		} else {
76 79
 			//When . is not preceeded by anything, treat it as part of the string instead of an operator
77 80
 			// foo.bar is treated as looking up `bar` in `foo` whereas .foo is treated as the string ".foo"
78 81
 			$lastResult = $this->result->pop();
79
-			if ($lastResult) $this->data = new ValueData($lastResult);
80
-			else {
82
+			if ($lastResult) {
83
+				$this->data = new ValueData($lastResult);
84
+			} else {
81 85
 				$this->processString(['value' => '.']);
82 86
 				$this->result->setMode(Tokenizer::CONCAT);
83 87
 			}
@@ -90,9 +94,10 @@  discard block
 block discarded – undo
90 94
 		$parser = new Value($this->baseData, $this->autoLookup);
91 95
 		if ($this->baseData instanceof \Transphporm\Functionset && $this->baseData->hasFunction($this->last)) {
92 96
 			$this->callTransphpormFunctions($token);
93
-		}
94
-		else {
95
-			if ($this->last !== null) $this->data->traverse($this->last);
97
+		} else {
98
+			if ($this->last !== null) {
99
+				$this->data->traverse($this->last);
100
+			}
96 101
 			$this->last = $parser->parseTokens($token['value'], null)[0];
97 102
 		}
98 103
 	}
@@ -112,8 +117,7 @@  discard block
 block discarded – undo
112 117
 	private function processBrackets($token) {
113 118
 		if ($this->baseData instanceof \Transphporm\Functionset && $this->baseData->hasFunction($this->last)) {
114 119
 			$this->callTransphpormFunctions($token);
115
-		}
116
-		else {
120
+		} else {
117 121
 			$this->processNested($token);
118 122
 		}
119 123
 	}
@@ -130,7 +134,9 @@  discard block
 block discarded – undo
130 134
 		foreach ($this->result->getResult() as $i => $value) {
131 135
 			if (is_scalar($value)) {
132 136
 				$val = $this->data->read($value);
133
-				if ($val) $this->result[$i] = $val;
137
+				if ($val) {
138
+					$this->result[$i] = $val;
139
+				}
134 140
 			}
135 141
 		}
136 142
 		$this->last = null;
@@ -142,12 +148,10 @@  discard block
 block discarded – undo
142 148
 			try {
143 149
 				$value = $this->data->extract($this->last, $this->autoLookup);
144 150
 				$this->result->processValue($value);
145
-			}
146
-			catch (\UnexpectedValueException $e) {
151
+			} catch (\UnexpectedValueException $e) {
147 152
 				if (!$this->autoLookup) {
148 153
 					$this->result->processValue($this->last);
149
-				}
150
-				else {
154
+				} else {
151 155
 					$this->result->clear();
152 156
 					$this->result[0] = false;
153 157
 				}
Please login to merge, or discard this patch.