Completed
Push — master ( 864802...71ae65 )
by Tom
02:26
created
src/Parser/Value.php 1 patch
Braces   +23 added lines, -18 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
54 54
 		$this->last = null;
55 55
 		$this->traversing = false;
56 56
 
57
-		if (count($tokens) <= 0) return [$data];
57
+		if (count($tokens) <= 0) {
58
+			return [$data];
59
+		}
58 60
 
59 61
 		foreach (new TokenFilterIterator($tokens, [Tokenizer::WHITESPACE, Tokenizer::NEW_LINE]) as $token) {
60 62
 			$this->{$this->tokenFuncs[$token['type']]}($token);
@@ -76,16 +78,16 @@  discard block
 block discarded – undo
76 78
 	//Reads the last selected value from $data regardless if it's an array or object and overrides $this->data with the new value
77 79
 	//Dot moves $data to the next object in $data foo.bar moves the $data pointer from `foo` to `bar`
78 80
 	private function processDot($token) {
79
-		if ($this->last !== null) $this->data->traverse($this->last);
80
-		else {
81
+		if ($this->last !== null) {
82
+			$this->data->traverse($this->last);
83
+		} else {
81 84
 			//When . is not preceeded by anything, treat it as part of the string instead of an operator
82 85
 			// foo.bar is treated as looking up `bar` in `foo` whereas .foo is treated as the string ".foo"
83 86
 			$lastResult = $this->result->pop();
84 87
 			if ($lastResult) {
85 88
 				$this->data = new ValueData($lastResult);
86 89
 				$this->traversing = true;
87
-			}
88
-			else {
90
+			} else {
89 91
 				$this->processString(['value' => '.']);
90 92
 				$this->result->setMode(Tokenizer::CONCAT);
91 93
 			}
@@ -98,15 +100,19 @@  discard block
 block discarded – undo
98 100
 		$parser = new Value($this->baseData, $this->autoLookup);
99 101
 		if ($this->baseData instanceof \Transphporm\Functionset && $this->baseData->hasFunction($this->last)) {
100 102
 			$this->callTransphpormFunctions($token);
101
-		}
102
-		else {
103
-			if ($this->last !== null) $this->data->traverse($this->last);
104
-			else {
103
+		} else {
104
+			if ($this->last !== null) {
105
+				$this->data->traverse($this->last);
106
+			} else {
105 107
 				$lastResult = $this->result->pop();
106
-				if ($lastResult) $this->data = new ValueData($lastResult);
108
+				if ($lastResult) {
109
+					$this->data = new ValueData($lastResult);
110
+				}
107 111
 			}
108 112
 			$this->last = $parser->parseTokens($token['value'], null)[0];
109
-			if (!is_bool($this->last)) $this->traversing = true;
113
+			if (!is_bool($this->last)) {
114
+				$this->traversing = true;
115
+			}
110 116
 		}
111 117
 	}
112 118
 
@@ -126,8 +132,7 @@  discard block
 block discarded – undo
126 132
 		if ($this->baseData instanceof \Transphporm\Functionset && $this->baseData->hasFunction($this->last)
127 133
 			&& !$this->data->methodExists($this->last)) {
128 134
 			$this->callTransphpormFunctions($token);
129
-		}
130
-		else {
135
+		} else {
131 136
 			$this->processNested($token);
132 137
 		}
133 138
 	}
@@ -144,7 +149,9 @@  discard block
 block discarded – undo
144 149
 		foreach ($this->result->getResult() as $i => $value) {
145 150
 			if (is_scalar($value)) {
146 151
 				$val = $this->data->read($value);
147
-				if ($val) $this->result[$i] = $val;
152
+				if ($val) {
153
+					$this->result[$i] = $val;
154
+				}
148 155
 			}
149 156
 		}
150 157
 		$this->last = null;
@@ -156,12 +163,10 @@  discard block
 block discarded – undo
156 163
 			try {
157 164
 				$value = $this->data->extract($this->last, $this->autoLookup, $this->traversing);
158 165
 				$this->result->processValue($value);
159
-			}
160
-			catch (\UnexpectedValueException $e) {
166
+			} catch (\UnexpectedValueException $e) {
161 167
 				if (!($this->autoLookup || $this->traversing)) {
162 168
 					$this->result->processValue($this->last);
163
-				}
164
-				else {
169
+				} else {
165 170
 					$this->result->clear();
166 171
 					$this->result[0] = false;
167 172
 				}
Please login to merge, or discard this patch.
src/Module/Format.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@
 block discarded – undo
15 15
 
16 16
 	private function getLocale() {
17 17
 		if (is_array($this->locale)) return $this->locale;
18
-		else if (strlen($this->locale) > 0) return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $this->locale . '.json'), true);
19
-		else return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true);
18
+		else if (strlen($this->locale) > 0) return json_decode(file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'../Formatter'.DIRECTORY_SEPARATOR.'Locale'.DIRECTORY_SEPARATOR.$this->locale.'.json'), true);
19
+		else return json_decode(file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'../Formatter'.DIRECTORY_SEPARATOR.'Locale'.DIRECTORY_SEPARATOR.'enGB.json'), true);
20 20
 	}
21 21
 
