Passed
Push — master ( 827600...d1e019 )
by Sebastian
04:24
created
src/Mailcode/Parser/Safeguard/Formatter/Type/HTMLHighlighting/Location.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     {
54 54
         $pos = $this->getStartPosition();
55 55
         
56
-        if(is_bool($pos))
56
+        if (is_bool($pos))
57 57
         {
58 58
             return '';
59 59
         }
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
     {
76 76
         $tagNames = $this->getParentTags();
77 77
         
78
-        foreach($tagNames as $tagName)
78
+        foreach ($tagNames as $tagName)
79 79
         {
80
-            if($this->formatter->isTagExcluded($tagName))
80
+            if ($this->formatter->isTagExcluded($tagName))
81 81
             {
82 82
                 return true;
83 83
             }
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
         // Create a stack of all direct parent tags of the command.
100 100
         // Handles closing tags as well.
101 101
         $stack = array();
102
-        foreach($tags[2] as $idx => $tagName)
102
+        foreach ($tags[2] as $idx => $tagName)
103 103
         {
104 104
             $closing = $tags[1][$idx] === '/';
105 105
             
106
-            if($closing)
106
+            if ($closing)
107 107
             {
108 108
                 array_pop($stack);
109 109
             }
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
         
129 129
         // This check is easy: if the command is in the attribute
130 130
         // of any of the tags, we will find the command marker in there.
131
-        foreach($tags[3] as $attributes)
131
+        foreach ($tags[3] as $attributes)
132 132
         {
133
-            if(strstr($attributes, self::COMMAND_MARKER))
133
+            if (strstr($attributes, self::COMMAND_MARKER))
134 134
             {
135 135
                 return true;
136 136
             }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     */
148 148
     private function getTagAncestry() : array
149 149
     {
150
-        if($this->ancestryChecked)
150
+        if ($this->ancestryChecked)
151 151
         {
152 152
             return $this->tagAncestry;
153 153
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/Location.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -89,23 +89,23 @@  discard block
 block discarded – undo
89 89
         
90 90
         $placeholderID = $this->placeholder->getID();
91 91
         
92
-        foreach($placeholders as $placeholder)
92
+        foreach ($placeholders as $placeholder)
93 93
         {
94
-            if($placeholder->getID() === $placeholderID)
94
+            if ($placeholder->getID() === $placeholderID)
95 95
             {
96 96
                 continue;
97 97
             }
98 98
             
99 99
             $start = $this->subject->getSubstrPosition($placeholder->getReplacementText());
100 100
             
101
-            if($start === false)
101
+            if ($start === false)
102 102
             {
103 103
                 continue;
104 104
             }
105 105
             
106 106
             $end = $start + $placeholder->getReplacementLength();
107 107
             
108
-            if($position >= $start && $position <= $end)
108
+            if ($position >= $start && $position <= $end)
109 109
             {
110 110
                 return true;
111 111
             }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     {
122 122
         $start = $this->getStartPosition();
123 123
         
124
-        if($start !== false)
124
+        if ($start !== false)
125 125
         {
126 126
             return $start + $this->placeholder->getReplacementLength();
127 127
         }
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
     {
152 152
         $needle = $this->placeholder->getReplacementText();
153 153
         
154
-        if($this->subject->replaceSubstrings($needle, $replacementText))
154
+        if ($this->subject->replaceSubstrings($needle, $replacementText))
155 155
         {
156 156
             return;
157 157
         }
158 158
         
159 159
         // Complain about missing placeholders only if we
160 160
         // are not in partial mode.
161
-        if(!$this->formatter->getFormatting()->isPartial())
161
+        if (!$this->formatter->getFormatting()->isPartial())
162 162
         {
163 163
             throw new Mailcode_Exception(
164 164
                 'Could not find the placeholder to replace',
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     
174 174
     public function format() : void
175 175
     {
176
-        if($this->requiresAdjustment() && (!empty($this->prepend) || !empty($this->append)))
176
+        if ($this->requiresAdjustment() && (!empty($this->prepend) || !empty($this->append)))
177 177
         {
178 178
             $this->replaceWith(sprintf(
179 179
                 '%s%s%s',
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     */
127 127
     public function setDelimiter(string $delimiter) : Mailcode_Parser_Safeguard
128 128
     {
129
-        if(empty($delimiter))
129
+        if (empty($delimiter))
130 130
         {
131 131
             throw new Mailcode_Exception(
132 132
                 'Empty delimiter',
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
         $placeholders = $this->getPlaceholders();
177 177
         $string = $this->originalString;
178 178
         
179
-        foreach($placeholders as $placeholder)
179
+        foreach ($placeholders as $placeholder)
180 180
         {
181 181
             $pos = mb_strpos($string, $placeholder->getOriginalText());
182 182
             
183
-            if($pos === false)
183
+            if ($pos === false)
184 184
             {
185 185
                 throw new Mailcode_Exception(
186 186
                     'Placeholder original text not found',
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     */
210 210
     public function createFormatting($subject) : Mailcode_Parser_Safeguard_Formatting
211 211
     {
212
-        if(is_string($subject))
212
+        if (is_string($subject))
213 213
         {
214 214
             $subject = Mailcode::create()->createString($subject);
215 215
         }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     */
226 226
     public function getPlaceholders()
227 227
     {
228
-        if(isset($this->placeholders))
228
+        if (isset($this->placeholders))
229 229
         {
230 230
             return $this->placeholders;
231 231
         }
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
         
235 235
         $cmds = $this->getCollection()->getCommands();
236 236
         
237
-        foreach($cmds as $command)
237
+        foreach ($cmds as $command)
238 238
         {
239 239
             self::$counter++;
240 240
             
@@ -248,21 +248,21 @@  discard block
 block discarded – undo
248 248
         return $this->placeholders;
249 249
     }
250 250
     
251
-    protected function restore(string $string, bool $partial=false, bool $highlighted=false) : string
251
+    protected function restore(string $string, bool $partial = false, bool $highlighted = false) : string
252 252
     {
253
-        if(!$partial)
253
+        if (!$partial)
254 254
         {
255 255
             $this->requireValidCollection();
256 256
         }
257 257
         
258 258
         $formatting = $this->createFormatting($string);
259 259
 
260
-        if($partial)
260
+        if ($partial)
261 261
         {
262 262
             $formatting->makePartial();
263 263
         }
264 264
         
265
-        if($highlighted)
265
+        if ($highlighted)
266 266
         {
267 267
             $formatting->replaceWithHTMLHighlighting();
268 268
         }
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
     */
359 359
     public function getCollection() : Mailcode_Collection
360 360
     {
361
-        if(isset($this->collection))
361
+        if (isset($this->collection))
362 362
         {
363 363
             return $this->collection;
364 364
         }
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
     */
381 381
     protected function requireValidCollection() : void
382 382
     {
383
-        if($this->getCollection()->isValid())
383
+        if ($this->getCollection()->isValid())
384 384
         {
385 385
             return;
386 386
         }
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
     */
404 404
     public function getPlaceholderStrings() : array
405 405
     {
406
-        if(is_array($this->placeholderStrings))
406
+        if (is_array($this->placeholderStrings))
407 407
         {
408 408
             return $this->placeholderStrings;
409 409
         }
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
         
413 413
         $this->placeholderStrings = array();
414 414
         
415
-        foreach($placeholders as $placeholder)
415
+        foreach ($placeholders as $placeholder)
416 416
         {
417 417
             $this->placeholderStrings[] = $placeholder->getReplacementText();
418 418
         }
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
     {
439 439
         $placeholders = $this->getPlaceholders();
440 440
         
441
-        foreach($placeholders as $placeholder)
441
+        foreach ($placeholders as $placeholder)
442 442
         {
443
-            if($placeholder->getID() === $id)
443
+            if ($placeholder->getID() === $id)
444 444
             {
445 445
                 return $placeholder;
446 446
             }
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
     {
468 468
         $placeholders = $this->getPlaceholders();
469 469
         
470
-        foreach($placeholders as $placeholder)
470
+        foreach ($placeholders as $placeholder)
471 471
         {
472
-            if($placeholder->getReplacementText() === $string)
472
+            if ($placeholder->getReplacementText() === $string)
473 473
             {
474 474
                 return $placeholder;
475 475
             }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/ShowVariable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
71 71
     {
72 72
         $tokens = $this->params->getInfo()->getTokens();
73 73
 
74
-        if(count($tokens) > 1)
74
+        if (count($tokens) > 1)
75 75
         {
76 76
             $this->validationResult->makeError(
77 77
                 t('Unknown parameters found:').' '.
Please login to merge, or discard this patch.
src/Mailcode/Collection.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             }
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
     {
263 263
         $result = array();
264 264
 
265
-        foreach($this->commands as $command)
265
+        foreach ($this->commands as $command)
266 266
         {
267
-            if($command instanceof $className)
267
+            if ($command instanceof $className)
268 268
             {
269 269
                 $result[] = $command;
270 270
             }
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     {
278 278
         $commands = $this->getCommands();
279 279
         
280
-        if(!empty($commands))
280
+        if (!empty($commands))
281 281
         {
282 282
             return array_shift($commands);
283 283
         }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      */
105 105
     protected $translationParams = array();
106 106
 
107
-    public function __construct(string $type='', string $paramsString='', string $matchedText='')
107
+    public function __construct(string $type = '', string $paramsString = '', string $matchedText = '')
108 108
     {
109 109
         $this->type = $type;
110 110
         $this->paramsString = html_entity_decode($paramsString);
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
     {
179 179
         $this->requireNonDummy();
180 180
         
181
-        if($this->hash === '') {
181
+        if ($this->hash === '') {
182 182
             $this->hash = md5($this->matchedText);
183 183
         }
184 184
         
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
     
188 188
     protected function requireNonDummy() : void
189 189
     {
190
-        if(!$this->isDummy())
190
+        if (!$this->isDummy())
191 191
         {
192 192
             return;
193 193
         }
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     
207 207
     protected function validate() : \AppUtils\OperationResult
208 208
     {
209
-        if(!$this->validated)
209
+        if (!$this->validated)
210 210
         {
211 211
             $this->requireNonDummy();
212 212
             $this->validateSyntax();
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
     
220 220
     public function getValidationResult() :  \AppUtils\OperationResult
221 221
     {
222
-        if(isset($this->validationResult)) 
222
+        if (isset($this->validationResult)) 
223 223
         {
224 224
             return $this->validationResult;
225 225
         }
@@ -235,10 +235,10 @@  discard block
 block discarded – undo
235 235
     {
236 236
         $validations = array_merge($this->validations, $this->getValidations());
237 237
         
238
-        foreach($validations as $validation)
238
+        foreach ($validations as $validation)
239 239
         {
240 240
             // break off at the first validation issue
241
-            if(!$this->validateSyntaxMethod($validation))
241
+            if (!$this->validateSyntaxMethod($validation))
242 242
             {
243 243
                 return;
244 244
             }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
     {
250 250
         $method = 'validateSyntax_'.$validation;
251 251
         
252
-        if(!method_exists($this, $method))
252
+        if (!method_exists($this, $method))
253 253
         {
254 254
             throw new Mailcode_Exception(
255 255
                 'Missing validation method ['.$validation.']',
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
     
275 275
     protected function validateSyntax_params_empty() : void
276 276
     {
277
-        if(!$this->requiresParameters())
277
+        if (!$this->requiresParameters())
278 278
         {
279 279
             return;
280 280
         }
281 281
         
282
-        if(empty($this->paramsString))
282
+        if (empty($this->paramsString))
283 283
         {
284 284
             $this->validationResult->makeError(
285 285
                 t('Parameters have to be specified.'),
@@ -291,14 +291,14 @@  discard block
 block discarded – undo
291 291
     
292 292
     protected function validateSyntax_params_keywords() : void
293 293
     {
294
-        if(!$this->supportsLogicKeywords())
294
+        if (!$this->supportsLogicKeywords())
295 295
         {
296 296
             return;
297 297
         }
298 298
         
299 299
         $this->logicKeywords = new Mailcode_Commands_LogicKeywords($this, $this->paramsString);
300 300
         
301
-        if(!$this->logicKeywords->isValid())
301
+        if (!$this->logicKeywords->isValid())
302 302
         {
303 303
             $this->validationResult->makeError(
304 304
                 t('Invalid parameters:').' '.$this->logicKeywords->getErrorMessage(),
@@ -313,14 +313,14 @@  discard block
 block discarded – undo
313 313
     
314 314
     protected function validateSyntax_params_parse() : void
315 315
     {
316
-        if(!$this->requiresParameters())
316
+        if (!$this->requiresParameters())
317 317
         {
318 318
             return;
319 319
         }
320 320
         
321 321
         $this->params = $this->mailcode->getParser()->createStatement($this->paramsString);
322 322
         
323
-        if(!$this->params->isValid())
323
+        if (!$this->params->isValid())
324 324
         {
325 325
             $error = $this->params->getValidationResult();
326 326
             
@@ -337,14 +337,14 @@  discard block
 block discarded – undo
337 337
     
338 338
     protected function validateSyntax_type_supported() : void
339 339
     {
340
-        if(!$this->supportsType() || empty($this->type))
340
+        if (!$this->supportsType() || empty($this->type))
341 341
         {
342 342
             return;
343 343
         }
344 344
         
345 345
         $types = $this->getSupportedTypes();
346 346
 
347
-        if(!in_array($this->type, $types))
347
+        if (!in_array($this->type, $types))
348 348
         {
349 349
             $this->validationResult->makeError(
350 350
                 t('The command addon %1$s is not supported.', $this->type).' '.
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
     
359 359
     protected function validateSyntax_type_unsupported() : void
360 360
     {
361
-        if($this->supportsType() || empty($this->type))
361
+        if ($this->supportsType() || empty($this->type))
362 362
         {
363 363
             return;
364 364
         }
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
     
377 377
     public function getType() : string
378 378
     {
379
-        if($this->supportsType())
379
+        if ($this->supportsType())
380 380
         {
381 381
             return $this->type;
382 382
         }
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
     
397 397
     public function getHighlighted() : string
398 398
     {
399
-        if(!$this->isValid())
399
+        if (!$this->isValid())
400 400
         {
401 401
             return '';
402 402
         }
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
     
408 408
     public function getParamsString() : string
409 409
     {
410
-        if($this->requiresParameters())
410
+        if ($this->requiresParameters())
411 411
         {
412 412
             return $this->paramsString;
413 413
         }
@@ -442,22 +442,22 @@  discard block
 block discarded – undo
442 442
     
443 443
     public final function getCommandType() : string
444 444
     {
445
-        if($this instanceof Mailcode_Commands_Command_Type_Closing)
445
+        if ($this instanceof Mailcode_Commands_Command_Type_Closing)
446 446
         {
447 447
             return 'Closing';
448 448
         }
449 449
         
450
-        if($this instanceof Mailcode_Commands_Command_Type_Opening)
450
+        if ($this instanceof Mailcode_Commands_Command_Type_Opening)
451 451
         {
452 452
             return 'Opening';
453 453
         }
454 454
         
455
-        if($this instanceof Mailcode_Commands_Command_Type_Sibling)
455
+        if ($this instanceof Mailcode_Commands_Command_Type_Sibling)
456 456
         {
457 457
             return 'Sibling';
458 458
         }
459 459
         
460
-        if($this instanceof Mailcode_Commands_Command_Type_Standalone)
460
+        if ($this instanceof Mailcode_Commands_Command_Type_Standalone)
461 461
         {
462 462
             return 'Standalone';
463 463
         }
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
     
508 508
     public function getLogicKeywords() : Mailcode_Commands_LogicKeywords
509 509
     {
510
-        if($this->supportsLogicKeywords() && isset($this->logicKeywords))
510
+        if ($this->supportsLogicKeywords() && isset($this->logicKeywords))
511 511
         {
512 512
             return $this->logicKeywords;
513 513
         }
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
     */
542 542
     public function getTranslationParam(string $name)
543 543
     {
544
-        if(isset($this->translationParams[$name]))
544
+        if (isset($this->translationParams[$name]))
545 545
         {
546 546
             return $this->translationParams[$name];
547 547
         }
Please login to merge, or discard this patch.
src/Mailcode/Translator/Syntax/ApacheVelocity/ShowDate.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     {
53 53
         $internalFormat = $command->getTranslationParam('internal_format');
54 54
 
55
-        if(empty($internalFormat))
55
+        if (empty($internalFormat))
56 56
         {
57 57
             $internalFormat = self::DEFAULT_INTERNAL_FORMAT;
58 58
         }
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
         $chars = ConvertHelper::string2array($formatString);
71 71
         $result = array();
72 72
         
73
-        foreach($chars as $char)
73
+        foreach ($chars as $char)
74 74
         {
75
-            if(!isset($this->charTable[$char]))
75
+            if (!isset($this->charTable[$char]))
76 76
             {
77 77
                 throw new Mailcode_Translator_Exception(
78 78
                     'Unknown date format string character',
Please login to merge, or discard this patch.