Completed
Push — master ( 4a2495...d872cd )
by Tom
04:00
created
src/Parser/CssToXpath.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
 		$this->functionSet = $functionSet;
20 20
 
21 21
 		$this->translators = [
22
-			Tokenizer::WHITESPACE => function($string) use ($prefix) { return '//' . $prefix . $string;	},
23
-            Tokenizer::MULTIPLY => function () { return '*'; },
24
-			'' => function($string) use ($prefix) { return '/' . $prefix . $string;	},
25
-			Tokenizer::GREATER_THAN => function($string) use ($prefix) { return '/' . $prefix  . $string; },
26
-			Tokenizer::NUM_SIGN => function($string) { return '[@id=\'' . $string . '\']'; },
27
-			Tokenizer::DOT => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' ' . $string . ' \')]'; },
28
-			Tokenizer::OPEN_SQUARE_BRACKET => function($string) { return '[' .'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \'' . base64_encode(serialize($string)) . '\', ., "' .  $this->id . '")' . ']';	}
22
+			Tokenizer::WHITESPACE => function($string) use ($prefix) { return '//'.$prefix.$string; },
23
+            Tokenizer::MULTIPLY => function() { return '*'; },
24
+			'' => function($string) use ($prefix) { return '/'.$prefix.$string; },
25
+			Tokenizer::GREATER_THAN => function($string) use ($prefix) { return '/'.$prefix.$string; },
26
+			Tokenizer::NUM_SIGN => function($string) { return '[@id=\''.$string.'\']'; },
27
+			Tokenizer::DOT => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' '.$string.' \')]'; },
28
+			Tokenizer::OPEN_SQUARE_BRACKET => function($string) { return '['.'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \''.base64_encode(serialize($string)).'\', ., "'.$this->id.'")'.']'; }
29 29
 		];
30 30
 	}
31 31
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		$functionSet->setElement($element[0]);
45 45
 
46 46
 		$attributes = array();
47
-        foreach($element[0]->attributes as $attribute_name => $attribute_node) {
47
+        foreach ($element[0]->attributes as $attribute_name => $attribute_node) {
48 48
             $attributes[$attribute_name] = $attribute_node->nodeValue;
49 49
         }
50 50
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	private function removeSpacesFromDirectDecend($css) {
92 92
 		$tokens = [];
93 93
 		foreach ($css->splitOnToken(Tokenizer::GREATER_THAN) as $token) {
94
-			foreach ($token->trim() as $t) $tokens[]  = $t;
94
+			foreach ($token->trim() as $t) $tokens[] = $t;
95 95
 			$tokens[] = ['type' => Tokenizer::GREATER_THAN];
96 96
 		}
97 97
 		return new Tokens(array_slice($tokens, 0, -1));
Please login to merge, or discard this patch.
src/Builder.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
 
53 53
 		$cachedOutput = $this->loadTemplate();
54 54
 		//To be a valid XML document it must have a root element, automatically wrap it in <template> to ensure it does
55
-		$template = new Template($this->isValidDoc($cachedOutput['body']) ? str_ireplace('<!doctype', '<!DOCTYPE', $cachedOutput['body']) : '<template>' . $cachedOutput['body'] . '</template>' );
55
+		$template = new Template($this->isValidDoc($cachedOutput['body']) ? str_ireplace('<!doctype', '<!DOCTYPE', $cachedOutput['body']) : '<template>'.$cachedOutput['body'].'</template>');
56 56
 		$valueParser = new Parser\Value($functionSet);
57 57
 		$this->config = new Config($functionSet, $valueParser, $elementData, new Hook\Formatter(), new Parser\CssToXpath($functionSet, $template->getPrefix(), md5($this->tss)), new FilePath($this->rootDir), $headers);
58 58
 
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,7 +27,9 @@  discard block
 block discarded – undo
27 27
 		$this->cache = new Cache(new \ArrayObject());
28 28
 
29 29
 		$modules = is_array($modules) ? $modules : $this->defaultModules;
30
-		foreach ($modules as $module) $this->loadModule(new $module);
30
+		foreach ($modules as $module) {
31
+			$this->loadModule(new $module);
32
+		}
31 33
 	}
32 34
 
33 35
 	//Allow setting the time used by Transphporm for caching. This is for testing purposes
@@ -56,7 +58,9 @@  discard block
 block discarded – undo
56 58
 		$valueParser = new Parser\Value($functionSet);
57 59
 		$this->config = new Config($functionSet, $valueParser, $elementData, new Hook\Formatter(), new Parser\CssToXpath($functionSet, $template->getPrefix(), md5($this->tss)), new FilePath($this->rootDir), $headers);
58 60
 
59
-		foreach ($this->modules as $module) $module->load($this->config);
61
+		foreach ($this->modules as $module) {
62
+			$module->load($this->config);
63
+		}
60 64
 
61 65
 		$this->processRules($template, $this->config);
62 66
 
@@ -70,7 +74,9 @@  discard block
 block discarded – undo
70 74
 		$rules = $this->getRules($template, $config);
71 75
 
72 76
 		foreach ($rules as $rule) {
73
-			if ($rule->shouldRun($this->time)) $this->executeTssRule($rule, $template, $config);
77
+			if ($rule->shouldRun($this->time)) {
78
+				$this->executeTssRule($rule, $template, $config);
79
+			}
74 80
 		}
75 81
 	}
76 82
 
@@ -95,8 +101,9 @@  discard block
 block discarded – undo
95 101
 		if (trim($this->template)[0] !== '<') {
96 102
 			$xml = $this->cache->load($this->template, filemtime($this->template));
97 103
 			return $xml ? $xml : ['body' => file_get_contents($this->template), 'headers' => []];
104
+		} else {
105
+			return ['body' => $this->template, 'headers' => []];
98 106
 		}
99
-		else return ['body' => $this->template, 'headers' => []];
100 107
 	}
101 108
 
102 109
 	//Load the TSS rules either from a file or as a string
Please login to merge, or discard this patch.