Completed
Push — master ( e6458b...c9bd8d )
by Tom
03:29
created
src/TSSFunction/Template.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,9 @@  discard block
 block discarded – undo
30 30
 		$newTemplate = new \Transphporm\Builder($this->baseDir . $args[0], $tss ? $this->baseDir . $tss : null);
31 31
 
32 32
 		$doc = $newTemplate->output($this->elementData->getData($element), true)->body;
33
-		if ($selector != '') return $this->templateSubsection($doc, $selector);
33
+		if ($selector != '') {
34
+			return $this->templateSubsection($doc, $selector);
35
+		}
34 36
 
35 37
 		return $this->getTemplateContent($doc, $tss);
36 38
 
@@ -60,7 +62,9 @@  discard block
 block discarded – undo
60 62
 
61 63
 	private function getClonedElement($node, $tss) {
62 64
 		$clone = $node->cloneNode(true);
63
-		if ($tss != null && $clone instanceof \DomElement) $clone->setAttribute('transphporm', 'includedtemplate');
65
+		if ($tss != null && $clone instanceof \DomElement) {
66
+			$clone->setAttribute('transphporm', 'includedtemplate');
67
+		}
64 68
 		return $clone;
65 69
 	}
66 70
 }
Please login to merge, or discard this patch.
src/Hook/ElementData.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@
 block discarded – undo
31 31
 	/** Returns the data that has been bound to $element, or, if no data is bound to $element climb the DOM tree to find the data bound to a parent node*/
