Completed
Push — master ( c7a737...22a063 )
by Tom
03:13
created
src/Parser/CssToXpath.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -50,6 +50,9 @@
 block discarded – undo
50 50
 		return $attr;
51 51
 	}
52 52
 
53
+	/**
54
+	 * @param string $comparator
55
+	 */
53 56
 	private static function compare($comparator, $a, $b) {
54 57
 		if ($comparator == '=') return $a == $b;
55 58
 		else if ($comparator == '!=') return $a != $b;
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 		$this->functionSet = $functionSet;		
21 21
 
22 22
 		$this->translators = [
23
-			' ' => function($string) use ($prefix) { return '//' . $prefix . $string;	},
24
-			'' => function($string) use ($prefix) { return '/' . $prefix . $string;	},
25
-			'>' => function($string) use ($prefix) { return '/' . $prefix  . $string; },
26
-			'#' => function($string) { return '[@id=\'' . $string . '\']'; },
27
-			'.' => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' ' . $string . ' \')]'; }, 
28
-			'[' => function($string) use ($hash) { return '[' .'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \'' . $string . '\', ., "' . $hash . '")' . ']';	},
23
+			' ' => function($string) use ($prefix) { return '//'.$prefix.$string; },
24
+			'' => function($string) use ($prefix) { return '/'.$prefix.$string; },
25
+			'>' => function($string) use ($prefix) { return '/'.$prefix.$string; },
26
+			'#' => function($string) { return '[@id=\''.$string.'\']'; },
27
+			'.' => function($string) { return '[contains(concat(\' \', normalize-space(@class), \' \'), \' '.$string.' \')]'; }, 
28
+			'[' => function($string) use ($hash) { return '['.'php:function(\'\Transphporm\Parser\CssToXpath::processAttr\', \''.$string.'\', ., "'.$hash.'")'.']'; },
29 29
 			']' => function() {	return ''; }
30 30
 		];
31 31
 	}
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	}
86 86
 
87 87
 	public function getXpath($css) {
88
-		$this->css = str_replace([' >', '> '],['>', '>'], trim($css));
88
+		$this->css = str_replace([' >', '> '], ['>', '>'], trim($css));
89 89
 		$css = explode(':', $this->css)[0];
90 90
 		$selectors = $this->split($css);
91 91
 		$xpath = '/';
Please login to merge, or discard this patch.
src/Pseudo/Not.php 1 patch
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -25,6 +25,11 @@
 block discarded – undo
25 25
 		return true;
26 26
 	}
27 27
 
