Completed
Push — master ( 032dee...940980 )
by Tom
05:25 queued 11s
created
src/Parser/Value.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@
 block discarded – undo
94 94
 		if ($lastResult) {
95 95
 			$this->traversing = true;
96 96
 		}
97
-		else if ($this->last === null)  {
97
+		else if ($this->last === null) {
98 98
 			$this->processString(['value' => '.']);
99 99
 			$this->result->setMode(Tokenizer::CONCAT);
100 100
 		}
Please login to merge, or discard this patch.
Braces   +12 added lines, -14 removed lines patch added patch discarded remove patch
@@ -56,7 +56,9 @@  discard block
 block discarded – undo
56 56
 		$this->last = null;
57 57
 		$this->traversing = false;
58 58
 
59
-		if (count($tokens) <= 0) return [$data];
59
+		if (count($tokens) <= 0) {
60
+			return [$data];
61
+		}
60 62
 
61 63
 		foreach (new TokenFilterIterator($tokens, [Tokenizer::WHITESPACE, Tokenizer::NEW_LINE]) as $token) {
62 64
 			$this->{$this->tokenFuncs[$token['type']]}($token);
@@ -84,8 +86,7 @@  discard block
 block discarded – undo
84 86
 		// foo.bar is treated as looking up `bar` in `foo` whereas .foo is treated as the string ".foo"
85 87
 		if ($lastResult) {
86 88
 			$this->traversing = true;
87
-		}
88
-		else if ($this->last === null)  {
89
+		} else if ($this->last === null)  {
89 90
 			$this->processString(['value' => '.']);
90 91
 			$this->result->setMode(Tokenizer::CONCAT);
91 92
 		}
@@ -101,11 +102,12 @@  discard block
 block discarded – undo
101 102
 		$parser = new Value($this->baseData, $this->autoLookup);
102 103
 		if ($this->hasFunction($this->last)) {
103 104
 			$this->callTransphpormFunctions($token);
104
-		}
105
-		else {
105
+		} else {
106 106
 			$this->data->traverse($this->last, $this->result);
107 107
 			$this->last = $parser->parseTokens($token['value'], null)[0];
108
-			if (!is_bool($this->last)) $this->traversing = true;
108
+			if (!is_bool($this->last)) {
109
+				$this->traversing = true;
110
+			}
109 111
 		}
110 112
 	}
111 113
 
@@ -128,8 +130,7 @@  discard block
 block discarded – undo
128 130
 		if ($this->hasFunction($this->last)
129 131
 			&& !$this->data->methodExists($this->last)) {
130 132
 			$this->callTransphpormFunctions($token);
131
-		}
132
-		else {
133
+		} else {
133 134
 			$this->processNested($token);
134 135
 		}
135 136
 	}
@@ -149,8 +150,7 @@  discard block
 block discarded – undo
149 150
 			$parser = new Value($this->data->getData());
150 151
 			$parsedVal = $parser->parse($val)[0] ?? null;
151 152
 			$this->result->postProcess($this->data, $val, $parsedVal, $this->allowNullResult);
152
-		}
153
-		else {
153
+		} else {
154 154
 			$this->result->postProcess($this->data, $val, null, $this->allowNullResult);
155 155
 		}
156 156
 
@@ -163,8 +163,7 @@  discard block
 block discarded – undo
163 163
 			try {
164 164
 				$value = $this->data->extract($this->last, $this->autoLookup, $this->traversing);
165 165
 				$this->result->processValue($value);
166
-			}
167
-			catch (\UnexpectedValueException $e) {
166
+			} catch (\UnexpectedValueException $e) {
168 167
 				$this->processLastUnexpected();
169 168
 			}
170 169
 		}
@@ -173,8 +172,7 @@  discard block
 block discarded – undo
