@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | public function getInfo() : Mailcode_Parser_Statement_Info |
77 | 77 | { |
78 | - if($this->info instanceof Mailcode_Parser_Statement_Info) |
|
78 | + if ($this->info instanceof Mailcode_Parser_Statement_Info) |
|
79 | 79 | { |
80 | 80 | return $this->info; |
81 | 81 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | protected function validate() : void |
89 | 89 | { |
90 | - if(!$this->tokenizer->hasTokens()) |
|
90 | + if (!$this->tokenizer->hasTokens()) |
|
91 | 91 | { |
92 | 92 | $this->result->makeError( |
93 | 93 | t('Empty statement'), |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | $unknown = $this->tokenizer->getFirstUnknown(); |
101 | 101 | |
102 | - if($unknown) |
|
102 | + if ($unknown) |
|
103 | 103 | { |
104 | 104 | $this->result->makeError( |
105 | 105 | t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')', |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard |
136 | 136 | { |
137 | - if(empty($delimiter)) |
|
137 | + if (empty($delimiter)) |
|
138 | 138 | { |
139 | 139 | throw new Mailcode_Exception( |
140 | 140 | 'Empty delimiter', |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $safe = str_replace(array_values($replaces), array_keys($replaces), $this->originalString); |
172 | 172 | |
173 | 173 | // If a formatter has been selected, let it modify the string. |
174 | - if(isset($this->formatter)) |
|
174 | + if (isset($this->formatter)) |
|
175 | 175 | { |
176 | 176 | $safe = $this->formatter->format($safe); |
177 | 177 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | { |
184 | 184 | $class = 'Mailcode\Mailcode_Parser_Safeguard_Formatter_'.$formatterID; |
185 | 185 | |
186 | - if(class_exists($class)) |
|
186 | + if (class_exists($class)) |
|
187 | 187 | { |
188 | 188 | $this->formatter = new $class($this); |
189 | 189 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | { |
210 | 210 | $formatter = $this->selectFormatter('SingleLines'); |
211 | 211 | |
212 | - if($formatter instanceof Mailcode_Parser_Safeguard_Formatter_SingleLines) |
|
212 | + if ($formatter instanceof Mailcode_Parser_Safeguard_Formatter_SingleLines) |
|
213 | 213 | { |
214 | 214 | return $formatter; |
215 | 215 | } |
@@ -231,17 +231,17 @@ discard block |
||
231 | 231 | * @param bool $highlighted |
232 | 232 | * @return string[]string |
233 | 233 | */ |
234 | - protected function getReplaces(bool $highlighted=false) : array |
|
234 | + protected function getReplaces(bool $highlighted = false) : array |
|
235 | 235 | { |
236 | 236 | $placeholders = $this->getPlaceholders(); |
237 | 237 | |
238 | 238 | $replaces = array(); |
239 | 239 | |
240 | - foreach($placeholders as $placeholder) |
|
240 | + foreach ($placeholders as $placeholder) |
|
241 | 241 | { |
242 | 242 | $replace = ''; |
243 | 243 | |
244 | - if($highlighted) |
|
244 | + if ($highlighted) |
|
245 | 245 | { |
246 | 246 | $replace = $placeholder->getHighlightedText(); |
247 | 247 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | public function getPlaceholders() |
267 | 267 | { |
268 | - if(isset($this->placeholders)) |
|
268 | + if (isset($this->placeholders)) |
|
269 | 269 | { |
270 | 270 | return $this->placeholders; |
271 | 271 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | |
275 | 275 | $cmds = $this->getCollection()->getGroupedByHash(); |
276 | 276 | |
277 | - foreach($cmds as $command) |
|
277 | + foreach ($cmds as $command) |
|
278 | 278 | { |
279 | 279 | self::$counter++; |
280 | 280 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | return $this->placeholders; |
289 | 289 | } |
290 | 290 | |
291 | - protected function restore(string $string, bool $highlighted=false) : string |
|
291 | + protected function restore(string $string, bool $highlighted = false) : string |
|
292 | 292 | { |
293 | 293 | $this->requireValidCollection(); |
294 | 294 | |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | |
297 | 297 | $placeholderStrings = array_keys($replaces); |
298 | 298 | |
299 | - foreach($placeholderStrings as $search) |
|
299 | + foreach ($placeholderStrings as $search) |
|
300 | 300 | { |
301 | - if(!strstr($string, $search)) |
|
301 | + if (!strstr($string, $search)) |
|
302 | 302 | { |
303 | 303 | throw new Mailcode_Exception( |
304 | 304 | 'Command placeholder not found', |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | */ |
357 | 357 | public function getCollection() : Mailcode_Collection |
358 | 358 | { |
359 | - if(isset($this->collection)) |
|
359 | + if (isset($this->collection)) |
|
360 | 360 | { |
361 | 361 | return $this->collection; |
362 | 362 | } |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | */ |
379 | 379 | protected function requireValidCollection() : void |
380 | 380 | { |
381 | - if($this->getCollection()->isValid()) |
|
381 | + if ($this->getCollection()->isValid()) |
|
382 | 382 | { |
383 | 383 | return; |
384 | 384 | } |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | */ |
402 | 402 | public function getPlaceholderStrings() : array |
403 | 403 | { |
404 | - if(is_array($this->placeholderStrings)) |
|
404 | + if (is_array($this->placeholderStrings)) |
|
405 | 405 | { |
406 | 406 | return $this->placeholderStrings; |
407 | 407 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | |
411 | 411 | $this->placeholderStrings = array(); |
412 | 412 | |
413 | - foreach($placeholders as $placeholder) |
|
413 | + foreach ($placeholders as $placeholder) |
|
414 | 414 | { |
415 | 415 | $this->placeholderStrings[] = $placeholder->getReplacementText(); |
416 | 416 | } |
@@ -436,9 +436,9 @@ discard block |
||
436 | 436 | { |
437 | 437 | $placeholders = $this->getPlaceholders(); |
438 | 438 | |
439 | - foreach($placeholders as $placeholder) |
|
439 | + foreach ($placeholders as $placeholder) |
|
440 | 440 | { |
441 | - if($placeholder->getID() === $id) |
|
441 | + if ($placeholder->getID() === $id) |
|
442 | 442 | { |
443 | 443 | return $placeholder; |
444 | 444 | } |
@@ -465,9 +465,9 @@ discard block |
||
465 | 465 | { |
466 | 466 | $placeholders = $this->getPlaceholders(); |
467 | 467 | |
468 | - foreach($placeholders as $placeholder) |
|
468 | + foreach ($placeholders as $placeholder) |
|
469 | 469 | { |
470 | - if($placeholder->getReplacementText() === $string) |
|
470 | + if ($placeholder->getReplacementText() === $string) |
|
471 | 471 | { |
472 | 472 | return $placeholder; |
473 | 473 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | $this->validate(); |
71 | 71 | |
72 | - if($this->variable instanceof Mailcode_Variables_Variable) |
|
72 | + if ($this->variable instanceof Mailcode_Variables_Variable) |
|
73 | 73 | { |
74 | 74 | return $this->variable; |
75 | 75 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $vars = $this->getVariables()->getGroupedByName(); |
101 | 101 | $amount = count($vars); |
102 | 102 | |
103 | - if($amount === 1) |
|
103 | + if ($amount === 1) |
|
104 | 104 | { |
105 | 105 | $this->variable = array_pop($vars); |
106 | 106 | return; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | { |
66 | 66 | $this->validate(); |
67 | 67 | |
68 | - if($this->variable instanceof Mailcode_Variables_Variable) |
|
68 | + if ($this->variable instanceof Mailcode_Variables_Variable) |
|
69 | 69 | { |
70 | 70 | return $this->variable; |
71 | 71 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | $var = $info->getVariableByIndex(0); |
97 | 97 | |
98 | - if($var) |
|
98 | + if ($var) |
|
99 | 99 | { |
100 | 100 | $this->variable = $var->getVariable(); |
101 | 101 | return; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | static $ids = array(); |
48 | 48 | |
49 | - if(empty($ids)) { |
|
49 | + if (empty($ids)) { |
|
50 | 50 | $ids = \AppUtils\FileHelper::createFileFinder(__DIR__.'/Commands/Command') |
51 | 51 | ->getPHPClassNames(); |
52 | 52 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function getAll() |
65 | 65 | { |
66 | - if(!empty($this->commands)) { |
|
66 | + if (!empty($this->commands)) { |
|
67 | 67 | return $this->commands; |
68 | 68 | } |
69 | 69 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | $result = array(); |
73 | 73 | |
74 | - foreach($ids as $id) |
|
74 | + foreach ($ids as $id) |
|
75 | 75 | { |
76 | 76 | $result[] = $this->getDummyCommand($id); |
77 | 77 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | { |
97 | 97 | static $instances = array(); |
98 | 98 | |
99 | - if(!isset($instances[$id])) |
|
99 | + if (!isset($instances[$id])) |
|
100 | 100 | { |
101 | 101 | $instances[$id] = $this->createCommand($id, '__dummy', '', ''); |
102 | 102 | } |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | { |
118 | 118 | $items = $this->getAll(); |
119 | 119 | |
120 | - foreach($items as $item) |
|
120 | + foreach ($items as $item) |
|
121 | 121 | { |
122 | - if($item->getName() === $name) { |
|
122 | + if ($item->getName() === $name) { |
|
123 | 123 | return $item->getID(); |
124 | 124 | } |
125 | 125 | } |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | { |
152 | 152 | $items = $this->getAll(); |
153 | 153 | |
154 | - foreach($items as $item) |
|
154 | + foreach ($items as $item) |
|
155 | 155 | { |
156 | - if($item->getName() === $name) { |
|
156 | + if ($item->getName() === $name) { |
|
157 | 157 | return true; |
158 | 158 | } |
159 | 159 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | { |
166 | 166 | $class = $this->resolveClassName($id, $type); |
167 | 167 | |
168 | - if(!class_exists($class)) |
|
168 | + if (!class_exists($class)) |
|
169 | 169 | { |
170 | 170 | throw new Mailcode_Exception( |
171 | 171 | 'No such command', |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | |
188 | 188 | $dummy = $this->getDummyCommand($id); |
189 | 189 | |
190 | - if($dummy->supportsType()) |
|
190 | + if ($dummy->supportsType()) |
|
191 | 191 | { |
192 | - if(empty($type)) |
|
192 | + if (empty($type)) |
|
193 | 193 | { |
194 | 194 | $type = $dummy->getDefaultType(); |
195 | 195 | } |
@@ -209,13 +209,13 @@ discard block |
||
209 | 209 | */ |
210 | 210 | private function getDummyCommand(string $id) : Mailcode_Commands_Command |
211 | 211 | { |
212 | - if(!isset(self::$dummyCommands[$id])) |
|
212 | + if (!isset(self::$dummyCommands[$id])) |
|
213 | 213 | { |
214 | 214 | $class = 'Mailcode\Mailcode_Commands_Command_'.$id; |
215 | 215 | self::$dummyCommands[$id] = new $class('__dummy'); |
216 | 216 | } |
217 | 217 | |
218 | - if(self::$dummyCommands[$id] instanceof Mailcode_Commands_Command) |
|
218 | + if (self::$dummyCommands[$id] instanceof Mailcode_Commands_Command) |
|
219 | 219 | { |
220 | 220 | return self::$dummyCommands[$id]; |
221 | 221 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | $var = $info->getVariableByIndex(0); |
55 | 55 | |
56 | - if($var !== null) |
|
56 | + if ($var !== null) |
|
57 | 57 | { |
58 | 58 | $this->variableToken = $var; |
59 | 59 | return; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | $operand = $info->getOperandByIndex(1); |
73 | 73 | |
74 | - if($operand === null) |
|
74 | + if ($operand === null) |
|
75 | 75 | { |
76 | 76 | $this->validationResult->makeError( |
77 | 77 | t('No operand sign after the variable name.'), |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | return; |
82 | 82 | } |
83 | 83 | |
84 | - if(!$operand->isComparator()) |
|
84 | + if (!$operand->isComparator()) |
|
85 | 85 | { |
86 | 86 | $this->validationResult->makeError( |
87 | 87 | t('The operand sign is not a comparison operand.'), |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | $token = $info->getTokenByIndex(2); |
102 | 102 | |
103 | - if($token === null) |
|
103 | + if ($token === null) |
|
104 | 104 | { |
105 | 105 | $this->validationResult->makeError( |
106 | 106 | t('Nothing found after the comparison operand.'), |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | return; |
111 | 111 | } |
112 | 112 | |
113 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Type_Value) |
|
113 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Type_Value) |
|
114 | 114 | { |
115 | 115 | $this->valueToken = $token; |
116 | 116 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function getVariable() : Mailcode_Variables_Variable |
132 | 132 | { |
133 | - if($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) |
|
133 | + if ($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) |
|
134 | 134 | { |
135 | 135 | return $this->variableToken->getVariable(); |
136 | 136 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function getComparator() : string |
152 | 152 | { |
153 | - if($this->comparisonToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand) |
|
153 | + if ($this->comparisonToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand) |
|
154 | 154 | { |
155 | 155 | return $this->comparisonToken->getOperand(); |
156 | 156 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function getValue() : string |
170 | 170 | { |
171 | - if($this->valueToken instanceof Mailcode_Parser_Statement_Tokenizer_Type_Value) |
|
171 | + if ($this->valueToken instanceof Mailcode_Parser_Statement_Tokenizer_Type_Value) |
|
172 | 172 | { |
173 | 173 | return $this->valueToken->getValue(); |
174 | 174 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | $variable = $info->getVariableByIndex(0); |
54 | 54 | |
55 | - if($variable !== null) |
|
55 | + if ($variable !== null) |
|
56 | 56 | { |
57 | 57 | $this->variableToken = $variable; |
58 | 58 | return; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | // first variant: variable "Search term" |
72 | 72 | $string = $info->getStringLiteralByIndex(1); |
73 | 73 | |
74 | - if($string !== null) |
|
74 | + if ($string !== null) |
|
75 | 75 | { |
76 | 76 | $this->stringToken = $string; |
77 | 77 | return; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | // second variant: variable insensitive: "Search term" |
88 | 88 | $keyword = $info->getKeywordByIndex(1); |
89 | 89 | |
90 | - if($keyword === null) |
|
90 | + if ($keyword === null) |
|
91 | 91 | { |
92 | 92 | $this->validationResult->makeError( |
93 | 93 | t('Expected a search term or the %1$s keyword after the variable name.', 'insensitive:'), |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | return; |
98 | 98 | } |
99 | 99 | |
100 | - if($keyword->getKeyword() !== 'insensitive:') |
|
100 | + if ($keyword->getKeyword() !== 'insensitive:') |
|
101 | 101 | { |
102 | 102 | $this->validationResult->makeError( |
103 | 103 | t('Invalid keyword %1$s.', $keyword->getKeyword()).' '. |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | $string = $info->getStringLiteralByIndex(2); |
121 | 121 | |
122 | - if($string !== null) |
|
122 | + if ($string !== null) |
|
123 | 123 | { |
124 | 124 | $this->stringToken = $string; |
125 | 125 | return; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function getVariable() : Mailcode_Variables_Variable |
140 | 140 | { |
141 | - if($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) |
|
141 | + if ($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) |
|
142 | 142 | { |
143 | 143 | return $this->variableToken->getVariable(); |
144 | 144 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | public function getSearchTerm() : string |
159 | 159 | { |
160 | - if($this->stringToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
160 | + if ($this->stringToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
161 | 161 | { |
162 | 162 | return $this->stringToken->getNormalized(); |
163 | 163 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | $errors = $this->errors; |
101 | 101 | |
102 | - if(!$result->isValid()) |
|
102 | + if (!$result->isValid()) |
|
103 | 103 | { |
104 | 104 | $errors[] = new Mailcode_Collection_Error_Message( |
105 | 105 | '', |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | { |
116 | 116 | $errors = $this->getErrors(); |
117 | 117 | |
118 | - if(!empty($errors)) |
|
118 | + if (!empty($errors)) |
|
119 | 119 | { |
120 | 120 | return array_shift($errors); |
121 | 121 | } |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | { |
158 | 158 | $hashes = array(); |
159 | 159 | |
160 | - foreach($this->commands as $command) |
|
160 | + foreach ($this->commands as $command) |
|
161 | 161 | { |
162 | 162 | $hash = $command->getHash(); |
163 | 163 | |
164 | - if(!isset($hashes[$hash])) |
|
164 | + if (!isset($hashes[$hash])) |
|
165 | 165 | { |
166 | 166 | $hashes[$hash] = $command; |
167 | 167 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function addCommands(array $commands) : Mailcode_Collection |
180 | 180 | { |
181 | - foreach($commands as $command) |
|
181 | + foreach ($commands as $command) |
|
182 | 182 | { |
183 | 183 | $this->addCommand($command); |
184 | 184 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | { |
198 | 198 | $collection = new Mailcode_Variables_Collection_Regular(); |
199 | 199 | |
200 | - foreach($this->commands as $command) |
|
200 | + foreach ($this->commands as $command) |
|
201 | 201 | { |
202 | 202 | $collection->mergeWith($command->getVariables()); |
203 | 203 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | public function getValidationResult() : OperationResult |
209 | 209 | { |
210 | - if($this->validationResult instanceof OperationResult) |
|
210 | + if ($this->validationResult instanceof OperationResult) |
|
211 | 211 | { |
212 | 212 | return $this->validationResult; |
213 | 213 | } |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | { |
224 | 224 | $errors = $this->getErrors(); |
225 | 225 | |
226 | - foreach($errors as $error) |
|
226 | + foreach ($errors as $error) |
|
227 | 227 | { |
228 | - if($error->getCode() === $code) |
|
228 | + if ($error->getCode() === $code) |
|
229 | 229 | { |
230 | 230 | return true; |
231 | 231 | } |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | { |
244 | 244 | $result = array(); |
245 | 245 | |
246 | - foreach($this->commands as $command) |
|
246 | + foreach ($this->commands as $command) |
|
247 | 247 | { |
248 | - if($command instanceof Mailcode_Commands_Command_ShowVariable) |
|
248 | + if ($command instanceof Mailcode_Commands_Command_ShowVariable) |
|
249 | 249 | { |
250 | 250 | $result[] = $command; |
251 | 251 | } |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | { |
259 | 259 | $commands = $this->getCommands(); |
260 | 260 | |
261 | - if(!empty($commands)) |
|
261 | + if (!empty($commands)) |
|
262 | 262 | { |
263 | 263 | return array_shift($commands); |
264 | 264 | } |