Completed
Push — master ( 0ada29...ecc437 )
by Richard
03:53 queued 11s
created
src/TSSFunction/Template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 	public function run(array $args, \DomElement $element) {
23 23
 		$selector = $this->readArray($args, 1);
24 24
 		$tss = $this->readArray($args, 2);
25
-		$newTemplate = new \Transphporm\Builder($this->baseDir . $args[0], $tss ? $this->baseDir . $tss : null);
25
+		$newTemplate = new \Transphporm\Builder($this->baseDir.$args[0], $tss ? $this->baseDir.$tss : null);
26 26
 
27 27
 		$doc = $newTemplate->output($this->elementData->getData($element), true)->body;
28 28
 		if ($selector != '') return $this->templateSubsection($doc, $selector);
Please login to merge, or discard this 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/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   +35 added lines, -14 removed lines patch added patch discarded remove patch
@@ -69,8 +69,11 @@  discard block
 block discarded – undo
69 69
 			$i += $this->doStrings($tokens, $char, $i);
70 70
 			$i += $this->doBrackets($tokens, $char, $i);
71 71
 		}
72
-		if ($returnObj) return new Tokens($tokens);
73
-		else return $tokens;
72
+		if ($returnObj) {
73
+			return new Tokens($tokens);
74
+		} else {
75
+			return $tokens;
76
+		}
74 77
 	}
75 78
 
76 79
 	private function doSimpleTokens(&$tokens, $char) {
@@ -93,10 +96,15 @@  discard block
 block discarded – undo
93 96
 	}
94 97
 
95 98
 	private function processLiterals(&$tokens, $name) {
96
-		if (is_numeric($name)) $tokens[] = ['type' => self::NUMERIC, 'value' => $name];
97
-		else if ($name == 'true') $tokens[] = ['type' => self::BOOL, 'value' => true];
98
-		else if ($name == 'false') $tokens[] = ['type' => self::BOOL, 'value' => false];
99
-		else $tokens[] = ['type' => self::NAME, 'value' => $name];
99
+		if (is_numeric($name)) {
100
+			$tokens[] = ['type' => self::NUMERIC, 'value' => $name];
101
+		} else if ($name == 'true') {
102
+			$tokens[] = ['type' => self::BOOL, 'value' => true];
103
+		} else if ($name == 'false') {
104
+			$tokens[] = ['type' => self::BOOL, 'value' => false];
105
+		} else {
106
+			$tokens[] = ['type' => self::NAME, 'value' => $name];
107
+		}
100 108
 	}
101 109
 
102 110
 	private function doBrackets(&$tokens, $char, $i) {
@@ -130,7 +138,9 @@  discard block
 block discarded – undo
130 138
 	private function extractString($pos) {
131 139
 		$char = $this->str[$pos];
132 140
 		$end = strpos($this->str, $char, $pos+1);
133
-		while ($end !== false && $this->str[$end-1] == '\\') $end = strpos($this->str, $char, $end+1);
141
+		while ($end !== false && $this->str[$end-1] == '\\') {
142
+			$end = strpos($this->str, $char, $end+1);
143
+		}
134 144
 
135 145
 		return substr($this->str, $pos+1, $end-$pos-1);
136 146
 	}
@@ -139,19 +149,27 @@  discard block
 block discarded – undo
139 149
 		$close = strpos($this->str, $closeBracket, $open);
140 150
 
141 151
 		$cPos = $open+1;
142
-		while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) $close = strpos($this->str, $closeBracket, $close+1);
152
+		while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) {
153
+			$close = strpos($this->str, $closeBracket, $close+1);
154
+		}
143 155
 		return substr($this->str, $open+1, $close-$open-1);
144 156
 	}
145 157
 
146 158
 	private function identifyChar($chr) {
147
-		if (isset($this->chars[$chr])) return $this->chars[$chr];
148
-		else return self::NAME;
159
+		if (isset($this->chars[$chr])) {
160
+			return $this->chars[$chr];
161
+		} else {
162
+			return self::NAME;
163
+		}
149 164
 	}
150 165
 
151 166
 	private function getChar($num) {
152 167
 		$chars = array_reverse($this->chars);
153
-		if (isset($chars[$num])) return $chars[$num];
154
-		else return false;
168
+		if (isset($chars[$num])) {
169
+			return $chars[$num];
170
+		} else {
171
+			return false;
172
+		}
155 173
 	}