173 172
 	private function processLastUnexpected() {
174 173
 		if (!($this->autoLookup || $this->traversing)) {
175 174
 			$this->result->processValue($this->last);
176
-		}
177
-		else {
175
+		} else {
178 176
 			$this->result->clear();
179 177
 			$this->result->processValue(false);
180 178
 		}
Please login to merge, or discard this patch.
src/Hook/PseudoMatcher.php 1 patch
Braces   +19 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@  discard block
 block discarded – undo
25 25
 		foreach ($this->pseudo as $tokens) {
26 26
 			foreach ($this->functions as $function) {
27 27
 				$matches = $this->match($tokens, $function, $element);
28
-				if ($matches === false) return false;
28
+				if ($matches === false) {
29
+					return false;
30
+				}
29 31
 			}
30 32
 		}
31 33
 		return true;
@@ -35,9 +37,10 @@  discard block
 block discarded – undo
35 37
 		try {
36 38
 			$parts = $this->getFuncParts($tokens);
37 39
 			$matches = $function->match($parts['name'], $parts['args'], $element);
38
-			if ($matches === false) return false;
39
-		}
40
-		catch (\Exception $e) {
40
+			if ($matches === false) {
41
+				return false;
42
+			}
43
+		} catch (\Exception $e) {
41 44
 			throw new \Transphporm\RunException(\Transphporm\Exception::PSEUDO, $parts['name'], $e);
42 45
 		}
43 46
 	}
@@ -46,31 +49,37 @@  discard block
 block discarded – undo
46 49
 		$parts['name'] = $this->getFuncName($tokens);
47 50
 		if ($parts['name'] === null || in_array($parts['name'], ['data', 'iteration', 'root'])) {
48 51
 			$parts['args'] = $this->valueParser->parseTokens($tokens);
49
-		}
50
-		else if (count($tokens) > 1) {
52
+		} else if (count($tokens) > 1) {
51 53
 			$tokens->rewind();
52 54
 			$tokens->next();
53 55
 			$parts['args'] = $this->valueParser->parseTokens($tokens->current()['value']);
56
+		} else {
57
+			$parts['args'] = [['']];
54 58
 		}
55
-		else $parts['args'] = [['']];
56 59
 		return $parts;
57 60
 	}
58 61
 
59 62
 	private function getFuncName($tokens) {
60
-		if ($tokens->type() === Tokenizer::NAME) return $tokens->read();
63
+		if ($tokens->type() === Tokenizer::NAME) {
64
+			return $tokens->read();
65
+		}
61 66
 		return null;
62 67
 	}
63 68
 
64 69
 	public function hasFunction($name) {
65 70
 		foreach ($this->pseudo as $tokens) {
66
-			if ($name === $this->getFuncName($tokens)) return true;
71
+			if ($name === $this->getFuncName($tokens)) {
72
+				return true;
73
+			}
67 74
 		}
68 75
 	}
69 76
 
70 77
 	public function getFuncArgs($name) {
71 78
 		foreach ($this->pseudo as $tokens) {
72 79
 			$parts = $this->getFuncParts($tokens);
73
-			if ($name === $parts['name']) return $parts['args'];
80
+			if ($name === $parts['name']) {
81
+				return $parts['args'];
82
+			}
74 83
 		}
75 84
 	}
76 85
 }
Please login to merge, or discard this patch.
src/Property/Repeat.php 3 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -11,6 +11,9 @@  discard block
 block discarded – undo
11 11
 	private $line;
12 12
     private $filePath;
13 13
 
14
+	/**
15
+	 * @param integer $line
16
+	 */
14 17
 	public function __construct(\Transphporm\FunctionSet $functionSet, \Transphporm\Hook\ElementData $elementData, &$line, \Transphporm\FilePath $filePath) {
15 18
 		$this->functionSet = $functionSet;
16 19
 		$this->elementData = $elementData;
@@ -58,6 +61,12 @@  discard block
 block discarded – undo
58 61
 		return $value;
59 62
 	}
60 63
 
64
+	/**
65
+	 * @param \DOMElement $element
66
+	 * @param integer $count
67
+	 *
68
+	 * @return \DOMElement
69
+	 */
61 70
 	private function cloneElement($element, $iteration, $key, $count) {
62 71
 		$clone = $element->cloneNode(true);
63 72
 		$this->tagElement($clone, $count);
@@ -77,6 +86,9 @@  discard block
 block discarded – undo
77 86
 		return isset($values[1]) ? $values[1] : PHP_INT_MAX;
78 87
 	}
79 88
 
