Passed
Push — master ( 2851e6...6e90f8 )
by Sebastian
05:27
created
src/Mailcode/Collection.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
     const ERROR_CANNOT_RETRIEVE_FIRST_ERROR = 52301;
26 26
     const ERROR_CANNOT_MODIFY_FINALIZED = 52302;
27 27
     
28
-   /**
29
-    * @var Mailcode_Commands_Command[]
30
-    */
28
+    /**
29
+     * @var Mailcode_Commands_Command[]
30
+     */
31 31
     protected $commands = array();
32 32
     
33 33
     /**
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
      */
36 36
     protected $errors = array();
37 37
     
38
-   /**
39
-    * @var OperationResult|NULL
40
-    */
38
+    /**
39
+     * @var OperationResult|NULL
40
+     */
41 41
     protected $validationResult;
42 42
 
43 43
     /**
@@ -77,21 +77,21 @@  discard block
 block discarded – undo
77 77
         return $this;
78 78
     }
79 79
     
80
-   /**
81
-    * Whether there are any commands in the collection.
82
-    * 
83
-    * @return bool
84
-    */
80
+    /**
81
+     * Whether there are any commands in the collection.
82
+     * 
83
+     * @return bool
84
+     */
85 85
     public function hasCommands() : bool
86 86
     {
87 87
         return !empty($this->commands);
88 88
     }
89 89
     
90
-   /**
91
-    * Counts the amount of commands in the collection.
92
-    * 
93
-    * @return int
94
-    */
90
+    /**
91
+     * Counts the amount of commands in the collection.
92
+     * 
93
+     * @return int
94
+     */
95 95
     public function countCommands() : int
96 96
     {
97 97
         return count($this->commands);
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
         $this->commands = $keep;
130 130
     }
131 131
     
132
-   /**
133
-    * @return Mailcode_Collection_Error[]
134
-    */
132
+    /**
133
+     * @return Mailcode_Collection_Error[]
134
+     */
135 135
     public function getErrors()
136 136
     {
137 137
         $result = $this->getValidationResult();
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
         return empty($errors);
174 174
     }
175 175
     
176
-   /**
177
-    * Retrieves all commands that were detected, in the exact order
178
-    * they were found.
179
-    * 
180
-    * @return Mailcode_Commands_Command[]
181
-    */
176
+    /**
177
+     * Retrieves all commands that were detected, in the exact order
178
+     * they were found.
179
+     * 
180
+     * @return Mailcode_Commands_Command[]
181
+     */
182 182
     public function getCommands()
183 183
     {
184 184
         $this->validate();
@@ -329,10 +329,10 @@  discard block
 block discarded – undo
329 329
     }
330 330
 
331 331
     /**
332
-    * Retrieves only show variable commands in the collection, if any.
333
-    * 
334
-    * @return Mailcode_Commands_Command_ShowVariable[]
335
-    */
332
+     * Retrieves only show variable commands in the collection, if any.
333
+     * 
334
+     * @return Mailcode_Commands_Command_ShowVariable[]
335
+     */
336 336
     public function getShowVariableCommands(): array
337 337
     {
338 338
         return $this->getCommandsByClass(Mailcode_Commands_Command_ShowVariable::class);
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
         return $this->getCommandsByClass(Mailcode_Commands_Command_For::class);
347 347
     }
348 348
 
349
-   /**
350
-    * Retrieves only show date commands in the collection, if any.
351
-    *
352
-    * @return Mailcode_Commands_Command_ShowDate[]
353
-    */
349
+    /**
350
+     * Retrieves only show date commands in the collection, if any.
351
+     *
352
+     * @return Mailcode_Commands_Command_ShowDate[]
353
+     */
354 354
     public function getShowDateCommands() : array