156 174
 
157 175
 	public function serialize($tokens) {
@@ -169,8 +187,11 @@  discard block
 block discarded – undo
169 187
 
170 188
 	private function serializeValue($token) {
171 189
 		if (isset($token['value'])) {
172
-			if ($token['value'] instanceof Tokens) return $this->serialize($token['value']);
173
-			else return $token['value'];	
190
+			if ($token['value'] instanceof Tokens) {
191
+				return $this->serialize($token['value']);
192
+			} else {
193
+				return $token['value'];
194
+			}
174 195
 		}			
175 196
 	}
176 197
 }
Please login to merge, or discard this patch.
src/TSSFunction/Data.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  * @version         1.0                                                             */
7 7
 namespace Transphporm\TSSFunction;
8 8
 /* Handles data() and iteration() function calls from the stylesheet */
9
-class Data implements \Transphporm\TSSFunction{
9
+class Data implements \Transphporm\TSSFunction {
10 10
 	private $data;
11 11
 	private $dataKey;
12 12
 	private $functionSet;
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,11 @@
 block discarded – undo
18 18
 	}
19 19
 
20 20
 	public function run(array $args, \DomElement $element = null) {
21
-		if ($this->dataKey === "root") $data = $this->data->getData(null, 'data');
22
-		else $data = $this->data->getData($element, $this->dataKey);
21
+		if ($this->dataKey === "root") {
22
+			$data = $this->data->getData(null, 'data');
23
+		} else {
24
+			$data = $this->data->getData($element, $this->dataKey);
25
+		}
23 26
 		$parser = new \Transphporm\Parser\Value($this->functionSet, true);
24 27
 		$return = $parser->parseTokens($args, $data);
25 28
 		return $return[0];
Please login to merge, or discard this patch.
src/TSSFunction/Json.php 3 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace Transphporm\TSSFunction;
3 3
 class Json implements \Transphporm\TSSFunction {
4
-    private $baseDir;
4
+	private $baseDir;
5 5
 
6
-    public function __construct(&$baseDir) {
7
-        $this->baseDir = &$baseDir;
8
-    }
6
+	public function __construct(&$baseDir) {
7
+		$this->baseDir = &$baseDir;
8
+	}
9 9
 
10
-    public function run(array $args, \DomElement $element = null) {
11
-        $json = $args[0];
10
+	public function run(array $args, \DomElement $element = null) {
11
+		$json = $args[0];
12 12
 
13
-        if (trim($json)[0] != '{') {
14
-            $path = $this->baseDir . $json;
15
-            if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
16
-            $json = file_get_contents($json);
17
-        }
13
+		if (trim($json)[0] != '{') {
14
+			$path = $this->baseDir . $json;
15
+			if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
16
+			$json = file_get_contents($json);
17
+		}
18 18
 
19
-        $map = json_decode($json, true);
19
+		$map = json_decode($json, true);
20 20
 
21
-        if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg());
21
+		if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg());
22 22
 
23
-        return $map;
24
-    }
23
+		return $map;
24
+	}
25 25
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@
 block discarded – undo
11 11
         $json = $args[0];
12 12
 
13 13
         if (trim($json)[0] != '{') {
14
-            $path = $this->baseDir . $json;
15
-            if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
14
+            $path = $this->baseDir.$json;
15
+            if (!file_exists($path)) throw new \Exception('File does not exist at: '.$path);
16 16
             $json = file_get_contents($json);
17 17
         }
18 18
 
19 19
         $map = json_decode($json, true);
20 20
 
21
-        if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg());
21
+        if (!is_array($map)) throw new \Exception('Could not decode json: '.json_last_error_msg());
22 22
 
23 23
         return $map;
24 24
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,13 +12,17 @@
 block discarded – undo
12 12
 
13 13
         if (trim($json)[0] != '{') {
14 14
             $path = $this->baseDir . $json;
15
-            if (!file_exists($path)) throw new \Exception('File does not exist at: ' . $path);
15
+            if (!file_exists($path)) {
16
+            	throw new \Exception('File does not exist at: ' . $path);
17
+            }
16 18
             $json = file_get_contents($json);
17 19
         }
18 20
 
19 21
         $map = json_decode($json, true);
20 22
 
