Passed
Push — master ( 90bef3...b87bd2 )
by Sebastian
11:38
created
src/Mailcode/Commands/Command.php 2 patches
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -32,44 +32,44 @@  discard block
 block discarded – undo
32 32
     const VALIDATION_UNKNOWN_COMMAND_NAME = 48304;
33 33
     const VALIDATION_INVALID_PARAMS_STATEMENT = 48305;
34 34
 
35
-   /**
36
-    * @var string
37
-    */
35
+    /**
36
+     * @var string
37
+     */
38 38
     protected $type = '';
39 39
 
40
-   /**
41
-    * @var string
42
-    */
40
+    /**
41
+     * @var string
42
+     */
43 43
     protected $paramsString = '';
44 44
     
45
-   /**
46
-    * @var string
47
-    */
45
+    /**
46
+     * @var string
47
+     */
48 48
     protected $matchedText = '';
49 49
 
50
-   /**
51
-    * @var string
52
-    */
50
+    /**
51
+     * @var string
52
+     */
53 53
     protected $hash = '';
54 54
     
55
-   /**
56
-    * @var \AppUtils\OperationResult
57
-    */
55
+    /**
56
+     * @var \AppUtils\OperationResult
57
+     */
58 58
     protected $validationResult = null;
59 59
     
60
-   /**
61
-    * @var \Mailcode\Mailcode
62
-    */
60
+    /**
61
+     * @var \Mailcode\Mailcode
62
+     */
63 63
     protected $mailcode;
64 64
     
65
-   /**
66
-    * @var \Mailcode\Mailcode_Parser_Statement
67
-    */
65
+    /**
66
+     * @var \Mailcode\Mailcode_Parser_Statement
67
+     */
68 68
     protected $params;
69 69
 
70
-   /**
71
-    * @var string[] 
72
-    */
70
+    /**
71
+     * @var string[] 
72
+     */
73 73
     protected $validations = array(
74 74
         'params_empty',
75 75
         'params_keywords',
@@ -78,24 +78,24 @@  discard block
 block discarded – undo
78 78
         'type_unsupported'
79 79
     );
80 80
     
81
-   /**
82
-    * @var string
83
-    */
81
+    /**
82
+     * @var string
83
+     */
84 84
     protected $comment = '';
85 85
     
86
-   /**
87
-    * @var Mailcode_Commands_LogicKeywords|NULL
88
-    */
86
+    /**
87
+     * @var Mailcode_Commands_LogicKeywords|NULL
88
+     */
89 89
     protected $logicKeywords;
90 90
     
91
-   /**
92
-    * @var Mailcode_Parser_Statement_Validator
93
-    */
91
+    /**
92
+     * @var Mailcode_Parser_Statement_Validator
93
+     */
94 94
     protected $validator;
95 95
     
96
-   /**
97
-    * @var boolean
98
-    */
96
+    /**
97
+     * @var boolean
98
+     */
99 99
     private $validated = false;
100 100
     
101 101
     public function __construct(string $type='', string $paramsString='', string $matchedText='')
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
         
115 115
     }
116 116
     
117
-   /**
118
-    * @return string The ID of the command = the name of the command class file.
119
-    */
117
+    /**
118
+     * @return string The ID of the command = the name of the command class file.
119
+     */
120 120
     public function getID() : string
121 121
     {
122 122
         // account for commands with types: If_Variable should still return If.
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
         return array_shift($tokens);
126 126
     }
127 127
     
128
-   /**
129
-    * Sets an optional comment that is not used anywhere, but
130
-    * can be used by the application to track why a command is
131
-    * used somewhere. 
132
-    * 
133
-    * @param string $comment
134
-    * @return Mailcode_Commands_Command
135
-    */
128
+    /**
129
+     * Sets an optional comment that is not used anywhere, but
130
+     * can be used by the application to track why a command is
131
+     * used somewhere. 
132
+     * 
133
+     * @param string $comment
134
+     * @return Mailcode_Commands_Command
135
+     */
136 136
     public function setComment(string $comment) : Mailcode_Commands_Command
137 137
     {
138 138
         $this->comment = $comment;
@@ -140,34 +140,34 @@  discard block
 block discarded – undo
140 140
         return $this;
141 141
     }
142 142
     
143
-   /**
144
-    * Retrieves the previously set comment, if any.
145
-    * 
146
-    * @return string
147
-    */
143
+    /**
144
+     * Retrieves the previously set comment, if any.
145
+     * 
146
+     * @return string
147
+     */
148 148
     public function getComment() : string
149 149
     {
150 150
         return $this->comment;
151 151
     }
152 152
     