32 32
 	public function getData(\DomElement $element = null, $type = 'data') {
33 33
 		while ($element) {
34
-			if (isset($this->elementMap[$element]) && isset($this->elementMap[$element][$type])) return $this->elementMap[$element][$type];
34
+			if (isset($this->elementMap[$element]) && isset($this->elementMap[$element][$type])) {
35
+				return $this->elementMap[$element][$type];
36
+			}
35 37
 			$element = $element->parentNode;
36 38
 		}
37 39
 		return $this->data;
Please login to merge, or discard this patch.
src/Parser/Value.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@
 block discarded – undo
156 156
 
157 157
 	private function callFuncOnObject($obj, $func, $args, $element) {
158 158
 		if (isset($obj->$func) && is_callable($obj->$func)) return call_user_func_array($obj->$func, $args);
159
-		else if (isset($obj->$func) && is_array($obj->$func))  {
159
+		else if (isset($obj->$func) && is_array($obj->$func)) {
160 160
 
161 161
 		}
162 162
 		else return call_user_func_array([$obj, $func], $args);
Please login to merge, or discard this patch.
Braces   +50 added lines, -32 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
 	public function parse($str, $element = null, $returnTokens = false) {
20 20
 		$tokenizer = new Tokenizer($str);
21 21
 		$tokens = $tokenizer->getTokens();
22
-		if ($returnTokens) return $tokens;
22
+		if ($returnTokens) {
23
+			return $tokens;
24
+		}
23 25
 		$result = $this->parseTokens($tokens, $element, $this->data);
24 26
 		return $result;
25 27
 	}
@@ -29,10 +31,14 @@  discard block
 block discarded – undo
29 31
 		$mode = Tokenizer::ARG;
30 32
 		$last = null;
31 33
 
32
-		if (empty($tokens)) return [$data];
34
+		if (empty($tokens)) {
35
+			return [$data];
36
+		}
33 37
 
34 38
 		foreach ($tokens as $token) {
35
-		if (is_string($token)) throw new \Exception($token);
39
+		if (is_string($token)) {
40
+			throw new \Exception($token);
41
+		}
36 42
 
37 43
 			if (in_array($token['type'], [Tokenizer::NOT, Tokenizer::EQUALS])) {
38 44
 				// ($last !== null) $result = $this->processValue($result, $mode, $last);
@@ -41,24 +47,32 @@  discard block
 block discarded – undo
41 47
 
42 48
 				if ($mode == Tokenizer::NOT && $token['type'] == Tokenizer::EQUALS) {
43 49
 					$mode = Tokenizer::NOT;
50
+				} else {
51
+					$mode = $token['type'];
44 52
 				}
45
-				else $mode = $token['type'];
46 53
 			}
47 54
 
48 55
 			if ($token['type'] === Tokenizer::DOT) {
49 56
 				if ($last !== null) {
50
-					if (isset($data->$last)) $data = $data->$last;
51
-					else if (is_array($data) && isset($data[$last])) $data = $data[$last];
57
+					if (isset($data->$last)) {
58
+						$data = $data->$last;
59
+					} else if (is_array($data) && isset($data[$last])) {
60
+						$data = $data[$last];
61
+					}
62
+				} else {
63
+					$data = array_pop($result);
52 64
 				}
53
-				else $data = array_pop($result);
54 65
 
55 66
 				$last = null;
56 67
 			}
57 68
 
58 69
 			if ($token['type'] == Tokenizer::OPEN_SQUARE_BRACKET) {
59 70
 				if ($last !== null) {
60
-					if (isset($data->$last)) $data = $data->$last;
61
-					else if (is_array($data) && isset($data[$last])) $data = $data[$last];
71
+					if (isset($data->$last)) {
72
+						$data = $data->$last;
73
+					} else if (is_array($data) && isset($data[$last])) {
74
+						$data = $data[$last];
75
+					}
62 76
 				}
63 77
 
64 78
 				$last = $this->parseTokens($token['value'], $element, null)[0];
@@ -85,19 +99,22 @@  discard block
 block discarded – undo
85 99
 
86 100
 					foreach ($result as $i => $value) {
87 101
 						if (is_array($data)) {
88
-							if (isset($data[$value])) $result[$i] = $data[$value];
102
+							if (isset($data[$value])) {
103
+								$result[$i] = $data[$value];
104
+							}
105
+						} else if (is_scalar($value) && isset($data->$value)) {
106
+							$result[$i] = $data->$value;
89 107
 						}
90
-						else if (is_scalar($value) && isset($data->$value)) $result[$i] = $data->$value;
91 108
 					}
92 109
 					$last = null;
93
-				}
94
-				else if ($data instanceof \Transphporm\Functionset) {
110
+				} else if ($data instanceof \Transphporm\Functionset) {
95 111
 					$result = $this->processValue($result, $mode, $data->$last($token['value'], $element));
96 112
 					$last = null;
97
-				}
98
-				else {
113
+				} else {
99 114
 					$args = $this->parseTokens($token['value'], $element, $data);
100
-					if ($args[0] == $data) $args = [];
115
+					if ($args[0] == $data) {
116
+						$args = [];
117
+					}
101 118
 					$funcResult = $this->callFunc($last, $args, $element, $data);
102 119
 					$result = $this->processValue($result, $mode, $funcResult);
103 120
 					$last = null;
@@ -120,14 +137,13 @@  discard block
 block discarded – undo
120 137
 		if ($last !== null) {
121 138
 			if ($this->autoLookup && isset($data->$last)) {
122 139
 				$result = $this->processValue($result, $mode, $data->$last);
123
-			}
124
-			else if (is_array($data) && isset($data[$last])) {
140
+			} else if (is_array($data) && isset($data[$last])) {
125 141
 				$result = $this->processValue($result, $mode, $data[$last]);
126
-			}
127
-			else if (!$this->autoLookup) {
142
+			} else if (!$this->autoLookup) {
128 143
 				$result = $this->processValue($result, $mode, $last);
144
+			} else {
145
+				$result = [false];
129 146
 			}
130
-			else $result = [false];
131 147
 		}
132 148
 		return $result;
133 149
 	}
@@ -135,14 +151,11 @@  discard block
 block discarded – undo
135 151
 	private function processValue($result, $mode, $newValue) {
136 152
 		if ($mode == Tokenizer::ARG) {
137 153
 			$result[] = $newValue;
138
-		}
139
-		else if ($mode == Tokenizer::CONCAT) {
154
+		} else if ($mode == Tokenizer::CONCAT) {
140 155
 				$result[count($result)-1] .= $newValue;
141
-		}
142
-		else if ($mode == Tokenizer::NOT) {
156
+		} else if ($mode == Tokenizer::NOT) {
143 157
 			$result[count($result)-1] = $result[count($result)-1] != $newValue;
144
-		}
145
-		else if ($mode == Tokenizer::EQUALS) {
158
+		} else if ($mode == Tokenizer::EQUALS) {
146 159
 			$result[count($result)-1] = $result[count($result)-1] == $newValue;
147 160
 		}
148 161
 
@@ -150,15 +163,20 @@  discard block
 block discarded – undo
150 163
 	}
151 164
 
152 165
 	private function callFunc($name, $args, $element, $data) {
153
-		if ($data instanceof \Transphporm\FunctionSet) return $data->$name($args, $element);
154
-		else return $this->callFuncOnObject($data, $name, $args, $element);
166
+		if ($data instanceof \Transphporm\FunctionSet) {
167
+			return $data->$name($args, $element);
168
+		} else {
169
+			return $this->callFuncOnObject($data, $name, $args, $element);
170
+		}
155 171
 	}
156 172
 
157 173
 	private function callFuncOnObject($obj, $func, $args, $element) {
158
-		if (isset($obj->$func) && is_callable($obj->$func)) return call_user_func_array($obj->$func, $args);
159
-		else if (isset($obj->$func) && is_array($obj->$func))  {
174
+		if (isset($obj->$func) && is_callable($obj->$func)) {
175
+			return call_user_func_array($obj->$func, $args);
176
+		} else if (isset($obj->$func) && is_array($obj->$func))  {
160 177
 
178
+		} else {
179
+			return call_user_func_array([$obj, $func], $args);
161 180
 		}
162
-		else return call_user_func_array([$obj, $func], $args);
163 181
 	}
164 182
 }
Please login to merge, or discard this patch.
src/Parser/Sheet.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 			}
29 29
 
30 30
 			$selector = trim(substr($this->tss, $pos, $next-$pos));
31
-			$pos =  strpos($this->tss, '}', $next)+1;
31
+			$pos = strpos($this->tss, '}', $next)+1;
32 32
 			$newRules = $this->cssToRules($selector, count($rules)+$indexStart, $this->getProperties(trim(substr($this->tss, $next+1, $pos-2-$next))));
33 33
 			$rules = $this->writeRule($rules, $newRules);
34 34
 		}
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	private function processingInstructions($tss, $pos, $next, $indexStart) {
64 64
 		$rules = [];
65 65
 		while (($atPos = strpos($tss, '@', $pos)) !== false) {
66
-			if ($atPos  <= (int) $next) {
66
+			if ($atPos <= (int) $next) {
67 67
 				$spacePos = strpos($tss, ' ', $atPos);
68 68
 				$funcName = substr($tss, $atPos+1, $spacePos-$atPos-1);
69 69
 				$pos = strpos($tss, ';', $spacePos);
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 	}
80 80
 
81 81
 	private function import($args, $indexStart) {
82
-		if (is_file(trim($args,'\'" '))) $fileName = trim($args,'\'" ');
82
+		if (is_file(trim($args, '\'" '))) $fileName = trim($args, '\'" ');
83 83
 		else $fileName = $this->valueParser->parse($args)[0];
84
-		$sheet = new Sheet(file_get_contents($this->baseDir . $fileName), $this->baseDir, $this->valueParser, $this->prefix);
84
+		$sheet = new Sheet(file_get_contents($this->baseDir.$fileName), $this->baseDir, $this->valueParser, $this->prefix);
85 85
 		return $sheet->parse(0, [], $indexStart);
86 86
 	}
87 87
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@  discard block
 block discarded – undo
33 33
 			$rules = $this->writeRule($rules, $newRules);
34 34
 		}
35 35
 		//there may be processing instructions at the end
36
-		if ($processing = $this->processingInstructions($this->tss, $pos, strlen($this->tss), count($rules)+$indexStart)) $rules = array_merge($rules, $processing['rules']);
36
+		if ($processing = $this->processingInstructions($this->tss, $pos, strlen($this->tss), count($rules)+$indexStart)) {
37
+			$rules = array_merge($rules, $processing['rules']);
38
+		}
37 39
 		usort($rules, [$this, 'sortRules']);
38 40
 		return $rules;
39 41
 	}
@@ -69,8 +71,7 @@  discard block
 block discarded – undo
69 71
 				$pos = strpos($tss, ';', $spacePos);
70 72
 				$args = substr($tss, $spacePos+1, $pos-$spacePos-1);
71 73
 				$rules = array_merge($rules, $this->$funcName($args, $indexStart));
72
-			}
73
-			else {
74
+			} else {
74 75
 				break;	
75 76
 			} 
76 77
 		}
@@ -79,15 +80,20 @@  discard block
 block discarded – undo
79 80
 	}