21
-        if (!is_array($map)) throw new \Exception('Could not decode json: ' . json_last_error_msg());
23
+        if (!is_array($map)) {
24
+        	throw new \Exception('Could not decode json: ' . json_last_error_msg());
25
+        }
22 26
 
23 27
         return $map;
24 28
     }
Please login to merge, or discard this patch.
src/Parser/ValueData.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 
52 52
 	public function extract($last, $autoLookup) {
53 53
 		$value = $this->read($last);
54
-		if ($value && ($autoLookup || is_array($this->data)) ) {
54
+		if ($value && ($autoLookup || is_array($this->data))) {
55 55
 			return $value;
56 56
 		}
57 57
 		throw new \UnexpectedValueException('Not found');
Please login to merge, or discard this patch.
Braces   +20 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,16 +14,23 @@  discard block
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	public function traverse($key) {
17
-		if (isset($this->data->{$key})) $this->data = $this->data->{$key};
18
-		else if (is_array($this->data) && isset($this->data[$key])) $this->data = $this->data[$key];
17
+		if (isset($this->data->{$key})) {
18
+			$this->data = $this->data->{$key};
19
+		} else if (is_array($this->data) && isset($this->data[$key])) {
20
+			$this->data = $this->data[$key];
21
+		}
19 22
 	}
20 23
 
21 24
 	public function read($value) {
22 25
 		if (is_array($this->data)) {
23
-			if (isset($this->data[$value])) return $this->data[$value];
26
+			if (isset($this->data[$value])) {
27
+				return $this->data[$value];
28
+			}
29
+		} else if (isset($this->data->$value)) {
30
+			return $this->data->$value;
31
+		} else {
32
+			return false;
24 33
 		}
25
-		else if (isset($this->data->$value)) return $this->data->$value;
26
-		else return false;
27 34
 	}
28 35
 
29 36
 	public function isFunctionSet() {
@@ -36,7 +43,9 @@  discard block
 block discarded – undo
36 43
 
37 44
 	public function parseNested($parser, $token, $funcName) {
38 45
 		$args = $parser->parseTokens($token['value'], $this->data);
39
-		if ($args[0] == $this->data) $args = [];
46
+		if ($args[0] == $this->data) {
47
+			$args = [];
48
+		}
40 49
 		return $this->callFunc($funcName, $args, $this->data);
41 50
 	}
42 51
 
@@ -45,8 +54,11 @@  discard block
 block discarded – undo
45 54
 	}
46 55
 
47 56
 	private function callFuncOnObject($obj, $func, $args) {
48
-		if (isset($obj->$func) && is_callable($obj->$func)) return call_user_func_array($obj->$func, $args);
49
-		else return call_user_func_array([$obj, $func], $args);
57
+		if (isset($obj->$func) && is_callable($obj->$func)) {
58
+			return call_user_func_array($obj->$func, $args);
59
+		} else {
60
+			return call_user_func_array([$obj, $func], $args);
61
+		}
50 62
 	}
51 63
 
52 64
 	public function extract($last, $autoLookup) {
Please login to merge, or discard this patch.
src/Pseudo/Not.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Pseudo/Attribute.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 match($name, $args, \DomElement $element) {
17
-		if (!($name === null || in_array($name, ['data', 'iteration', 'root'])))  return true;
17
+		if (!($name === null || in_array($name, ['data', 'iteration', 'root']))) {
18
+			return true;
19
+		}
18 20
 		return $args[0];
19 21
 	}
20 22
 }
Please login to merge, or discard this patch.
src/Property/Content.php 2 patches
Doc Comments   +16 added lines patch added patch discarded remove patch
@@ -28,6 +28,9 @@  discard block
 block discarded – undo
28 28
 		}
29 29
 	}
30 30
 