153
-   /**
154
-    * Checks whether this is a dummy command, which is only
155
-    * used to access information on the command type. It cannot
156
-    * be used as an actual live command.
157
-    * 
158
-    * @return bool
159
-    */
153
+    /**
154
+     * Checks whether this is a dummy command, which is only
155
+     * used to access information on the command type. It cannot
156
+     * be used as an actual live command.
157
+     * 
158
+     * @return bool
159
+     */
160 160
     public function isDummy() : bool
161 161
     {
162 162
         return $this->type === '__dummy';
163 163
     }
164 164
     
165
-   /**
166
-    * Retrieves a hash of the actual matched command string,
167
-    * which is used in collections to detect duplicate commands.
168
-    * 
169
-    * @return string
170
-    */
165
+    /**
166
+     * Retrieves a hash of the actual matched command string,
167
+     * which is used in collections to detect duplicate commands.
168
+     * 
169
+     * @return string
170
+     */
171 171
     public function getHash() : string
172 172
     {
173 173
         $this->requireNonDummy();
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
         return $this->validationResult->isValid();
262 262
     }
263 263
     
264
-   /**
265
-    * @return string[]
266
-    */
264
+    /**
265
+     * @return string[]
266
+     */
267 267
     abstract protected function getValidations() : array;
268 268
     
269 269
     protected function validateSyntax_params_empty() : void
@@ -422,12 +422,12 @@  discard block
 block discarded – undo
422 422
     
423 423
     abstract public function supportsType() : bool;
424 424
     
425
-   /**
426
-    * Whether the command allows using logic keywords like "and:" or "or:"
427
-    * in the command parameters.
428
-    * 
429
-    * @return bool
430
-    */
425
+    /**
426
+     * Whether the command allows using logic keywords like "and:" or "or:"
427
+     * in the command parameters.
428
+     * 
429
+     * @return bool
430
+     */
431 431
     abstract public function supportsLogicKeywords() : bool;
432 432
     
433 433
     abstract public function generatesContent() : bool;
@@ -473,22 +473,22 @@  discard block
 block discarded – undo
473 473
         return $normalizer->normalize();
474 474
     }
475 475
     
476
-   /**
477
-    * Retrieves the names of all the command's supported types: the part
478
-    * between the command name and the colon. Example: {command type: params}.
479
-    * 
480
-    * @return string[]
481
-    */
476
+    /**
477
+     * Retrieves the names of all the command's supported types: the part
478
+     * between the command name and the colon. Example: {command type: params}.
479
+     * 
480
+     * @return string[]
481
+     */
482 482
     public function getSupportedTypes() : array
483 483
     {
484 484
         return array();
485 485
     }
486 486
     
487
-   /**
488
-    * Retrieves all variable names used in the command.
489
-    * 
490
-    * @return Mailcode_Variables_Collection_Regular
491
-    */
487
+    /**
488
+     * Retrieves all variable names used in the command.
489
+     * 
490
+     * @return Mailcode_Variables_Collection_Regular
491
+     */
492 492
     public function getVariables() : Mailcode_Variables_Collection_Regular