28
+	/**
29
+	 * @param \Transphporm\Parser\Value $valueParser
30
+	 * @param \DOMXPath $xpath
31
+	 * @param \DOMElement $element
32
+	 */
28 33
 	private function notElement($css, $valueParser, $xpath, $element) {
29 34
 		foreach ($css as $selector) {
30 35
 			$xpathString = $this->cssToXpath->getXpath($selector);					
Please login to merge, or discard this patch.
src/Parser/Sheet.php 1 patch
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
 		}
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	private function processingInstructions($tss, $pos, $next, $indexStart) {
63 63
 		$rules = [];
64 64
 		while (($atPos = strpos($tss, '@', $pos)) !== false) {
65
-			if ($atPos  <= (int) $next) {
65
+			if ($atPos <= (int) $next) {
66 66
 				$spacePos = strpos($tss, ' ', $atPos);
67 67
 				$funcName = substr($tss, $atPos+1, $spacePos-$atPos-1);
68 68
 				$pos = strpos($tss, ';', $spacePos);
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 	}
79 79
 
80 80
 	private function import($args, $indexStart) {
81
-		if (is_file(trim($args,'\'" '))) $fileName = trim($args,'\'" ');
81
+		if (is_file(trim($args, '\'" '))) $fileName = trim($args, '\'" ');
82 82
 		else $fileName = $this->valueParser->parse($args)[0];
83
-		$sheet = new Sheet(file_get_contents($this->baseDir . $fileName), $this->baseDir, $this->xPath, $this->valueParser);
83
+		$sheet = new Sheet(file_get_contents($this->baseDir.$fileName), $this->baseDir, $this->xPath, $this->valueParser);
84 84
 		return $sheet->parse(0, [], $indexStart);
85 85
 	}
86 86
 
Please login to merge, or discard this patch.
src/Config.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,12 +67,16 @@
 block discarded – undo
67 67
 	}
68 68
 
69 69
 	public function loadProperties(Hook\PropertyHook $hook) {
70
-		foreach ($this->properties as $name => $property) $hook->registerProperty($name, $property);
70
+		foreach ($this->properties as $name => $property) {
71
+			$hook->registerProperty($name, $property);
72
+		}
71 73
 	}
72 74
 
73 75
 	public function createPseudoMatcher($pseudo) {
74 76
 		$pseudoMatcher = new Hook\PseudoMatcher($pseudo);
75
-		foreach ($this->pseudo as $pseudoFunction) $pseudoMatcher->registerFunction($pseudoFunction);
77
+		foreach ($this->pseudo as $pseudoFunction) {
78
+			$pseudoMatcher->registerFunction($pseudoFunction);
79
+		}
76 80
 		return $pseudoMatcher;
77 81
 	}
78 82
 
Please login to merge, or discard this patch.
src/Builder.php 1 patch
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		$this->cache = new Cache(new \ArrayObject());
27 27
 
28 28
 		$modules = is_array($modules) ? $modules : $this->defaultModules;
29
-		foreach ($modules as $module) $this->loadModule(new $module);
29
+		foreach ($modules as $module) {
30
+			$this->loadModule(new $module);
31
+		}
30 32
 	}
31 33
 
32 34
 	//Allow setting the time used by Transphporm for caching. This is for testing purposes
@@ -51,7 +53,9 @@  discard block
 block discarded – undo
51 53
 		$valueParser = new Parser\Value($data);
52 54
 		$config = new Config($data, $valueParser, $elementData, new Hook\Formatter(), new Parser\CssToXpath($valueParser, $data, $template->getPrefix()), $headers, $this->baseDir);
53 55
 
54
-		foreach ($this->modules as $module) $module->load($config);
56
+		foreach ($this->modules as $module) {
57
+			$module->load($config);
58
+		}
55 59
 
56 60
 		$this->processRules($template, $config);
57 61
 
@@ -66,7 +70,9 @@  discard block
 block discarded – undo
66 70
 		$rules = $this->getRules($template, $config);
67 71
 
68 72
 		foreach ($rules as $rule) {
69
-			if ($rule->shouldRun($this->time)) $this->executeTssRule($rule, $template, $config);
73
+			if ($rule->shouldRun($this->time)) {
74
+				$this->executeTssRule($rule, $template, $config);
75
+			}
70 76
 		}
71 77
 	}
72 78
 
@@ -91,8 +97,9 @@  discard block
 block discarded – undo
91 97
 		if (trim($this->template)[0] !== '<') {
92 98
 			$xml = $this->cache->load($this->template, filemtime($this->template));
93 99
 			return $xml ? $xml : ['body' => file_get_contents($this->template), 'headers' => []];
100
+		} else {
101
+			return ['body' => $this->template, 'headers' => []];
94 102
 		}
95
-		else return ['body' => $this->template, 'headers' => []];
96 103
 	}
97 104
 
98 105
 	//Load the TSS rules either from a file or as a string
@@ -107,10 +114,14 @@  discard block
 block discarded – undo
107 114
 			//Try to load the cached rules, if not set in the cache (or expired) parse the supplied sheet
108 115
 			$rules = $this->cache->load($key, filemtime($this->tss));
109 116
 		
110
-			if (!$rules) return $this->cache->write($key, (new Parser\Sheet(file_get_contents($this->tss), $this->baseDir, $config->getCssToXpath(), $config->getValueParser()))->parse());
111
-			else return $rules;
117
+			if (!$rules) {
118
+				return $this->cache->write($key, (new Parser\Sheet(file_get_contents($this->tss), $this->baseDir, $config->getCssToXpath(), $config->getValueParser()))->parse());
119
+			} else {
120
+				return $rules;
121
+			}
122
+		} else {
123
+			return (new Parser\Sheet($this->tss, $this->baseDir, $config->getCssToXpath(), $config->getValueParser()))->parse();
112 124
 		}
113
-		else return (new Parser\Sheet($this->tss, $this->baseDir, $config->getCssToXpath(), $config->getValueParser()))->parse();
114 125
 	}
115 126
 
116 127
 	public function setCache(\ArrayAccess $cache) {
Please login to merge, or discard this patch.