355 355
     {
356 356
         return $this->getCommandsByClass(Mailcode_Commands_Command_ShowDate::class);
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function addCommand(Mailcode_Commands_Command $command) : Mailcode_Collection
61 61
     {
62
-        if($this->finalized)
62
+        if ($this->finalized)
63 63
         {
64 64
             throw new Mailcode_Exception(
65 65
                 'Cannot add commands to a finalized collection',
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
     {
119 119
         $keep = array();
120 120
 
121
-        foreach($this->commands as $existing)
121
+        foreach ($this->commands as $existing)
122 122
         {
123
-            if($existing !== $command)
123
+            if ($existing !== $command)
124 124
             {
125 125
                 $keep[] = $existing;
126 126
             }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         
139 139
         $errors = $this->errors;
140 140
         
141
-        if(!$result->isValid())
141
+        if (!$result->isValid())
142 142
         {
143 143
             $errors[] = new Mailcode_Collection_Error_Message(
144 144
                 '',
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
     {
155 155
         $errors = $this->getErrors();
156 156
         
157
-        if(!empty($errors))
157
+        if (!empty($errors))
158 158
         {
159 159
             return array_shift($errors);
160 160
         }
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 
202 202
         $hashes = array();
203 203
         
204
-        foreach($this->commands as $command)
204
+        foreach ($this->commands as $command)
205 205
         {
206 206
             $hash = $command->getHash();
207 207
             
208
-            if(!isset($hashes[$hash]))
208
+            if (!isset($hashes[$hash]))
209 209
             {
210 210
                 $hashes[$hash] = $command;
211 211
             }
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      */
224 224
     public function addCommands(array $commands) : Mailcode_Collection
225 225
     {
226
-        foreach($commands as $command)
226
+        foreach ($commands as $command)
227 227
         {
228 228
             $this->addCommand($command);
229 229
         }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 
247 247
         $collection = new Mailcode_Variables_Collection_Regular();
248 248
         
249
-        foreach($this->commands as $command)
249
+        foreach ($this->commands as $command)
250 250
         {
251 251
             $collection->mergeWith($command->getVariables());
252 252
         }
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 
275 275
     private function validate() : void
276 276
     {
277
-        if(isset($this->validationResult) || $this->validating)
277
+        if (isset($this->validationResult) || $this->validating)
278 278
         {
279 279
             return;
280 280
         }
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
     {
295 295
         $errors = $this->getErrors();
296 296
         
297
-        foreach($errors as $error)
297
+        foreach ($errors as $error)
298 298
         {
299
-            if($error->getCode() === $code)
299
+            if ($error->getCode() === $code)
300 300
             {
301 301
                 return true;
302 302
             }
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
     {
365 365
         $result = array();
366 366
 
367
-        foreach($this->commands as $command)
367
+        foreach ($this->commands as $command)
368 368
         {
369
-            if($command instanceof $className)
369
+            if ($command instanceof $className)
370 370
             {
371 371
                 $result[] = $command;
372 372
             }
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
     {
380 380
         $commands = $this->getCommands();
381 381
         
382
-        if(!empty($commands))
382
+        if (!empty($commands))
383 383
         {
384 384
             return array_shift($commands);
385 385
         }
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
 
402 402
     private function validateNesting() : void
403 403
     {
404
-        foreach($this->commands as $command)
404
+        foreach ($this->commands as $command)
405 405
         {
406 406
             $command->validateNesting();
407 407
 
408
-            if(!$command->isValid()) {
408
+            if (!$command->isValid()) {
409 409
                 $this->addInvalidCommand($command);
410 410
             }
411 411
         }
Please login to merge, or discard this patch.
src/Mailcode/Factory/CommandSets/Set/Misc.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     
41 41
         $this->instantiator->checkCommand($cmd);
42 42
         
43
-        if($cmd instanceof Mailcode_Commands_Command_Comment)
43
+        if ($cmd instanceof Mailcode_Commands_Command_Comment)
44 44
         {
45 45
             return $cmd;
46 46
         }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @throws Mailcode_Exception
58 58
      * @throws Mailcode_Factory_Exception
59 59
      */
60
-    public function for(string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For
60
+    public function for (string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For
61 61
     {
62 62
         $sourceVariable = '$'.ltrim($sourceVariable, '$');
63 63
         $loopVariable = '$'.ltrim($loopVariable, '$');
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         
80 80
         $this->instantiator->checkCommand($cmd);
81 81
         
82
-        if($cmd instanceof Mailcode_Commands_Command_For)
82
+        if ($cmd instanceof Mailcode_Commands_Command_For)
83 83
         {
84 84
             return $cmd;
85 85
         }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
         $this->instantiator->checkCommand($cmd);
109 109
 
110
-        if($cmd instanceof Mailcode_Commands_Command_Break)
110
+        if ($cmd instanceof Mailcode_Commands_Command_Break)
111 111
         {
112 112
             return $cmd;
113 113
         }
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
      * @throws Mailcode_Exception
128 128
      * @throws Mailcode_Factory_Exception
129 129
      */
130
-    public function mono(bool $multiline=false, array $classes=array()) : Mailcode_Commands_Command_Mono
130
+    public function mono(bool $multiline = false, array $classes = array()) : Mailcode_Commands_Command_Mono
131 131
     {
132 132
         $params = '';
133 133
         $source = '{code';
134 134
 
135
-        if($multiline) {
135
+        if ($multiline) {
136 136
             $params = 'multiline:';
137 137
             $source = '{code: multiline:';
138 138
         }
139 139
 
140
-        if(!empty($classes)) {
140
+        if (!empty($classes)) {
141 141
             $classString = sprintf('"%s"', implode(' ', $classes));
142 142
             $params .= $classString;
143 143
             $source .= $classString;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 
155 155
         $this->instantiator->checkCommand($cmd);
156 156
 
157
-        if($cmd instanceof Mailcode_Commands_Command_Mono)
157
+        if ($cmd instanceof Mailcode_Commands_Command_Mono)
158 158
         {
159 159
             return $cmd;
160 160
         }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 
180 180
         $this->instantiator->checkCommand($cmd);
181 181
 
182
-        if($cmd instanceof Mailcode_Commands_Command_Code)
182
+        if ($cmd instanceof Mailcode_Commands_Command_Code)
183 183
         {
184 184
             return $cmd;
185 185
         }
Please login to merge, or discard this patch.
src/Mailcode/Traits/Commands/Validation/Multiline.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@
 block discarded – undo
26 26
  */
27 27
 trait Mailcode_Traits_Commands_Validation_Multiline
28 28
 {
29
-   /**
30
-    * @var boolean
31
-    */
29
+    /**
30
+     * @var boolean
31
+     */
32 32
     protected $multiline = false;
33 33
 
34
-   /**
35
-    * @var Mailcode_Parser_Statement_Tokenizer_Token_Keyword|NULL
36
-    */
34
+    /**
35
+     * @var Mailcode_Parser_Statement_Tokenizer_Token_Keyword|NULL
36
+     */
37 37
     protected $multilineToken;
38 38
     
39 39
     protected function validateSyntax_multiline() : void
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         
43 43
         $this->multiline = $val->isValid();
44 44
         
45
-        if($val->isValid())
45
+        if ($val->isValid())
46 46
         {
47 47
             $this->multilineToken = $val->getToken();
48 48
         }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     
56 56
     public function getMultilineToken() : ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword
57 57
     {
58
-        if($this->multilineToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword)
58
+        if ($this->multilineToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword)
59 59
         {
60 60
             return $this->multilineToken;
61 61
         }
Please login to merge, or discard this patch.
src/Mailcode/Traits/Commands/Validation/ParseParams.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
             $this
42 42
         );
43 43
 
44
-        if(!$this->params->isValid() && $this->requiresParameters())
44
+        if (!$this->params->isValid() && $this->requiresParameters())
45 45
         {
46 46
             $error = $this->params->getValidationResult();
47 47
 
Please login to merge, or discard this patch.
src/Mailcode/Traits/Commands/Type/Sibling.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,15 +40,15 @@
 block discarded – undo
40 40
     {
41 41
         $opening = $this->getOpeningCommand();
42 42
 
43
-        if($opening === null) {
43
+        if ($opening === null) {
44 44
             return array();
45 45
         }
46 46
 
47 47
         $siblings = $opening->getSiblingCommands();
48 48
         $result = array();
49
-        foreach($siblings as $sibling)
49
+        foreach ($siblings as $sibling)
50 50
         {
51
-            if($sibling !== $this) {
51
+            if ($sibling !== $this) {
52 52
                 $result[] = $sibling;
53 53
             }
54 54
         }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/Mono.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -84,15 +84,15 @@  discard block
 block discarded – undo
84 84
     {
85 85
         $literals = $this->params->getInfo()->getStringLiterals();
86 86
 
87
-        if(empty($literals)) {
87
+        if (empty($literals)) {
88 88
             return;
89 89
         }
90 90
 
91
-        foreach($literals as $literal)
91
+        foreach ($literals as $literal)
92 92
         {
93 93
             $parts = ConvertHelper::explodeTrim(' ', $literal->getText());
94 94
 
95
-            foreach($parts as $part) {
95
+            foreach ($parts as $part) {
96 96
                 $this->addClass($part);
97 97
             }
98 98
         }
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
     {
107 107
         $className = trim($className);
108 108
 
109
-        if($this->isClassNameValid($className))
109
+        if ($this->isClassNameValid($className))
110 110
         {
111
-            if(!in_array($className, $this->classes)) {
111
+            if (!in_array($className, $this->classes)) {
112 112
                 $this->classes[] = $className;
113 113
             }
114 114
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
     public function preProcessOpening(): string
142 142
     {
143
-        if($this->isMultiline()) {
143
+        if ($this->isMultiline()) {
144 144
             return sprintf('<pre%s>', $this->renderAttributes());
145 145
         }
146 146
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
     public function preProcessClosing(): string
151 151
     {
152
-        if($this->isMultiline()) {
152
+        if ($this->isMultiline()) {
153 153
             return '</pre>';
154 154
         }
155 155
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
     private function renderAttributes() : string
160 160
     {
161
-        if(empty($this->classes)) {
161
+        if (empty($this->classes)) {
162 162
             return '';
163 163
         }
164 164
 
Please login to merge, or discard this patch.
src/Mailcode/Collection/NestingValidator.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
         
61 61
         $commands = $this->collection->getCommands();
62 62
         
63
-        foreach($commands as $command)
63
+        foreach ($commands as $command)
64 64
         {
65 65
             $method = 'validate_'.$command->getCommandType();
66 66
             
67
-            if(!method_exists($this, $method))
67
+            if (!method_exists($this, $method))
68 68
             {
69 69
                 throw new Mailcode_Exception(
70 70
                     'Unknown command type validation method.',
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
             
80 80
             $this->$method($command);
81 81
             
82
-            if(!$this->validationResult->isValid())
82
+            if (!$this->validationResult->isValid())
83 83
             {
84 84
                 break;
85 85
             }
86 86
         }
87 87
         
88
-        if($this->validationResult->isValid())
88
+        if ($this->validationResult->isValid())
89 89
         {
90 90
             $this->validate_Unclosed();
91 91
         }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     {
98 98
         $leftover = $this->getOpenCommand();
99 99
         
100
-        if($leftover === null)
100
+        if ($leftover === null)
101 101
         {
102 102
             return;
103 103
         }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     
114 114
     protected function getOpenCommand() : ?Mailcode_Commands_Command_Type_Opening
115 115
     {
116
-        if(empty($this->stack))
116
+        if (empty($this->stack))
117 117
         {
118 118
             return null;
119 119
         }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         
125 125
         $cmd = $this->stack[$idx];
126 126
         
127
-        if($cmd instanceof Mailcode_Commands_Command_Type_Opening)
127
+        if ($cmd instanceof Mailcode_Commands_Command_Type_Opening)
128 128
         {
129 129
             return $cmd;
130 130
         }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     {
149 149
         $parent = $this->getOpenCommand();
150 150
         
151
-        if($parent === null)
151
+        if ($parent === null)
152 152
         {
153 153
             $this->validationResult->makeError(
154 154
                 t(
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             return;
163 163
         }
164 164
         
165
-        if($parent->getName() !== $command->getParentName())
165
+        if ($parent->getName() !== $command->getParentName())
166 166
         {
167 167
             $this->validationResult->makeError(
168 168
                 t(
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
     
185 185
     protected function validate_Closing(Mailcode_Commands_Command_Type_Closing $command) : void
186 186
     {
187
-        if(empty($this->stack))
187
+        if (empty($this->stack))
188 188
         {
189 189
             $this->validationResult->makeError(
190 190
                 t('All open commands have already been ended.'),
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         
197 197
         $openingCommand = array_pop($this->stack);
198 198
 
199
-        if($openingCommand instanceof Mailcode_Commands_Command_Type_Opening)
199
+        if ($openingCommand instanceof Mailcode_Commands_Command_Type_Opening)
200 200
         {
201 201
             $this->log(sprintf('Closing command %s', $openingCommand->getName()));
202 202
 
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,19 +30,19 @@
 block discarded – undo
30 30
     const VALIDATION_UNCLOSED_COMMAND = 49104;
31 31
     const VALIDATION_CLOSING_NON_OPENING_COMMAND = 49105;
32 32
     
33
-   /**
34
-    * @var Mailcode_Collection
35
-    */
33
+    /**
34
+     * @var Mailcode_Collection
35
+     */
36 36
     protected $collection;
37 37
     
38
-   /**
39
-    * @var OperationResult
40
-    */
38
+    /**
39
+     * @var OperationResult
40
+     */
41 41
     protected $validationResult;
42 42
     
43
-   /**
44
-    * @var Mailcode_Commands_Command_Type[]
45
-    */
43
+    /**
44
+     * @var Mailcode_Commands_Command_Type[]
45
+     */
46 46
     protected $stack = array();
47 47
     
48 48
     public function __construct(Mailcode_Collection $collection)
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/Type/PreProcessing.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@
 block discarded – undo
25 25
     {
26 26
         $command = $location->getPlaceholder()->getCommand();
27 27
 
28
-        if($command instanceof Mailcode_Interfaces_Commands_PreProcessing)
28
+        if ($command instanceof Mailcode_Interfaces_Commands_PreProcessing)
29 29
         {
30 30
             return $command->preProcessOpening();
31 31
         }
32 32
 
33
-        if($command instanceof Mailcode_Commands_Command_Type_Closing)
33
+        if ($command instanceof Mailcode_Commands_Command_Type_Closing)
34 34
         {
35 35
             $opening = $command->getOpeningCommand();
36 36
 
37
-            if($opening instanceof Mailcode_Interfaces_Commands_PreProcessing) {
37
+            if ($opening instanceof Mailcode_Interfaces_Commands_PreProcessing) {
38 38
                 return $opening->preProcessClosing();
39 39
             }
40 40
         }
Please login to merge, or discard this patch.
src/Mailcode/Translator/Syntax/ApacheVelocity/End.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
         // This ending command is tied to a preprocessing command: Since
26 26
         // we do not want to keep these, we return an empty string to strip
27 27
         // it out.
28
-        if($command->getOpeningCommand() instanceof Mailcode_Interfaces_Commands_PreProcessing) {
28
+        if ($command->getOpeningCommand() instanceof Mailcode_Interfaces_Commands_PreProcessing) {
29 29
             return '';
30 30
         }
31 31
 
Please login to merge, or discard this patch.