89
+	/**
90
+	 * @param \Transphporm\Hook\PseudoMatcher $pseudoMatcher
91
+	 */
80 92
 	private function createHook($newRules, $pseudoMatcher, $properties) {
81 93
 		$hook = new \Transphporm\Hook\PropertyHook($newRules, $this->line, null, $this->line, $pseudoMatcher, new \Transphporm\Parser\Value($this->functionSet), $this->functionSet, $this->filePath);
82 94
 		foreach ($properties as $name => $property) $hook->registerProperty($name, $property);
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@
 block discarded – undo
9 9
 	private $functionSet;
10 10
 	private $elementData;
11 11
 	private $line;
12
-    private $filePath;
12
+	private $filePath;
13 13
 
14 14
 	public function __construct(\Transphporm\FunctionSet $functionSet, \Transphporm\Hook\ElementData $elementData, &$line, \Transphporm\FilePath $filePath) {
15 15
 		$this->functionSet = $functionSet;
16 16
 		$this->elementData = $elementData;
17 17
 		$this->line = &$line;
18
-        $this->filePath = $filePath;
18
+		$this->filePath = $filePath;
19 19
 	}
20 20
 
21 21
 	public function run(array $values, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) {
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
 
21 21
 	public function run(array $values, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) {
22 22
 		$values = $this->fixEmpty($values);
23
-		if ($element->getAttribute('transphporm') === 'added') return $element->parentNode->removeChild($element);
23
+		if ($element->getAttribute('transphporm') === 'added') {
24
+			return $element->parentNode->removeChild($element);
25
+		}
24 26
 		$max = $this->getMax($values);
25 27
 		$count = 0;
26 28
 		$repeat = $this->getRepeatValue($values, $max);
@@ -29,7 +31,9 @@  discard block
 block discarded – undo
29 31
 		$hook = $this->createHook($rules, $pseudoMatcher, $properties);
30 32
 
31 33
 		foreach ($repeat as $key => $iteration) {
32
-			if ($count+1 > $max) break;
34
+			if ($count+1 > $max) {
35
+				break;
36
+			}
33 37
 			$clone = $this->cloneElement($element, $iteration, $key, $count++);
34 38
 			//Re-run the hook on the new element, but use the iterated data
35 39
 			$hook->run($clone);
@@ -41,8 +45,9 @@  discard block
 block discarded – undo
41 45
 
42 46
 	private function getRepeatValue($values, &$max) {
43 47
 		$mode = $this->getMode($values);
44
-		if ($mode === 'each') $repeat = $values[0];
45
-		else if ($mode === 'loop') {
48
+		if ($mode === 'each') {
49
+			$repeat = $values[0];
50
+		} else if ($mode === 'loop') {
46 51
 			$repeat = range($values[0], $max);
47 52
 			$max++;
48 53
 		}
@@ -54,7 +59,9 @@  discard block
 block discarded – undo
54 59
 	}
55 60
 
56 61
 	private function fixEmpty($value) {
57
-		if (empty($value[0])) $value[0] = [];
62
+		if (empty($value[0])) {
63
+			$value[0] = [];
64
+		}
58 65
 		return $value;
59 66
 	}
60 67
 
@@ -70,7 +77,9 @@  discard block
 block discarded – undo
70 77
 
71 78
 	private function tagElement($element, $count) {
72 79
 		//Mark all but one of the nodes as having been added by transphporm, when the hook is run again, these are removed
73
-		if ($count > 0) $element->setAttribute('transphporm', 'added');
80
+		if ($count > 0) {
81
+			$element->setAttribute('transphporm', 'added');
82
+		}
74 83
 	}
75 84
 
76 85
 	private function getMax($values) {
@@ -79,7 +88,9 @@  discard block
 block discarded – undo
79 88
 
80 89
 	private function createHook($newRules, $pseudoMatcher, $properties) {
81 90
 		$hook = new \Transphporm\Hook\PropertyHook($newRules, $this->line, null, $this->line, $pseudoMatcher, new \Transphporm\Parser\Value($this->functionSet), $this->functionSet, $this->filePath);
82
-		foreach ($properties as $name => $property) $hook->registerProperty($name, $property);
91
+		foreach ($properties as $name => $property) {
92
+			$hook->registerProperty($name, $property);
93
+		}
83 94
 		return $hook;
84 95
 	}
85 96
 }
Please login to merge, or discard this patch.
src/Parser/Last.php 1 patch
Braces   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@  discard block
 block discarded – undo
28 28
 
29 29
 
30 30
 	public function traverse() {
31
-		if ($this->last !== null) $this->data->traverse($this->last);
32
-		else {
31
+		if ($this->last !== null) {
32
+			$this->data->traverse($this->last);
33
+		} else {
33 34
 			$lastResult = $this->result->pop();
34 35
 			if ($lastResult) {
35 36
 				$this->data = new ValueData($lastResult);
@@ -67,8 +68,7 @@  discard block
 block discarded – undo
67 68
 			try {
68 69
 				$value = $this->data->extract($this->last, $this->autoLookup, $this->traversing);
69 70
 				$this->result->processValue($value);
70
-			}
71
-			catch (\UnexpectedValueException $e) {
71
+			} catch (\UnexpectedValueException $e) {
72 72
 				$this->processLastUnexpected();
73 73
 			}
74 74
 		}
@@ -77,8 +77,7 @@  discard block
 block discarded – undo
77 77
 	private function processLastUnexpected() {
78 78
 		if (!($this->autoLookup || $this->traversing)) {
79 79
 			$this->result->processValue($this->last);
80
-		}
81
-		else {
80
+		} else {
82 81
 			$this->result->clear();
83 82
 			$this->result[0] = false;
84 83
 		}
Please login to merge, or discard this patch.
src/Parser/Tokenizer.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@
 block discarded – undo
145 145
 			$string = $this->extractString($i);
146 146
 			$length = strlen($string)+1;
147 147
 			$char = $this->getChar($char);
148
-			$string = str_replace('\\' . $char, $char, $string);
148
+			$string = str_replace('\\'.$char, $char, $string);
149 149
 			$tokens[] = ['type' => self::STRING, 'value' => $string, 'line' => $this->lineNo];
150 150
 			return $length;
151 151
 		}
Please login to merge, or discard this patch.
Braces   +30 added lines, -12 removed lines patch added patch discarded remove patch
@@ -79,8 +79,11 @@  discard block
 block discarded – undo
79 79
 			$i += $this->doStrings($tokens, $char, $i);
80 80
 			$i += $this->doBrackets($tokens, $char, $i);
81 81
 		}
82
-		if ($returnObj) return new Tokens($tokens);
83
-		else return $tokens;
82
+		if ($returnObj) {
83
+			return new Tokens($tokens);
84
+		} else {
85
+			return $tokens;
86
+		}
84 87
 	}
85 88
 
86 89
 	private function doSimpleTokens(&$tokens, $char) {
@@ -117,10 +120,15 @@  discard block
 block discarded – undo
117 120
 	}
118 121
 
119 122
 	private function processLiterals(&$tokens, $name) {
120
-		if (is_numeric($name)) $tokens[] = ['type' => self::NUMERIC, 'value' => $name];
121
-		else if ($name == 'true') $tokens[] = ['type' => self::BOOL, 'value' => true];
122
-		else if ($name == 'false') $tokens[] = ['type' => self::BOOL, 'value' => false];
123
-		else $tokens[] = ['type' => self::NAME, 'value' => $name, 'line' => $this->lineNo];
123
+		if (is_numeric($name)) {
124
+			$tokens[] = ['type' => self::NUMERIC, 'value' => $name];
125
+		} else if ($name == 'true') {
126
+			$tokens[] = ['type' => self::BOOL, 'value' => true];
127
+		} else if ($name == 'false') {
128
+			$tokens[] = ['type' => self::BOOL, 'value' => false];
129
+		} else {
130
+			$tokens[] = ['type' => self::NAME, 'value' => $name, 'line' => $this->lineNo];
131
+		}
124 132
 	}
125 133
 
126 134
 	private function doBrackets(&$tokens, $char, $i) {
@@ -154,7 +162,9 @@  discard block
 block discarded – undo
154 162
 	private function extractString($pos) {
155 163
 		$char = $this->str[$pos];
156 164
 		$end = strpos($this->str, $char, $pos+1);
157
-		while ($end !== false && $this->str[$end-1] == '\\') $end = strpos($this->str, $char, $end+1);
165
+		while ($end !== false && $this->str[$end-1] == '\\') {
166
+			$end = strpos($this->str, $char, $end+1);
167
+		}
158 168
 
159 169
 		return substr($this->str, $pos+1, $end-$pos-1);
160 170
 	}
@@ -163,18 +173,26 @@  discard block
 block discarded – undo
163 173
 		$close = strpos($this->str, $closeBracket, $open);
164 174
 
165 175
 		$cPos = $open+1;
166
-		while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) $close = strpos($this->str, $closeBracket, $close+1);
176
+		while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) {
177
+			$close = strpos($this->str, $closeBracket, $close+1);
178
+		}
167 179
 		return substr($this->str, $open+1, $close-$open-1);
168 180
 	}
169 181
 
170 182
 	private function identifyChar($chr) {
171
-		if (isset($this->chars[$chr])) return $this->chars[$chr];
172
-		else return self::NAME;
183
+		if (isset($this->chars[$chr])) {
184
+			return $this->chars[$chr];
185
+		} else {
186
+			return self::NAME;
187
+		}
173 188
 	}
174 189
 
175 190
 	private function getChar($num) {
176 191
 		$chars = array_reverse($this->chars);
177
-		if (isset($chars[$num])) return $chars[$num];
178
-		else return false;
192
+		if (isset($chars[$num])) {
193
+			return $chars[$num];
194
+		} else {
195
+			return false;
196
+		}
179 197
 	}
180 198
 }
Please login to merge, or discard this patch.
src/TSSValidator.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -2,55 +2,55 @@
 block discarded – undo
2 2
 namespace Transphporm;
3 3
 use Transphporm\Parser\Tokenizer;
4 4
 class TSSValidator {
5
-    private $error;
5
+	private $error;
6 6
 
7
-    public function validate($tss) {
8
-        $this->error = null;
9
-        $tokens = $this->tokenize($tss);
7
+	public function validate($tss) {
8
+		$this->error = null;
9
+		$tokens = $this->tokenize($tss);
10 10
 
11
-        foreach ($tokens as $token)
12
-            if (!$this->validateRule($token)) return false;
11
+		foreach ($tokens as $token)
12
+			if (!$this->validateRule($token)) return false;
13 13
 
14
-        return true;
15
-    }
14
+		return true;
15
+	}
16 16
 
17
-    public function getLastError() {
18
-        return $this->error;
19
-    }
17
+	public function getLastError() {
18
+		return $this->error;
19
+	}
20 20
 
21
-    private function validateRule($token) {
22
-        if ($token['type'] !== Tokenizer::OPEN_BRACE) return true;
21
+	private function validateRule($token) {
22
+		if ($token['type'] !== Tokenizer::OPEN_BRACE) return true;
23 23
 
24
-        return $this->checkBraces($token) && $this->checkSemicolons($token)
25
-            && $this->checkParenthesis($token);
26
-    }
24
+		return $this->checkBraces($token) && $this->checkSemicolons($token)
25
+			&& $this->checkParenthesis($token);
26
+	}
27 27
 
28
-    private function checkBraces($token) {
29
-        return strpos($token['string'], '{') === false;
30
-    }
28
+	private function checkBraces($token) {
29
+		return strpos($token['string'], '{') === false;
30
+	}
31 31
 
32
-    private function checkSemicolons($braceToken) {
33
-        $splitTokens = $braceToken['value']->splitOnToken(Tokenizer::COLON);
34
-        array_shift($splitTokens); array_pop($splitTokens);
35
-        foreach ($splitTokens as $tokens)
36
-            if (!in_array(Tokenizer::SEMI_COLON, array_column(iterator_to_array($tokens), 'type'))) return false;
32
+	private function checkSemicolons($braceToken) {
33
+		$splitTokens = $braceToken['value']->splitOnToken(Tokenizer::COLON);
34
+		array_shift($splitTokens); array_pop($splitTokens);
35
+		foreach ($splitTokens as $tokens)
36
+			if (!in_array(Tokenizer::SEMI_COLON, array_column(iterator_to_array($tokens), 'type'))) return false;
37 37
 
38
-        return true;
39
-    }
38
+		return true;
39
+	}
40 40
 
41
-    private function checkParenthesis($token) {
42
-        return substr_count($token['string'], '(') === substr_count($token['string'], ')');
43
-    }
41
+	private function checkParenthesis($token) {
42
+		return substr_count($token['string'], '(') === substr_count($token['string'], ')');
43
+	}
44 44
 
45
-    private function tokenize($tss) {
46
-        if (is_file($tss)) $tss = file_get_contents($tss);
47
-        $tss = $this->stripComments($tss, '//', "\n");
45
+	private function tokenize($tss) {
46
+		if (is_file($tss)) $tss = file_get_contents($tss);
47
+		$tss = $this->stripComments($tss, '//', "\n");
48 48
 		$tss = $this->stripComments($tss, '/*', '*/');
49 49
 		$tokenizer = new Tokenizer($tss);
50 50
 		return $tokenizer->getTokens();
51
-    }
51
+	}
52 52
 
53
-    private function stripComments($str, $open, $close) {
53
+	private function stripComments($str, $open, $close) {
54 54
 		$pos = 0;
55 55
 		while (($pos = strpos($str, $open, $pos)) !== false) {
56 56
 			$end = strpos($str, $close, $pos);
Please login to merge, or discard this patch.
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,8 +8,9 @@  discard block
 block discarded – undo
8 8
         $this->error = null;
9 9
         $tokens = $this->tokenize($tss);
10 10
 
11
-        foreach ($tokens as $token)
12
-            if (!$this->validateRule($token)) return false;
11
+        foreach ($tokens as $token) {
12
+                    if (!$this->validateRule($token)) return false;
13
+        }
13 14
 
14 15
         return true;
15 16
     }
@@ -19,7 +20,9 @@  discard block
 block discarded – undo
19 20
     }
20 21
 
21 22
     private function validateRule($token) {
22
-        if ($token['type'] !== Tokenizer::OPEN_BRACE) return true;
23
+        if ($token['type'] !== Tokenizer::OPEN_BRACE) {
24
+        	return true;
25
+        }
23 26
 
24 27
         return $this->checkBraces($token) && $this->checkSemicolons($token)
25 28
             && $this->checkParenthesis($token);
@@ -32,8 +35,9 @@  discard block
 block discarded – undo
32 35
     private function checkSemicolons($braceToken) {
33 36
         $splitTokens = $braceToken['value']->splitOnToken(Tokenizer::COLON);
34 37
         array_shift($splitTokens); array_pop($splitTokens);
35
-        foreach ($splitTokens as $tokens)
36
-            if (!in_array(Tokenizer::SEMI_COLON, array_column(iterator_to_array($tokens), 'type'))) return false;
38
+        foreach ($splitTokens as $tokens) {
39
+                    if (!in_array(Tokenizer::SEMI_COLON, array_column(iterator_to_array($tokens), 'type'))) return false;
40
+        }
37 41
 
38 42
         return true;
39 43
     }
@@ -43,7 +47,9 @@  discard block
 block discarded – undo
43 47
     }
44 48
 
45 49
     private function tokenize($tss) {
46
-        if (is_file($tss)) $tss = file_get_contents($tss);
50
+        if (is_file($tss)) {
51
+        	$tss = file_get_contents($tss);
52
+        }
47 53
         $tss = $this->stripComments($tss, '//', "\n");
48 54
 		$tss = $this->stripComments($tss, '/*', '*/');
49 55
 		$tokenizer = new Tokenizer($tss);
@@ -54,7 +60,9 @@  discard block
 block discarded – undo
54 60
 		$pos = 0;
55 61
 		while (($pos = strpos($str, $open, $pos)) !== false) {
56 62
 			$end = strpos($str, $close, $pos);
57
-			if ($end === false) break;
63
+			if ($end === false) {
64
+				break;
65
+			}
58 66
 			$str = substr_replace($str, '', $pos, $end-$pos+strlen($close));
59 67
 		}
60 68
 
Please login to merge, or discard this patch.
src/Hook/PropertyHook.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 	private $rules;
11 11
 	private $configLine;
12 12
 	private $file;
13
-    private $filePath;
13
+	private $filePath;
14 14
 	private $line;
15 15
 	private $valueParser;
16 16
 	private $pseudoMatcher;
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
 	private $functionSet;
19 19
 
20 20
 	public function __construct(array $rules, &$configLine, $file, $line, PseudoMatcher $pseudoMatcher,
21
-            \Transphporm\Parser\Value $valueParser, \Transphporm\FunctionSet $functionSet, \Transphporm\FilePath $filePath) {
21
+			\Transphporm\Parser\Value $valueParser, \Transphporm\FunctionSet $functionSet, \Transphporm\FilePath $filePath) {
22 22
 		$this->rules = $rules;
23 23
 		$this->configLine = &$configLine;
24 24
 		$this->file = $file;
25
-        $this->filePath = $filePath;
25
+		$this->filePath = $filePath;
26 26
 		$this->line = $line;
27 27
 		$this->valueParser = $valueParser;
28 28
 		$this->pseudoMatcher = $pseudoMatcher;
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	}
31 31
 
32 32
 	public function run(\DomElement $element) {
33
-        if ($this->file !== null) $this->filePath->setBaseDir(dirname(realpath($this->file)) . DIRECTORY_SEPARATOR);
33
+		if ($this->file !== null) $this->filePath->setBaseDir(dirname(realpath($this->file)) . DIRECTORY_SEPARATOR);
34 34
 		$this->functionSet->setElement($element);
35 35
 		$this->configLine = $this->line;
36 36
 		try {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 	}
31 31
 
32 32
 	public function run(\DomElement $element) {
33
-        if ($this->file !== null) $this->filePath->setBaseDir(dirname(realpath($this->file)) . DIRECTORY_SEPARATOR);
33
+        if ($this->file !== null) $this->filePath->setBaseDir(dirname(realpath($this->file)).DIRECTORY_SEPARATOR);
34 34
 		$this->functionSet->setElement($element);
35 35
 		$this->configLine = $this->line;
36 36
 		try {
Please login to merge, or discard this patch.
Braces   +14 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,15 +30,18 @@  discard block
 block discarded – undo
30 30
 	}
31 31
 
32 32
 	public function run(\DomElement $element) {
33
-        if ($this->file !== null) $this->filePath->setBaseDir(dirname(realpath($this->file)) . DIRECTORY_SEPARATOR);
33
+        if ($this->file !== null) {
34
+        	$this->filePath->setBaseDir(dirname(realpath($this->file)) . DIRECTORY_SEPARATOR);
35
+        }
34 36
 		$this->functionSet->setElement($element);
35 37
 		$this->configLine = $this->line;
36 38
 		try {
37 39
 			//Don't run if there's a pseudo element like nth-child() and this element doesn't match it
38
-			if (!$this->pseudoMatcher->matches($element)) return;
40
+			if (!$this->pseudoMatcher->matches($element)) {
41
+				return;
42
+			}
39 43
 			$this->callProperties($element);
40
-		}
41
-		catch (\Transphporm\RunException $e) {
44
+		} catch (\Transphporm\RunException $e) {
42 45
 			throw new \Transphporm\Exception($e, $this->file, $this->line);
43 46
 		}
44 47
 	}
@@ -49,7 +52,9 @@  discard block
 block discarded – undo
49 52
 	private function callProperties($element) {
50 53
 		foreach ($this->rules as $name => $value) {
51 54
 			$result = $this->callProperty($name, $element, $this->getArgs($value));
52
-			if ($result === false) break;
55
+			if ($result === false) {
56
+				break;
57
+			}
53 58
 		}
54 59
 	}
55 60
 	private function getArgs($value) {
@@ -64,9 +69,10 @@  discard block
 block discarded – undo
64 69
 		if (isset($this->properties[$name])) {
65 70
 			try {
66 71
 				return $this->properties[$name]->run($value, $element, $this->rules, $this->pseudoMatcher, $this->properties);
67
-			}
68
-			catch (\Exception $e) {
69
-				if ($e instanceof \Transphporm\RunException) throw $e;
72
+			} catch (\Exception $e) {
73
+				if ($e instanceof \Transphporm\RunException) {
74
+					throw $e;
75
+				}
70 76
 				throw new \Transphporm\RunException(\Transphporm\Exception::PROPERTY, $name, $e);
71 77
 			}
72 78
 		}
Please login to merge, or discard this patch.
src/FunctionSet.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,8 +20,7 @@  discard block
 block discarded – undo
20 20
 			if (isset($this->functions[$name])) {
21 21
 				return $this->functions[$name]->run($this->getArgs0($name, $args), $this->element);
22 22
 			}
23
-		}
24
-		catch (\Exception $e) {
23
+		} catch (\Exception $e) {
25 24
 			throw new RunException(Exception::TSS_FUNCTION, $name, $e);
26 25
 		}
27 26
 		return false;
@@ -32,8 +31,7 @@  discard block
 block discarded – undo
32 31
 			$tokens = $args[0];
33 32
 			$parser = new \Transphporm\Parser\Value($this);
34 33
 			return $parser->parseTokens($tokens, $this->elementData->getData($this->element));
35
-		}
36
-		else if ($args[0] instanceof Parser\Tokens) {
34
+		} else if ($args[0] instanceof Parser\Tokens) {
37 35
 			return iterator_to_array($args[0]);
38 36
 		}
39 37
 
Please login to merge, or discard this patch.