@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | { |
135 | 135 | $result = array(); |
136 | 136 | |
137 | - foreach($this->tokensOrdered as $token) |
|
137 | + foreach ($this->tokensOrdered as $token) |
|
138 | 138 | { |
139 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
139 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
140 | 140 | { |
141 | 141 | $result[] = $token; |
142 | 142 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | { |
150 | 150 | $unknown = $this->getUnknown(); |
151 | 151 | |
152 | - if(!empty($unknown)) |
|
152 | + if (!empty($unknown)) |
|
153 | 153 | { |
154 | 154 | return array_shift($unknown); |
155 | 155 | } |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | { |
162 | 162 | $parts = array(); |
163 | 163 | |
164 | - foreach($this->tokensOrdered as $token) |
|
164 | + foreach ($this->tokensOrdered as $token) |
|
165 | 165 | { |
166 | 166 | $string = $token->getNormalized(); |
167 | 167 | |
168 | - if(!empty($string)) |
|
168 | + if (!empty($string)) |
|
169 | 169 | { |
170 | 170 | $parts[] = $string; |
171 | 171 | } |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | { |
179 | 179 | $this->tokenized = trim($statement); |
180 | 180 | |
181 | - foreach($this->tokenCategories as $token) |
|
181 | + foreach ($this->tokenCategories as $token) |
|
182 | 182 | { |
183 | 183 | $method = 'tokenize_'.$token; |
184 | 184 | |
185 | - if(!method_exists($this, $method)) |
|
185 | + if (!method_exists($this, $method)) |
|
186 | 186 | { |
187 | 187 | throw new Mailcode_Exception( |
188 | 188 | 'Unknown statement token.', |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * @param string $matchedText |
207 | 207 | * @param mixed $subject |
208 | 208 | */ |
209 | - protected function registerToken(string $type, string $matchedText, $subject=null) : void |
|
209 | + protected function registerToken(string $type, string $matchedText, $subject = null) : void |
|
210 | 210 | { |
211 | 211 | $tokenID = $this->generateID(); |
212 | 212 | |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | |
224 | 224 | protected function getTokenByID(string $tokenID) : ?Mailcode_Parser_Statement_Tokenizer_Token |
225 | 225 | { |
226 | - foreach($this->tokensTemporary as $token) |
|
226 | + foreach ($this->tokensTemporary as $token) |
|
227 | 227 | { |
228 | - if($token->getID() === $tokenID) |
|
228 | + if ($token->getID() === $tokenID) |
|
229 | 229 | { |
230 | 230 | return $token; |
231 | 231 | } |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | |
242 | 242 | protected function tokenize_keywords() : void |
243 | 243 | { |
244 | - foreach($this->keywords as $keyword) |
|
244 | + foreach ($this->keywords as $keyword) |
|
245 | 245 | { |
246 | - if(strstr($this->tokenized, $keyword)) |
|
246 | + if (strstr($this->tokenized, $keyword)) |
|
247 | 247 | { |
248 | 248 | $this->registerToken('Keyword', $keyword); |
249 | 249 | } |
@@ -257,12 +257,12 @@ discard block |
||
257 | 257 | // over that could not be tokenized. |
258 | 258 | $parts = \AppUtils\ConvertHelper::explodeTrim($this->delimiter, $this->tokenized); |
259 | 259 | |
260 | - foreach($parts as $part) |
|
260 | + foreach ($parts as $part) |
|
261 | 261 | { |
262 | 262 | $token = $this->getTokenByID($part); |
263 | 263 | |
264 | 264 | // if the entry is a token, simply add it. |
265 | - if($token) |
|
265 | + if ($token) |
|
266 | 266 | { |
267 | 267 | $this->tokensOrdered[] = $token; |
268 | 268 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | { |
279 | 279 | $vars = Mailcode::create()->findVariables($this->tokenized)->getGroupedByHash(); |
280 | 280 | |
281 | - foreach($vars as $var) |
|
281 | + foreach ($vars as $var) |
|
282 | 282 | { |
283 | 283 | $this->registerToken('Variable', $var->getMatchedText(), $var); |
284 | 284 | } |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | |
287 | 287 | protected function tokenize_operands() : void |
288 | 288 | { |
289 | - foreach($this->operands as $operand) |
|
289 | + foreach ($this->operands as $operand) |
|
290 | 290 | { |
291 | - if(strstr($this->tokenized, $operand)) |
|
291 | + if (strstr($this->tokenized, $operand)) |
|
292 | 292 | { |
293 | 293 | $this->registerToken('Operand', $operand); |
294 | 294 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | $matches = array(); |
301 | 301 | preg_match_all('/"(.*)"/sx', $this->tokenized, $matches, PREG_PATTERN_ORDER); |
302 | 302 | |
303 | - foreach($matches[0] as $match) |
|
303 | + foreach ($matches[0] as $match) |
|
304 | 304 | { |
305 | 305 | $this->registerToken('StringLiteral', $match); |
306 | 306 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $matches = array(); |
312 | 312 | preg_match_all('/-*[0-9]+\s*[.,]\s*[0-9]+|-*[0-9]+/sx', $this->tokenized, $matches, PREG_PATTERN_ORDER); |
313 | 313 | |
314 | - foreach($matches[0] as $match) |
|
314 | + foreach ($matches[0] as $match) |
|
315 | 315 | { |
316 | 316 | $this->registerToken('Number', $match); |
317 | 317 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | { |
329 | 329 | static $alphas; |
330 | 330 | |
331 | - if(!isset($alphas)) |
|
331 | + if (!isset($alphas)) |
|
332 | 332 | { |
333 | 333 | $alphas = range('A', 'Z'); |
334 | 334 | } |
@@ -337,12 +337,12 @@ discard block |
||
337 | 337 | |
338 | 338 | $result = ''; |
339 | 339 | |
340 | - for($i=0; $i < $amount; $i++) |
|
340 | + for ($i = 0; $i < $amount; $i++) |
|
341 | 341 | { |
342 | 342 | $result .= $alphas[array_rand($alphas)]; |
343 | 343 | } |
344 | 344 | |
345 | - if(!in_array($result, self::$ids)) |
|
345 | + if (!in_array($result, self::$ids)) |
|
346 | 346 | { |
347 | 347 | self::$ids[] = $result; |
348 | 348 | return $result; |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * @param \Exception|NULL $previous |
33 | 33 | * @param Mailcode_Commands_Command|NULL $command |
34 | 34 | */ |
35 | - public function __construct(string $message, $details=null, $code=null, $previous=null, Mailcode_Commands_Command $command=null) |
|
35 | + public function __construct(string $message, $details = null, $code = null, $previous = null, Mailcode_Commands_Command $command = null) |
|
36 | 36 | { |
37 | 37 | parent::__construct($message, $details, $code, $previous); |
38 | 38 |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | { |
63 | 63 | $fullName = $this->fixName($fullName); |
64 | 64 | |
65 | - foreach($this->variables as $variable) |
|
65 | + foreach ($this->variables as $variable) |
|
66 | 66 | { |
67 | - if($variable->getFullName() === $fullName) |
|
67 | + if ($variable->getFullName() === $fullName) |
|
68 | 68 | { |
69 | 69 | return true; |
70 | 70 | } |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | |
88 | 88 | $collection = new Mailcode_Variables_Collection_Regular(); |
89 | 89 | |
90 | - foreach($this->variables as $variable) |
|
90 | + foreach ($this->variables as $variable) |
|
91 | 91 | { |
92 | - if($variable->getFullName() === $fullName) |
|
92 | + if ($variable->getFullName() === $fullName) |
|
93 | 93 | { |
94 | 94 | $collection->add($variable); |
95 | 95 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | protected function fixName(string $fullName) : string |
108 | 108 | { |
109 | - if(substr($fullName, 0, 1) === '$') |
|
109 | + if (substr($fullName, 0, 1) === '$') |
|
110 | 110 | { |
111 | 111 | return $fullName; |
112 | 112 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | { |
125 | 125 | $entries = array(); |
126 | 126 | |
127 | - foreach($this->variables as $variable) |
|
127 | + foreach ($this->variables as $variable) |
|
128 | 128 | { |
129 | 129 | $entries[$variable->getHash()] = $variable; |
130 | 130 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | { |
142 | 142 | $entries = array(); |
143 | 143 | |
144 | - foreach($this->variables as $variable) |
|
144 | + foreach ($this->variables as $variable) |
|
145 | 145 | { |
146 | 146 | $entries[$variable->getFullName()] = $variable; |
147 | 147 | } |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | { |
167 | 167 | $result = array(); |
168 | 168 | |
169 | - foreach($this->variables as $variable) |
|
169 | + foreach ($this->variables as $variable) |
|
170 | 170 | { |
171 | 171 | $name = $variable->getFullName(); |
172 | 172 | |
173 | - if(!in_array($name, $result)) |
|
173 | + if (!in_array($name, $result)) |
|
174 | 174 | { |
175 | 175 | $result[] = $name; |
176 | 176 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | { |
210 | 210 | $variables = $collection->getGroupedByHash(); |
211 | 211 | |
212 | - foreach($variables as $variable) |
|
212 | + foreach ($variables as $variable) |
|
213 | 213 | { |
214 | 214 | $this->add($variable); |
215 | 215 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | { |
222 | 222 | $variables = $this->getAll(); |
223 | 223 | |
224 | - if(!empty($variables)) |
|
224 | + if (!empty($variables)) |
|
225 | 225 | { |
226 | 226 | return array_shift($variables); |
227 | 227 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | |
77 | 77 | public function getFullName() : string |
78 | 78 | { |
79 | - if(empty($this->path)) |
|
79 | + if (empty($this->path)) |
|
80 | 80 | { |
81 | 81 | return '$'.$this->name; |
82 | 82 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | public function getHash() : string |
103 | 103 | { |
104 | - if(empty($this->hash)) |
|
104 | + if (empty($this->hash)) |
|
105 | 105 | { |
106 | 106 | $this->hash = md5($this->matchedText); |
107 | 107 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | public function getValidationResult() : OperationResult |
118 | 118 | { |
119 | - if(isset($this->validationResult)) |
|
119 | + if (isset($this->validationResult)) |
|
120 | 120 | { |
121 | 121 | return $this->validationResult; |
122 | 122 | } |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | |
131 | 131 | protected function validate() : void |
132 | 132 | { |
133 | - foreach($this->validations as $validation) |
|
133 | + foreach ($this->validations as $validation) |
|
134 | 134 | { |
135 | 135 | $method = 'validate_'.$validation; |
136 | 136 | |
137 | - if(!method_exists($this, $method)) |
|
137 | + if (!method_exists($this, $method)) |
|
138 | 138 | { |
139 | 139 | throw new Mailcode_Exception( |
140 | 140 | 'Unknown validation method', |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | $this->$method(); |
151 | 151 | |
152 | - if(!$this->validationResult->isValid()) |
|
152 | + if (!$this->validationResult->isValid()) |
|
153 | 153 | { |
154 | 154 | return; |
155 | 155 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | |
179 | 179 | protected function validateNumber(string $value, int $errorCode) : void |
180 | 180 | { |
181 | - if(!is_numeric(substr($value, 0, 1))) |
|
181 | + if (!is_numeric(substr($value, 0, 1))) |
|
182 | 182 | { |
183 | 183 | return; |
184 | 184 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | protected function validateUnderscore(string $value, int $errorCode) : void |
197 | 197 | { |
198 | 198 | // allow empty paths |
199 | - if(empty($value)) |
|
199 | + if (empty($value)) |
|
200 | 200 | { |
201 | 201 | return; |
202 | 202 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $length = strlen($value); |
205 | 205 | |
206 | 206 | // trimming underscores does not change the length: no underscores at start or end of string. |
207 | - if(strlen(trim($value, '_')) == $length) |
|
207 | + if (strlen(trim($value, '_')) == $length) |
|
208 | 208 | { |
209 | 209 | return; |
210 | 210 | } |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | $matches = array(); |
41 | 41 | preg_match_all(self::REGEX_VARIABLE_NAME, $subject, $matches, PREG_PATTERN_ORDER); |
42 | 42 | |
43 | - if(!isset($matches[0]) || empty($matches[0])) |
|
43 | + if (!isset($matches[0]) || empty($matches[0])) |
|
44 | 44 | { |
45 | 45 | return $this->collection; |
46 | 46 | } |
47 | 47 | |
48 | - foreach($matches[0] as $idx => $matchedText) |
|
48 | + foreach ($matches[0] as $idx => $matchedText) |
|
49 | 49 | { |
50 | - if(!empty($matches[3][$idx])) |
|
50 | + if (!empty($matches[3][$idx])) |
|
51 | 51 | { |
52 | 52 | $this->addSingle($matches[3][$idx], $matchedText); |
53 | 53 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | protected function addSingle(string $name, string $matchedText) : void |
64 | 64 | { |
65 | 65 | // ignore US style numbers like $451 |
66 | - if(is_numeric($name)) |
|
66 | + if (is_numeric($name)) |
|
67 | 67 | { |
68 | 68 | return; |
69 | 69 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | protected function addPathed(string $path, string $name, string $matchedText) : void |
75 | 75 | { |
76 | 76 | // ignore US style numbers like $45.12 |
77 | - if(is_numeric($path.'.'.$name)) |
|
77 | + if (is_numeric($path.'.'.$name)) |
|
78 | 78 | { |
79 | 79 | return; |
80 | 80 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function getParser() : Mailcode_Parser |
75 | 75 | { |
76 | - if(!isset($this->parser)) |
|
76 | + if (!isset($this->parser)) |
|
77 | 77 | { |
78 | 78 | $this->parser = new Mailcode_Parser($this); |
79 | 79 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function getCommands() : Mailcode_Commands |
91 | 91 | { |
92 | - if(!isset($this->commands)) |
|
92 | + if (!isset($this->commands)) |
|
93 | 93 | { |
94 | 94 | $this->commands = new Mailcode_Commands(); |
95 | 95 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | public function createVariables() : Mailcode_Variables |
117 | 117 | { |
118 | - if(!isset($this->variables)) |
|
118 | + if (!isset($this->variables)) |
|
119 | 119 | { |
120 | 120 | $this->variables = new Mailcode_Variables(); |
121 | 121 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function createTranslator() : Mailcode_Translator |
133 | 133 | { |
134 | - if(!isset($this->translator)) |
|
134 | + if (!isset($this->translator)) |
|
135 | 135 | { |
136 | 136 | $this->translator = new Mailcode_Translator(); |
137 | 137 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | $total = count($matches[0]); |
75 | 75 | |
76 | - for($i=0; $i < $total; $i++) |
|
76 | + for ($i = 0; $i < $total; $i++) |
|
77 | 77 | { |
78 | 78 | $match = $this->parseMatch($matches, $i); |
79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | protected function prepareString(string $subject) : string |
87 | 87 | { |
88 | - if(!ConvertHelper::isStringHTML($subject)) |
|
88 | + if (!ConvertHelper::isStringHTML($subject)) |
|
89 | 89 | { |
90 | 90 | return $subject; |
91 | 91 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | $name = $match->getName(); |
108 | 108 | |
109 | - if(!$this->commands->nameExists($name)) |
|
109 | + if (!$this->commands->nameExists($name)) |
|
110 | 110 | { |
111 | 111 | $collection->addErrorMessage( |
112 | 112 | $match->getMatchedString(), |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $match->getMatchedString() |
124 | 124 | ); |
125 | 125 | |
126 | - if($cmd->isValid()) |
|
126 | + if ($cmd->isValid()) |
|
127 | 127 | { |
128 | 128 | $collection->addCommand($cmd); |
129 | 129 | return; |
@@ -153,16 +153,16 @@ discard block |
||
153 | 153 | // 5 = parameter type command, type |
154 | 154 | // 6 = parameter type command, params |
155 | 155 | |
156 | - if(!empty($matches[1][$index])) |
|
156 | + if (!empty($matches[1][$index])) |
|
157 | 157 | { |
158 | 158 | $name = $matches[1][$index]; |
159 | 159 | } |
160 | - else if(!empty($matches[2][$index])) |
|
160 | + else if (!empty($matches[2][$index])) |
|
161 | 161 | { |
162 | 162 | $name = $matches[2][$index]; |
163 | 163 | $params = $matches[3][$index]; |
164 | 164 | } |
165 | - else if(!empty($matches[4][$index])) |
|
165 | + else if (!empty($matches[4][$index])) |
|
166 | 166 | { |
167 | 167 | $name = $matches[4][$index]; |
168 | 168 | $type = $matches[5][$index]; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | public function getInfo() : Mailcode_Parser_Statement_Info |
77 | 77 | { |
78 | - if(isset($this->info)) |
|
78 | + if (isset($this->info)) |
|
79 | 79 | { |
80 | 80 | return $this->info; |
81 | 81 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | protected function validate() : void |
89 | 89 | { |
90 | - if(!$this->tokenizer->hasTokens()) |
|
90 | + if (!$this->tokenizer->hasTokens()) |
|
91 | 91 | { |
92 | 92 | $this->result->makeError( |
93 | 93 | t('Empty statement'), |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | $unknown = $this->tokenizer->getFirstUnknown(); |
101 | 101 | |
102 | - if($unknown) |
|
102 | + if ($unknown) |
|
103 | 103 | { |
104 | 104 | $this->result->makeError( |
105 | 105 | t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')', |
@@ -25,7 +25,7 @@ |
||
25 | 25 | $this->paramsString = trim($this->paramsString); |
26 | 26 | |
27 | 27 | // automatically quote the parameters, since comments don't require any. |
28 | - if(substr($this->paramsString, 0, 1) != '"') |
|
28 | + if (substr($this->paramsString, 0, 1) != '"') |
|
29 | 29 | { |
30 | 30 | $this->paramsString = '"'.$this->paramsString.'"'; |
31 | 31 | } |