@@ -11,7 +11,7 @@ |
||
11 | 11 | $matches = array(); |
12 | 12 | preg_match_all('/-*[0-9]+\s*[.,]\s*[0-9]+|-*[0-9]+/sx', $this->tokenized, $matches, PREG_PATTERN_ORDER); |
13 | 13 | |
14 | - foreach($matches[0] as $match) |
|
14 | + foreach ($matches[0] as $match) |
|
15 | 15 | { |
16 | 16 | $this->registerToken('Number', $match); |
17 | 17 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | public function protectContent(string $string, Mailcode_Parser_Safeguard_Placeholder $open, Mailcode_Parser_Safeguard_Placeholder $end) : string |
35 | 35 | { |
36 | - if(!$end->getCommand() instanceof Mailcode_Commands_Command_End) |
|
36 | + if (!$end->getCommand() instanceof Mailcode_Commands_Command_End) |
|
37 | 37 | { |
38 | 38 | throw new Mailcode_Exception( |
39 | 39 | 'Invalid commands nesting', |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $start = strpos($string, $open->getReplacementText()) + $open->getReplacementLength(); |
46 | 46 | $end = strpos($string, $end->getReplacementText()); |
47 | 47 | |
48 | - $content = substr($string, $start, ($end-$start)); |
|
48 | + $content = substr($string, $start, ($end - $start)); |
|
49 | 49 | |
50 | 50 | return $this->replaceContent($string, $content); |
51 | 51 | } |
@@ -56,23 +56,23 @@ |
||
56 | 56 | |
57 | 57 | private function analyzeURL(string $url) : void |
58 | 58 | { |
59 | - if(stristr($url, 'tel:')) |
|
59 | + if (stristr($url, 'tel:')) |
|
60 | 60 | { |
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | 64 | $placeholders = $this->safeguard->getPlaceholders(); |
65 | 65 | |
66 | - foreach($placeholders as $placeholder) |
|
66 | + foreach ($placeholders as $placeholder) |
|
67 | 67 | { |
68 | 68 | $command = $placeholder->getCommand(); |
69 | 69 | |
70 | - if(!$command->supportsURLEncoding()) |
|
70 | + if (!$command->supportsURLEncoding()) |
|
71 | 71 | { |
72 | 72 | continue; |
73 | 73 | } |
74 | 74 | |
75 | - if(strstr($url, $placeholder->getReplacementText()) && !$command->isURLDecoded()) |
|
75 | + if (strstr($url, $placeholder->getReplacementText()) && !$command->isURLDecoded()) |
|
76 | 76 | { |
77 | 77 | $command->setURLEncoding(true); |
78 | 78 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | private function validate() : OperationResult |
46 | 46 | { |
47 | - if(empty($this->delimiter)) |
|
47 | + if (empty($this->delimiter)) |
|
48 | 48 | { |
49 | 49 | return $this->makeError( |
50 | 50 | 'Delimiters may not be empty.', |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | ); |
53 | 53 | } |
54 | 54 | |
55 | - if(strlen($this->delimiter) < 2) |
|
55 | + if (strlen($this->delimiter) < 2) |
|
56 | 56 | { |
57 | 57 | return $this->makeError( |
58 | 58 | 'The delimiter must have at least 2 characters in length.', |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | $encoded = urlencode($this->delimiter); |
64 | 64 | |
65 | - if($encoded !== $this->delimiter) |
|
65 | + if ($encoded !== $this->delimiter) |
|
66 | 66 | { |
67 | 67 | return $this->makeError( |
68 | 68 | 'The delimiter is not URL encoding neutral: it must not be modified by a urlencode() call.', |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | public function throwExceptionIfInvalid() : void |
77 | 77 | { |
78 | - if($this->isValid()) { |
|
78 | + if ($this->isValid()) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | */ |
21 | 21 | abstract class Mailcode_Translator_Syntax_ApacheVelocity extends Mailcode_Translator_Command |
22 | 22 | { |
23 | - /** |
|
24 | - * @var string[] |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var string[] |
|
25 | + */ |
|
26 | 26 | private $regexSpecialChars = array( |
27 | 27 | '?', |
28 | 28 | '.', |
@@ -47,15 +47,15 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | - * Filters the string for use in an Apache Velocity (Java) |
|
51 | - * regex string: escapes all special characters. |
|
52 | - * |
|
53 | - * Velocity does its own escaping, so no need to escape special |
|
54 | - * characters as if they were a javascript string. |
|
55 | - * |
|
56 | - * @param string $string |
|
57 | - * @return string |
|
58 | - */ |
|
50 | + * Filters the string for use in an Apache Velocity (Java) |
|
51 | + * regex string: escapes all special characters. |
|
52 | + * |
|
53 | + * Velocity does its own escaping, so no need to escape special |
|
54 | + * characters as if they were a javascript string. |
|
55 | + * |
|
56 | + * @param string $string |
|
57 | + * @return string |
|
58 | + */ |
|
59 | 59 | protected function filterRegexString(string $string) : string |
60 | 60 | { |
61 | 61 | // Special case: previously escaped quotes. |
@@ -69,7 +69,7 @@ |
||
69 | 69 | |
70 | 70 | // All other special characters have to be escaped |
71 | 71 | // with two backslashes. |
72 | - foreach($this->regexSpecialChars as $char) |
|
72 | + foreach ($this->regexSpecialChars as $char) |
|
73 | 73 | { |
74 | 74 | $string = str_replace($char, '\\'.$char, $string); |
75 | 75 | } |
@@ -25,9 +25,9 @@ discard block |
||
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 |
||
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 | /** |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | private $finalized = false; |
47 | 47 | |
48 | 48 | /** |
49 | - * Adds a command to the collection. |
|
50 | - * |
|
51 | - * @param Mailcode_Commands_Command $command |
|
52 | - * @return Mailcode_Collection |
|
53 | - */ |
|
49 | + * Adds a command to the collection. |
|
50 | + * |
|
51 | + * @param Mailcode_Commands_Command $command |
|
52 | + * @return Mailcode_Collection |
|
53 | + */ |
|
54 | 54 | public function addCommand(Mailcode_Commands_Command $command) : Mailcode_Collection |
55 | 55 | { |
56 | 56 | if($this->finalized) |
@@ -71,21 +71,21 @@ discard block |
||
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | |
74 | - /** |
|
75 | - * Whether there are any commands in the collection. |
|
76 | - * |
|
77 | - * @return bool |
|
78 | - */ |
|
74 | + /** |
|
75 | + * Whether there are any commands in the collection. |
|
76 | + * |
|
77 | + * @return bool |
|
78 | + */ |
|
79 | 79 | public function hasCommands() : bool |
80 | 80 | { |
81 | 81 | return !empty($this->commands); |
82 | 82 | } |
83 | 83 | |
84 | - /** |
|
85 | - * Counts the amount of commands in the collection. |
|
86 | - * |
|
87 | - * @return int |
|
88 | - */ |
|
84 | + /** |
|
85 | + * Counts the amount of commands in the collection. |
|
86 | + * |
|
87 | + * @return int |
|
88 | + */ |
|
89 | 89 | public function countCommands() : int |
90 | 90 | { |
91 | 91 | return count($this->commands); |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | $this->commands = $keep; |
124 | 124 | } |
125 | 125 | |
126 | - /** |
|
127 | - * @return Mailcode_Collection_Error[] |
|
128 | - */ |
|
126 | + /** |
|
127 | + * @return Mailcode_Collection_Error[] |
|
128 | + */ |
|
129 | 129 | public function getErrors() |
130 | 130 | { |
131 | 131 | $result = $this->getValidationResult(); |
@@ -167,25 +167,25 @@ discard block |
||
167 | 167 | return empty($errors); |
168 | 168 | } |
169 | 169 | |
170 | - /** |
|
171 | - * Retrieves all commands that were detected, in the exact order |
|
172 | - * they were found. |
|
173 | - * |
|
174 | - * @return \Mailcode\Mailcode_Commands_Command[] |
|
175 | - */ |
|
170 | + /** |
|
171 | + * Retrieves all commands that were detected, in the exact order |
|
172 | + * they were found. |
|
173 | + * |
|
174 | + * @return \Mailcode\Mailcode_Commands_Command[] |
|
175 | + */ |
|
176 | 176 | public function getCommands() |
177 | 177 | { |
178 | - return $this->commands; |
|
178 | + return $this->commands; |
|
179 | 179 | } |
180 | 180 | |
181 | - /** |
|
182 | - * Retrieves all unique commands by their matched |
|
183 | - * string hash: this ensures only commands that were |
|
184 | - * written the exact same way (including spacing) |
|
185 | - * are returned. |
|
186 | - * |
|
187 | - * @return \Mailcode\Mailcode_Commands_Command[] |
|
188 | - */ |
|
181 | + /** |
|
182 | + * Retrieves all unique commands by their matched |
|
183 | + * string hash: this ensures only commands that were |
|
184 | + * written the exact same way (including spacing) |
|
185 | + * are returned. |
|
186 | + * |
|
187 | + * @return \Mailcode\Mailcode_Commands_Command[] |
|
188 | + */ |
|
189 | 189 | public function getGroupedByHash() |
190 | 190 | { |
191 | 191 | $hashes = array(); |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | return array_values($hashes); |
204 | 204 | } |
205 | 205 | |
206 | - /** |
|
207 | - * Adds several commands at once. |
|
208 | - * |
|
209 | - * @param Mailcode_Commands_Command[] $commands |
|
210 | - * @return Mailcode_Collection |
|
211 | - */ |
|
206 | + /** |
|
207 | + * Adds several commands at once. |
|
208 | + * |
|
209 | + * @param Mailcode_Commands_Command[] $commands |
|
210 | + * @return Mailcode_Collection |
|
211 | + */ |
|
212 | 212 | public function addCommands(array $commands) : Mailcode_Collection |
213 | 213 | { |
214 | 214 | foreach($commands as $command) |
@@ -281,10 +281,10 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
284 | - * Retrieves only show variable commands in the collection, if any. |
|
285 | - * |
|
286 | - * @return Mailcode_Commands_Command_ShowVariable[] |
|
287 | - */ |
|
284 | + * Retrieves only show variable commands in the collection, if any. |
|
285 | + * |
|
286 | + * @return Mailcode_Commands_Command_ShowVariable[] |
|
287 | + */ |
|
288 | 288 | public function getShowVariableCommands() |
289 | 289 | { |
290 | 290 | return $this->getCommandsByClass(Mailcode_Commands_Command_ShowVariable::class); |
@@ -298,11 +298,11 @@ discard block |
||
298 | 298 | return $this->getCommandsByClass(Mailcode_Commands_Command_For::class); |
299 | 299 | } |
300 | 300 | |
301 | - /** |
|
302 | - * Retrieves only show date commands in the collection, if any. |
|
303 | - * |
|
304 | - * @return Mailcode_Commands_Command_ShowDate[] |
|
305 | - */ |
|
301 | + /** |
|
302 | + * Retrieves only show date commands in the collection, if any. |
|
303 | + * |
|
304 | + * @return Mailcode_Commands_Command_ShowDate[] |
|
305 | + */ |
|
306 | 306 | public function getShowDateCommands() : array |
307 | 307 | { |
308 | 308 | return $this->getCommandsByClass(Mailcode_Commands_Command_ShowDate::class); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function addCommand(Mailcode_Commands_Command $command) : Mailcode_Collection |
55 | 55 | { |
56 | - if($this->finalized) |
|
56 | + if ($this->finalized) |
|
57 | 57 | { |
58 | 58 | throw new Mailcode_Exception( |
59 | 59 | 'Cannot add commands to a finalized collection', |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | { |
113 | 113 | $keep = array(); |
114 | 114 | |
115 | - foreach($this->commands as $existing) |
|
115 | + foreach ($this->commands as $existing) |
|
116 | 116 | { |
117 | - if($existing !== $command) |
|
117 | + if ($existing !== $command) |
|
118 | 118 | { |
119 | 119 | $keep[] = $existing; |
120 | 120 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | $errors = $this->errors; |
134 | 134 | |
135 | - if(!$result->isValid()) |
|
135 | + if (!$result->isValid()) |
|
136 | 136 | { |
137 | 137 | $errors[] = new Mailcode_Collection_Error_Message( |
138 | 138 | '', |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | { |
149 | 149 | $errors = $this->getErrors(); |
150 | 150 | |
151 | - if(!empty($errors)) |
|
151 | + if (!empty($errors)) |
|
152 | 152 | { |
153 | 153 | return array_shift($errors); |
154 | 154 | } |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | { |
191 | 191 | $hashes = array(); |
192 | 192 | |
193 | - foreach($this->commands as $command) |
|
193 | + foreach ($this->commands as $command) |
|
194 | 194 | { |
195 | 195 | $hash = $command->getHash(); |
196 | 196 | |
197 | - if(!isset($hashes[$hash])) |
|
197 | + if (!isset($hashes[$hash])) |
|
198 | 198 | { |
199 | 199 | $hashes[$hash] = $command; |
200 | 200 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | */ |
212 | 212 | public function addCommands(array $commands) : Mailcode_Collection |
213 | 213 | { |
214 | - foreach($commands as $command) |
|
214 | + foreach ($commands as $command) |
|
215 | 215 | { |
216 | 216 | $this->addCommand($command); |
217 | 217 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | { |
233 | 233 | $collection = new Mailcode_Variables_Collection_Regular(); |
234 | 234 | |
235 | - foreach($this->commands as $command) |
|
235 | + foreach ($this->commands as $command) |
|
236 | 236 | { |
237 | 237 | $collection->mergeWith($command->getVariables()); |
238 | 238 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | public function getValidationResult() : OperationResult |
244 | 244 | { |
245 | - if($this->validationResult instanceof OperationResult) |
|
245 | + if ($this->validationResult instanceof OperationResult) |
|
246 | 246 | { |
247 | 247 | return $this->validationResult; |
248 | 248 | } |
@@ -258,9 +258,9 @@ discard block |
||
258 | 258 | { |
259 | 259 | $errors = $this->getErrors(); |
260 | 260 | |
261 | - foreach($errors as $error) |
|
261 | + foreach ($errors as $error) |
|
262 | 262 | { |
263 | - if($error->getCode() === $code) |
|
263 | + if ($error->getCode() === $code) |
|
264 | 264 | { |
265 | 265 | return true; |
266 | 266 | } |
@@ -316,9 +316,9 @@ discard block |
||
316 | 316 | { |
317 | 317 | $result = array(); |
318 | 318 | |
319 | - foreach($this->commands as $command) |
|
319 | + foreach ($this->commands as $command) |
|
320 | 320 | { |
321 | - if($command instanceof $className) |
|
321 | + if ($command instanceof $className) |
|
322 | 322 | { |
323 | 323 | $result[] = $command; |
324 | 324 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | { |
332 | 332 | $commands = $this->getCommands(); |
333 | 333 | |
334 | - if(!empty($commands)) |
|
334 | + if (!empty($commands)) |
|
335 | 335 | { |
336 | 336 | return array_shift($commands); |
337 | 337 | } |
@@ -353,11 +353,11 @@ discard block |
||
353 | 353 | |
354 | 354 | private function validateNesting() : void |
355 | 355 | { |
356 | - foreach($this->commands as $command) |
|
356 | + foreach ($this->commands as $command) |
|
357 | 357 | { |
358 | 358 | $command->validateNesting(); |
359 | 359 | |
360 | - if(!$command->isValid()) { |
|
360 | + if (!$command->isValid()) { |
|
361 | 361 | $this->addInvalidCommand($command); |
362 | 362 | } |
363 | 363 | } |
@@ -43,44 +43,44 @@ discard block |
||
43 | 43 | |
44 | 44 | const META_URL_ENCODING = 'url_encoding'; |
45 | 45 | |
46 | - /** |
|
47 | - * @var string |
|
48 | - */ |
|
46 | + /** |
|
47 | + * @var string |
|
48 | + */ |
|
49 | 49 | protected $type = ''; |
50 | 50 | |
51 | - /** |
|
52 | - * @var string |
|
53 | - */ |
|
51 | + /** |
|
52 | + * @var string |
|
53 | + */ |
|
54 | 54 | protected $paramsString = ''; |
55 | 55 | |
56 | - /** |
|
57 | - * @var string |
|
58 | - */ |
|
56 | + /** |
|
57 | + * @var string |
|
58 | + */ |
|
59 | 59 | protected $matchedText = ''; |
60 | 60 | |
61 | - /** |
|
62 | - * @var string |
|
63 | - */ |
|
61 | + /** |
|
62 | + * @var string |
|
63 | + */ |
|
64 | 64 | protected $hash = ''; |
65 | 65 | |
66 | - /** |
|
67 | - * @var OperationResult |
|
68 | - */ |
|
66 | + /** |
|
67 | + * @var OperationResult |
|
68 | + */ |
|
69 | 69 | protected $validationResult = null; |
70 | 70 | |
71 | - /** |
|
72 | - * @var \Mailcode\Mailcode |
|
73 | - */ |
|
71 | + /** |
|
72 | + * @var \Mailcode\Mailcode |
|
73 | + */ |
|
74 | 74 | protected $mailcode; |
75 | 75 | |
76 | - /** |
|
77 | - * @var \Mailcode\Mailcode_Parser_Statement |
|
78 | - */ |
|
76 | + /** |
|
77 | + * @var \Mailcode\Mailcode_Parser_Statement |
|
78 | + */ |
|
79 | 79 | protected $params; |
80 | 80 | |
81 | - /** |
|
82 | - * @var string[] |
|
83 | - */ |
|
81 | + /** |
|
82 | + * @var string[] |
|
83 | + */ |
|
84 | 84 | protected $validations = array( |
85 | 85 | 'params_empty', |
86 | 86 | 'params_keywords', |
@@ -89,24 +89,24 @@ discard block |
||
89 | 89 | 'type_unsupported' |
90 | 90 | ); |
91 | 91 | |
92 | - /** |
|
93 | - * @var string |
|
94 | - */ |
|
92 | + /** |
|
93 | + * @var string |
|
94 | + */ |
|
95 | 95 | protected $comment = ''; |
96 | 96 | |
97 | - /** |
|
98 | - * @var Mailcode_Commands_LogicKeywords|NULL |
|
99 | - */ |
|
97 | + /** |
|
98 | + * @var Mailcode_Commands_LogicKeywords|NULL |
|
99 | + */ |
|
100 | 100 | protected $logicKeywords; |
101 | 101 | |
102 | - /** |
|
103 | - * @var Mailcode_Parser_Statement_Validator |
|
104 | - */ |
|
102 | + /** |
|
103 | + * @var Mailcode_Parser_Statement_Validator |
|
104 | + */ |
|
105 | 105 | protected $validator; |
106 | 106 | |
107 | - /** |
|
108 | - * @var boolean |
|
109 | - */ |
|
107 | + /** |
|
108 | + * @var boolean |
|
109 | + */ |
|
110 | 110 | private $validated = false; |
111 | 111 | |
112 | 112 | /** |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | |
147 | 147 | } |
148 | 148 | |
149 | - /** |
|
150 | - * Sets the command's parent opening command, if any. |
|
151 | - * NOTE: This is set automatically by the parser, and |
|
152 | - * should not be called manually. |
|
153 | - * |
|
154 | - * @param Mailcode_Commands_Command $command |
|
155 | - */ |
|
149 | + /** |
|
150 | + * Sets the command's parent opening command, if any. |
|
151 | + * NOTE: This is set automatically by the parser, and |
|
152 | + * should not be called manually. |
|
153 | + * |
|
154 | + * @param Mailcode_Commands_Command $command |
|
155 | + */ |
|
156 | 156 | public function setParent(Mailcode_Commands_Command $command) : void |
157 | 157 | { |
158 | 158 | $this->parent = $command; |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | return $this->parent; |
169 | 169 | } |
170 | 170 | |
171 | - /** |
|
172 | - * @return string The ID of the command = the name of the command class file. |
|
173 | - */ |
|
171 | + /** |
|
172 | + * @return string The ID of the command = the name of the command class file. |
|
173 | + */ |
|
174 | 174 | public function getID() : string |
175 | 175 | { |
176 | 176 | // account for commands with types: If_Variable should still return If. |
@@ -179,14 +179,14 @@ discard block |
||
179 | 179 | return array_shift($tokens); |
180 | 180 | } |
181 | 181 | |
182 | - /** |
|
183 | - * Sets an optional comment that is not used anywhere, but |
|
184 | - * can be used by the application to track why a command is |
|
185 | - * used somewhere. |
|
186 | - * |
|
187 | - * @param string $comment |
|
188 | - * @return Mailcode_Commands_Command |
|
189 | - */ |
|
182 | + /** |
|
183 | + * Sets an optional comment that is not used anywhere, but |
|
184 | + * can be used by the application to track why a command is |
|
185 | + * used somewhere. |
|
186 | + * |
|
187 | + * @param string $comment |
|
188 | + * @return Mailcode_Commands_Command |
|
189 | + */ |
|
190 | 190 | public function setComment(string $comment) : Mailcode_Commands_Command |
191 | 191 | { |
192 | 192 | $this->comment = $comment; |
@@ -194,34 +194,34 @@ discard block |
||
194 | 194 | return $this; |
195 | 195 | } |
196 | 196 | |
197 | - /** |
|
198 | - * Retrieves the previously set comment, if any. |
|
199 | - * |
|
200 | - * @return string |
|
201 | - */ |
|
197 | + /** |
|
198 | + * Retrieves the previously set comment, if any. |
|
199 | + * |
|
200 | + * @return string |
|
201 | + */ |
|
202 | 202 | public function getComment() : string |
203 | 203 | { |
204 | 204 | return $this->comment; |
205 | 205 | } |
206 | 206 | |
207 | - /** |
|
208 | - * Checks whether this is a dummy command, which is only |
|
209 | - * used to access information on the command type. It cannot |
|
210 | - * be used as an actual live command. |
|
211 | - * |
|
212 | - * @return bool |
|
213 | - */ |
|
207 | + /** |
|
208 | + * Checks whether this is a dummy command, which is only |
|
209 | + * used to access information on the command type. It cannot |
|
210 | + * be used as an actual live command. |
|
211 | + * |
|
212 | + * @return bool |
|
213 | + */ |
|
214 | 214 | public function isDummy() : bool |
215 | 215 | { |
216 | 216 | return $this->type === '__dummy'; |
217 | 217 | } |
218 | 218 | |
219 | - /** |
|
220 | - * Retrieves a hash of the actual matched command string, |
|
221 | - * which is used in collections to detect duplicate commands. |
|
222 | - * |
|
223 | - * @return string |
|
224 | - */ |
|
219 | + /** |
|
220 | + * Retrieves a hash of the actual matched command string, |
|
221 | + * which is used in collections to detect duplicate commands. |
|
222 | + * |
|
223 | + * @return string |
|
224 | + */ |
|
225 | 225 | public function getHash() : string |
226 | 226 | { |
227 | 227 | $this->requireNonDummy(); |
@@ -323,9 +323,9 @@ discard block |
||
323 | 323 | return $this->validationResult->isValid(); |
324 | 324 | } |
325 | 325 | |
326 | - /** |
|
327 | - * @return string[] |
|
328 | - */ |
|
326 | + /** |
|
327 | + * @return string[] |
|
328 | + */ |
|
329 | 329 | abstract protected function getValidations() : array; |
330 | 330 | |
331 | 331 | protected function _validateNesting() : void |
@@ -413,12 +413,12 @@ discard block |
||
413 | 413 | |
414 | 414 | abstract public function supportsURLEncoding() : bool; |
415 | 415 | |
416 | - /** |
|
417 | - * Whether the command allows using logic keywords like "and:" or "or:" |
|
418 | - * in the command parameters. |
|
419 | - * |
|
420 | - * @return bool |
|
421 | - */ |
|
416 | + /** |
|
417 | + * Whether the command allows using logic keywords like "and:" or "or:" |
|
418 | + * in the command parameters. |
|
419 | + * |
|
420 | + * @return bool |
|
421 | + */ |
|
422 | 422 | abstract public function supportsLogicKeywords() : bool; |
423 | 423 | |
424 | 424 | abstract public function generatesContent() : bool; |
@@ -464,22 +464,22 @@ discard block |
||
464 | 464 | return $normalizer->normalize(); |
465 | 465 | } |
466 | 466 | |
467 | - /** |
|
468 | - * Retrieves the names of all the command's supported types: the part |
|
469 | - * between the command name and the colon. Example: {command type: params}. |
|
470 | - * |
|
471 | - * @return string[] |
|
472 | - */ |
|
467 | + /** |
|
468 | + * Retrieves the names of all the command's supported types: the part |
|
469 | + * between the command name and the colon. Example: {command type: params}. |
|
470 | + * |
|
471 | + * @return string[] |
|
472 | + */ |
|
473 | 473 | public function getSupportedTypes() : array |
474 | 474 | { |
475 | 475 | return array(); |
476 | 476 | } |
477 | 477 | |
478 | - /** |
|
479 | - * Retrieves all variable names used in the command. |
|
480 | - * |
|
481 | - * @return Mailcode_Variables_Collection_Regular |
|
482 | - */ |
|
478 | + /** |
|
479 | + * Retrieves all variable names used in the command. |
|
480 | + * |
|
481 | + * @return Mailcode_Variables_Collection_Regular |
|
482 | + */ |
|
483 | 483 | public function getVariables() : Mailcode_Variables_Collection_Regular |
484 | 484 | { |
485 | 485 | return Mailcode::create()->findVariables($this->paramsString); |
@@ -504,26 +504,26 @@ discard block |
||
504 | 504 | ); |
505 | 505 | } |
506 | 506 | |
507 | - /** |
|
508 | - * Sets a parameter for the translation backend. The backend can use |
|
509 | - * these to allow command-specific configurations. |
|
510 | - * |
|
511 | - * @param string $name |
|
512 | - * @param mixed $value |
|
513 | - * @return $this |
|
514 | - */ |
|
507 | + /** |
|
508 | + * Sets a parameter for the translation backend. The backend can use |
|
509 | + * these to allow command-specific configurations. |
|
510 | + * |
|
511 | + * @param string $name |
|
512 | + * @param mixed $value |
|
513 | + * @return $this |
|
514 | + */ |
|
515 | 515 | public function setTranslationParam(string $name, $value) |
516 | 516 | { |
517 | 517 | $this->translationParams[$name] = $value; |
518 | 518 | return $this; |
519 | 519 | } |
520 | 520 | |
521 | - /** |
|
522 | - * Retrieves a previously set translation parameter. |
|
523 | - * |
|
524 | - * @param string $name |
|
525 | - * @return mixed |
|
526 | - */ |
|
521 | + /** |
|
522 | + * Retrieves a previously set translation parameter. |
|
523 | + * |
|
524 | + * @param string $name |
|
525 | + * @return mixed |
|
526 | + */ |
|
527 | 527 | public function getTranslationParam(string $name) |
528 | 528 | { |
529 | 529 | if(isset($this->translationParams[$name])) |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | private $nestingValidated = false; |
132 | 132 | |
133 | - public function __construct(string $type='', string $paramsString='', string $matchedText='') |
|
133 | + public function __construct(string $type = '', string $paramsString = '', string $matchedText = '') |
|
134 | 134 | { |
135 | 135 | $this->type = $type; |
136 | 136 | $this->paramsString = html_entity_decode($paramsString); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | { |
227 | 227 | $this->requireNonDummy(); |
228 | 228 | |
229 | - if($this->hash === '') { |
|
229 | + if ($this->hash === '') { |
|
230 | 230 | $this->hash = md5($this->matchedText); |
231 | 231 | } |
232 | 232 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | protected function requireNonDummy() : void |
237 | 237 | { |
238 | - if(!$this->isDummy()) |
|
238 | + if (!$this->isDummy()) |
|
239 | 239 | { |
240 | 240 | return; |
241 | 241 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | |
255 | 255 | protected function validate() : OperationResult |
256 | 256 | { |
257 | - if(!$this->validated) |
|
257 | + if (!$this->validated) |
|
258 | 258 | { |
259 | 259 | $this->requireNonDummy(); |
260 | 260 | $this->validateSyntax(); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | |
268 | 268 | public function getValidationResult() : OperationResult |
269 | 269 | { |
270 | - if(isset($this->validationResult)) |
|
270 | + if (isset($this->validationResult)) |
|
271 | 271 | { |
272 | 272 | return $this->validationResult; |
273 | 273 | } |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | { |
284 | 284 | $validations = $this->resolveValidations(); |
285 | 285 | |
286 | - foreach($validations as $validation) |
|
286 | + foreach ($validations as $validation) |
|
287 | 287 | { |
288 | 288 | // break off at the first validation issue |
289 | - if(!$this->validateSyntaxMethod($validation)) |
|
289 | + if (!$this->validateSyntaxMethod($validation)) |
|
290 | 290 | { |
291 | 291 | return; |
292 | 292 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | { |
306 | 306 | $method = 'validateSyntax_'.$validation; |
307 | 307 | |
308 | - if(!method_exists($this, $method)) |
|
308 | + if (!method_exists($this, $method)) |
|
309 | 309 | { |
310 | 310 | throw new Mailcode_Exception( |
311 | 311 | 'Missing validation method ['.$validation.']', |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | |
336 | 336 | public function validateNesting() : OperationResult |
337 | 337 | { |
338 | - if($this->nestingValidated) |
|
338 | + if ($this->nestingValidated) |
|
339 | 339 | { |
340 | 340 | return $this->validationResult; |
341 | 341 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | |
360 | 360 | public function getType() : string |
361 | 361 | { |
362 | - if($this->supportsType()) |
|
362 | + if ($this->supportsType()) |
|
363 | 363 | { |
364 | 364 | return $this->type; |
365 | 365 | } |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | |
380 | 380 | public function getHighlighted() : string |
381 | 381 | { |
382 | - if(!$this->isValid()) |
|
382 | + if (!$this->isValid()) |
|
383 | 383 | { |
384 | 384 | return ''; |
385 | 385 | } |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | |
391 | 391 | public function getParamsString() : string |
392 | 392 | { |
393 | - if($this->requiresParameters()) |
|
393 | + if ($this->requiresParameters()) |
|
394 | 394 | { |
395 | 395 | return $this->paramsString; |
396 | 396 | } |
@@ -427,22 +427,22 @@ discard block |
||
427 | 427 | |
428 | 428 | public final function getCommandType() : string |
429 | 429 | { |
430 | - if($this instanceof Mailcode_Commands_Command_Type_Closing) |
|
430 | + if ($this instanceof Mailcode_Commands_Command_Type_Closing) |
|
431 | 431 | { |
432 | 432 | return 'Closing'; |
433 | 433 | } |
434 | 434 | |
435 | - if($this instanceof Mailcode_Commands_Command_Type_Opening) |
|
435 | + if ($this instanceof Mailcode_Commands_Command_Type_Opening) |
|
436 | 436 | { |
437 | 437 | return 'Opening'; |
438 | 438 | } |
439 | 439 | |
440 | - if($this instanceof Mailcode_Commands_Command_Type_Sibling) |
|
440 | + if ($this instanceof Mailcode_Commands_Command_Type_Sibling) |
|
441 | 441 | { |
442 | 442 | return 'Sibling'; |
443 | 443 | } |
444 | 444 | |
445 | - if($this instanceof Mailcode_Commands_Command_Type_Standalone) |
|
445 | + if ($this instanceof Mailcode_Commands_Command_Type_Standalone) |
|
446 | 446 | { |
447 | 447 | return 'Standalone'; |
448 | 448 | } |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | |
493 | 493 | public function getLogicKeywords() : Mailcode_Commands_LogicKeywords |
494 | 494 | { |
495 | - if($this->supportsLogicKeywords() && isset($this->logicKeywords)) |
|
495 | + if ($this->supportsLogicKeywords() && isset($this->logicKeywords)) |
|
496 | 496 | { |
497 | 497 | return $this->logicKeywords; |
498 | 498 | } |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | */ |
527 | 527 | public function getTranslationParam(string $name) |
528 | 528 | { |
529 | - if(isset($this->translationParams[$name])) |
|
529 | + if (isset($this->translationParams[$name])) |
|
530 | 530 | { |
531 | 531 | return $this->translationParams[$name]; |
532 | 532 | } |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | * @param bool $encoding |
539 | 539 | * @return $this |
540 | 540 | */ |
541 | - public function setURLEncoding(bool $encoding=true) |
|
541 | + public function setURLEncoding(bool $encoding = true) |
|
542 | 542 | { |
543 | 543 | $this->requireURLEncoding(); |
544 | 544 | |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | * @return $this |
555 | 555 | * @throws Mailcode_Exception |
556 | 556 | */ |
557 | - public function setURLDecoding(bool $decode=true) |
|
557 | + public function setURLDecoding(bool $decode = true) |
|
558 | 558 | { |
559 | 559 | $this->requireURLEncoding(); |
560 | 560 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | |
566 | 566 | protected function requireURLEncoding() : void |
567 | 567 | { |
568 | - if($this->supportsURLEncoding()) { |
|
568 | + if ($this->supportsURLEncoding()) { |
|
569 | 569 | return; |
570 | 570 | } |
571 | 571 |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | protected function _validateNesting() : void |
71 | 71 | { |
72 | - if($this->findParentFor($this)) |
|
72 | + if ($this->findParentFor($this)) |
|
73 | 73 | { |
74 | 74 | return; |
75 | 75 | } |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | { |
85 | 85 | $parent = $command->getParent(); |
86 | 86 | |
87 | - if($parent === null) |
|
87 | + if ($parent === null) |
|
88 | 88 | { |
89 | 89 | return false; |
90 | 90 | } |
91 | 91 | |
92 | - if($parent instanceof Mailcode_Commands_Command_For) |
|
92 | + if ($parent instanceof Mailcode_Commands_Command_For) |
|
93 | 93 | { |
94 | 94 | return true; |
95 | 95 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | $this->instantiator->checkCommand($cmd); |
36 | 36 | |
37 | - if($cmd instanceof Mailcode_Commands_Command_Comment) |
|
37 | + if ($cmd instanceof Mailcode_Commands_Command_Comment) |
|
38 | 38 | { |
39 | 39 | return $cmd; |
40 | 40 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | throw $this->instantiator->exceptionUnexpectedType('Comment', $cmd); |
43 | 43 | } |
44 | 44 | |
45 | - public function for(string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For |
|
45 | + public function for (string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For |
|
46 | 46 | { |
47 | 47 | $sourceVariable = '$'.ltrim($sourceVariable, '$'); |
48 | 48 | $loopVariable = '$'.ltrim($loopVariable, '$'); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | $this->instantiator->checkCommand($cmd); |
66 | 66 | |
67 | - if($cmd instanceof Mailcode_Commands_Command_For) |
|
67 | + if ($cmd instanceof Mailcode_Commands_Command_For) |
|
68 | 68 | { |
69 | 69 | return $cmd; |
70 | 70 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | $this->instantiator->checkCommand($cmd); |
85 | 85 | |
86 | - if($cmd instanceof Mailcode_Commands_Command_Break) |
|
86 | + if ($cmd instanceof Mailcode_Commands_Command_Break) |
|
87 | 87 | { |
88 | 88 | return $cmd; |
89 | 89 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | $this->instantiator->checkCommand($cmd); |
110 | 110 | |
111 | - if($cmd instanceof Mailcode_Commands_Command_Code) |
|
111 | + if ($cmd instanceof Mailcode_Commands_Command_Code) |
|
112 | 112 | { |
113 | 113 | return $cmd; |
114 | 114 | } |