80 81
 
81 82
 	private function import($args, $indexStart) {
82
-		if (is_file(trim($args,'\'" '))) $fileName = trim($args,'\'" ');
83
-		else $fileName = $this->valueParser->parse($args)[0];
83
+		if (is_file(trim($args,'\'" '))) {
84
+			$fileName = trim($args,'\'" ');
85
+		} else {
86
+			$fileName = $this->valueParser->parse($args)[0];
87
+		}
84 88
 		$sheet = new Sheet(file_get_contents($this->baseDir . $fileName), $this->baseDir, $this->valueParser, $this->prefix);
85 89
 		return $sheet->parse(0, [], $indexStart);
86 90
 	}
87 91
 
88 92
 	private function sortRules($a, $b) {
89 93
 		//If they have the same depth, compare on index
90
-		if ($a->depth === $b->depth) return $a->index < $b->index ? -1 : 1;
94
+		if ($a->depth === $b->depth) {
95
+			return $a->index < $b->index ? -1 : 1;
96
+		}
91 97
 
92 98
 		return ($a->depth < $b->depth) ? -1 : 1;
93 99
 	}
@@ -96,7 +102,9 @@  discard block
 block discarded – undo
96 102
 		$pos = 0;
97 103
 		while (($pos = strpos($str, $open, $pos)) !== false) {
98 104
 			$end = strpos($str, $close, $pos);
99
-			if ($end === false) break;
105
+			if ($end === false) {
106
+				break;
107
+			}
100 108
 			$str = substr_replace($str, '', $pos, $end-$pos+2);
101 109
 		}