493 493
     {
494 494
         return Mailcode::create()->findVariables($this->paramsString);
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     */
99 99
     private $validated = false;
100 100
     
101
-    public function __construct(string $type='', string $paramsString='', string $matchedText='')
101
+    public function __construct(string $type = '', string $paramsString = '', string $matchedText = '')
102 102
     {
103 103
         $this->type = $type;
104 104
         $this->paramsString = html_entity_decode($paramsString);
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     {
173 173
         $this->requireNonDummy();
174 174
         
175
-        if($this->hash === '') {
175
+        if ($this->hash === '') {
176 176
             $this->hash = md5($this->matchedText);
177 177
         }
178 178
         
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     
182 182
     protected function requireNonDummy() : void
183 183
     {
184
-        if(!$this->isDummy())
184
+        if (!$this->isDummy())
185 185
         {
186 186
             return;
187 187
         }
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     
201 201
     protected function validate() : \AppUtils\OperationResult
202 202
     {
203
-        if(!$this->validated)
203
+        if (!$this->validated)
204 204
         {
205 205
             $this->requireNonDummy();
206 206
             $this->validateSyntax();
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
     
214 214
     public function getValidationResult() :  \AppUtils\OperationResult
215 215
     {
216
-        if(isset($this->validationResult)) 
216
+        if (isset($this->validationResult)) 
217 217
         {
218 218
             return $this->validationResult;
219 219
         }
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
     {
230 230
         $validations = array_merge($this->validations, $this->getValidations());
231 231
         
232
-        foreach($validations as $validation)
232
+        foreach ($validations as $validation)
233 233
         {
234 234
             // break off at the first validation issue
235
-            if(!$this->validateSyntaxMethod($validation))
235
+            if (!$this->validateSyntaxMethod($validation))
236 236
             {
237 237
                 return;
238 238
             }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     {
244 244
         $method = 'validateSyntax_'.$validation;
245 245
         
246
-        if(!method_exists($this, $method))
246
+        if (!method_exists($this, $method))
247 247
         {
248 248
             throw new Mailcode_Exception(
249 249
                 'Missing validation method ['.$validation.']',
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
     
269 269
     protected function validateSyntax_params_empty() : void
270 270
     {
271
-        if(!$this->requiresParameters())
271
+        if (!$this->requiresParameters())
272 272
         {
273 273
             return;
274 274
         }
275 275
         
276
-        if(empty($this->paramsString))
276
+        if (empty($this->paramsString))
277 277
         {
278 278
             $this->validationResult->makeError(
279 279
                 t('Parameters have to be specified.'),
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
     
286 286
     protected function validateSyntax_params_keywords() : void
287 287
     {
288
-        if(!$this->supportsLogicKeywords())
288
+        if (!$this->supportsLogicKeywords())
289 289
         {
290 290
             return;
291 291
         }
292 292
         
293 293
         $this->logicKeywords = new Mailcode_Commands_LogicKeywords($this, $this->paramsString);
294 294
         
295
-        if(!$this->logicKeywords->isValid())
295
+        if (!$this->logicKeywords->isValid())
296 296
         {
297 297
             $this->validationResult->makeError(
298 298
                 t('Invalid parameters:').' '.$this->logicKeywords->getErrorMessage(),
@@ -307,14 +307,14 @@  discard block
 block discarded – undo
307 307
     
308 308
     protected function validateSyntax_params_parse() : void
309 309
     {
310
-        if(!$this->requiresParameters())
310
+        if (!$this->requiresParameters())
311 311
         {
312 312
             return;
313 313
         }
314 314
         
315 315
         $this->params = $this->mailcode->getParser()->createStatement($this->paramsString);
316 316
         
317
-        if(!$this->params->isValid())
317
+        if (!$this->params->isValid())
318 318
         {
319 319
             $error = $this->params->getValidationResult();
320 320
             
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
     
332 332
     protected function validateSyntax_type_supported() : void
333 333
     {
334
-        if(!$this->supportsType() || empty($this->type))
334
+        if (!$this->supportsType() || empty($this->type))
335 335
         {
336 336
             return;
337 337
         }
338 338
         
339 339
         $types = $this->getSupportedTypes();
340 340
 
341
-        if(!in_array($this->type, $types))
341
+        if (!in_array($this->type, $types))
342 342
         {
343 343
             $this->validationResult->makeError(
344 344
                 t('The command addon %1$s is not supported.', $this->type).' '.
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
     
353 353
     protected function validateSyntax_type_unsupported() : void
354 354
     {
355
-        if($this->supportsType() || empty($this->type))
355
+        if ($this->supportsType() || empty($this->type))
356 356
         {
357 357
             return;
358 358
         }
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
     
371 371
     public function getType() : string
372 372
     {
373
-        if($this->supportsType())
373
+        if ($this->supportsType())
374 374
         {
375 375
             return $this->type;
376 376
         }
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
     
391 391
     public function getHighlighted() : string
392 392
     {
393
-        if(!$this->isValid())
393
+        if (!$this->isValid())
394 394
         {
395 395
             return '';
396 396
         }
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
     
402 402
     public function getParamsString() : string
403 403
     {
404
-        if($this->requiresParameters())
404
+        if ($this->requiresParameters())
405 405
         {
406 406
             return $this->paramsString;
407 407
         }
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
     
437 437
     public final function getCommandType() : string
438 438
     {
439
-        if($this instanceof Mailcode_Commands_Command_Type_Closing)
439
+        if ($this instanceof Mailcode_Commands_Command_Type_Closing)
440 440
         {
441 441
             return 'Closing';
442 442
         }
443 443
         
444
-        if($this instanceof Mailcode_Commands_Command_Type_Opening)
444
+        if ($this instanceof Mailcode_Commands_Command_Type_Opening)
445 445
         {
446 446
             return 'Opening';
447 447
         }
448 448
         
449
-        if($this instanceof Mailcode_Commands_Command_Type_Sibling)
449
+        if ($this instanceof Mailcode_Commands_Command_Type_Sibling)
450 450
         {
451 451
             return 'Sibling';
452 452
         }
453 453
         
454
-        if($this instanceof Mailcode_Commands_Command_Type_Standalone)
454
+        if ($this instanceof Mailcode_Commands_Command_Type_Standalone)
455 455
         {
456 456
             return 'Standalone';
457 457
         }
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
     
502 502
     public function getLogicKeywords() : Mailcode_Commands_LogicKeywords
503 503
     {
504
-        if($this->supportsLogicKeywords() && isset($this->logicKeywords))
504
+        if ($this->supportsLogicKeywords() && isset($this->logicKeywords))
505 505
         {
506 506
             return $this->logicKeywords;
507 507
         }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/SetVariable.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class Mailcode_Commands_Command_SetVariable extends Mailcode_Commands_Command implements Mailcode_Commands_Command_Type_Standalone
22 22
 {
23
-   /**
24
-    * @var Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL
25
-    */
23
+    /**
24
+     * @var Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL
25
+     */
26 26
     private $variableToken;
27 27
     
28 28
     public function getName() : string
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
         );
127 127
     }
128 128
     
129
-   /**
130
-    * @return Mailcode_Parser_Statement_Tokenizer_Token[]
131
-    */
129
+    /**
130
+     * @return Mailcode_Parser_Statement_Tokenizer_Token[]
131
+     */
132 132
     public function getAssignmentTokens() : array
133 133
     {
134 134
         $params = $this->params->getInfo()->getTokens();
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -76,8 +76,7 @@
 block discarded – undo
76 76
         if($val->isValid())
77 77
         {
78 78
             $this->variableToken = $val->getToken();
79
-        }
80
-        else
79
+        } else
81 80
         {
82 81
             $this->validationResult->makeError(
83 82
                 'The first parameter must be a variable name.',
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     {
74 74
         $val = $this->validator->createVariable()->setIndex(0);
75 75
         
76
-        if($val->isValid())
76
+        if ($val->isValid())
77 77
         {
78 78
             $this->variableToken = $val->getToken();
79 79
         }
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
     {
91 91
         $tokens = $this->params->getInfo()->createPruner()->limitToOperands()->getTokens();
92 92
 
93
-        foreach($tokens as $token)
93
+        foreach ($tokens as $token)
94 94
         {
95
-            if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand)
95
+            if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand)
96 96
             {
97 97
                 $this->validateOperand($token);
98 98
             }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         
109 109
         // ensure that the operand we have in the command is one of the
110 110
         // allowed ones.
111
-        if(!in_array($sign, $allowed))
111
+        if (!in_array($sign, $allowed))
112 112
         {
113 113
             $this->validationResult->makeError(
114 114
                 t('The %1$s sign is not allowed in this command.', '<code>'.$sign.'</code>'),
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     {
122 122
         $tokens = $this->getAssignmentTokens();
123 123
         
124
-        if(empty($tokens))
124
+        if (empty($tokens))
125 125
         {
126 126
             $this->validationResult->makeError(
127 127
                 t('No value assigned to the variable.'),
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     
133 133
     public function getVariable() : Mailcode_Variables_Variable
134 134
     {
135
-        if($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
135
+        if ($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
136 136
         {
137 137
             return $this->variableToken->getVariable();
138 138
         }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         $eq = array_shift($params); // equals sign
157 157
         
158 158
         // in case the equals sign was omitted.
159
-        if(!$eq instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand)
159
+        if (!$eq instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand)
160 160
         {
161 161
             array_unshift($params, $eq);
162 162
         }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
         
171 171
         $items = array();
172 172
         
173
-        foreach($tokens as $token)
173
+        foreach ($tokens as $token)
174 174
         {
175 175
             $items[] = $token->getNormalized();
176 176
         }
Please login to merge, or discard this patch.
src/Mailcode/Traits/Commands/IfVariable.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,9 +36,9 @@
 block discarded – undo
36 36
         );
37 37
     }
38 38
     
39
-   /**
40
-    * @return array<string>
41
-    */
39
+    /**
40
+     * @return array<string>
41
+     */
42 42
     protected function getAllowedOperands() : array
43 43
     {
44 44
         return Mailcode_Parser_Statement_Tokenizer_Token_Operand::getComparisonSigns();
Please login to merge, or discard this patch.
src/Mailcode/Traits/Commands/Validation/SearchTerm.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     {
34 34
         $val = $this->validator->createStringLiteral();
35 35
         
36
-        if($val->isValid())
36
+        if ($val->isValid())
37 37
         {
38 38
             $this->searchTerm = $val->getToken();
39 39
         }
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     
49 49
     public function getSearchTerm() : string
50 50
     {
51
-        if($this->searchTerm instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral)
51
+        if ($this->searchTerm instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral)
52 52
         {
53 53
             return $this->searchTerm->getNormalized();
54 54
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,8 +36,7 @@
 block discarded – undo
36 36
         if($val->isValid())
37 37
         {
38 38
             $this->searchTerm = $val->getToken();
39
-        }
40
-        else
39
+        } else
41 40
         {
42 41
             $this->validationResult->makeError(
43 42
                 t('No search term specified.'),
Please login to merge, or discard this patch.
src/Mailcode/Traits/Commands/Validation/Value.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
  */
25 25
 trait Mailcode_Traits_Commands_Validation_Value
26 26
 {
27
-   /**
28
-    * @var Mailcode_Parser_Statement_Tokenizer_ValueInterface|NULL
29
-    */
27
+    /**
28
+     * @var Mailcode_Parser_Statement_Tokenizer_ValueInterface|NULL
29
+     */
30 30
     protected $valueToken;
31 31
     
32 32
     protected function validateSyntax_value() : void
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
         }
47 47
     }
48 48
     
49
-   /**
50
-    * Retrieves the variable being compared.
51
-    *
52
-    * @return string
53
-    */
49
+    /**
50
+     * Retrieves the variable being compared.
51
+     *
52
+     * @return string
53
+     */
54 54
     public function getValue() : string
55 55
     {
56 56
         if($this->valueToken instanceof Mailcode_Parser_Statement_Tokenizer_ValueInterface)
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     {
34 34
         $var = $this->validator->createValue();
35 35
         
36
-        if($var->isValid())
36
+        if ($var->isValid())
37 37
         {
38 38
             $this->valueToken = $var->getToken();
39 39
         }
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     */
54 54
     public function getValue() : string
55 55
     {
56
-        if($this->valueToken instanceof Mailcode_Parser_Statement_Tokenizer_ValueInterface)
56
+        if ($this->valueToken instanceof Mailcode_Parser_Statement_Tokenizer_ValueInterface)
57 57
         {
58 58
             return $this->valueToken->getValue();
59 59
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,8 +36,7 @@
 block discarded – undo
36 36
         if($var->isValid())
37 37
         {
38 38
             $this->valueToken = $var->getToken();
39
-        }
40
-        else
39
+        } else
41 40
         {
42 41
             $this->validationResult->makeError(
43 42
                 t('No variable has been specified.'),
Please login to merge, or discard this patch.
src/Mailcode/Traits/Commands/Validation/Operand.php 3 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
  */
26 26
 trait Mailcode_Traits_Commands_Validation_Operand
27 27
 {
28
-   /**
29
-    * @var Mailcode_Parser_Statement_Tokenizer_Token_Operand|NULL
30
-    */
28
+    /**
29
+     * @var Mailcode_Parser_Statement_Tokenizer_Token_Operand|NULL
30
+     */
31 31
     protected $operandToken;
32 32
     
33
-   /**
34
-    * @return string[]
35
-    */
33
+    /**
34
+     * @return string[]
35
+     */
36 36
     abstract protected function getAllowedOperands() : array;
37 37
     
38 38
     protected function validateSyntax_operand() : void
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
         );
79 79
     }
80 80
     
81
-   /**
82
-    * Retrieves the operand sign.
83
-    *
84
-    * @return string
85
-    */
81
+    /**
82
+     * Retrieves the operand sign.
83
+     *
84
+     * @return string
85
+     */
86 86
     public function getSign() : string
87 87
     {
88 88
         return $this->getOperand()->getSign();
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
     {
40 40
         $var = $this->validator->createOperand();
41 41
         
42
-        if($var->isValid())
42
+        if ($var->isValid())
43 43
         {
44
-            if(in_array($var->getSign(), $this->getAllowedOperands()))
44
+            if (in_array($var->getSign(), $this->getAllowedOperands()))
45 45
             {
46 46
                 $this->operandToken = $var->getToken();
47 47
             }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     
67 67
     public function getOperand() : Mailcode_Parser_Statement_Tokenizer_Token_Operand
68 68
     {
69
-        if($this->operandToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand)
69
+        if ($this->operandToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand)
70 70
         {
71 71
             return $this->operandToken;
72 72
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,8 +44,7 @@  discard block
 block discarded – undo
44 44
             if(in_array($var->getSign(), $this->getAllowedOperands()))
45 45
             {
46 46
                 $this->operandToken = $var->getToken();
47
-            }
48
-            else
47
+            } else
49 48
             {
50 49
                 $this->validationResult->makeError(
51 50
                     t('Invalid operand %1$s.', $var->getSign()).' '.
@@ -54,8 +53,7 @@  discard block
 block discarded – undo
54 53
                     Mailcode_Commands_CommonConstants::VALIDATION_INVALID_OPERAND
55 54
                 );
56 55
             }
57
-        }
58
-        else
56
+        } else
59 57
         {
60 58
             $this->validationResult->makeError(
61 59
                 t('No operand has been specified.'),
Please login to merge, or discard this patch.
src/Mailcode/Traits/Commands/Validation/Variable.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
  */
25 25
 trait Mailcode_Traits_Commands_Validation_Variable
26 26
 {
27
-   /**
28
-    * @var Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL
29
-    */
27
+    /**
28
+     * @var Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL
29
+     */
30 30
     protected $variableToken;
31 31
     
32 32
     protected function validateSyntax_variable() : void
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
         }
47 47
     }
48 48
     
49
-   /**
50
-    * Retrieves the variable being compared.
51
-    *
52
-    * @return Mailcode_Variables_Variable
53
-    */
49
+    /**
50
+     * Retrieves the variable being compared.
51
+     *
52
+     * @return Mailcode_Variables_Variable
53
+     */
54 54
     public function getVariable() : Mailcode_Variables_Variable
55 55
     {
56 56
         if($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable)
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,8 +36,7 @@
 block discarded – undo
36 36
         if($var->isValid())
37 37
         {
38 38
             $this->variableToken = $var->getToken();
39
-        }
40
-        else
39
+        } else
41 40
         {
42 41
             $this->validationResult->makeError(
43 42
                 t('No variable has been specified.'),
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement/Info/Pruner.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -22,19 +22,19 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class Mailcode_Parser_Statement_Info_Pruner
24 24
 {
25
-   /**
26
-    * @var Mailcode_Parser_Statement_Info
27
-    */
25
+    /**
26
+     * @var Mailcode_Parser_Statement_Info
27
+     */
28 28
     private $info;
29 29
     
30
-   /**
31
-    * @var string[]
32
-    */
30
+    /**
31
+     * @var string[]
32
+     */
33 33
     private $exclude = array();
34 34
     
35
-   /**
36
-    * @var string[]
37
-    */
35
+    /**
36
+     * @var string[]
37
+     */
38 38
     private $classNames = array();
39 39
     
40 40
     public function __construct(Mailcode_Parser_Statement_Info $info)
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
         return $this;
75 75
     }
76 76
     
77
-   /**
78
-    * Retrieves all tokens in the statement matching the
79
-    * current criteria.
80
-    * 
81
-    * @return Mailcode_Parser_Statement_Tokenizer_Token[]
82
-    */
77
+    /**
78
+     * Retrieves all tokens in the statement matching the
79
+     * current criteria.
80
+     * 
81
+     * @return Mailcode_Parser_Statement_Tokenizer_Token[]
82
+     */
83 83
     public function getTokens() : array
84 84
     {
85 85
         $tokens = $this->info->getTokens();
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
     {
47 47
         $id = $token->getID();
48 48
         
49
-        if(!in_array($id, $this->exclude))
49
+        if (!in_array($id, $this->exclude))
50 50
         {
51 51
             $this->exclude[] = $id;
52 52
         }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     
67 67
     public function limitByClassName(string $className) : Mailcode_Parser_Statement_Info_Pruner
68 68
     {
69
-        if(!in_array($className, $this->classNames))
69
+        if (!in_array($className, $this->classNames))
70 70
         {
71 71
             $this->classNames[] = $className;
72 72
         }
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
         $tokens = $this->info->getTokens();
86 86
         $keep = array(); 
87 87
         
88
-        foreach($tokens as $token)
88
+        foreach ($tokens as $token)
89 89
         {
90
-            if(in_array($token->getID(), $this->exclude))
90
+            if (in_array($token->getID(), $this->exclude))
91 91
             {
92 92
                 continue;
93 93
             }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement/Tokenizer.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
     {
136 136
         $result = array();
137 137
         
138
-        foreach($this->tokensOrdered as $token)
138
+        foreach ($this->tokensOrdered as $token)
139 139
         {
140
-            if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown)
140
+            if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown)
141 141
             {
142 142
                 $result[] = $token;
143 143
             }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     {
151 151
         $unknown = $this->getUnknown();
152 152
         
153
-        if(!empty($unknown))
153
+        if (!empty($unknown))
154 154
         {
155 155
             return array_shift($unknown);
156 156
         }
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
     {
163 163
         $parts = array();
164 164
         
165
-        foreach($this->tokensOrdered as $token)
165
+        foreach ($this->tokensOrdered as $token)
166 166
         {
167 167
             $string = $token->getNormalized();
168 168
             
169
-            if($string != '')
169
+            if ($string != '')
170 170
             {
171 171
                 $parts[] = $string;
172 172
             }
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
     {
180 180
         $this->tokenized = trim($statement);
181 181
         
182
-        foreach($this->tokenCategories as $token)
182
+        foreach ($this->tokenCategories as $token)
183 183
         {
184 184
             $method = 'tokenize_'.$token;
185 185
             
186
-            if(!method_exists($this, $method))
186
+            if (!method_exists($this, $method))
187 187
             {
188 188
                 throw new Mailcode_Exception(
189 189
                     'Unknown statement token.',
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     * @param string $matchedText
208 208
     * @param mixed $subject
209 209
     */
210
-    protected function registerToken(string $type, string $matchedText, $subject=null) : void
210
+    protected function registerToken(string $type, string $matchedText, $subject = null) : void
211 211
     {
212 212
         $tokenID = $this->generateID();
213 213
         
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
     
225 225
     protected function getTokenByID(string $tokenID) : ?Mailcode_Parser_Statement_Tokenizer_Token
226 226
     {
227
-        foreach($this->tokensTemporary as $token)
227
+        foreach ($this->tokensTemporary as $token)
228 228
         {
229
-            if($token->getID() === $tokenID)
229
+            if ($token->getID() === $tokenID)
230 230
             {
231 231
                 return $token;
232 232
             }
@@ -242,9 +242,9 @@  discard block
 block discarded – undo
242 242
     
243 243
     protected function tokenize_keywords() : void
244 244
     {
245
-        foreach($this->keywords as $keyword)
245
+        foreach ($this->keywords as $keyword)
246 246
         {
247
-            if(strstr($this->tokenized, $keyword))
247
+            if (strstr($this->tokenized, $keyword))
248 248
             {
249 249
                 $this->registerToken('Keyword', $keyword);
250 250
             }
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
         // over that could not be tokenized.
259 259
         $parts = \AppUtils\ConvertHelper::explodeTrim($this->delimiter, $this->tokenized);
260 260
 
261
-        foreach($parts as $part)
261
+        foreach ($parts as $part)
262 262
         {
263 263
             $token = $this->getTokenByID($part);
264 264
             
265 265
             // if the entry is a token, simply add it.
266
-            if($token)
266
+            if ($token)
267 267
             {
268 268
                 $this->tokensOrdered[] = $token;
269 269
             }
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
     {
280 280
         $vars = Mailcode::create()->findVariables($this->tokenized)->getGroupedByHash();
281 281
         
282
-        foreach($vars as $var)
282
+        foreach ($vars as $var)
283 283
         {
284 284
             $this->registerToken('Variable', $var->getMatchedText(), $var);
285 285
         }
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
     
288 288
     protected function tokenize_operands() : void
289 289
     {
290
-        foreach($this->operands as $operand)
290
+        foreach ($this->operands as $operand)
291 291
         {
292
-            if(strstr($this->tokenized, $operand))
292
+            if (strstr($this->tokenized, $operand))
293 293
             {
294 294
                 $this->registerToken('Operand', $operand);
295 295
             }
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         $matches = array();
302 302
         preg_match_all('/"(.*)"/sxU', $this->tokenized, $matches, PREG_PATTERN_ORDER);
303 303
         
304
-        foreach($matches[0] as $match)
304
+        foreach ($matches[0] as $match)
305 305
         {
306 306
             $this->registerToken('StringLiteral', $match);
307 307
         }
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
         $matches = array();
313 313
         preg_match_all('/-*[0-9]+\s*[.,]\s*[0-9]+|-*[0-9]+/sx', $this->tokenized, $matches, PREG_PATTERN_ORDER);
314 314
         
315
-        foreach($matches[0] as $match)
315
+        foreach ($matches[0] as $match)
316 316
         {
317 317
             $this->registerToken('Number', $match);
318 318
         }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
     {
330 330
         static $alphas;
331 331
         
332
-        if(!isset($alphas))
332
+        if (!isset($alphas))
333 333
         {
334 334
             $alphas = range('A', 'Z');
335 335
         }
@@ -338,12 +338,12 @@  discard block
 block discarded – undo
338 338
         
339 339
         $result = '';
340 340
         
341
-        for($i=0; $i < $amount; $i++)
341
+        for ($i = 0; $i < $amount; $i++)
342 342
         {
343 343
             $result .= $alphas[array_rand($alphas)];
344 344
         }
345 345
         
346
-        if(!in_array($result, self::$ids))
346
+        if (!in_array($result, self::$ids))
347 347
         {
348 348
             self::$ids[] = $result;
349 349
             return $result;
Please login to merge, or discard this patch.
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 {
24 24
     const ERROR_TOKENIZE_METHOD_MISSING = 49801;
25 25
     
26
-   /**
27
-    * @var string[]
28
-    */
26
+    /**
27
+     * @var string[]
28
+     */
29 29
     protected $operands = array(
30 30
         '==',
31 31
         '<=',
@@ -40,17 +40,17 @@  discard block
 block discarded – undo
40 40
         '<'
41 41
     );
42 42
     
43
-   /**
44
-    * @var string[]
45
-    */
43
+    /**
44
+     * @var string[]
45
+     */
46 46
     protected $keywords = array(
47 47
         'in:',
48 48
         'insensitive:'
49 49
     );
50 50
     
51
-   /**
52
-    * @var string
53
-    */
51
+    /**
52
+     * @var string
53
+     */
54 54
     protected $delimiter = '§§';
55 55
     
56 56
     /**
@@ -67,19 +67,19 @@  discard block
 block discarded – undo
67 67
         'extract_tokens'
68 68
     );
69 69
     
70
-   /**
71
-    * @var Mailcode_Parser_Statement
72
-    */
70
+    /**
71
+     * @var Mailcode_Parser_Statement
72
+     */
73 73
     protected $statement;
74 74
     
75
-   /**
76
-    * @var string
77
-    */
75
+    /**
76
+     * @var string
77
+     */
78 78
     protected $tokenized;
79 79
     
80
-   /**
81
-    * @var Mailcode_Parser_Statement_Tokenizer_Token[]
82
-    */
80
+    /**
81
+     * @var Mailcode_Parser_Statement_Tokenizer_Token[]
82
+     */
83 83
     protected $tokensTemporary = array();
84 84
     
85 85
     /**
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
      */
88 88
     protected $tokensOrdered = array();
89 89
     
90
-   /**
91
-    * @var string[]
92
-    */
90
+    /**
91
+     * @var string[]
92
+     */
93 93
     protected static $ids = array();
94 94
     
95 95
     public function __construct(Mailcode_Parser_Statement $statement)
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
         $this->tokenize($statement->getStatementString());
100 100
     }
101 101
 
102
-   /**
103
-    * Retrieves all tokens detected in the statement string, in 
104
-    * the order they were found.
105
-    * 
106
-    * @return Mailcode_Parser_Statement_Tokenizer_Token[]
107
-    */
102
+    /**
103
+     * Retrieves all tokens detected in the statement string, in 
104
+     * the order they were found.
105
+     * 
106
+     * @return Mailcode_Parser_Statement_Tokenizer_Token[]
107
+     */
108 108
     public function getTokens()
109 109
     {
110 110
         return $this->tokensOrdered;
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
         return !empty($this->tokensOrdered);
116 116
     }
117 117
     
118
-   /**
119
-    * Whether there were any unknown tokens in the statement.
120
-    * 
121
-    * @return bool
122
-    */
118
+    /**
119
+     * Whether there were any unknown tokens in the statement.
120
+     * 
121
+     * @return bool
122
+     */
123 123
     public function hasUnknown() : bool
124 124
     {
125 125
         $unknown = $this->getUnknown();
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
         return !empty($unknown);
128 128
     }
129 129
     
130
-   /**
131
-    * Retrieves all unknown content tokens, if any.
132
-    * 
133
-    * @return \Mailcode\Mailcode_Parser_Statement_Tokenizer_Token_Unknown[]
134
-    */
130
+    /**
131
+     * Retrieves all unknown content tokens, if any.
132
+     * 
133
+     * @return \Mailcode\Mailcode_Parser_Statement_Tokenizer_Token_Unknown[]
134
+     */
135 135
     public function getUnknown()
136 136
     {
137 137
         $result = array();
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
         }
202 202
     }
203 203
    
204
-   /**
205
-    * Registers a token to add in the statement string.
206
-    * 
207
-    * @param string $type
208
-    * @param string $matchedText
209
-    * @param mixed $subject
210
-    */
204
+    /**
205
+     * Registers a token to add in the statement string.
206
+     * 
207
+     * @param string $type
208
+     * @param string $matchedText
209
+     * @param mixed $subject
210
+     */
211 211
     protected function registerToken(string $type, string $matchedText, $subject=null) : void
212 212
     {
213 213
         $tokenID = $this->generateID();
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
         return null;
237 237
     }
238 238
     
239
-   /**
240
-    * Some WYSIWYG editors like using pretty quotes instead
241
-    * of the usual double quotes. This simply replaces all
242
-    * occurrences with the regular variant.
243
-    */
239
+    /**
240
+     * Some WYSIWYG editors like using pretty quotes instead
241
+     * of the usual double quotes. This simply replaces all
242
+     * occurrences with the regular variant.
243
+     */
244 244
     protected function tokenize_normalize_quotes() : void
245 245
     {
246 246
         $this->tokenized = str_replace(array('“', '”'), '"', $this->tokenized);
@@ -329,13 +329,13 @@  discard block
 block discarded – undo
329 329
         }
330 330
     }
331 331
     
332
-   /**
333
-    * Generates a unique alphabet-based ID without numbers
334
-    * to use as token name, to avoid conflicts with the
335
-    * numbers detection.
336
-    * 
337
-    * @return string
338
-    */
332
+    /**
333
+     * Generates a unique alphabet-based ID without numbers
334
+     * to use as token name, to avoid conflicts with the
335
+     * numbers detection.
336
+     * 
337
+     * @return string
338
+     */
339 339
     protected function generateID() : string
340 340
     {
341 341
         static $alphas;
Please login to merge, or discard this patch.