31
+	/**
32
+	 * @param \DOMElement $element
33
+	 */
31 34
 	private function shouldRun($element) {
32 35
 		do {
33 36
 			if ($element->getAttribute('transphporm') == 'includedtemplate') return false;
@@ -40,6 +43,10 @@  discard block
 block discarded – undo
40 43
 		return (isset($rules['content-mode'])) ? $rules['content-mode'] : 'append';
41 44
 	}
42 45
 
46
+	/**
47
+	 * @param \DOMElement $element
48
+	 * @param \Transphporm\Hook\PseudoMatcher $pseudoMatcher
49
+	 */
43 50
 	private function processPseudo($value, $element, $pseudoMatcher) {
44 51
 		$pseudoContent = ['attr', 'header', 'before', 'after'];
45 52
 		foreach ($pseudoContent as $pseudo) {
@@ -96,6 +103,9 @@  discard block
 block discarded – undo
96 103
 		}
97 104
 	}
98 105
 
106
+	/**
107
+	 * @param \DOMElement $element
108
+	 */
99 109
 	private function replaceContent($element, $content) {
100 110
 		//If this rule was cached, the elements that were added last time need to be removed prior to running the rule again.
101 111
 		foreach ($this->getNode($content, $element->ownerDocument) as $node) {
@@ -104,12 +114,18 @@  discard block
 block discarded – undo
104 114
 		$element->setAttribute('transphporm', 'remove');
105 115
 	}
106 116
 
117
+	/**
118
+	 * @param \DOMElement $element
119
+	 */
107 120
 	private function appendContent($element, $content) {
108 121
 		foreach ($this->getNode($content, $element->ownerDocument) as $node) {
109 122
 			$element->appendChild($node);
110 123
 		}
111 124
 	}
112 125
 
126
+	/**
127
+	 * @param \DOMElement $element
128
+	 */
113 129
 	private function removeAllChildren($element) {
114 130
 		while ($element->hasChildNodes()) $element->removeChild($element->firstChild);
115 131
 	}
Please login to merge, or discard this patch.
Braces   +22 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,21 +15,28 @@  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 (!$this->shouldRun($element)) return false;
18
+		if (!$this->shouldRun($element)) {
19
+			return false;
20
+		}
19 21
 		$values = $this->formatter->format($values, $rules);
20 22
 
21 23
 		if (!$this->processPseudo($values, $element, $pseudoMatcher)) {
22 24
 			//Remove the current contents
23 25
 			$this->removeAllChildren($element);
24 26
 			//Now make a text node
25
-			if ($this->getContentMode($rules) === 'replace') $this->replaceContent($element, $values);
26
-			else $this->appendContent($element, $values);
27
+			if ($this->getContentMode($rules) === 'replace') {
28
+				$this->replaceContent($element, $values);
29
+			} else {
30
+				$this->appendContent($element, $values);
31
+			}
27 32
 		}
28 33
 	}
29 34
 
30 35
 	private function shouldRun($element) {
31 36
 		do {
32
-			if ($element->getAttribute('transphporm') == 'includedtemplate') return false;
37
+			if ($element->getAttribute('transphporm') == 'includedtemplate') {
38
+				return false;
39
+			}
33 40
 		}
34 41
 		while (($element = $element->parentNode) instanceof \DomElement);
35 42
 		return true;
@@ -53,9 +60,10 @@  discard block
 block discarded – undo
53 60
 	private function getNode($node, $document) {
54 61
 		foreach ($node as $n) {
55 62
 			if (is_array($n)) {
56
-				foreach ($this->getNode($n, $document) as $new) yield $new;
57
-			}
58
-			else {
63
+				foreach ($this->getNode($n, $document) as $new) {
64
+					yield $new;
65
+				}
66
+			} else {
59 67
 				yield $this->convertNode($n, $document);
60 68
 			}
61 69
 		}
@@ -66,9 +74,10 @@  discard block
 block discarded – undo
66 74
 			$new = $document->importNode($node, true);
67 75
 			//Removing this might cause problems with caching...
68 76
 			//$new->setAttribute('transphporm', 'added');
69
-		}
70
-		else {
71
-			if ($node instanceof \DomText) $node = $node->nodeValue;
77
+		} else {
78
+			if ($node instanceof \DomText) {
79
+				$node = $node->nodeValue;
80
+			}
72 81
 			$new = $document->createElement('text');
73 82
 
74 83
 			$new->appendChild($document->createTextNode($node));
@@ -114,6 +123,8 @@  discard block
 block discarded – undo
114 123
 	}
115 124
 
116 125
 	private function removeAllChildren($element) {
117
-		while ($element->hasChildNodes()) $element->removeChild($element->firstChild);
126
+		while ($element->hasChildNodes()) {
127
+			$element->removeChild($element->firstChild);
128
+		}
118 129
 	}
119 130
 }
Please login to merge, or discard this patch.