102 110
 
@@ -109,7 +117,9 @@  discard block
 block discarded – undo
109 117
 		$return = [];
110 118
 
111 119
 		foreach ($rules as $rule) {
112
-			if (trim($rule) === '') continue;
120
+			if (trim($rule) === '') {
121
+				continue;
122
+			}
113 123
 			$parts = explode(':', $rule, 2);
114 124
 			$parts[1] = $stringExtractor->rebuild($parts[1]);
115 125
 			$return[trim($parts[0])] = isset($parts[1]) ? trim($parts[1]) : '';
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
@@ -105,7 +105,7 @@
 block discarded – undo
105 105
 			$string = $this->extractString($i);
106 106
 			$length = strlen($string)+1;
107 107
 			$char = $this->getChar($char);
108
-			$string = str_replace('\\' . $char, $char, $string);
108
+			$string = str_replace('\\'.$char, $char, $string);
109 109
 			$tokens[] = ['type' => self::STRING, 'value' => $string];
110 110
 			return $length;
111 111
 		}
Please login to merge, or discard this patch.
Braces   +25 added lines, -10 removed lines patch added patch discarded remove patch
@@ -76,10 +76,15 @@  discard block
 block discarded – undo
76 76
 				$name .= $this->str[$i+1];
77 77
 				$i++;
78 78
 			}
79
-			if (is_numeric($name)) $tokens[] = ['type' => self::NUMERIC, 'value' => $name];
80
-			else if ($name == 'true') $tokens[] = ['type' => self::BOOL, 'value' => true];
81
-			else if ($name == 'false') $tokens[] = ['type' => self::BOOL, 'value' => false];
82
-			else $tokens[] = ['type' => self::NAME, 'value' => $name];
79
+			if (is_numeric($name)) {
80
+				$tokens[] = ['type' => self::NUMERIC, 'value' => $name];
81
+			} else if ($name == 'true') {
82
+				$tokens[] = ['type' => self::BOOL, 'value' => true];
83
+			} else if ($name == 'false') {
84
+				$tokens[] = ['type' => self::BOOL, 'value' => false];
85
+			} else {
86
+				$tokens[] = ['type' => self::NAME, 'value' => $name];
87
+			}
83 88
 		}
84 89
 	}
85 90
 
@@ -114,7 +119,9 @@  discard block
 block discarded – undo
114 119
 	private function extractString($pos) {
115 120
 		$char = $this->str[$pos];
116 121
 		$end = strpos($this->str, $char, $pos+1);
117
-		while ($end !== false && $this->str[$end-1] == '\\') $end = strpos($this->str, $char, $end+1);
122
+		while ($end !== false && $this->str[$end-1] == '\\') {
123
+			$end = strpos($this->str, $char, $end+1);
124
+		}
118 125
 
119 126
 		return substr($this->str, $pos+1, $end-$pos-1);
120 127
 	}
@@ -123,18 +130,26 @@  discard block
 block discarded – undo
123 130
 		$close = strpos($this->str, $closeBracket, $open);
124 131
 
125 132
 		$cPos = $open+1;
126
-		while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) $close = strpos($this->str, $closeBracket, $close+1);
133
+		while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) {
134
+			$close = strpos($this->str, $closeBracket, $close+1);
135
+		}
127 136
 		return substr($this->str, $open+1, $close-$open-1);
128 137
 	}
129 138
 
