Completed
Pull Request — master (#239)
by Nathan
13s
created
src/Hook/PropertyHook.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 	private $rules;
11 11
 	private $configLine;
12 12
 	private $file;
13
-    private $filePath;
13
+	private $filePath;
14 14
 	private $line;
15 15
 	private $valueParser;
16 16
 	private $pseudoMatcher;
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
 	private $functionSet;
19 19
 
20 20
 	public function __construct(array $rules, &$configLine, $file, $line, PseudoMatcher $pseudoMatcher,
21
-            \Transphporm\Parser\Value $valueParser, \Transphporm\FunctionSet $functionSet, \Transphporm\FilePath $filePath) {
21
+			\Transphporm\Parser\Value $valueParser, \Transphporm\FunctionSet $functionSet, \Transphporm\FilePath $filePath) {
22 22
 		$this->rules = $rules;
23 23
 		$this->configLine = &$configLine;
24 24
 		$this->file = $file;
25
-        $this->filePath = $filePath;
25
+		$this->filePath = $filePath;
26 26
 		$this->line = $line;
27 27
 		$this->valueParser = $valueParser;
28 28
 		$this->pseudoMatcher = $pseudoMatcher;
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
 	public function run(\DomElement $element) {
33 33
 		//Set the baseDir so that all files for this rule are relative to the file it came from
34
-        if ($this->file !== null) $this->filePath->setBaseDir(dirname(realpath($this->file)));
34
+		if ($this->file !== null) $this->filePath->setBaseDir(dirname(realpath($this->file)));
35 35
 		$this->functionSet->setElement($element);
36 36
 		$this->configLine = $this->line;
37 37
 		try {
Please login to merge, or discard this patch.
Braces   +14 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,15 +31,18 @@  discard block
 block discarded – undo
31 31
 
32 32
 	public function run(\DomElement $element) {
33 33
 		//Set the baseDir so that all files for this rule are relative to the file it came from
34
-        if ($this->file !== null) $this->filePath->setBaseDir(dirname(realpath($this->file)));
34
+        if ($this->file !== null) {
35
+        	$this->filePath->setBaseDir(dirname(realpath($this->file)));
36
+        }
35 37
 		$this->functionSet->setElement($element);
36 38
 		$this->configLine = $this->line;
37 39
 		try {
38 40
 			//Don't run if there's a pseudo element like nth-child() and this element doesn't match it
39
-			if (!$this->pseudoMatcher->matches($element)) return;
41
+			if (!$this->pseudoMatcher->matches($element)) {
42
+				return;
43
+			}
40 44
 			$this->callProperties($element);
41
-		}
42
-		catch (\Transphporm\RunException $e) {
45
+		} catch (\Transphporm\RunException $e) {
43 46
 			throw new \Transphporm\Exception($e, $this->file, $this->line);
44 47
 		}
45 48
 	}
@@ -50,7 +53,9 @@  discard block
 block discarded – undo
50 53
 	private function callProperties($element) {
51 54
 		foreach ($this->rules as $name => $value) {
52 55
 			$result = $this->callProperty($name, $element, $this->getArgs($value));
53
-			if ($result === false) break;
56
+			if ($result === false) {
57
+				break;
58
+			}
54 59
 		}
55 60
 	}
56 61
 	private function getArgs($value) {
@@ -65,9 +70,10 @@  discard block
 block discarded – undo
65 70
 		if (isset($this->properties[$name])) {
66 71
 			try {
67 72
 				return $this->properties[$name]->run($value, $element, $this->rules, $this->pseudoMatcher, $this->properties);
68
-			}
69
-			catch (\Exception $e) {
70
-				if ($e instanceof \Transphporm\RunException) throw $e;
73
+			} catch (\Exception $e) {
74
+				if ($e instanceof \Transphporm\RunException) {
75
+					throw $e;
76
+				}
71 77
 				throw new \Transphporm\RunException(\Transphporm\Exception::PROPERTY, $name, $e);
72 78
 			}
73 79
 		}
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
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
 
70 70
 	public function extract($last, $autoLookup, $traversing) {
71 71
 		$value = $this->read($last);
72
-		if ($value !== null && ($autoLookup || $traversing) ) {
72
+		if ($value !== null && ($autoLookup || $traversing)) {
73 73
 			return $value;
74 74
 		}
75 75
 		throw new \UnexpectedValueException('Not found');
Please login to merge, or discard this patch.
Braces   +25 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,13 +15,17 @@  discard block
 block discarded – undo
15 15
 
16 16
 	//Read $key from array, $this->data = $this->data[$key] but also works for objects
17 17
 	private function traverseInto($key) {
18
-		if (isset($this->data->{$key})) $this->data = $this->data->{$key};
19
-		else if ($this->isArray() && isset($this->data[$key])) $this->data = $this->data[$key];
18
+		if (isset($this->data->{$key})) {
19
+			$this->data = $this->data->{$key};
20
+		} else if ($this->isArray() && isset($this->data[$key])) {
21
+			$this->data = $this->data[$key];
22
+		}
20 23
 	}
21 24
 
22 25
 	public function traverse($key, $result) {
23
-		if ($key !== null) $this->traverseInto($key);
24
-		else {
26
+		if ($key !== null) {
27
+			$this->traverseInto($key);
28
+		} else {
25 29
 			//But if the key is null, replace the data structure with the result of the last function call
26 30
 			$lastResult = $result->pop();
27 31
 			if ($lastResult) {
@@ -41,10 +45,14 @@  discard block
 block discarded – undo
41 45
 
42 46
 	public function read($value) {
43 47
 		if ($this->isArray()) {
44
-			if (isset($this->data[$value])) return $this->data[$value];
48
+			if (isset($this->data[$value])) {
49
+				return $this->data[$value];
50
+			}
51
+		} else if (isset($this->data->$value)) {
52
+			return $this->data->$value;
53
+		} else {
54
+			return null;
45 55
 		}
46
-		else if (isset($this->data->$value)) return $this->data->$value;
47
-		else return null;
48 56
 	}
49 57
 
50 58
 	public function call($func, $args) {
@@ -57,14 +65,20 @@  discard block
 block discarded – undo
57 65
 
58 66
 	public function parseNested($parser, $token, $funcName) {
59 67
 		$args = $parser->parseTokens($token['value'], $this->data);
60
-		if ($args[0] === $this->data) $args = [];
68
+		if ($args[0] === $this->data) {
69
+			$args = [];
70
+		}
61 71
 		return $this->callFuncOnObject($this->data, $funcName, $args);
62 72
 	}
63 73
 
64 74
 	private function callFuncOnObject($obj, $func, $args) {
65
-		if (isset($obj->$func) && is_callable($obj->$func)) return call_user_func_array($obj->$func, $args);
66
-		else if (is_callable([$obj, $func])) return call_user_func_array([$obj, $func], $args);
67
-		else return false;
75
+		if (isset($obj->$func) && is_callable($obj->$func)) {
76
+			return call_user_func_array($obj->$func, $args);
77
+		} else if (is_callable([$obj, $func])) {
78
+			return call_user_func_array([$obj, $func], $args);
79
+		} else {
80
+			return false;
81
+		}
68 82
 	}
69 83
 
70 84
 	public function extract($last, $autoLookup, $traversing) {
Please login to merge, or discard this patch.
src/Parser/Last.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@
 block discarded – undo
53 53
 		$this->last = $value;
54 54
 	}
55 55
 
56
-    public function makeTraversing() {
57
-        $this->traversing = true;
58
-    }
56
+	public function makeTraversing() {
57
+		$this->traversing = true;
58
+	}
59 59
 
60 60
 	//Applies the current operation to whatever is in $last based on $mode
61 61
 	public function process() {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,8 +63,7 @@  discard block
 block discarded – undo
63 63
 			try {
64 64
 				$value = $this->data->extract($this->last, $this->autoLookup, $this->traversing);
65 65
 				$this->result->processValue($value);
66
-			}
67
-			catch (\UnexpectedValueException $e) {
66
+			} catch (\UnexpectedValueException $e) {
68 67
 				$this->processLastUnexpected();
69 68
 			}
70 69
 		}
@@ -73,8 +72,7 @@  discard block
 block discarded – undo
73 72
 	private function processLastUnexpected() {
74 73
 		if (!($this->autoLookup || $this->traversing)) {
75 74
 			$this->result->processValue($this->last);
76
-		}
77
-		else {
75
+		} else {
78 76
 			$this->result->clear();
79 77
 			$this->result->processValue(false);
80 78
 		}
Please login to merge, or discard this patch.
src/Parser/Value.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@
 block discarded – undo
148 148
 		}
149 149
 		else $parsedVal = null;
150 150
         
151
-        $this->result->postProcess($this->data, $val, $parsedVal, $this->allowNullResult);
151
+		$this->result->postProcess($this->data, $val, $parsedVal, $this->allowNullResult);
152 152
 
153 153
 		$this->last->clear();
154 154
 	}
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@
 block discarded – undo
85 85
 		if ($lastResult) {
86 86
 			$this->last->makeTraversing();
87 87
 		}
88
-		else if ($this->last->isEmpty())  {
88
+		else if ($this->last->isEmpty()) {
89 89
 			$this->processString(['value' => '.']);
90 90
 			$this->result->setMode(Tokenizer::CONCAT);
91 91
 		}
Please login to merge, or discard this patch.
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
54 54
 	}
55 55
 
56 56
 	public function parseTokens($tokens, $data = null) {
57
-		if (count($tokens) === 0) return [$data];
57
+		if (count($tokens) === 0) {
58
+			return [$data];
59
+		}
58 60
 
59 61
 		$this->result = new ValueResult();
60 62
 		$this->data = new ValueData($data ? $data : $this->baseData);
@@ -64,7 +66,9 @@  discard block
 block discarded – undo
64 66
 
65 67
 
66 68
 		foreach ($tokens as $name => $token) {
67
-			if ($token['type'] == 'WHITESPACE' || $token['type'] == 'NEWLINE') continue;
69
+			if ($token['type'] == 'WHITESPACE' || $token['type'] == 'NEWLINE') {
70
+				continue;
71
+			}
68 72
 			$this->{$this->tokenFuncs[$token['type']]}($token);
69 73
 		}
70 74
 
@@ -91,8 +95,7 @@  discard block
 block discarded – undo
91 95
 		// foo.bar is treated as looking up `bar` in `foo` whereas .foo is treated as the string ".foo"
92 96
 		if ($lastResult) {
93 97
 			$this->last->makeTraversing();
94
-		}
95
-		else if ($this->last->isEmpty())  {
98
+		} else if ($this->last->isEmpty())  {
96 99
 			$this->processString(['value' => '.']);
97 100
 			$this->result->setMode(Tokenizer::CONCAT);
98 101
 		}
@@ -107,11 +110,12 @@  discard block
 block discarded – undo
107 110
 	private function processSquareBracket($token) {
108 111
 		if ($this->hasFunction($this->last->read())) {
109 112
 			$this->callTransphpormFunctions($token);
110
-		}
111
-		else {
113
+		} else {
112 114
 			$this->last->traverse();
113 115
 			$this->last->set($this->getNewParser()->parseTokens($token['value'], null)[0]);
114
-			if (!is_bool($this->last->read())) $this->last->makeTraversing();
116
+			if (!is_bool($this->last->read())) {
117
+				$this->last->makeTraversing();
118
+			}
115 119
 		}
116 120
 	}
117 121
 
@@ -134,8 +138,7 @@  discard block
 block discarded – undo
134 138
 		if ($this->hasFunction($this->last->read())
135 139
 			&& !$this->data->methodExists($this->last->read())) {
136 140
 			$this->callTransphpormFunctions($token);
137
-		}
138
-		else {
141
+		} else {
139 142
 			$this->last->processNested($this->getNewParser(), $token);
140 143
 		}
141 144
 	}
@@ -152,8 +155,9 @@  discard block
 block discarded – undo
152 155
 			$parser = new Value($this->data->getData());
153 156
 			$parsedArr = $parser->parse($val);
154 157
 			$parsedVal = isset($parsedArr[0]) ? $parsedArr[0] : null;
158
+		} else {
159
+			$parsedVal = null;
155 160
 		}
156
-		else $parsedVal = null;
157 161
 
158 162
         $this->result->postProcess($this->data, $val, $parsedVal, $this->allowNullResult);
159 163
 
Please login to merge, or discard this patch.
src/Formatter/Date.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,10 +92,10 @@
 block discarded – undo
92 92
 		return $ranges;
93 93
 	}
94 94
 
95
-    private function add2DayRanges(&$ranges, $property, $when) {
96
-        $rangeVal = $when === "before" ? 2 : -2;
97
-        array_unshift($ranges, [$rangeVal, $rangeVal, $property, 1, '']);
98
-    }
95
+	private function add2DayRanges(&$ranges, $property, $when) {
96
+		$rangeVal = $when === "before" ? 2 : -2;
97
+		array_unshift($ranges, [$rangeVal, $rangeVal, $property, 1, '']);
98
+	}
99 99
 
100 100
 	/** Converts "week" to "weeks", "month" to "months" etc when plural is required using language from $locale */
101 101
 	private function getPlural($strings, $num, $interval) {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	/** Converts $val into a \DateTime object if it's not already */
17 17
 	private function getDate($val) {
18 18
 		$tz = new \DateTimeZone($this->locale['timezone']);
19
-		$date =  $val instanceof \DateTimeInterface ? $val : new \DateTime((string)$val, $tz);
19
+		$date = $val instanceof \DateTimeInterface ? $val : new \DateTime((string) $val, $tz);
20 20
 		$date->setTimeZone($tz);
21 21
 		return $date;
22 22
 	}
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
 	/** Formats \DateTime as Date and Time using formats from $locale */
37 37
 	public function dateTime($val) {
38
-		return $this->date($val, $this->locale['date_format'] . ' ' . $this->locale['time_format']);
38
+		return $this->date($val, $this->locale['date_format'].' '.$this->locale['time_format']);
39 39
 	}
40 40
 
41 41
 	/** Generates relative time offsets based on system clock. e.g "10 minutes ago" or "In 6 months"
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		$date->add(new \DateInterval("PT${secondsToAdd}S"));
50 50
 
51 51
 		$diff = $now->diff($date);
52
-		$diffDays = $diff->invert === 1 ? $diff->days : 0- $diff->days;
52
+		$diffDays = $diff->invert === 1 ? $diff->days : 0-$diff->days;
53 53
 
54 54
 		if ($diffDays !== 0) return $this->dayOffset($diffDays);
55 55
 		else return $this->timeOffset($diff);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 	/** Gets date ranges to represent uses of weeks/months/days/etc */
79 79
 	private function getRanges($strings) {
80
-		$ranges =  [
80
+		$ranges = [
81 81
 			[1, 1, $strings['yesterday'], 1, ''],
82 82
 			[1, 13, $strings['past'], 1, 'days'],
83 83
 			[13, 28, $strings['past'], 7, 'weeks'],
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
 	/** Converts "week" to "weeks", "month" to "months" etc when plural is required using language from $locale */
103 103
 	private function getPlural($strings, $num, $interval) {
104
-		if ($interval !== '') return $num == 1 ? $strings[$interval . '_singular'] : $strings[$interval . '_plural'];
104
+		if ($interval !== '') return $num == 1 ? $strings[$interval.'_singular'] : $strings[$interval.'_plural'];
105 105
 		else return '';
106 106
 	}
107 107
 
Please login to merge, or discard this patch.
Braces   +16 added lines, -6 removed lines patch added patch discarded remove patch
@@ -51,8 +51,11 @@  discard block
 block discarded – undo
51 51
 		$diff = $now->diff($date);
52 52
 		$diffDays = $diff->invert === 1 ? $diff->days : 0- $diff->days;
53 53
 
54
-		if ($diffDays !== 0) return $this->dayOffset($diffDays);
55
-		else return $this->timeOffset($diff);
54
+		if ($diffDays !== 0) {
55
+			return $this->dayOffset($diffDays);
56
+		} else {
57
+			return $this->timeOffset($diff);
58
+		}
56 59
 	}
57 60
 
58 61
 	/** Calculates offset in hours/minutes/seconds */
@@ -89,8 +92,12 @@  discard block
 block discarded – undo
89 92
 			[-365, -28, $strings['future'], 28, 'months'],
90 93
 			[-999999, -365, $strings['future'], 365, 'years'],
91 94
 		];
92
-		if (isset($strings['day_before_yesterday'])) $this->add2DayRanges($ranges, $strings['day_before_yesterday'], "before");
93
-		if (isset($strings['day_after_tomorrow'])) $this->add2DayRanges($ranges, $strings['day_after_tomorrow'], "after");
95
+		if (isset($strings['day_before_yesterday'])) {
96
+			$this->add2DayRanges($ranges, $strings['day_before_yesterday'], "before");
97
+		}
98
+		if (isset($strings['day_after_tomorrow'])) {
99
+			$this->add2DayRanges($ranges, $strings['day_after_tomorrow'], "after");
100
+		}
94 101
 		return $ranges;
95 102
 	}
96 103
 
@@ -101,8 +108,11 @@  discard block
 block discarded – undo
101 108
 
102 109
 	/** Converts "week" to "weeks", "month" to "months" etc when plural is required using language from $locale */
103 110
 	private function getPlural($strings, $num, $interval) {
104
-		if ($interval !== '') return $num == 1 ? $strings[$interval . '_singular'] : $strings[$interval . '_plural'];
105
-		else return '';
111
+		if ($interval !== '') {
112
+			return $num == 1 ? $strings[$interval . '_singular'] : $strings[$interval . '_plural'];
113
+		} else {
114
+			return '';
115
+		}
106 116
 	}
107 117
 
108 118
 	/** Calculates offset in days/weeks/month/years */
Please login to merge, or discard this patch.
src/Parser/Tokenizer/TokenizedString.php 2 patches
Braces   +16 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,8 +40,11 @@  discard block
 block discarded – undo
40 40
 	}
41 41
 
42 42
 	public function move($n) {
43
-		if ($n === false) $this->pos = strlen($this->str)-1;
44
-		else $this->pos += $n;
43
+		if ($n === false) {
44
+			$this->pos = strlen($this->str)-1;
45
+		} else {
46
+			$this->pos += $n;
47
+		}
45 48
 	}
46 49
 
47 50
 	public function next() {
@@ -60,8 +63,11 @@  discard block
 block discarded – undo
60 63
 
61 64
 	public function identifyChar($offset = 0) {
62 65
 		$chr = $this->str[$this->pos + $offset];
63
-		if (!empty($this->chars[$chr])) return $this->chars[$chr];
64
-		else return Tokenizer::NAME;
66
+		if (!empty($this->chars[$chr])) {
67
+			return $this->chars[$chr];
68
+		} else {
69
+			return Tokenizer::NAME;
70
+		}
65 71
 	}
66 72
 
67 73
 	public function has($offset = 0) {
@@ -85,7 +91,9 @@  discard block
 block discarded – undo
85 91
 		$pos = $this->pos + $offset;
86 92
 		$char = $this->str[$pos];
87 93
 		$end = strpos($this->str, $char, $pos+1);
88
-		while ($end !== false && $this->str[$end-1] == '\\') $end = strpos($this->str, $char, $end+1);
94
+		while ($end !== false && $this->str[$end-1] == '\\') {
95
+			$end = strpos($this->str, $char, $end+1);
96
+		}
89 97
 
90 98
 		return substr($this->str, $pos+1, $end-$pos-1);
91 99
 	}
@@ -95,7 +103,9 @@  discard block
 block discarded – undo
95 103
 		$close = strpos($this->str, $closeBracket, $open);
96 104
 
97 105
 		$cPos = $open+1;
98
-		while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) $close = strpos($this->str, $closeBracket, $close+1);
106
+		while (($cPos = strpos($this->str, $startBracket, $cPos+1)) !== false && $cPos < $close) {
107
+			$close = strpos($this->str, $closeBracket, $close+1);
108
+		}
99 109
 		return substr($this->str, $open+1, $close-$open-1);
100 110
 	}
101 111
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
 	public function next() {
54 54
 		$this->pos++;
55
-		return $this->pos < strlen((string)$this->str);
55
+		return $this->pos < strlen((string) $this->str);
56 56
 	}
57 57
 
58 58
 	public function reset() {
@@ -61,21 +61,21 @@  discard block
 block discarded – undo
61 61
 	}
62 62
 
63 63
 	public function read($offset = 0) {
64
-		return $this->str[$this->pos + $offset];
64
+		return $this->str[$this->pos+$offset];
65 65
 	}
66 66
 
67 67
 	public function identifyChar($offset = 0) {
68
-		$chr = $this->str[$this->pos + $offset];
68
+		$chr = $this->str[$this->pos+$offset];
69 69
 		if (!empty($this->chars[$chr])) return $this->chars[$chr];
70 70
 		else return Tokenizer::NAME;
71 71
 	}
72 72
 
73 73
 	public function has($offset = 0) {
74
-		return isset($this->str[$this->pos + $offset]);
74
+		return isset($this->str[$this->pos+$offset]);
75 75
 	}
76 76
 
77 77
 	public function pos($str) {
78
-		$pos = strpos($this->str,  $str, $this->pos);
78
+		$pos = strpos($this->str, $str, $this->pos);
79 79
 		return $pos ? $pos-$this->pos : false;
80 80
 	}
81 81
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	}
89 89
 
90 90
 	public function extractString($offset = 0) {
91
-		$pos = $this->pos + $offset;
91
+		$pos = $this->pos+$offset;
92 92
 		$char = $this->str[$pos];
93 93
 		$end = strpos($this->str, $char, $pos+1);
94 94
 		while ($end !== false && $this->str[$end-1] == '\\') $end = strpos($this->str, $char, $end+1);
Please login to merge, or discard this patch.
src/Parser/Tokenizer/Strings.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 			$chr = $str->read();
11 11
 			$string = $str->extractString();
12 12
 			$length = strlen($string)+1;
13
-			$string = str_replace('\\' . $chr, $chr, $string);
13
+			$string = str_replace('\\'.$chr, $chr, $string);
14 14
 			$tokens->add(['type' => Tokenizer::STRING, 'value' => $string, 'line' => $str->lineNo()]);
15 15
 			$str->move($length);
16 16
 		}
Please login to merge, or discard this patch.
src/Parser/CssToXpath.php 2 patches
Spacing   +8 added lines, -8 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 = [];
47
-		foreach($element[0]->attributes as $name => $node) {
47
+		foreach ($element[0]->attributes as $name => $node) {
48 48
 			$attributes[$name] = $node->nodeValue;
49 49
 		}
50 50
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -69,7 +69,9 @@  discard block
 block discarded – undo
69 69
 				$selector->type = $token['type'];
70 70
 				$selectors[] = $selector;
71 71
 			}
72
-			if (isset($token['value'])) $selectors[count($selectors)-1]->string = $token['value'];
72
+			if (isset($token['value'])) {
73
+				$selectors[count($selectors)-1]->string = $token['value'];
74
+			}
73 75
 		}
74 76
 		return $selectors;
75 77
 	}
@@ -79,7 +81,9 @@  discard block
 block discarded – undo
79 81
 		$selectors = $this->split($css);
80 82
 		$xpath = '/';
81 83
 		foreach ($selectors as $selector) {
82
-			if (isset($this->translators[$selector->type])) $xpath .= $this->translators[$selector->type]($selector->string, $xpath);
84
+			if (isset($this->translators[$selector->type])) {
85
+				$xpath .= $this->translators[$selector->type]($selector->string, $xpath);
86
+			}
83 87
 		}
84 88
 
85 89
 		$xpath = str_replace('/[', '/*[', $xpath);
@@ -92,11 +96,15 @@  discard block
 block discarded – undo
92 96
 		$split = $css->splitOnToken(Tokenizer::GREATER_THAN);
93 97
 		$numSplits = count($split);
94 98
 
95
-		if ($numSplits <= 1) return $css;
99
+		if ($numSplits <= 1) {
100
+			return $css;
101
+		}
96 102
 
97 103
 		for ($i = 0; $i < $numSplits; $i++) {
98 104
 			$tokens->add($split[$i]->trim());
99
-			if (isset($split[$i+1])) $tokens->add(['type' => Tokenizer::GREATER_THAN]);
105
+			if (isset($split[$i+1])) {
106
+				$tokens->add(['type' => Tokenizer::GREATER_THAN]);
107
+			}
100 108
 		}
101 109
 
102 110
 		return $tokens;
Please login to merge, or discard this patch.
src/Property/ContentPseudo/Attr.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@
 block discarded – undo
5 5
 		$implodedValue = implode('', $value);
6 6
 
7 7
 		if ($pseudoMatcher->hasFunction('before')) {
8
-			$attrValue = $implodedValue . $element->getAttribute($pseudoArgs);
8
+			$attrValue = $implodedValue.$element->getAttribute($pseudoArgs);
9 9
 		}
10 10
 		else if ($pseudoMatcher->hasFunction('after')) {
11
-			$attrValue = $element->getAttribute($pseudoArgs) . $implodedValue;
11
+			$attrValue = $element->getAttribute($pseudoArgs).$implodedValue;
12 12
 		}
13 13
 		else {
14 14
 			$attrValue = implode('', $value);
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,11 +6,9 @@
 block discarded – undo
6 6
 
7 7
 		if ($pseudoMatcher->hasFunction('before')) {
8 8
 			$attrValue = $implodedValue . $element->getAttribute($pseudoArgs);
9
-		}
10
-		else if ($pseudoMatcher->hasFunction('after')) {
9
+		} else if ($pseudoMatcher->hasFunction('after')) {
11 10
 			$attrValue = $element->getAttribute($pseudoArgs) . $implodedValue;
12
-		}
13
-		else {
11
+		} else {
14 12
 			$attrValue = implode('', $value);
15 13
 		}
16 14
 
Please login to merge, or discard this patch.