@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | function init() : void |
25 | 25 | { |
26 | - if(!class_exists('\AppLocalize\Localization')) { |
|
26 | + if (!class_exists('\AppLocalize\Localization')) { |
|
27 | 27 | return; |
28 | 28 | } |
29 | 29 |
@@ -20,19 +20,19 @@ |
||
20 | 20 | */ |
21 | 21 | abstract class Mailcode_Collection_Error |
22 | 22 | { |
23 | - /** |
|
24 | - * @var integer |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var integer |
|
25 | + */ |
|
26 | 26 | protected $code = 0; |
27 | 27 | |
28 | - /** |
|
29 | - * @var string |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var string |
|
30 | + */ |
|
31 | 31 | protected $matchedText = ''; |
32 | 32 | |
33 | - /** |
|
34 | - * @var string |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var string |
|
35 | + */ |
|
36 | 36 | protected $message = ''; |
37 | 37 | |
38 | 38 | public function getCode() : int |
@@ -60,11 +60,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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( |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | protected function validate_Closing(Mailcode_Commands_Command_Type_Closing $command) : void |
183 | 183 | { |
184 | - if(empty($this->stack)) |
|
184 | + if (empty($this->stack)) |
|
185 | 185 | { |
186 | 186 | $this->validationResult->makeError( |
187 | 187 | t('All open commands have already been ended.'), |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | |
25 | 25 | const ERROR_UNEXPECTED_COMMAND_TYPE = 50002; |
26 | 26 | |
27 | - /** |
|
28 | - * Creates a ShowVariable command. |
|
29 | - * |
|
30 | - * @param string $variableName A variable name, with or without the $ sign prepended. |
|
31 | - * @return Mailcode_Commands_Command_ShowVariable |
|
32 | - */ |
|
27 | + /** |
|
28 | + * Creates a ShowVariable command. |
|
29 | + * |
|
30 | + * @param string $variableName A variable name, with or without the $ sign prepended. |
|
31 | + * @return Mailcode_Commands_Command_ShowVariable |
|
32 | + */ |
|
33 | 33 | public static function showVariable(string $variableName) : Mailcode_Commands_Command_ShowVariable |
34 | 34 | { |
35 | 35 | $variableName = self::_filterVariableName($variableName); |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | return $cmd; |
46 | 46 | } |
47 | 47 | |
48 | - /** |
|
49 | - * Creates a SetVariable command. |
|
50 | - * |
|
51 | - * @param string $variableName A variable name, with or without the $ sign prepended. |
|
52 | - * @param string $value |
|
53 | - * @param bool $quoteValue Whether to treat the value as a string literal, and add quotes to it. |
|
54 | - * @return Mailcode_Commands_Command_SetVariable |
|
55 | - * @throws Mailcode_Factory_Exception |
|
56 | - * |
|
57 | - * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED |
|
58 | - */ |
|
48 | + /** |
|
49 | + * Creates a SetVariable command. |
|
50 | + * |
|
51 | + * @param string $variableName A variable name, with or without the $ sign prepended. |
|
52 | + * @param string $value |
|
53 | + * @param bool $quoteValue Whether to treat the value as a string literal, and add quotes to it. |
|
54 | + * @return Mailcode_Commands_Command_SetVariable |
|
55 | + * @throws Mailcode_Factory_Exception |
|
56 | + * |
|
57 | + * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED |
|
58 | + */ |
|
59 | 59 | public static function setVariable(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable |
60 | 60 | { |
61 | 61 | $variableName = self::_filterVariableName($variableName); |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | return '$'.ltrim($name, '$'); |
266 | 266 | } |
267 | 267 | |
268 | - /** |
|
269 | - * Quotes a string literal: adds the quotes, and escapes any quotes already present in it. |
|
270 | - * |
|
271 | - * @param string $string |
|
272 | - * @return string |
|
273 | - */ |
|
268 | + /** |
|
269 | + * Quotes a string literal: adds the quotes, and escapes any quotes already present in it. |
|
270 | + * |
|
271 | + * @param string $string |
|
272 | + * @return string |
|
273 | + */ |
|
274 | 274 | protected static function _quoteString(string $string) : string |
275 | 275 | { |
276 | 276 | return '"'.str_replace('"', '\"', $string).'"'; |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED |
58 | 58 | */ |
59 | - public static function setVariable(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable |
|
59 | + public static function setVariable(string $variableName, string $value, bool $quoteValue = true) : Mailcode_Commands_Command_SetVariable |
|
60 | 60 | { |
61 | 61 | $variableName = self::_filterVariableName($variableName); |
62 | 62 | |
63 | - if($quoteValue) |
|
63 | + if ($quoteValue) |
|
64 | 64 | { |
65 | 65 | $value = self::_quoteString($value); |
66 | 66 | } |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | return $cmd; |
121 | 121 | } |
122 | 122 | |
123 | - protected static function _buildIf(string $cmd, string $condition, string $type='') : Mailcode_Commands_Command |
|
123 | + protected static function _buildIf(string $cmd, string $condition, string $type = '') : Mailcode_Commands_Command |
|
124 | 124 | { |
125 | 125 | $stringType = $type; |
126 | 126 | |
127 | - if(!empty($type)) |
|
127 | + if (!empty($type)) |
|
128 | 128 | { |
129 | 129 | $stringType = ' '.$type; |
130 | 130 | } |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | return $cmd; |
148 | 148 | } |
149 | 149 | |
150 | - protected static function _buildIfVar(string $cmd, string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command |
|
150 | + protected static function _buildIfVar(string $cmd, string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command |
|
151 | 151 | { |
152 | - if($quoteValue) |
|
152 | + if ($quoteValue) |
|
153 | 153 | { |
154 | 154 | $value = self::_quoteString($value); |
155 | 155 | } |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | return self::_buildIf($cmd, $condition, 'variable'); |
165 | 165 | } |
166 | 166 | |
167 | - public static function if(string $condition, string $type='') : Mailcode_Commands_Command_If |
|
167 | + public static function if (string $condition, string $type = '') : Mailcode_Commands_Command_If |
|
168 | 168 | { |
169 | 169 | $cmd = self::_buildIf('If', $condition, $type); |
170 | 170 | |
171 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
171 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
172 | 172 | { |
173 | 173 | return $cmd; |
174 | 174 | } |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | throw self::_exceptionUnexpectedType($cmd); |
177 | 177 | } |
178 | 178 | |
179 | - public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If |
|
179 | + public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If |
|
180 | 180 | { |
181 | 181 | $cmd = self::_buildIfVar('If', $variable, $operand, $value, $quoteValue); |
182 | 182 | |
183 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
183 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
184 | 184 | { |
185 | 185 | return $cmd; |
186 | 186 | } |
@@ -188,11 +188,11 @@ discard block |
||
188 | 188 | throw self::_exceptionUnexpectedType($cmd); |
189 | 189 | } |
190 | 190 | |
191 | - public static function ifVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If |
|
191 | + public static function ifVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If |
|
192 | 192 | { |
193 | 193 | $cmd = self::_buildIfVar('If', $variable, '==', $value, $quoteValue); |
194 | 194 | |
195 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
195 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
196 | 196 | { |
197 | 197 | return $cmd; |
198 | 198 | } |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | throw self::_exceptionUnexpectedType($cmd); |
201 | 201 | } |
202 | 202 | |
203 | - public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If |
|
203 | + public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If |
|
204 | 204 | { |
205 | 205 | $cmd = self::_buildIfVar('If', $variable, '!=', $value, $quoteValue); |
206 | 206 | |
207 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
207 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
208 | 208 | { |
209 | 209 | return $cmd; |
210 | 210 | } |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | throw self::_exceptionUnexpectedType($cmd); |
213 | 213 | } |
214 | 214 | |
215 | - public static function elseIf(string $condition, string $type='') : Mailcode_Commands_Command_ElseIf |
|
215 | + public static function elseIf (string $condition, string $type = '') : Mailcode_Commands_Command_ElseIf |
|
216 | 216 | { |
217 | 217 | $cmd = self::_buildIf('ElseIf', $condition, $type); |
218 | 218 | |
219 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
219 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
220 | 220 | { |
221 | 221 | return $cmd; |
222 | 222 | } |
@@ -224,11 +224,11 @@ discard block |
||
224 | 224 | throw self::_exceptionUnexpectedType($cmd); |
225 | 225 | } |
226 | 226 | |
227 | - public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf |
|
227 | + public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf |
|
228 | 228 | { |
229 | 229 | $cmd = self::_buildIfVar('ElseIf', $variable, $operand, $value, $quoteValue); |
230 | 230 | |
231 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
231 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
232 | 232 | { |
233 | 233 | return $cmd; |
234 | 234 | } |
@@ -236,11 +236,11 @@ discard block |
||
236 | 236 | throw self::_exceptionUnexpectedType($cmd); |
237 | 237 | } |
238 | 238 | |
239 | - public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf |
|
239 | + public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf |
|
240 | 240 | { |
241 | 241 | $cmd = self::_buildIfVar('ElseIf', $variable, '==', $value, $quoteValue); |
242 | 242 | |
243 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
243 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
244 | 244 | { |
245 | 245 | return $cmd; |
246 | 246 | } |
@@ -248,11 +248,11 @@ discard block |
||
248 | 248 | throw self::_exceptionUnexpectedType($cmd); |
249 | 249 | } |
250 | 250 | |
251 | - public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf |
|
251 | + public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf |
|
252 | 252 | { |
253 | 253 | $cmd = self::_buildIfVar('ElseIf', $variable, '!=', $value, $quoteValue); |
254 | 254 | |
255 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
255 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
256 | 256 | { |
257 | 257 | return $cmd; |
258 | 258 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | |
279 | 279 | protected static function _checkCommand(Mailcode_Commands_Command $command) : void |
280 | 280 | { |
281 | - if($command->isValid()) |
|
281 | + if ($command->isValid()) |
|
282 | 282 | { |
283 | 283 | return; |
284 | 284 | } |
@@ -94,13 +94,15 @@ |
||
94 | 94 | return $cmd; |
95 | 95 | } |
96 | 96 | |
97 | - public static function else() : Mailcode_Commands_Command_Else |
|
97 | + public static function else { |
|
98 | + () : Mailcode_Commands_Command_Else |
|
98 | 99 | { |
99 | 100 | $cmd = new Mailcode_Commands_Command_Else( |
100 | 101 | '', // type, |
101 | 102 | '', // params, |
102 | 103 | '{else}' |
103 | 104 | ); |
105 | + } |
|
104 | 106 | |
105 | 107 | self::_checkCommand($cmd); |
106 | 108 |
@@ -30,44 +30,44 @@ discard block |
||
30 | 30 | const VALIDATION_UNKNOWN_COMMAND_NAME = 48304; |
31 | 31 | const VALIDATION_INVALID_PARAMS_STATEMENT = 48305; |
32 | 32 | |
33 | - /** |
|
34 | - * @var string |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var string |
|
35 | + */ |
|
36 | 36 | protected $type = ''; |
37 | 37 | |
38 | - /** |
|
39 | - * @var string |
|
40 | - */ |
|
38 | + /** |
|
39 | + * @var string |
|
40 | + */ |
|
41 | 41 | protected $paramsString = ''; |
42 | 42 | |
43 | - /** |
|
44 | - * @var string |
|
45 | - */ |
|
43 | + /** |
|
44 | + * @var string |
|
45 | + */ |
|
46 | 46 | protected $matchedText = ''; |
47 | 47 | |
48 | - /** |
|
49 | - * @var string |
|
50 | - */ |
|
48 | + /** |
|
49 | + * @var string |
|
50 | + */ |
|
51 | 51 | protected $hash = ''; |
52 | 52 | |
53 | - /** |
|
54 | - * @var \AppUtils\OperationResult |
|
55 | - */ |
|
53 | + /** |
|
54 | + * @var \AppUtils\OperationResult |
|
55 | + */ |
|
56 | 56 | protected $validationResult = null; |
57 | 57 | |
58 | - /** |
|
59 | - * @var \Mailcode\Mailcode |
|
60 | - */ |
|
58 | + /** |
|
59 | + * @var \Mailcode\Mailcode |
|
60 | + */ |
|
61 | 61 | protected $mailcode; |
62 | 62 | |
63 | - /** |
|
64 | - * @var \Mailcode\Mailcode_Parser_Statement |
|
65 | - */ |
|
63 | + /** |
|
64 | + * @var \Mailcode\Mailcode_Parser_Statement |
|
65 | + */ |
|
66 | 66 | protected $params; |
67 | 67 | |
68 | - /** |
|
69 | - * @var string[] |
|
70 | - */ |
|
68 | + /** |
|
69 | + * @var string[] |
|
70 | + */ |
|
71 | 71 | protected $validations = array( |
72 | 72 | 'params', |
73 | 73 | 'type_supported', |
@@ -89,33 +89,33 @@ discard block |
||
89 | 89 | |
90 | 90 | } |
91 | 91 | |
92 | - /** |
|
93 | - * @return string The ID of the command = the name of the command class file. |
|
94 | - */ |
|
92 | + /** |
|
93 | + * @return string The ID of the command = the name of the command class file. |
|
94 | + */ |
|
95 | 95 | public function getID() : string |
96 | 96 | { |
97 | 97 | $tokens = explode('_', get_class($this)); |
98 | 98 | return array_pop($tokens); |
99 | 99 | } |
100 | 100 | |
101 | - /** |
|
102 | - * Checks whether this is a dummy command, which is only |
|
103 | - * used to access information on the command type. It cannot |
|
104 | - * be used as an actual live command. |
|
105 | - * |
|
106 | - * @return bool |
|
107 | - */ |
|
101 | + /** |
|
102 | + * Checks whether this is a dummy command, which is only |
|
103 | + * used to access information on the command type. It cannot |
|
104 | + * be used as an actual live command. |
|
105 | + * |
|
106 | + * @return bool |
|
107 | + */ |
|
108 | 108 | public function isDummy() : bool |
109 | 109 | { |
110 | 110 | return $this->type === '__dummy'; |
111 | 111 | } |
112 | 112 | |
113 | - /** |
|
114 | - * Retrieves a hash of the actual matched command string, |
|
115 | - * which is used in collections to detect duplicate commands. |
|
116 | - * |
|
117 | - * @return string |
|
118 | - */ |
|
113 | + /** |
|
114 | + * Retrieves a hash of the actual matched command string, |
|
115 | + * which is used in collections to detect duplicate commands. |
|
116 | + * |
|
117 | + * @return string |
|
118 | + */ |
|
119 | 119 | public function getHash() : string |
120 | 120 | { |
121 | 121 | $this->requireNonDummy(); |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
210 | - /** |
|
211 | - * @return string[] |
|
212 | - */ |
|
210 | + /** |
|
211 | + * @return string[] |
|
212 | + */ |
|
213 | 213 | abstract protected function getValidations() : array; |
214 | 214 | |
215 | 215 | protected function validateSyntax_params() : void |
@@ -364,12 +364,12 @@ discard block |
||
364 | 364 | return implode('', $parts); |
365 | 365 | } |
366 | 366 | |
367 | - /** |
|
368 | - * Retrieves the names of all the command's supported types: the part |
|
369 | - * between the command name and the colon. Example: {command type: params}. |
|
370 | - * |
|
371 | - * @return string[] |
|
372 | - */ |
|
367 | + /** |
|
368 | + * Retrieves the names of all the command's supported types: the part |
|
369 | + * between the command name and the colon. Example: {command type: params}. |
|
370 | + * |
|
371 | + * @return string[] |
|
372 | + */ |
|
373 | 373 | public function getSupportedTypes() : array |
374 | 374 | { |
375 | 375 | return array(); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | 'type_unsupported' |
75 | 75 | ); |
76 | 76 | |
77 | - public function __construct(string $type='', string $paramsString='', string $matchedText='') |
|
77 | + public function __construct(string $type = '', string $paramsString = '', string $matchedText = '') |
|
78 | 78 | { |
79 | 79 | $this->type = $type; |
80 | 80 | $this->paramsString = $paramsString; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | $this->requireNonDummy(); |
122 | 122 | |
123 | - if($this->hash === '') { |
|
123 | + if ($this->hash === '') { |
|
124 | 124 | $this->hash = md5($this->matchedText); |
125 | 125 | } |
126 | 126 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | protected function requireNonDummy() : void |
131 | 131 | { |
132 | - if(!$this->isDummy()) |
|
132 | + if (!$this->isDummy()) |
|
133 | 133 | { |
134 | 134 | return; |
135 | 135 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | { |
151 | 151 | $this->requireNonDummy(); |
152 | 152 | |
153 | - if(isset($this->validationResult)) |
|
153 | + if (isset($this->validationResult)) |
|
154 | 154 | { |
155 | 155 | return $this->validationResult; |
156 | 156 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | public function getValidationResult() : \AppUtils\OperationResult |
166 | 166 | { |
167 | - if(isset($this->validationResult)) |
|
167 | + if (isset($this->validationResult)) |
|
168 | 168 | { |
169 | 169 | return $this->validationResult; |
170 | 170 | } |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | { |
181 | 181 | $validations = array_merge($this->validations, $this->getValidations()); |
182 | 182 | |
183 | - foreach($validations as $validation) |
|
183 | + foreach ($validations as $validation) |
|
184 | 184 | { |
185 | 185 | $method = 'validateSyntax_'.$validation; |
186 | 186 | |
187 | - if(!method_exists($this, $method)) |
|
187 | + if (!method_exists($this, $method)) |
|
188 | 188 | { |
189 | 189 | throw new Mailcode_Exception( |
190 | 190 | 'Missing validation method', |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $this->$method(); |
201 | 201 | |
202 | 202 | // break off at the first validation issue |
203 | - if(!$this->validationResult->isValid()) |
|
203 | + if (!$this->validationResult->isValid()) |
|
204 | 204 | { |
205 | 205 | return; |
206 | 206 | } |
@@ -214,12 +214,12 @@ discard block |
||
214 | 214 | |
215 | 215 | protected function validateSyntax_params() : void |
216 | 216 | { |
217 | - if(!$this->requiresParameters()) |
|
217 | + if (!$this->requiresParameters()) |
|
218 | 218 | { |
219 | 219 | return; |
220 | 220 | } |
221 | 221 | |
222 | - if(empty($this->paramsString)) |
|
222 | + if (empty($this->paramsString)) |
|
223 | 223 | { |
224 | 224 | $this->validationResult->makeError( |
225 | 225 | t('Parameters have to be specified.'), |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | $this->params = $this->mailcode->getParser()->createStatement($this->paramsString); |
232 | 232 | |
233 | - if(!$this->params->isValid()) |
|
233 | + if (!$this->params->isValid()) |
|
234 | 234 | { |
235 | 235 | $error = $this->params->getValidationResult(); |
236 | 236 | |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | |
244 | 244 | protected function validateSyntax_type_supported() : void |
245 | 245 | { |
246 | - if(!$this->supportsType() || empty($this->type)) |
|
246 | + if (!$this->supportsType() || empty($this->type)) |
|
247 | 247 | { |
248 | 248 | return; |
249 | 249 | } |
250 | 250 | |
251 | 251 | $types = $this->getSupportedTypes(); |
252 | 252 | |
253 | - if(!in_array($this->type, $types)) |
|
253 | + if (!in_array($this->type, $types)) |
|
254 | 254 | { |
255 | 255 | $this->validationResult->makeError( |
256 | 256 | t('The command addon %1$s is not supported.', $this->type).' '. |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | |
265 | 265 | protected function validateSyntax_type_unsupported() : void |
266 | 266 | { |
267 | - if($this->supportsType() || empty($this->type)) |
|
267 | + if ($this->supportsType() || empty($this->type)) |
|
268 | 268 | { |
269 | 269 | return; |
270 | 270 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | |
283 | 283 | public function getType() : string |
284 | 284 | { |
285 | - if($this->supportsType()) |
|
285 | + if ($this->supportsType()) |
|
286 | 286 | { |
287 | 287 | return $this->type; |
288 | 288 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | public function getHighlighted() : string |
304 | 304 | { |
305 | - if(!$this->isValid()) |
|
305 | + if (!$this->isValid()) |
|
306 | 306 | { |
307 | 307 | return ''; |
308 | 308 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | |
314 | 314 | public function getParamsString() : string |
315 | 315 | { |
316 | - if($this->requiresParameters()) |
|
316 | + if ($this->requiresParameters()) |
|
317 | 317 | { |
318 | 318 | return $this->paramsString; |
319 | 319 | } |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | |
341 | 341 | public function getNormalized() : string |
342 | 342 | { |
343 | - if(!$this->isValid()) |
|
343 | + if (!$this->isValid()) |
|
344 | 344 | { |
345 | 345 | return ''; |
346 | 346 | } |
@@ -348,12 +348,12 @@ discard block |
||
348 | 348 | $parts = array(); |
349 | 349 | $parts[] = '{'.$this->getName(); |
350 | 350 | |
351 | - if($this->supportsType() && $this->hasType()) |
|
351 | + if ($this->supportsType() && $this->hasType()) |
|
352 | 352 | { |
353 | 353 | $parts[] = ' '.$this->getType(); |
354 | 354 | } |
355 | 355 | |
356 | - if($this->requiresParameters() && isset($this->params)) |
|
356 | + if ($this->requiresParameters() && isset($this->params)) |
|
357 | 357 | { |
358 | 358 | $parts[] = ': '; |
359 | 359 | $parts[] = $this->params->getNormalized(); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | { |
59 | 59 | $variable = $this->params->getInfo()->getVariableByIndex(0); |
60 | 60 | |
61 | - if($variable) |
|
61 | + if ($variable) |
|
62 | 62 | { |
63 | 63 | return $variable->getVariable(); |
64 | 64 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | protected function validateSyntax_assignment() : void |
88 | 88 | { |
89 | - if($this->params->getInfo()->isVariableAssignment()) |
|
89 | + if ($this->params->getInfo()->isVariableAssignment()) |
|
90 | 90 | { |
91 | 91 | return; |
92 | 92 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | protected function init() : void |
24 | 24 | { |
25 | 25 | // automatically quote the parameters, since comments don't require any. |
26 | - if(!strstr($this->paramsString, '"')) |
|
26 | + if (!strstr($this->paramsString, '"')) |
|
27 | 27 | { |
28 | 28 | $this->paramsString = '"'.$this->paramsString.'"'; |
29 | 29 | } |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | |
25 | 25 | const VALIDATION_VARIABLE_COUNT_MISMATCH = 48401; |
26 | 26 | |
27 | - /** |
|
28 | - * @var Mailcode_Variables_Variable|NULL |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var Mailcode_Variables_Variable|NULL |
|
29 | + */ |
|
30 | 30 | protected $variable; |
31 | 31 | |
32 | 32 | public function getName() : string |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | return true; |
50 | 50 | } |
51 | 51 | |
52 | - /** |
|
53 | - * Retrieves the variable to show. |
|
54 | - * |
|
55 | - * NOTE: Only available once the command has been |
|
56 | - * validated. Always use isValid() first. |
|
57 | - * |
|
58 | - * @throws Mailcode_Exception |
|
59 | - * @return Mailcode_Variables_Variable |
|
60 | - */ |
|
52 | + /** |
|
53 | + * Retrieves the variable to show. |
|
54 | + * |
|
55 | + * NOTE: Only available once the command has been |
|
56 | + * validated. Always use isValid() first. |
|
57 | + * |
|
58 | + * @throws Mailcode_Exception |
|
59 | + * @return Mailcode_Variables_Variable |
|
60 | + */ |
|
61 | 61 | public function getVariable() : Mailcode_Variables_Variable |
62 | 62 | { |
63 | 63 | $this->validate(); |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | ); |
75 | 75 | } |
76 | 76 | |
77 | - /** |
|
78 | - * Retrieves the full name of the variable to show. |
|
79 | - * |
|
80 | - * NOTE: Only available once the command has been |
|
81 | - * validated. Always use isValid() first. |
|
82 | - * |
|
83 | - * @throws Mailcode_Exception |
|
84 | - * @return string |
|
85 | - */ |
|
77 | + /** |
|
78 | + * Retrieves the full name of the variable to show. |
|
79 | + * |
|
80 | + * NOTE: Only available once the command has been |
|
81 | + * validated. Always use isValid() first. |
|
82 | + * |
|
83 | + * @throws Mailcode_Exception |
|
84 | + * @return string |
|
85 | + */ |
|
86 | 86 | public function getVariableName() : string |
87 | 87 | { |
88 | 88 | return $this->getVariable()->getFullName(); |
@@ -90,19 +90,19 @@ discard block |
||
90 | 90 | |
91 | 91 | protected function validateSyntax_require_variable() : void |
92 | 92 | { |
93 | - $vars = $this->getVariables()->getGroupedByName(); |
|
94 | - $amount = count($vars); |
|
93 | + $vars = $this->getVariables()->getGroupedByName(); |
|
94 | + $amount = count($vars); |
|
95 | 95 | |
96 | - if($amount === 1) |
|
97 | - { |
|
98 | - $this->variable = array_pop($vars); |
|
99 | - return; |
|
100 | - } |
|
96 | + if($amount === 1) |
|
97 | + { |
|
98 | + $this->variable = array_pop($vars); |
|
99 | + return; |
|
100 | + } |
|
101 | 101 | |
102 | - $this->validationResult->makeError( |
|
102 | + $this->validationResult->makeError( |
|
103 | 103 | t('Command has %1$s variables, %2$s expected.', $amount, 1), |
104 | 104 | self::VALIDATION_VARIABLE_COUNT_MISMATCH |
105 | - ); |
|
105 | + ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | protected function getValidations() : array |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | $this->validate(); |
64 | 64 | |
65 | - if(isset($this->variable)) |
|
65 | + if (isset($this->variable)) |
|
66 | 66 | { |
67 | 67 | return $this->variable; |
68 | 68 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $vars = $this->getVariables()->getGroupedByName(); |
94 | 94 | $amount = count($vars); |
95 | 95 | |
96 | - if($amount === 1) |
|
96 | + if ($amount === 1) |
|
97 | 97 | { |
98 | 98 | $this->variable = array_pop($vars); |
99 | 99 | return; |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | { |
23 | 23 | const VALIDATION_VARIABLE_COUNT_MISMATCH = 49201; |
24 | 24 | |
25 | - /** |
|
26 | - * @var Mailcode_Variables_Variable |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var Mailcode_Variables_Variable |
|
27 | + */ |
|
28 | 28 | protected $variable; |
29 | 29 | |
30 | 30 | public function getName() : string |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | return $this->type === 'variable'; |
58 | 58 | } |
59 | 59 | |
60 | - /** |
|
61 | - * Available only if the command is of type "variable". |
|
62 | - * |
|
63 | - * @return Mailcode_Variables_Variable|NULL |
|
64 | - */ |
|
60 | + /** |
|
61 | + * Available only if the command is of type "variable". |
|
62 | + * |
|
63 | + * @return Mailcode_Variables_Variable|NULL |
|
64 | + */ |
|
65 | 65 | public function getVariable() : ?Mailcode_Variables_Variable |
66 | 66 | { |
67 | 67 | if(isset($this->variable)) |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function getVariable() : ?Mailcode_Variables_Variable |
66 | 66 | { |
67 | - if(isset($this->variable)) |
|
67 | + if (isset($this->variable)) |
|
68 | 68 | { |
69 | 69 | return $this->variable; |
70 | 70 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | { |
77 | 77 | $amount = $this->getVariables()->countVariables(); |
78 | 78 | |
79 | - if($amount >= 1) |
|
79 | + if ($amount >= 1) |
|
80 | 80 | { |
81 | 81 | return; |
82 | 82 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | { |
92 | 92 | $validations = array(); |
93 | 93 | |
94 | - if($this->getType() === 'variable') |
|
94 | + if ($this->getType() === 'variable') |
|
95 | 95 | { |
96 | 96 | $validations[] = 'require_variable'; |
97 | 97 | } |