130 139
 	private function identifyChar($chr) {
131
-		if (isset($this->chars[$chr])) return $this->chars[$chr];
132
-		else return self::NAME;
140
+		if (isset($this->chars[$chr])) {
141
+			return $this->chars[$chr];
142
+		} else {
143
+			return self::NAME;
144
+		}
133 145
 	}
134 146
 
135 147
 	private function getChar($num) {
136 148
 		$chars = array_reverse($this->chars);
137
-		if (isset($chars[$num])) return $chars[$num];
138
-		else return false;
149
+		if (isset($chars[$num])) {
150
+			return $chars[$num];
151
+		} else {
152
+			return false;
153
+		}
139 154
 	}
140 155
 }
Please login to merge, or discard this patch.
src/Property/Repeat.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,13 +15,19 @@  discard block
 block discarded – undo
15 15
 	}
16 16
 
17 17
 	public function run(array $values, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) {
18
-		if ($element->getAttribute('transphporm') === 'added') return $element->parentNode->removeChild($element);
18
+		if ($element->getAttribute('transphporm') === 'added') {
19
+			return $element->parentNode->removeChild($element);
20
+		}
19 21
 		$max = $this->getMax($values);
20 22
 		$count = 0;
21 23
 
22
-		if (empty($values[0])) $values[0] = [];
24
+		if (empty($values[0])) {
25
+			$values[0] = [];
26
+		}
23 27
 		foreach ($values[0] as $key => $iteration) {
24
-			if ($count+1 > $max) break;
28
+			if ($count+1 > $max) {
29
+				break;
30
+			}
25 31
 			$clone = $this->cloneElement($element, $iteration, $key, $count++);
26 32
 			//Re-run the hook on the new element, but use the iterated data
27 33
 			//Don't run repeat on the clones element or it will loop forever
@@ -45,7 +51,9 @@  discard block
 block discarded – undo
45 51
 
46 52
 	private function tagElement($element, $count) {
47 53
 		//Mark all but one of the nodes as having been added by transphporm, when the hook is run again, these are removed
48
-		if ($count > 0) $element->setAttribute('transphporm', 'added');
54
+		if ($count > 0) {
55
+			$element->setAttribute('transphporm', 'added');
56
+		}
49 57
 	}
50 58
 
51 59
 	private function getMax($values) {
@@ -54,7 +62,9 @@  discard block
 block discarded – undo
54 62
 
55 63
 	private function createHook($newRules, $pseudoMatcher, $properties) {
56 64
 		$hook = new \Transphporm\Hook\PropertyHook($newRules, $pseudoMatcher, new \Transphporm\Parser\Value($this->functionSet));
57
-		foreach ($properties as $name => $property) $hook->registerProperty($name, $property);
65
+		foreach ($properties as $name => $property) {
66
+			$hook->registerProperty($name, $property);
67
+		}
58 68
 		return $hook;
59 69
 	}
60 70
 }
Please login to merge, or discard this patch.
src/Property/Display.php 1 patch
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,8 +7,12 @@
 block discarded – undo
7 7
 namespace Transphporm\Property;
8 8
 class Display implements \Transphporm\Property {
9 9
 	public function run(array $values, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) {
10
-		if ($pseudoMatcher->hasFunction('attr')) $element->removeAttribute($pseudoMatcher->getFuncArgs('attr'));
11
-		else if (strtolower($values[0]) === 'none') $element->setAttribute('transphporm', 'remove');
12
-		else $element->setAttribute('transphporm', 'show');
10
+		if ($pseudoMatcher->hasFunction('attr')) {
11
+			$element->removeAttribute($pseudoMatcher->getFuncArgs('attr'));
12
+		} else if (strtolower($values[0]) === 'none') {
13
+			$element->setAttribute('transphporm', 'remove');
14
+		} else {
15
+			$element->setAttribute('transphporm', 'show');
16
+		}
13 17
 	}
14 18
 }
15 19
\ No newline at end of file
Please login to merge, or discard this patch.
src/Property/Content.php 1 patch
Braces   +24 added lines, -10 removed lines patch added patch discarded remove patch
@@ -18,21 +18,28 @@  discard block
 block discarded – undo
18 18
 	}
19 19
 
20 20
 	public function run(array $values, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) {
21
-		if (!$this->shouldRun($element)) return false;
21
+		if (!$this->shouldRun($element)) {
22
+			return false;
23
+		}
22 24
 
23 25
 		$values = $this->formatter->format($values, $rules);
24 26
 		if (!$this->processPseudo($values, $element, $pseudoMatcher)) {
25 27
 			//Remove the current contents
26 28
 			$this->removeAllChildren($element);
27 29
 			//Now make a text node
28
-			if ($this->getContentMode($rules) === 'replace') $this->replaceContent($element, $values);
29
-			else $this->appendContent($element, $values);
30
+			if ($this->getContentMode($rules) === 'replace') {
31
+				$this->replaceContent($element, $values);
32
+			} else {
33
+				$this->appendContent($element, $values);
34
+			}
30 35
 		}
31 36
 	}
32 37
 
33 38
 	private function shouldRun($element) {
34 39
 		do {
35
-			if ($element->getAttribute('transphporm') == 'includedtemplate') return false;
40
+			if ($element->getAttribute('transphporm') == 'includedtemplate') {
41
+				return false;
42
+			}
36 43
 		}
37 44
 		while (($element = $element->parentNode) instanceof \DomElement);
38 45
 		return true;
@@ -54,21 +61,26 @@  discard block
 block discarded – undo
54 61
 	}
55 62
 	
56 63
 	private function getNode($node, $document) {
57
-		if (is_array($node[0])) $node = $node[0];
64
+		if (is_array($node[0])) {
65
+			$node = $node[0];
66
+		}
58 67
 		foreach ($node as $n) {
59 68
 
60 69
 			if ($n instanceof \DomElement) {
61 70
 				$new = $document->importNode($n, true);
62 71
 				//Removing this might cause problems with caching... 
63 72
 				//$new->setAttribute('transphporm', 'added');
64
-			}
65
-			else {
73
+			} else {
66 74
 				
67 75
 
68 76
 
69
-				if ($n instanceof \DomText) $n = $n->nodeValue;
77
+				if ($n instanceof \DomText) {
78
+					$n = $n->nodeValue;
79
+				}
70 80
 				$new = $document->createElement('text');
71
-				if (is_array($n)) throw new \Exception();
81
+				if (is_array($n)) {
82
+					throw new \Exception();
83
+				}
72 84
 				
73 85
 				$new->appendChild($document->createTextNode($n));
74 86
 				$new->setAttribute('transphporm', 'text');
@@ -114,6 +126,8 @@  discard block
 block discarded – undo
114 126
 	}
115 127
 	
116 128
 	private function removeAllChildren($element) {
117
-		while ($element->hasChildNodes()) $element->removeChild($element->firstChild);
129
+		while ($element->hasChildNodes()) {
130
+			$element->removeChild($element->firstChild);
131
+		}
118 132
 	}
119 133
 }
120 134
\ No newline at end of file
Please login to merge, or discard this patch.
src/Pseudo/Attribute.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 
26 26
 		$valueParser = new \Transphporm\Parser\Value($this->functionSet);
27 27
 
28
-		$criteria = $name . '(' . $criteria;
28
+		$criteria = $name.'('.$criteria;
29 29
 
30 30
 		$pos = strpos($pseudo, '!');
31 31
 		if ($pos === false) $pos = strpos($pseudo, '=');
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,10 +15,14 @@  discard block
 block discarded – undo
15 15
 	public function match($pseudo, \DomElement $element) {
16 16
 
17 17
 		$pos = strpos($pseudo, '[');
18
-		if ($pos === false) return true;
18
+		if ($pos === false) {
19
+			return true;
20
+		}
19 21
 
20 22
 		$name = substr($pseudo, 0, $pos);
21
-		if (!is_callable([$this->functionSet, $name])) return true;
23
+		if (!is_callable([$this->functionSet, $name])) {
24
+			return true;
25
+		}
22 26
 
23 27
 		$bracketMatcher = new \Transphporm\Parser\BracketMatcher($pseudo);
24 28
 		$criteria = $bracketMatcher->match('[', ']');
@@ -28,11 +32,14 @@  discard block
 block discarded – undo
28 32
 		$criteria = $name . '(' . $criteria;
29 33
 
30 34
 		$pos = strpos($pseudo, '!');
31
-		if ($pos === false) $pos = strpos($pseudo, '=');
35
+		if ($pos === false) {
36
+			$pos = strpos($pseudo, '=');
37
+		}
32 38
 		if ($pos === false) {
33 39
 			$criteria .= ')=true';
40
+		} else {
41
+			$criteria = substr_replace($criteria, ')', $pos, 0);
34 42
 		}
35
-		else $criteria = substr_replace($criteria, ')', $pos, 0);
36 43
 
37 44
 		return $valueParser->parse($criteria, $element)[0];
38 45
 	}
Please login to merge, or discard this patch.