22 22
 	public function load(\Transphporm\Config $config) {
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,9 +14,13 @@
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	private function getLocale() {
17
-		if (is_array($this->locale)) return $this->locale;
18
-		else if (strlen($this->locale) > 0) return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $this->locale . '.json'), true);
19
-		else return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true);
17
+		if (is_array($this->locale)) {
18
+			return $this->locale;
19
+		} else if (strlen($this->locale) > 0) {
20
+			return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . $this->locale . '.json'), true);
21
+		} else {
22
+			return json_decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '../Formatter' . DIRECTORY_SEPARATOR . 'Locale' . DIRECTORY_SEPARATOR . 'enGB.json'), true);
23
+		}
20 24
 	}
21 25
 
22 26
 	public function load(\Transphporm\Config $config) {
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
@@ -7,7 +7,9 @@
 block discarded – undo
7 7
 namespace Transphporm\Pseudo;
8 8
 class Attribute implements \Transphporm\Pseudo {
9 9
 	public function match($name, $args, \DomElement $element) {
10
-		if (!($name === null || in_array($name, ['data', 'iteration', 'root'])))  return true;
10
+		if (!($name === null || in_array($name, ['data', 'iteration', 'root']))) {
11
+			return true;
12
+		}
11 13
 		return $args[0];
12 14
 	}
13 15
 }
Please login to merge, or discard this patch.
src/Cache.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@
 block discarded – undo
21 21
 		$key = md5($key);
22 22
 		if (isset($this->cache[$key]) && $this->cache[$key]['timestamp'] >= $modified) {
23 23
 			return $this->cache[$key]['content'];
24
+		} else {
25
+			return false;
24 26
 		}
25
-		else return false;
26 27
 	}
27 28
 }
28 29
\ No newline at end of file
Please login to merge, or discard this patch.
src/Template.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 				$this->save = function($content = null) {
38 38
 					return $this->document->saveHtml($content);
39 39
 				};
40
-				$this->document->loadHtml('<' . '?xml encoding="UTF-8">' .$doc,  LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED);
40
+				$this->document->loadHtml('<'.'?xml encoding="UTF-8">'.$doc, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED);
41 41
 
42 42
 				if (strpos($doc, '<!') !== 0) {
43 43
 					$templateNode = $this->document->getElementsByTagName('template')[0];
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		 //Either return a whole DomDocument or return the output HTML
89 89
 		if ($document) return $this->document;
90 90
 
91
-		$output = ($this->document->doctype) ? ($this->save)($this->document->doctype) . "\n" : '';
91
+		$output = ($this->document->doctype) ? ($this->save)($this->document->doctype)."\n" : '';
92 92
 
93 93
 		if ($this->document->documentElement->tagName !== 'template') $output .= ($this->save)($this->document->documentElement);
94 94
 		else $output = $this->printDocument();
Please login to merge, or discard this patch.
Braces   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -66,7 +66,9 @@  discard block
 block discarded – undo
66 66
 	/** Loops through all assigned hooks, runs the Xpath query and calls the hook */
67 67
 	private function processHooks() {
68 68
 		foreach ($this->hooks as list($query, $hook)) {
69
-			foreach ($this->xpath->query($query) as $element) $hook->run($element);
69
+			foreach ($this->xpath->query($query) as $element) {
70
+				$hook->run($element);
71
+			}
70 72
 		}
71 73
 		$this->hooks = [];
72 74
 	}
@@ -74,7 +76,9 @@  discard block
 block discarded – undo
74 76
 	/** Prints out the current DomDocument as HTML */
75 77
 	private function printDocument() {
76 78
 		$output = '';
77
-		foreach ($this->document->documentElement->childNodes as $node) $output .= ($this->save)($node);
79
+		foreach ($this->document->documentElement->childNodes as $node) {
80
+			$output .= ($this->save)($node);
81
+		}
78 82
 		return $output;
79 83
 	}
80 84
 
@@ -86,12 +90,17 @@  discard block
 block discarded – undo
86 90
 		//Generate the document by taking only the childnodes of the template, ignoring the <template> and </template> tags
87 91
 		//TODO: Is there a faster way of doing this without string manipulation on the output or this loop through childnodes?
88 92
 		 //Either return a whole DomDocument or return the output HTML
89
-		if ($document) return $this->document;
93
+		if ($document) {
94
+			return $this->document;
95
+		}
90 96
 
91 97
 		$output = ($this->document->doctype) ? ($this->save)($this->document->doctype) . "\n" : '';
92 98
 
93
-		if ($this->document->documentElement->tagName !== 'template') $output .= ($this->save)($this->document->documentElement);
94
-		else $output = $this->printDocument();
99
+		if ($this->document->documentElement->tagName !== 'template') {
100
+			$output .= ($this->save)($this->document->documentElement);
101
+		} else {
102
+			$output = $this->printDocument();
103
+		}
95 104
 
96 105
 		//repair empty tags. Browsers break on <script /> and <div /> so can't avoid LIBXML_NOEMPTYTAG but they also break on <base></base> so repair them
97 106
 		$output = str_replace(['></img>', '></br>', '></meta>', '></base>', '></link>', '></hr>', '></input>'], ' />', $output);
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 true;
@@ -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 (isset($args[0]) && $args[0] instanceof Parser\Tokens) {
34
+		} else if (isset($args[0]) && $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.