Completed
Push — master ( 0ec6f2...04a4d1 )
by Tom
02:21
created
src/Parser/Tokenizer/Literals.php 1 patch
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,9 +37,13 @@
 block discarded – undo
37 37
 	}
38 38
 
39 39
 	private function processLiterals($tokens, $name, $str) {
40
-		if (is_numeric($name)) $tokens->add(['type' => Tokenizer::NUMERIC, 'value' => $name]);
41
-		else if (method_exists($this, $name)) $this->$name($tokens);
42
-		else $tokens->add(['type' => Tokenizer::NAME, 'value' => $name, 'line' => $str->lineNo()]);
40
+		if (is_numeric($name)) {
41
+			$tokens->add(['type' => Tokenizer::NUMERIC, 'value' => $name]);
42
+		} else if (method_exists($this, $name)) {
43
+			$this->$name($tokens);
44
+		} else {
45
+			$tokens->add(['type' => Tokenizer::NAME, 'value' => $name, 'line' => $str->lineNo()]);
46
+		}
43 47
 	}
44 48
 
45 49
 	private function true($tokens) {
Please login to merge, or discard this patch.
src/Parser/ValueResult.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@
 block discarded – undo
108 108
 
109 109
 	//Postprocessing - replace values with null where allowed, or override a value at position
110 110
 	public function postProcess(ValueData $data, $val, $overrideVal, $allowNull) {
111
-        if ($this->getMode() !== Tokenizer::ARG) return;
111
+		if ($this->getMode() !== Tokenizer::ARG) return;
112 112
 		foreach ($this->getResult() as $i => $value) {
113 113
 			if (is_scalar($value)) {
114 114
 				$val = ($overrideVal == $val) ? $data->read($value) : $overrideVal;
Please login to merge, or discard this patch.
Braces   +11 added lines, -6 removed lines patch added patch discarded remove patch
@@ -33,14 +33,17 @@  discard block
 block discarded – undo
33 33
 		];
34 34
 
35 35
 		if ($funcs[$this->mode] === 'concat' && is_numeric($newValue)
36
-			&& is_numeric($this->result[count($this->result)-1]))
37
-			$this->add($newValue);
38
-		else
39
-			$this->{$funcs[$this->mode]}($newValue);
36
+			&& is_numeric($this->result[count($this->result)-1])) {
37
+					$this->add($newValue);
38
+		} else {
39
+					$this->{$funcs[$this->mode]}($newValue);
40
+		}
40 41
 	}
41 42
 
42 43
 	public function in($value) {
43
-		if (!is_array($value)) throw new \Exception(' `in` can only be used with arrays');
44
+		if (!is_array($value)) {
45
+			throw new \Exception(' `in` can only be used with arrays');
46
+		}
44 47
 		$this->result[count($this->result)-1] = in_array($this->result[count($this->result)-1], $value);
45 48
 	}
46 49
 
@@ -108,7 +111,9 @@  discard block
 block discarded – undo
108 111
 
109 112
 	//Postprocessing - replace values with null where allowed, or override a value at position
110 113
 	public function postProcess(ValueData $data, $val, $overrideVal, $allowNull) {
111
-        if ($this->getMode() !== Tokenizer::ARG) return;
114
+        if ($this->getMode() !== Tokenizer::ARG) {
115
+        	return;
116
+        }
112 117
 		foreach ($this->getResult() as $i => $value) {
113 118
 			if (is_scalar($value)) {
114 119
 				$val = ($overrideVal == $val) ? $data->read($value) : $overrideVal;
Please login to merge, or discard this patch.
src/FunctionSet.php 1 patch
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,11 +26,12 @@
 block discarded – undo
26 26
 	private function getArgs0($name, $args) {
27 27
 		if (isset($this->functions[$name]) && !($this->functions[$name] instanceof TSSFunction\Data)) {
28 28
 			$tokens = $args[0];
29
-			if ($tokens->count() == 0) return [];
29
+			if ($tokens->count() == 0) {
30
+				return [];
31
+			}
30 32
 			$parser = new \Transphporm\Parser\Value($this);
31 33
 			return $parser->parseTokens($tokens, $this->elementData->getData($this->element));
32
-		}
33
-		else {
34
+		} else {
34 35
 			return iterator_to_array($args[0]);
35 36
 		}
36 37
 
Please login to merge, or discard this patch.
src/Property/Content.php 1 patch
Braces   +28 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	public function run(array $values, \DomElement $element, array $rules, \Transphporm\Hook\PseudoMatcher $pseudoMatcher, array $properties = []) {
17
-		if (!$this->shouldRun($element)) return false;
17
+		if (!$this->shouldRun($element)) {
18
+			return false;
19
+		}
18 20
 
19 21
 		$values = $this->formatter->format($values, $rules);
20 22
 
@@ -22,14 +24,19 @@  discard block
 block discarded – undo
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;
@@ -56,9 +63,10 @@  discard block
 block discarded – undo
56 63
 	public function getNode($node, $document) {
57 64
 		foreach ($node as $n) {
58 65
 			if (is_array($n)) {
59
-				foreach ($this->getNode($n, $document) as $new) yield $new;
60
-			}
61
-			else {
66
+				foreach ($this->getNode($n, $document) as $new) {
67
+					yield $new;
68
+				}
69
+			} else {
62 70
 				yield $this->convertNode($n, $document);
63 71
 			}
64 72
 		}
@@ -69,9 +77,10 @@  discard block
 block discarded – undo
69 77
 			$new = $document->importNode($node, true);
70 78
 			//Removing this might cause problems with caching...
71 79
 			//$new->setAttribute('transphporm', 'added');
72
-		}
73
-		else {
74
-			if ($node instanceof \DomText) $node = $node->nodeValue;
80
+		} else {
81
+			if ($node instanceof \DomText) {
82
+				$node = $node->nodeValue;
83
+			}
75 84
 			$new = $document->createElement('text');
76 85
 
77 86
 			$new->appendChild($document->createTextNode($node));
@@ -82,14 +91,18 @@  discard block
 block discarded – undo
82 91
 
83 92
 
84 93
 	private function replaceContent($element, $content) {
85
-		if ($element->getAttribute('transphporm') == 'added') return;
94
+		if ($element->getAttribute('transphporm') == 'added') {
95
+			return;
96
+		}
86 97
 		//If this rule was cached, the elements that were added last time need to be removed prior to running the rule again.
87 98
 		if ($element->getAttribute('transphporm')) {
88 99
 			$this->replaceCachedContent($element);
89 100
 		}
90 101
 
91 102
 		foreach ($this->getNode($content, $element->ownerDocument) as $node) {
92
-			if (!$node->getAttribute('transphporm'))  $node->setAttribute('transphporm', 'added');
103
+			if (!$node->getAttribute('transphporm')) {
104
+				$node->setAttribute('transphporm', 'added');
105
+			}
93 106
 			$element->parentNode->insertBefore($node, $element);
94 107
 		}
95 108
 
@@ -123,6 +136,8 @@  discard block
 block discarded – undo
123 136
 	}
124 137
 
125 138
 	private function removeAllChildren($element) {
126
-		while ($element->hasChildNodes()) $element->removeChild($element->firstChild);
139
+		while ($element->hasChildNodes()) {
140
+			$element->removeChild($element->firstChild);
141
+		}
127 142
 	}
128 143
 }
129 144
\ No newline at end of file
Please login to merge, or discard this patch.