Test Failed
Push — master ( 36c5b6...af11e6 )
by Sebastian
04:51
created
src/Mailcode/Factory/CommandSets/Set/Show.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         
34 34
         $this->instantiator->checkCommand($cmd);
35 35
         
36
-        if($cmd instanceof Mailcode_Commands_Command_ShowVariable)
36
+        if ($cmd instanceof Mailcode_Commands_Command_ShowVariable)
37 37
         {
38 38
             return $cmd;
39 39
         }
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
         throw $this->instantiator->exceptionUnexpectedType('ShowVariable', $cmd);
42 42
     }
43 43
     
44
-    public function date(string $variableName, string $formatString="") : Mailcode_Commands_Command_ShowDate
44
+    public function date(string $variableName, string $formatString = "") : Mailcode_Commands_Command_ShowDate
45 45
     {
46 46
         $variableName = $this->instantiator->filterVariableName($variableName);
47 47
         
48 48
         $format = '';
49
-        if(!empty($formatString))
49
+        if (!empty($formatString))
50 50
         {
51 51
             $format = sprintf(
52 52
                 ' "%s"',
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         
68 68
         $this->instantiator->checkCommand($cmd);
69 69
         
70
-        if($cmd instanceof Mailcode_Commands_Command_ShowDate)
70
+        if ($cmd instanceof Mailcode_Commands_Command_ShowDate)
71 71
         {
72 72
             return $cmd;
73 73
         }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         throw $this->instantiator->exceptionUnexpectedType('ShowDate', $cmd);
76 76
     }
77 77
 
78
-    public function number(string $variableName, string $formatString="", bool $absolute=false) : Mailcode_Commands_Command_ShowNumber
78
+    public function number(string $variableName, string $formatString = "", bool $absolute = false) : Mailcode_Commands_Command_ShowNumber
79 79
     {
80 80
         $variableName = $this->instantiator->filterVariableName($variableName);
81 81
         $paramsString = $this->compileNumberParams($formatString, $absolute);
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
         $this->instantiator->checkCommand($cmd);
95 95
 
96
-        if($cmd instanceof Mailcode_Commands_Command_ShowNumber)
96
+        if ($cmd instanceof Mailcode_Commands_Command_ShowNumber)
97 97
         {
98 98
             return $cmd;
99 99
         }
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
         throw $this->instantiator->exceptionUnexpectedType('ShowNumber', $cmd);
102 102
     }
103 103
 
104
-    private function compileNumberParams(string $formatString="", bool $absolute=false) : string
104
+    private function compileNumberParams(string $formatString = "", bool $absolute = false) : string
105 105
     {
106 106
         $params = array();
107 107
 
108
-        if(!empty($formatString))
108
+        if (!empty($formatString))
109 109
         {
110 110
             $params[] = sprintf(
111 111
                 ' "%s"',
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
             );
114 114
         }
115 115
 
116
-        if($absolute)
116
+        if ($absolute)
117 117
         {
118 118
             $params[] = ' absolute:';
119 119
         }
120 120
 
121
-        if(!empty($params))
121
+        if (!empty($params))
122 122
         {
123 123
             return ' '.implode(' ', $params);
124 124
         }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      * @throws Mailcode_Exception
137 137
      * @throws Mailcode_Factory_Exception
138 138
      */
139
-    public function phone(string $variableName, string $sourceFormat, string $urlEncoding=Mailcode_Factory::URL_ENCODING_NONE) : Mailcode_Commands_Command_ShowPhone
139
+    public function phone(string $variableName, string $sourceFormat, string $urlEncoding = Mailcode_Factory::URL_ENCODING_NONE) : Mailcode_Commands_Command_ShowPhone
140 140
     {
141 141
         $variableName = $this->instantiator->filterVariableName($variableName);
142 142
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         $this->instantiator->checkCommand($cmd);
160 160
         $this->instantiator->setEncoding($cmd, $urlEncoding);
161 161
 
162
-        if($cmd instanceof Mailcode_Commands_Command_ShowPhone)
162
+        if ($cmd instanceof Mailcode_Commands_Command_ShowPhone)
163 163
         {
164 164
             return $cmd;
165 165
         }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
         
181 181
         $this->instantiator->checkCommand($cmd);
182 182
         
183
-        if($cmd instanceof Mailcode_Commands_Command_ShowSnippet)
183
+        if ($cmd instanceof Mailcode_Commands_Command_ShowSnippet)
184 184
         {
185 185
             return $cmd;
186 186
         }
Please login to merge, or discard this patch.
src/Mailcode/Commands/LogicKeywords.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -31,27 +31,27 @@  discard block
 block discarded – undo
31 31
     public const VALIDATION_CANNOT_MIX_LOGIC_KEYWORDS = 60701;
32 32
     public const VALIDATION_INVALID_SUB_COMMAND = 60702;
33 33
     
34
-   /**
35
-    * @var string
36
-    */
34
+    /**
35
+     * @var string
36
+     */
37 37
     private $paramsString;
38 38
     
39
-   /**
40
-    * @var string[]
41
-    */
39
+    /**
40
+     * @var string[]
41
+     */
42 42
     private $names = array(
43 43
         'and', 
44 44
         'or'
45 45
     );
46 46
     
47
-   /**
48
-    * @var Mailcode_Commands_LogicKeywords_Keyword[]
49
-    */
47
+    /**
48
+     * @var Mailcode_Commands_LogicKeywords_Keyword[]
49
+     */
50 50
     private $keywords = array();
51 51
     
52
-   /**
53
-    * @var string
54
-    */
52
+    /**
53
+     * @var string
54
+     */
55 55
     private $mainParams = '';
56 56
     
57 57
     public function __construct(Mailcode_Commands_Command $command, string $paramsString)
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
         }
138 138
     }
139 139
     
140
-   /**
141
-    * @return string[]
142
-    */
140
+    /**
141
+     * @return string[]
142
+     */
143 143
     private function detectParameters() : array
144 144
     {
145 145
         $params = $this->paramsString;
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
         return $stack;
158 158
     }
159 159
 
160
-   /**
161
-    * @param string $params
162
-    * @param Mailcode_Commands_LogicKeywords_Keyword $keyword
163
-    * @param string[] $stack
164
-    * @throws Mailcode_Exception
165
-    * @return string
166
-    */
160
+    /**
161
+     * @param string $params
162
+     * @param Mailcode_Commands_LogicKeywords_Keyword $keyword
163
+     * @param string[] $stack
164
+     * @throws Mailcode_Exception
165
+     * @return string
166
+     */
167 167
     private function detectParamsKeyword(string $params, Mailcode_Commands_LogicKeywords_Keyword $keyword, array &$stack) : string
168 168
     {
169 169
         $search = $keyword->getMatchedString();
@@ -188,22 +188,22 @@  discard block
 block discarded – undo
188 188
         return $params;
189 189
     }
190 190
     
191
-   /**
192
-    * Extracts the parameters string to use for the 
193
-    * original command itself, omitting all the logic
194
-    * keywords for the sub-commands.
195
-    * 
196
-    * @return string
197
-    */
191
+    /**
192
+     * Extracts the parameters string to use for the 
193
+     * original command itself, omitting all the logic
194
+     * keywords for the sub-commands.
195
+     * 
196
+     * @return string
197
+     */
198 198
     public function getMainParamsString() : string
199 199
     {
200 200
         return $this->mainParams;
201 201
     }
202 202
     
203
-   /**
204
-    * Retrieves the detected keyword names.
205
-    * @return string[]
206
-    */
203
+    /**
204
+     * Retrieves the detected keyword names.
205
+     * @return string[]
206
+     */
207 207
     public function getDetectedNames() : array
208 208
     {
209 209
         $names = array();
@@ -221,23 +221,23 @@  discard block
 block discarded – undo
221 221
         return $names;
222 222
     }
223 223
     
224
-   /**
225
-    * Retrieves all keywords that were detected in the
226
-    * command's parameters string, if any.
227
-    * 
228
-    * @return Mailcode_Commands_LogicKeywords_Keyword[]
229
-    */
224
+    /**
225
+     * Retrieves all keywords that were detected in the
226
+     * command's parameters string, if any.
227
+     * 
228
+     * @return Mailcode_Commands_LogicKeywords_Keyword[]
229
+     */
230 230
     public function getKeywords() : array
231 231
     {
232 232
         return $this->keywords;
233 233
     }
234 234
     
235
-   /**
236
-    * Detects any keyword statements in the parameters by keyword name.
237
-    * 
238
-    * @param string $name
239
-    * @return Mailcode_Commands_LogicKeywords_Keyword[]
240
-    */
235
+    /**
236
+     * Detects any keyword statements in the parameters by keyword name.
237
+     * 
238
+     * @param string $name
239
+     * @return Mailcode_Commands_LogicKeywords_Keyword[]
240
+     */
241 241
     private function detectKeywords(string $name) : array
242 242
     {
243 243
         $regex = sprintf('/%1$s\s+([a-z\-0-9]+):|%1$s:/x', $name);
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
     
72 72
     private function parse() : void
73 73
     {
74
-        foreach($this->names as $name)
74
+        foreach ($this->names as $name)
75 75
         {
76
-            if(!stristr($this->paramsString, $name))
76
+            if (!stristr($this->paramsString, $name))
77 77
             {
78 78
                 continue;
79 79
             }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         $names = $this->getDetectedNames();
91 91
         $amount = count($names);
92 92
         
93
-        if($amount > 1)
93
+        if ($amount > 1)
94 94
         {
95 95
             $this->makeError(
96 96
                 t(
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     
111 111
     private function splitParams() : void
112 112
     {
113
-        if(empty($this->keywords))
113
+        if (empty($this->keywords))
114 114
         {
115 115
             $this->mainParams = $this->paramsString;
116 116
             
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
         
120 120
         $params = $this->detectParameters();
121 121
         
122
-        foreach($this->keywords as $keyword)
122
+        foreach ($this->keywords as $keyword)
123 123
         {
124 124
             $kParams = (string)array_shift($params);
125 125
             
126 126
             $keyword->setParamsString($kParams);
127 127
             
128
-            if(!$keyword->isValid())
128
+            if (!$keyword->isValid())
129 129
             {
130 130
                 $this->makeError(
131 131
                     t('Error #%1$s:', $keyword->getCode()).' '.$keyword->getErrorMessage(),
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         $params = $this->paramsString;
146 146
         $stack = array();
147 147
         
148
-        foreach($this->keywords as $keyword)
148
+        foreach ($this->keywords as $keyword)
149 149
         {
150 150
             $params = $this->detectParamsKeyword($params, $keyword, $stack);
151 151
         }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         $search = $keyword->getMatchedString();
170 170
         $pos = strpos($params, $search, 0);
171 171
         
172
-        if($pos === false)
172
+        if ($pos === false)
173 173
         {
174 174
             throw new Mailcode_Exception(
175 175
                 'Keyword matched string not found',
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         $length = strlen($search);
182 182
         
183 183
         $store = substr($params, 0, $pos);
184
-        $params = trim(substr($params, $pos+$length));
184
+        $params = trim(substr($params, $pos + $length));
185 185
         
186 186
         $stack[] = $store;
187 187
         
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
     {
209 209
         $names = array();
210 210
         
211
-        foreach($this->keywords as $keyword)
211
+        foreach ($this->keywords as $keyword)
212 212
         {
213 213
             $name = $keyword->getName();
214 214
             
215
-            if(!in_array($name, $names))
215
+            if (!in_array($name, $names))
216 216
             {
217 217
                 $names[] = $name;
218 218
             }
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
         $matches = array();
246 246
         preg_match_all($regex, $this->paramsString, $matches, PREG_PATTERN_ORDER);
247 247
         
248
-        if(!isset($matches[0][0]) || empty($matches[0][0]))
248
+        if (!isset($matches[0][0]) || empty($matches[0][0]))
249 249
         {
250 250
             return array();
251 251
         }
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
         $amount = count($matches[0]);
254 254
         $result = array();
255 255
         
256
-        for($i=0; $i < $amount; $i++)
256
+        for ($i = 0; $i < $amount; $i++)
257 257
         {
258 258
             $result[] = $this->createKeyword(
259 259
                 $name, 
@@ -270,22 +270,22 @@  discard block
 block discarded – undo
270 270
         return !empty($this->keywords);
271 271
     }
272 272
     
273
-    public function appendAND(string $paramsString, string $type='') : Mailcode_Commands_LogicKeywords_Keyword
273
+    public function appendAND(string $paramsString, string $type = '') : Mailcode_Commands_LogicKeywords_Keyword
274 274
     {
275 275
         return $this->appendKeyword('and', $paramsString, $type);
276 276
     }
277 277
     
278
-    public function appendOR(string $paramsString, string $type='') : Mailcode_Commands_LogicKeywords_Keyword
278
+    public function appendOR(string $paramsString, string $type = '') : Mailcode_Commands_LogicKeywords_Keyword
279 279
     {
280 280
         return $this->appendKeyword('or', $paramsString, $type);
281 281
     }
282 282
     
283
-    public function appendKeyword(string $name, string $paramsString, string $type='') : Mailcode_Commands_LogicKeywords_Keyword
283
+    public function appendKeyword(string $name, string $paramsString, string $type = '') : Mailcode_Commands_LogicKeywords_Keyword
284 284
     {
285 285
         $keyword = $this->createKeyword($name, $type);
286 286
         $keyword->setParamsString($paramsString);
287 287
         
288
-        if(!$keyword->isValid())
288
+        if (!$keyword->isValid())
289 289
         {
290 290
             throw new Mailcode_Exception(
291 291
                 'Cannot append invalid logic keyword',
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
         return $keyword;
307 307
     }
308 308
     
309
-    private function createKeyword(string $name, string $type='', string $matchedString='') : Mailcode_Commands_LogicKeywords_Keyword
309
+    private function createKeyword(string $name, string $type = '', string $matchedString = '') : Mailcode_Commands_LogicKeywords_Keyword
310 310
     {
311
-        if(empty($matchedString))
311
+        if (empty($matchedString))
312 312
         {
313 313
             $matchedString = $name;
314 314
             
315
-            if(!empty($type))
315
+            if (!empty($type))
316 316
             {
317 317
                 $matchedString .= ' '.$type;
318 318
             }
Please login to merge, or discard this patch.
src/Mailcode/Commands/Command/ShowNumber.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
     public const VALIDATION_INVALID_DECIMAL_SEPARATOR = 72209;
32 32
     public const VALIDATION_SEPARATORS_SAME_CHARACTER = 72210;
33 33
     
34
-   /**
35
-    * The default number format string.
36
-    * @var string
37
-    */
34
+    /**
35
+     * The default number format string.
36
+     * @var string
37
+     */
38 38
     private $formatString = Mailcode_Number_Info::DEFAULT_FORMAT;
39 39
 
40 40
     /**
@@ -65,16 +65,16 @@  discard block
 block discarded – undo
65 65
 
66 66
     protected function validateSyntax_check_format() : void
67 67
     {
68
-         $tokens = $this->params->getInfo()->getStringLiterals();
68
+            $tokens = $this->params->getInfo()->getStringLiterals();
69 69
          
70
-         // no format specified? Use the default one.
71
-         if(empty($tokens))
72
-         {
73
-             return;
74
-         }
75
-
76
-         $token = array_pop($tokens);
77
-         $this->parseFormatString($token->getText());
70
+            // no format specified? Use the default one.
71
+            if(empty($tokens))
72
+            {
73
+                return;
74
+            }
75
+
76
+            $token = array_pop($tokens);
77
+            $this->parseFormatString($token->getText());
78 78
     }
79 79
 
80 80
     protected function validateSyntax_absolute() : void
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
         );
108 108
     }
109 109
     
110
-   /**
111
-    * Retrieves the format string used to format the number.
112
-    * 
113
-    * @return string
114
-    */
110
+    /**
111
+     * Retrieves the format string used to format the number.
112
+     * 
113
+     * @return string
114
+     */
115 115
     public function getFormatString() : string
116 116
     {
117 117
         return $this->formatString;
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 
133 133
         if($absolute === true && !isset($this->absoluteKeyword))
134 134
         {
135
-             $this->params
136
-                 ->getInfo()
137
-                 ->addKeyword(Mailcode_Commands_Keywords::TYPE_ABSOLUTE);
135
+                $this->params
136
+                    ->getInfo()
137
+                    ->addKeyword(Mailcode_Commands_Keywords::TYPE_ABSOLUTE);
138 138
 
139
-             $this->validateSyntax_absolute();
139
+                $this->validateSyntax_absolute();
140 140
         }
141 141
 
142 142
         return $this;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
          $tokens = $this->params->getInfo()->getStringLiterals();
69 69
          
70 70
          // no format specified? Use the default one.
71
-         if(empty($tokens))
71
+         if (empty($tokens))
72 72
          {
73 73
              return;
74 74
          }
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
     {
82 82
         $keywords = $this->params->getInfo()->getKeywords();
83 83
 
84
-        foreach($keywords as $keyword)
84
+        foreach ($keywords as $keyword)
85 85
         {
86
-            if($keyword->getKeyword() === Mailcode_Commands_Keywords::TYPE_ABSOLUTE)
86
+            if ($keyword->getKeyword() === Mailcode_Commands_Keywords::TYPE_ABSOLUTE)
87 87
             {
88 88
                 $this->absoluteKeyword = $keyword;
89 89
                 break;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     {
96 96
         $result = new Mailcode_Number_Info($format);
97 97
 
98
-        if($result->isValid())
98
+        if ($result->isValid())
99 99
         {
100 100
             $this->formatString = $format;
101 101
             return;
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
 
125 125
     public function setAbsolute(bool $absolute) : Mailcode_Commands_Command_ShowNumber
126 126
     {
127
-        if($absolute === false && isset($this->absoluteKeyword))
127
+        if ($absolute === false && isset($this->absoluteKeyword))
128 128
         {
129 129
             $this->params->getInfo()->removeKeyword($this->absoluteKeyword->getKeyword());
130 130
             $this->absoluteKeyword = null;
131 131
         }
132 132
 
133
-        if($absolute === true && !isset($this->absoluteKeyword))
133
+        if ($absolute === true && !isset($this->absoluteKeyword))
134 134
         {
135 135
              $this->params
136 136
                  ->getInfo()
Please login to merge, or discard this patch.
src/Mailcode/Translator/Syntax/ApacheVelocity/ShowDate.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@
 block discarded – undo
24 24
 {
25 25
     public const ERROR_UNKNOWN_DATE_FORMAT_CHARACTER = 55501;
26 26
 
27
-   /**
28
-    * The date format used in the date variable. This is used to convert
29
-    * the native date to the format specified in the variable command.
30
-    */
27
+    /**
28
+     * The date format used in the date variable. This is used to convert
29
+     * the native date to the format specified in the variable command.
30
+     */
31 31
     public const DEFAULT_INTERNAL_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
32 32
 
33
-   /**
34
-    * @var string[]string
35
-    */
33
+    /**
34
+     * @var string[]string
35
+     */
36 36
     private $charTable = array(
37 37
         'd' => 'dd',
38 38
         'j' => 'd',
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         $internalFormat = $command->getTranslationParam('internal_format');
56 56
 
57
-        if(is_string($internalFormat) && !empty($internalFormat))
57
+        if (is_string($internalFormat) && !empty($internalFormat))
58 58
         {
59 59
             return $internalFormat;
60 60
         }
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
         $chars = ConvertHelper::string2array($formatString);
84 84
         $result = array();
85 85
         
86
-        foreach($chars as $char)
86
+        foreach ($chars as $char)
87 87
         {
88
-            if(!isset($this->charTable[$char]))
88
+            if (!isset($this->charTable[$char]))
89 89
             {
90 90
                 throw new Mailcode_Translator_Exception(
91 91
                     'Unknown date format string character',
Please login to merge, or discard this patch.
src/Mailcode/Parser/StringPreProcessor.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      */
63 63
     private function stripStyleTags() : void
64 64
     {
65
-        if(!ConvertHelper::isStringHTML($this->subject))
65
+        if (!ConvertHelper::isStringHTML($this->subject))
66 66
         {
67 67
             return;
68 68
         }
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 
77 77
     private function replaceBrackets(string $subject, string $needle) : string
78 78
     {
79
-        $replacement =  str_replace(
79
+        $replacement = str_replace(
80 80
             array('{', '}'),
81 81
             array(
82 82
                 self::LITERAL_BRACKET_LEFT_REPLACEMENT,
Please login to merge, or discard this patch.
src/Mailcode/Variables/Collection/Invalid.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
     public function add(Mailcode_Variables_Variable $variable) : Mailcode_Variables_Collection
28 28
     {
29
-        if($variable->isValid())
29
+        if ($variable->isValid())
30 30
         {
31 31
             return $this;
32 32
         }
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     {
39 39
         $first = $this->getFirst();
40 40
 
41
-        if($first)
41
+        if ($first)
42 42
         {
43 43
             return $first->getValidationResult();
44 44
         }
Please login to merge, or discard this patch.
src/Mailcode/Variables/Variable.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -32,34 +32,34 @@
 block discarded – undo
32 32
     public const VALIDATION_ERROR_PATH_UNDERSCORE = 48203;
33 33
     public const VALIDATION_ERROR_NAME_UNDERSCORE = 48204;
34 34
     
35
-   /**
36
-    * @var string
37
-    */
35
+    /**
36
+     * @var string
37
+     */
38 38
     protected string $path;
39 39
     
40
-   /**
41
-    * @var string
42
-    */
40
+    /**
41
+     * @var string
42
+     */
43 43
     protected string $name;
44 44
     
45
-   /**
46
-    * @var string
47
-    */
45
+    /**
46
+     * @var string
47
+     */
48 48
     protected string $matchedText;
49 49
     
50
-   /**
51
-    * @var string
52
-    */
50
+    /**
51
+     * @var string
52
+     */
53 53
     protected string $hash = '';
54 54
     
55
-   /**
56
-    * @var OperationResult|NULL
57
-    */
55
+    /**
56
+     * @var OperationResult|NULL
57
+     */
58 58
     protected ?OperationResult $validationResult = null;
59 59
     
60
-   /**
61
-    * @var array<string>
62
-    */
60
+    /**
61
+     * @var array<string>
62
+     */
63 63
     protected $validations = array(
64 64
         'number_path',
65 65
         'number_name',
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     private ?Mailcode_Commands_Command $command;
74 74
 
75
-    public function __construct(string $path, string $name, string $matchedText, ?Mailcode_Commands_Command $sourceCommand=null)
75
+    public function __construct(string $path, string $name, string $matchedText, ?Mailcode_Commands_Command $sourceCommand = null)
76 76
     {
77 77
         $this->path = $path;
78 78
         $this->name = $name;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     
96 96
     public function getFullName() : string
97 97
     {
98
-        if(empty($this->path))
98
+        if (empty($this->path))
99 99
         {
100 100
             return '$'.$this->name;
101 101
         }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function getUniqueName() : string
115 115
     {
116
-        if(isset($this->command))
116
+        if (isset($this->command))
117 117
         {
118 118
             return $this->getFullName().'/'.$this->command->getHash();
119 119
         }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     
139 139
     public function getHash() : string
140 140
     {
141
-        if(empty($this->hash))
141
+        if (empty($this->hash))
142 142
         {
143 143
             $this->hash = md5($this->matchedText);
144 144
         }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      */
158 158
     public function getValidationResult() : OperationResult
159 159
     {
160
-        if(isset($this->validationResult))
160
+        if (isset($this->validationResult))
161 161
         {
162 162
             return $this->validationResult;
163 163
         }
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 
172 172
     protected function validate(OperationResult $result) : void
173 173
     {
174
-        foreach($this->validations as $validation)
174
+        foreach ($this->validations as $validation)
175 175
         {
176 176
             $method = 'validate_'.$validation;
177 177
             
178
-            if(!method_exists($this, $method))
178
+            if (!method_exists($this, $method))
179 179
             {
180 180
                 throw new Mailcode_Exception(
181 181
                     'Unknown validation method',
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
     
221 221
     protected function validateNumber(string $value, int $errorCode) : void
222 222
     {
223
-        if(!is_numeric(substr($value, 0, 1)))
223
+        if (!is_numeric(substr($value, 0, 1)))
224 224
         {
225 225
             return;
226 226
         }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     protected function validateUnderscore(string $value, int $errorCode) : void
239 239
     {
240 240
         // allow empty paths
241
-        if(empty($value))
241
+        if (empty($value))
242 242
         {
243 243
             return;
244 244
         }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
         $length = strlen($value);
247 247
         
248 248
         // trimming underscores does not change the length: no underscores at start or end of string.
249
-        if(strlen(trim($value, '_')) === $length)
249
+        if (strlen(trim($value, '_')) === $length)
250 250
         {
251 251
             return;
252 252
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/PreParser.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public static function getContent(int $id) : string
113 113
     {
114
-        if(isset(self::$contents[$id]))
114
+        if (isset(self::$contents[$id]))
115 115
         {
116 116
             return self::$contents[$id];
117 117
         }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      */
135 135
     public static function clearContent(int $id) : void
136 136
     {
137
-        if(isset(self::$contents[$id]))
137
+        if (isset(self::$contents[$id]))
138 138
         {
139 139
             unset(self::$contents[$id]);
140 140
         }
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 
156 156
         $names = $this->getContentCommandNames();
157 157
 
158
-        foreach($names as $name)
158
+        foreach ($names as $name)
159 159
         {
160 160
             $this->collapseContentCommand($name);
161 161
         }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
         $commands = Mailcode::create()->getCommands()->getContentCommands();
175 175
         $result = array();
176 176
 
177
-        foreach($commands as $command)
177
+        foreach ($commands as $command)
178 178
         {
179 179
             $result[] = $command->getName();
180 180
         }
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
     {
246 246
         $this->commands = $this->detectCommands($name);
247 247
 
248
-        foreach($this->commands as $commandDef)
248
+        foreach ($this->commands as $commandDef)
249 249
         {
250 250
             $this->processCommand($commandDef);
251 251
         }
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
 
256 256
     private function validateCommandContents() : void
257 257
     {
258
-        foreach($this->commands as $command)
258
+        foreach ($this->commands as $command)
259 259
         {
260
-            if(!$command->validateContent($this, $this->collection))
260
+            if (!$command->validateContent($this, $this->collection))
261 261
             {
262 262
                 return;
263 263
             }
@@ -271,14 +271,14 @@  discard block
 block discarded – undo
271 271
     {
272 272
         $openingCommands = $this->detectOpeningCommands($name);
273 273
 
274
-        if(empty($openingCommands))
274
+        if (empty($openingCommands))
275 275
         {
276 276
             return array();
277 277
         }
278 278
 
279 279
         $closingCommands = $this->detectClosingCommands($name);
280 280
 
281
-        if(count($closingCommands) !== count($openingCommands))
281
+        if (count($closingCommands) !== count($openingCommands))
282 282
         {
283 283
             $this->addClosingError($name);
284 284
             return array();
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 
287 287
         $result = array();
288 288
 
289
-        foreach($openingCommands as $idx => $def)
289
+        foreach ($openingCommands as $idx => $def)
290 290
         {
291 291
             $result[] = new Mailcode_PreParser_CommandDef(
292 292
                 $name,
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
      */
329 329
     private function debugOpeningCommands(array $matches) : void
330 330
     {
331
-        if($this->debug === false)
331
+        if ($this->debug === false)
332 332
         {
333 333
             return;
334 334
         }
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 
383 383
     private function debugCommandDef(Mailcode_PreParser_CommandDef $commandDef) : void
384 384
     {
385
-        if($this->debug === true)
385
+        if ($this->debug === true)
386 386
         {
387 387
             echo 'Command definition:'.PHP_EOL;
388 388
             print_r($commandDef->toArray());
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -26,24 +26,24 @@  discard block
 block discarded – undo
26 26
     public const VALIDATION_EMPTY = 48801;
27 27
     public const VALIDATION_UNQUOTED_STRING_LITERALS = 48802;
28 28
     
29
-   /**
30
-    * @var string
31
-    */
29
+    /**
30
+     * @var string
31
+     */
32 32
     protected string $statement;
33 33
     
34
-   /**
35
-    * @var OperationResult
36
-    */
34
+    /**
35
+     * @var OperationResult
36
+     */
37 37
     protected OperationResult $result;
38 38
     
39
-   /**
40
-    * @var Mailcode_Parser_Statement_Tokenizer
41
-    */
39
+    /**
40
+     * @var Mailcode_Parser_Statement_Tokenizer
41
+     */
42 42
     protected Mailcode_Parser_Statement_Tokenizer $tokenizer;
43 43
     
44
-   /**
45
-    * @var Mailcode_Parser_Statement_Info|NULL
46
-    */
44
+    /**
45
+     * @var Mailcode_Parser_Statement_Info|NULL
46
+     */
47 47
     protected ?Mailcode_Parser_Statement_Info $info = null;
48 48
 
49 49
     /**
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         if($unknown)
139 139
         {
140 140
             $this->result->makeError(
141
-               t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')',
141
+                t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')',
142 142
                 self::VALIDATION_UNQUOTED_STRING_LITERALS
143 143
             );
144 144
         }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     private ?Mailcode_Commands_Command $sourceCommand = null;
58 58
 
59
-    public function __construct(string $statement, bool $freeform=false, ?Mailcode_Commands_Command $sourceCommand=null)
59
+    public function __construct(string $statement, bool $freeform = false, ?Mailcode_Commands_Command $sourceCommand = null)
60 60
     {
61 61
         $this->sourceCommand = $sourceCommand;
62 62
         $this->statement = $this->prepareStatement($statement);
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     
107 107
     public function getInfo() : Mailcode_Parser_Statement_Info
108 108
     {
109
-        if($this->info instanceof Mailcode_Parser_Statement_Info)
109
+        if ($this->info instanceof Mailcode_Parser_Statement_Info)
110 110
         {
111 111
             return $this->info; 
112 112
         }
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
     
119 119
     protected function validate() : void
120 120
     {
121
-        if($this->freeform)
121
+        if ($this->freeform)
122 122
         {
123 123
             return;
124 124
         }
125 125
 
126
-        if(!$this->tokenizer->hasTokens())
126
+        if (!$this->tokenizer->hasTokens())
127 127
         {
128 128
             $this->result->makeError(
129 129
                 t('Empty statement'),
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         
136 136
         $unknown = $this->tokenizer->getFirstUnknown();
137 137
         
138
-        if($unknown)
138
+        if ($unknown)
139 139
         {
140 140
             $this->result->makeError(
141 141
                t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')',
Please login to merge, or discard this patch.