@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | protected $parent = null; |
111 | 111 | |
112 | - public function __construct(string $type='', string $paramsString='', string $matchedText='') |
|
112 | + public function __construct(string $type = '', string $paramsString = '', string $matchedText = '') |
|
113 | 113 | { |
114 | 114 | $this->type = $type; |
115 | 115 | $this->paramsString = html_entity_decode($paramsString); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | { |
206 | 206 | $this->requireNonDummy(); |
207 | 207 | |
208 | - if($this->hash === '') { |
|
208 | + if ($this->hash === '') { |
|
209 | 209 | $this->hash = md5($this->matchedText); |
210 | 210 | } |
211 | 211 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | |
215 | 215 | protected function requireNonDummy() : void |
216 | 216 | { |
217 | - if(!$this->isDummy()) |
|
217 | + if (!$this->isDummy()) |
|
218 | 218 | { |
219 | 219 | return; |
220 | 220 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | protected function validate() : \AppUtils\OperationResult |
235 | 235 | { |
236 | - if(!$this->validated) |
|
236 | + if (!$this->validated) |
|
237 | 237 | { |
238 | 238 | $this->requireNonDummy(); |
239 | 239 | $this->validateSyntax(); |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | public function getValidationResult() : \AppUtils\OperationResult |
248 | 248 | { |
249 | - if(isset($this->validationResult)) |
|
249 | + if (isset($this->validationResult)) |
|
250 | 250 | { |
251 | 251 | return $this->validationResult; |
252 | 252 | } |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | { |
263 | 263 | $validations = array_merge($this->validations, $this->getValidations()); |
264 | 264 | |
265 | - foreach($validations as $validation) |
|
265 | + foreach ($validations as $validation) |
|
266 | 266 | { |
267 | 267 | // break off at the first validation issue |
268 | - if(!$this->validateSyntaxMethod($validation)) |
|
268 | + if (!$this->validateSyntaxMethod($validation)) |
|
269 | 269 | { |
270 | 270 | return; |
271 | 271 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | { |
277 | 277 | $method = 'validateSyntax_'.$validation; |
278 | 278 | |
279 | - if(!method_exists($this, $method)) |
|
279 | + if (!method_exists($this, $method)) |
|
280 | 280 | { |
281 | 281 | throw new Mailcode_Exception( |
282 | 282 | 'Missing validation method ['.$validation.']', |
@@ -301,12 +301,12 @@ discard block |
||
301 | 301 | |
302 | 302 | protected function validateSyntax_params_empty() : void |
303 | 303 | { |
304 | - if(!$this->requiresParameters()) |
|
304 | + if (!$this->requiresParameters()) |
|
305 | 305 | { |
306 | 306 | return; |
307 | 307 | } |
308 | 308 | |
309 | - if(empty($this->paramsString)) |
|
309 | + if (empty($this->paramsString)) |
|
310 | 310 | { |
311 | 311 | $this->validationResult->makeError( |
312 | 312 | t('Parameters have to be specified.'), |
@@ -318,14 +318,14 @@ discard block |
||
318 | 318 | |
319 | 319 | protected function validateSyntax_params_keywords() : void |
320 | 320 | { |
321 | - if(!$this->supportsLogicKeywords()) |
|
321 | + if (!$this->supportsLogicKeywords()) |
|
322 | 322 | { |
323 | 323 | return; |
324 | 324 | } |
325 | 325 | |
326 | 326 | $this->logicKeywords = new Mailcode_Commands_LogicKeywords($this, $this->paramsString); |
327 | 327 | |
328 | - if(!$this->logicKeywords->isValid()) |
|
328 | + if (!$this->logicKeywords->isValid()) |
|
329 | 329 | { |
330 | 330 | $this->validationResult->makeError( |
331 | 331 | t('Invalid parameters:').' '.$this->logicKeywords->getErrorMessage(), |
@@ -340,14 +340,14 @@ discard block |
||
340 | 340 | |
341 | 341 | protected function validateSyntax_params_parse() : void |
342 | 342 | { |
343 | - if(!$this->requiresParameters()) |
|
343 | + if (!$this->requiresParameters()) |
|
344 | 344 | { |
345 | 345 | return; |
346 | 346 | } |
347 | 347 | |
348 | 348 | $this->params = $this->mailcode->getParser()->createStatement($this->paramsString); |
349 | 349 | |
350 | - if(!$this->params->isValid()) |
|
350 | + if (!$this->params->isValid()) |
|
351 | 351 | { |
352 | 352 | $error = $this->params->getValidationResult(); |
353 | 353 | |
@@ -364,14 +364,14 @@ discard block |
||
364 | 364 | |
365 | 365 | protected function validateSyntax_type_supported() : void |
366 | 366 | { |
367 | - if(!$this->supportsType() || empty($this->type)) |
|
367 | + if (!$this->supportsType() || empty($this->type)) |
|
368 | 368 | { |
369 | 369 | return; |
370 | 370 | } |
371 | 371 | |
372 | 372 | $types = $this->getSupportedTypes(); |
373 | 373 | |
374 | - if(!in_array($this->type, $types)) |
|
374 | + if (!in_array($this->type, $types)) |
|
375 | 375 | { |
376 | 376 | $this->validationResult->makeError( |
377 | 377 | t('The command addon %1$s is not supported.', $this->type).' '. |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | |
386 | 386 | protected function validateSyntax_type_unsupported() : void |
387 | 387 | { |
388 | - if($this->supportsType() || empty($this->type)) |
|
388 | + if ($this->supportsType() || empty($this->type)) |
|
389 | 389 | { |
390 | 390 | return; |
391 | 391 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | |
404 | 404 | public function getType() : string |
405 | 405 | { |
406 | - if($this->supportsType()) |
|
406 | + if ($this->supportsType()) |
|
407 | 407 | { |
408 | 408 | return $this->type; |
409 | 409 | } |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | |
424 | 424 | public function getHighlighted() : string |
425 | 425 | { |
426 | - if(!$this->isValid()) |
|
426 | + if (!$this->isValid()) |
|
427 | 427 | { |
428 | 428 | return ''; |
429 | 429 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | |
435 | 435 | public function getParamsString() : string |
436 | 436 | { |
437 | - if($this->requiresParameters()) |
|
437 | + if ($this->requiresParameters()) |
|
438 | 438 | { |
439 | 439 | return $this->paramsString; |
440 | 440 | } |
@@ -469,22 +469,22 @@ discard block |
||
469 | 469 | |
470 | 470 | public final function getCommandType() : string |
471 | 471 | { |
472 | - if($this instanceof Mailcode_Commands_Command_Type_Closing) |
|
472 | + if ($this instanceof Mailcode_Commands_Command_Type_Closing) |
|
473 | 473 | { |
474 | 474 | return 'Closing'; |
475 | 475 | } |
476 | 476 | |
477 | - if($this instanceof Mailcode_Commands_Command_Type_Opening) |
|
477 | + if ($this instanceof Mailcode_Commands_Command_Type_Opening) |
|
478 | 478 | { |
479 | 479 | return 'Opening'; |
480 | 480 | } |
481 | 481 | |
482 | - if($this instanceof Mailcode_Commands_Command_Type_Sibling) |
|
482 | + if ($this instanceof Mailcode_Commands_Command_Type_Sibling) |
|
483 | 483 | { |
484 | 484 | return 'Sibling'; |
485 | 485 | } |
486 | 486 | |
487 | - if($this instanceof Mailcode_Commands_Command_Type_Standalone) |
|
487 | + if ($this instanceof Mailcode_Commands_Command_Type_Standalone) |
|
488 | 488 | { |
489 | 489 | return 'Standalone'; |
490 | 490 | } |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | |
535 | 535 | public function getLogicKeywords() : Mailcode_Commands_LogicKeywords |
536 | 536 | { |
537 | - if($this->supportsLogicKeywords() && isset($this->logicKeywords)) |
|
537 | + if ($this->supportsLogicKeywords() && isset($this->logicKeywords)) |
|
538 | 538 | { |
539 | 539 | return $this->logicKeywords; |
540 | 540 | } |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | */ |
569 | 569 | public function getTranslationParam(string $name) |
570 | 570 | { |
571 | - if(isset($this->translationParams[$name])) |
|
571 | + if (isset($this->translationParams[$name])) |
|
572 | 572 | { |
573 | 573 | return $this->translationParams[$name]; |
574 | 574 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | { |
34 | 34 | $var = $this->validator->createVariable(); |
35 | 35 | |
36 | - if($var->isValid()) |
|
36 | + if ($var->isValid()) |
|
37 | 37 | { |
38 | 38 | $this->variableToken = $var->getToken(); |
39 | 39 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function getVariable() : Mailcode_Variables_Variable |
55 | 55 | { |
56 | - if($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) |
|
56 | + if ($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) |
|
57 | 57 | { |
58 | 58 | return $this->variableToken->getVariable(); |
59 | 59 | } |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | { |
102 | 102 | $parent = $subject->getParent(); |
103 | 103 | |
104 | - if($parent === null) |
|
104 | + if ($parent === null) |
|
105 | 105 | { |
106 | 106 | return null; |
107 | 107 | } |
108 | 108 | |
109 | - if($parent instanceof Mailcode_Commands_Command_For) |
|
109 | + if ($parent instanceof Mailcode_Commands_Command_For) |
|
110 | 110 | { |
111 | 111 | return $parent; |
112 | 112 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | public function setTemplate(string $template) : Mailcode_Parser_Safeguard_Formatter_Type_MarkVariables |
62 | 62 | { |
63 | - if(substr_count($template, '%s') !== 1) |
|
63 | + if (substr_count($template, '%s') !== 1) |
|
64 | 64 | { |
65 | 65 | throw new Mailcode_Exception( |
66 | 66 | 'Invalid tag template', |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $parts = explode('%s', $this->getTemplate()); |
102 | 102 | $tag = array_shift($parts); |
103 | 103 | |
104 | - if($this->templateMode === self::TEMPLATE_MODE_INLINE) |
|
104 | + if ($this->templateMode === self::TEMPLATE_MODE_INLINE) |
|
105 | 105 | { |
106 | 106 | $tag = str_replace('__STYLES__', $this->getInlineStyles(), $tag); |
107 | 107 | } |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | $styles = ''; |
130 | 130 | $regex = '/\.'.self::DEFAULT_CLASS_NAME.'{([^}]+)}/'; |
131 | 131 | |
132 | - if(preg_match($regex, $this->getCSS(), $matches)) |
|
132 | + if (preg_match($regex, $this->getCSS(), $matches)) |
|
133 | 133 | { |
134 | 134 | $styles = $matches[1]; |
135 | 135 | } |
136 | 136 | |
137 | - if(empty($styles)) |
|
137 | + if (empty($styles)) |
|
138 | 138 | { |
139 | 139 | throw new Mailcode_Exception( |
140 | 140 | 'Cannot extract styles.', |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $file = MAILCODE_INSTALL_FOLDER.'/css/marked-variables.css'; |
192 | 192 | $path = realpath($file); |
193 | 193 | |
194 | - if($path !== false) |
|
194 | + if ($path !== false) |
|
195 | 195 | { |
196 | 196 | return $path; |
197 | 197 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $total = count($matches[0]); |
80 | 80 | |
81 | - for($i=0; $i < $total; $i++) |
|
81 | + for ($i = 0; $i < $total; $i++) |
|
82 | 82 | { |
83 | 83 | $match = $this->parseMatch($matches, $i); |
84 | 84 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | protected function prepareString(string $subject) : string |
92 | 92 | { |
93 | - if(!ConvertHelper::isStringHTML($subject)) |
|
93 | + if (!ConvertHelper::isStringHTML($subject)) |
|
94 | 94 | { |
95 | 95 | return $subject; |
96 | 96 | } |
@@ -140,17 +140,17 @@ discard block |
||
140 | 140 | private function handleNesting(Mailcode_Commands_Command $cmd) : void |
141 | 141 | { |
142 | 142 | // Set the command's parent from the stack, if any is present. |
143 | - if(!empty($this->stack)) |
|
143 | + if (!empty($this->stack)) |
|
144 | 144 | { |
145 | 145 | $cmd->setParent($this->stack[array_key_last($this->stack)]); |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Handle opening and closing commands, adding and removing from the stack. |
149 | - if($cmd instanceof Mailcode_Commands_Command_Type_Opening) |
|
149 | + if ($cmd instanceof Mailcode_Commands_Command_Type_Opening) |
|
150 | 150 | { |
151 | 151 | $this->stack[] = $cmd; |
152 | 152 | } |
153 | - else if($cmd instanceof Mailcode_Commands_Command_Type_Closing) |
|
153 | + else if ($cmd instanceof Mailcode_Commands_Command_Type_Closing) |
|
154 | 154 | { |
155 | 155 | array_pop($this->stack); |
156 | 156 | } |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | // 5 = parameter type command, type |
178 | 178 | // 6 = parameter type command, params |
179 | 179 | |
180 | - if(!empty($matches[1][$index])) |
|
180 | + if (!empty($matches[1][$index])) |
|
181 | 181 | { |
182 | 182 | $name = $matches[1][$index]; |
183 | 183 | } |
184 | - else if(!empty($matches[2][$index])) |
|
184 | + else if (!empty($matches[2][$index])) |
|
185 | 185 | { |
186 | 186 | $name = $matches[2][$index]; |
187 | 187 | $params = $matches[3][$index]; |
188 | 188 | } |
189 | - else if(!empty($matches[4][$index])) |
|
189 | + else if (!empty($matches[4][$index])) |
|
190 | 190 | { |
191 | 191 | $name = $matches[4][$index]; |
192 | 192 | $type = $matches[5][$index]; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | // IF type. |
40 | 40 | $method = 'translate'.$this->getIfType($command); |
41 | 41 | |
42 | - if(method_exists($this, $method)) |
|
42 | + if (method_exists($this, $method)) |
|
43 | 43 | { |
44 | 44 | return strval($this->$method($command)); |
45 | 45 | } |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | |
54 | 54 | $keywords = $command->getLogicKeywords()->getKeywords(); |
55 | 55 | |
56 | - foreach($keywords as $keyword) |
|
56 | + foreach ($keywords as $keyword) |
|
57 | 57 | { |
58 | 58 | $keyCommand = $keyword->getCommand(); |
59 | 59 | |
60 | - if($keyCommand instanceof Mailcode_Commands_IfBase) |
|
60 | + if ($keyCommand instanceof Mailcode_Commands_IfBase) |
|
61 | 61 | { |
62 | 62 | $body .= ' '.$this->getSign($keyword).' '.$this->translateBody($keyCommand); |
63 | 63 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | protected function getSign(Mailcode_Commands_LogicKeywords_Keyword $keyword) : string |
82 | 82 | { |
83 | - switch($keyword->getName()) |
|
83 | + switch ($keyword->getName()) |
|
84 | 84 | { |
85 | 85 | case 'and': |
86 | 86 | return '&&'; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | { |
104 | 104 | $sign = ''; |
105 | 105 | |
106 | - if($notEmpty) |
|
106 | + if ($notEmpty) |
|
107 | 107 | { |
108 | 108 | $sign = '!'; |
109 | 109 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | { |
120 | 120 | $params = $command->getParams(); |
121 | 121 | |
122 | - if(!$params) |
|
122 | + if (!$params) |
|
123 | 123 | { |
124 | 124 | return ''; |
125 | 125 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $test = strtolower(trim($value, '"')); |
133 | 133 | $fullName = $variable->getFullName(); |
134 | 134 | |
135 | - if(in_array($test, array('true', 'false'))) |
|
135 | + if (in_array($test, array('true', 'false'))) |
|
136 | 136 | { |
137 | 137 | $fullName .= '.toLowerCase()'; |
138 | 138 | $value = '"'.$test.'"'; |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | $varName = $variable->getFullName(); |
160 | 160 | |
161 | 161 | $opts = 's'; |
162 | - if($caseSensitive) |
|
162 | + if ($caseSensitive) |
|
163 | 163 | { |
164 | 164 | $opts = 'is'; |
165 | 165 | } |
166 | 166 | |
167 | - foreach($searchTerms as $token) |
|
167 | + foreach ($searchTerms as $token) |
|
168 | 168 | { |
169 | 169 | $parts[] = sprintf( |
170 | 170 | '%s.matches("(?%s)%s")', |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | protected function _translateSearch(string $mode, Mailcode_Variables_Variable $variable, bool $caseSensitive, string $searchTerm) : string |
181 | 181 | { |
182 | 182 | $method = $mode.'With'; |
183 | - if($caseSensitive) |
|
183 | + if ($caseSensitive) |
|
184 | 184 | { |
185 | 185 | $method = $mode.'WithIgnoreCase'; |
186 | 186 | } |