@@ -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 |
@@ -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 | |
@@ -24,17 +24,17 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | const ERROR_UNEXPECTED_COMMAND_TYPE = 50002; |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var Mailcode_Renderer |
|
| 29 | - */ |
|
| 27 | + /** |
|
| 28 | + * @var Mailcode_Renderer |
|
| 29 | + */ |
|
| 30 | 30 | protected static $renderer; |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Creates a ShowVariable command. |
|
| 34 | - * |
|
| 35 | - * @param string $variableName A variable name, with or without the $ sign prepended. |
|
| 36 | - * @return Mailcode_Commands_Command_ShowVariable |
|
| 37 | - */ |
|
| 32 | + /** |
|
| 33 | + * Creates a ShowVariable command. |
|
| 34 | + * |
|
| 35 | + * @param string $variableName A variable name, with or without the $ sign prepended. |
|
| 36 | + * @return Mailcode_Commands_Command_ShowVariable |
|
| 37 | + */ |
|
| 38 | 38 | public static function showVar(string $variableName) : Mailcode_Commands_Command_ShowVariable |
| 39 | 39 | { |
| 40 | 40 | $variableName = self::_filterVariableName($variableName); |
@@ -50,17 +50,17 @@ discard block |
||
| 50 | 50 | return $cmd; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Creates a SetVariable command. |
|
| 55 | - * |
|
| 56 | - * @param string $variableName A variable name, with or without the $ sign prepended. |
|
| 57 | - * @param string $value |
|
| 58 | - * @param bool $quoteValue Whether to treat the value as a string literal, and add quotes to it. |
|
| 59 | - * @return Mailcode_Commands_Command_SetVariable |
|
| 60 | - * @throws Mailcode_Factory_Exception |
|
| 61 | - * |
|
| 62 | - * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED |
|
| 63 | - */ |
|
| 53 | + /** |
|
| 54 | + * Creates a SetVariable command. |
|
| 55 | + * |
|
| 56 | + * @param string $variableName A variable name, with or without the $ sign prepended. |
|
| 57 | + * @param string $value |
|
| 58 | + * @param bool $quoteValue Whether to treat the value as a string literal, and add quotes to it. |
|
| 59 | + * @return Mailcode_Commands_Command_SetVariable |
|
| 60 | + * @throws Mailcode_Factory_Exception |
|
| 61 | + * |
|
| 62 | + * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED |
|
| 63 | + */ |
|
| 64 | 64 | public static function setVar(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable |
| 65 | 65 | { |
| 66 | 66 | $variableName = self::_filterVariableName($variableName); |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | return $cmd; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Like setVar(), but treats the value as a string literal |
|
| 88 | - * and automatically adds quotes to it. |
|
| 89 | - * |
|
| 90 | - * @param string $variableName |
|
| 91 | - * @param string $value |
|
| 92 | - * @return Mailcode_Commands_Command_SetVariable |
|
| 93 | - */ |
|
| 86 | + /** |
|
| 87 | + * Like setVar(), but treats the value as a string literal |
|
| 88 | + * and automatically adds quotes to it. |
|
| 89 | + * |
|
| 90 | + * @param string $variableName |
|
| 91 | + * @param string $value |
|
| 92 | + * @return Mailcode_Commands_Command_SetVariable |
|
| 93 | + */ |
|
| 94 | 94 | public static function setVarString(string $variableName, string $value) : Mailcode_Commands_Command_SetVariable |
| 95 | 95 | { |
| 96 | 96 | return self::setVar($variableName, $value, true); |
@@ -355,12 +355,12 @@ discard block |
||
| 355 | 355 | return '$'.ltrim($name, '$'); |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - /** |
|
| 359 | - * Quotes a string literal: adds the quotes, and escapes any quotes already present in it. |
|
| 360 | - * |
|
| 361 | - * @param string $string |
|
| 362 | - * @return string |
|
| 363 | - */ |
|
| 358 | + /** |
|
| 359 | + * Quotes a string literal: adds the quotes, and escapes any quotes already present in it. |
|
| 360 | + * |
|
| 361 | + * @param string $string |
|
| 362 | + * @return string |
|
| 363 | + */ |
|
| 364 | 364 | protected static function _quoteString(string $string) : string |
| 365 | 365 | { |
| 366 | 366 | return '"'.str_replace('"', '\"', $string).'"'; |
@@ -393,23 +393,23 @@ discard block |
||
| 393 | 393 | ); |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | - /** |
|
| 397 | - * Creates a renderer instance, which can be used to easily |
|
| 398 | - * create and convert commands to strings. |
|
| 399 | - * |
|
| 400 | - * @return Mailcode_Renderer |
|
| 401 | - */ |
|
| 396 | + /** |
|
| 397 | + * Creates a renderer instance, which can be used to easily |
|
| 398 | + * create and convert commands to strings. |
|
| 399 | + * |
|
| 400 | + * @return Mailcode_Renderer |
|
| 401 | + */ |
|
| 402 | 402 | public static function createRenderer() : Mailcode_Renderer |
| 403 | 403 | { |
| 404 | 404 | return new Mailcode_Renderer(); |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - /** |
|
| 408 | - * Creates a printer instance, which works like the renderer, |
|
| 409 | - * but outputs the generated strings to standard output. |
|
| 410 | - * |
|
| 411 | - * @return Mailcode_Printer |
|
| 412 | - */ |
|
| 407 | + /** |
|
| 408 | + * Creates a printer instance, which works like the renderer, |
|
| 409 | + * but outputs the generated strings to standard output. |
|
| 410 | + * |
|
| 411 | + * @return Mailcode_Printer |
|
| 412 | + */ |
|
| 413 | 413 | public static function createPrinter() : Mailcode_Printer |
| 414 | 414 | { |
| 415 | 415 | return new Mailcode_Printer(); |
@@ -61,11 +61,11 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @see Mailcode_Factory::ERROR_INVALID_COMMAND_CREATED |
| 63 | 63 | */ |
| 64 | - public static function setVar(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable |
|
| 64 | + public static function setVar(string $variableName, string $value, bool $quoteValue = true) : Mailcode_Commands_Command_SetVariable |
|
| 65 | 65 | { |
| 66 | 66 | $variableName = self::_filterVariableName($variableName); |
| 67 | 67 | |
| 68 | - if($quoteValue) |
|
| 68 | + if ($quoteValue) |
|
| 69 | 69 | { |
| 70 | 70 | $value = self::_quoteString($value); |
| 71 | 71 | } |
@@ -138,11 +138,11 @@ discard block |
||
| 138 | 138 | return $cmd; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - protected static function _buildIf(string $cmd, string $condition, string $type='') : Mailcode_Commands_Command |
|
| 141 | + protected static function _buildIf(string $cmd, string $condition, string $type = '') : Mailcode_Commands_Command |
|
| 142 | 142 | { |
| 143 | 143 | $stringType = $type; |
| 144 | 144 | |
| 145 | - if(!empty($type)) |
|
| 145 | + if (!empty($type)) |
|
| 146 | 146 | { |
| 147 | 147 | $stringType = ' '.$type; |
| 148 | 148 | } |
@@ -165,9 +165,9 @@ discard block |
||
| 165 | 165 | return $cmd; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - protected static function _buildIfVar(string $cmd, string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command |
|
| 168 | + protected static function _buildIfVar(string $cmd, string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command |
|
| 169 | 169 | { |
| 170 | - if($quoteValue) |
|
| 170 | + if ($quoteValue) |
|
| 171 | 171 | { |
| 172 | 172 | $value = self::_quoteString($value); |
| 173 | 173 | } |
@@ -182,11 +182,11 @@ discard block |
||
| 182 | 182 | return self::_buildIf($cmd, $condition, 'variable'); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - public static function if(string $condition, string $type='') : Mailcode_Commands_Command_If |
|
| 185 | + public static function if (string $condition, string $type = '') : Mailcode_Commands_Command_If |
|
| 186 | 186 | { |
| 187 | 187 | $cmd = self::_buildIf('If', $condition, $type); |
| 188 | 188 | |
| 189 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
| 189 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
| 190 | 190 | { |
| 191 | 191 | return $cmd; |
| 192 | 192 | } |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | throw self::_exceptionUnexpectedType($cmd); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If |
|
| 197 | + public static function ifVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If |
|
| 198 | 198 | { |
| 199 | 199 | $cmd = self::_buildIfVar('If', $variable, $operand, $value, $quoteValue); |
| 200 | 200 | |
| 201 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
| 201 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
| 202 | 202 | { |
| 203 | 203 | return $cmd; |
| 204 | 204 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | { |
| 211 | 211 | $cmd = self::_buildIfVar('If', $variable, $operand, $value, true); |
| 212 | 212 | |
| 213 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
| 213 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
| 214 | 214 | { |
| 215 | 215 | return $cmd; |
| 216 | 216 | } |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | throw self::_exceptionUnexpectedType($cmd); |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - public static function ifVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If |
|
| 221 | + public static function ifVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If |
|
| 222 | 222 | { |
| 223 | 223 | $cmd = self::_buildIfVar('If', $variable, '==', $value, $quoteValue); |
| 224 | 224 | |
| 225 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
| 225 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
| 226 | 226 | { |
| 227 | 227 | return $cmd; |
| 228 | 228 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | { |
| 235 | 235 | $cmd = self::_buildIfVar('If', $variable, '==', $value, true); |
| 236 | 236 | |
| 237 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
| 237 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
| 238 | 238 | { |
| 239 | 239 | return $cmd; |
| 240 | 240 | } |
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | throw self::_exceptionUnexpectedType($cmd); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_If |
|
| 245 | + public static function ifVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_If |
|
| 246 | 246 | { |
| 247 | 247 | $cmd = self::_buildIfVar('If', $variable, '!=', $value, $quoteValue); |
| 248 | 248 | |
| 249 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
| 249 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
| 250 | 250 | { |
| 251 | 251 | return $cmd; |
| 252 | 252 | } |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | { |
| 259 | 259 | $cmd = self::_buildIfVar('If', $variable, '!=', $value, true); |
| 260 | 260 | |
| 261 | - if($cmd instanceof Mailcode_Commands_Command_If) |
|
| 261 | + if ($cmd instanceof Mailcode_Commands_Command_If) |
|
| 262 | 262 | { |
| 263 | 263 | return $cmd; |
| 264 | 264 | } |
@@ -266,11 +266,11 @@ discard block |
||
| 266 | 266 | throw self::_exceptionUnexpectedType($cmd); |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - public static function elseIf(string $condition, string $type='') : Mailcode_Commands_Command_ElseIf |
|
| 269 | + public static function elseIf (string $condition, string $type = '') : Mailcode_Commands_Command_ElseIf |
|
| 270 | 270 | { |
| 271 | 271 | $cmd = self::_buildIf('ElseIf', $condition, $type); |
| 272 | 272 | |
| 273 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 273 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 274 | 274 | { |
| 275 | 275 | return $cmd; |
| 276 | 276 | } |
@@ -278,11 +278,11 @@ discard block |
||
| 278 | 278 | throw self::_exceptionUnexpectedType($cmd); |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf |
|
| 281 | + public static function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf |
|
| 282 | 282 | { |
| 283 | 283 | $cmd = self::_buildIfVar('ElseIf', $variable, $operand, $value, $quoteValue); |
| 284 | 284 | |
| 285 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 285 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 286 | 286 | { |
| 287 | 287 | return $cmd; |
| 288 | 288 | } |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | { |
| 295 | 295 | $cmd = self::_buildIfVar('ElseIf', $variable, $operand, $value, true); |
| 296 | 296 | |
| 297 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 297 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 298 | 298 | { |
| 299 | 299 | return $cmd; |
| 300 | 300 | } |
@@ -302,11 +302,11 @@ discard block |
||
| 302 | 302 | throw self::_exceptionUnexpectedType($cmd); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf |
|
| 305 | + public static function elseIfVarEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf |
|
| 306 | 306 | { |
| 307 | 307 | $cmd = self::_buildIfVar('ElseIf', $variable, '==', $value, $quoteValue); |
| 308 | 308 | |
| 309 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 309 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 310 | 310 | { |
| 311 | 311 | return $cmd; |
| 312 | 312 | } |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | { |
| 319 | 319 | $cmd = self::_buildIfVar('ElseIf', $variable, '==', $value, true); |
| 320 | 320 | |
| 321 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 321 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 322 | 322 | { |
| 323 | 323 | return $cmd; |
| 324 | 324 | } |
@@ -326,11 +326,11 @@ discard block |
||
| 326 | 326 | throw self::_exceptionUnexpectedType($cmd); |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue=false) : Mailcode_Commands_Command_ElseIf |
|
| 329 | + public static function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue = false) : Mailcode_Commands_Command_ElseIf |
|
| 330 | 330 | { |
| 331 | 331 | $cmd = self::_buildIfVar('ElseIf', $variable, '!=', $value, $quoteValue); |
| 332 | 332 | |
| 333 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 333 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 334 | 334 | { |
| 335 | 335 | return $cmd; |
| 336 | 336 | } |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | { |
| 343 | 343 | $cmd = self::_buildIfVar('ElseIf', $variable, '!=', $value, true); |
| 344 | 344 | |
| 345 | - if($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 345 | + if ($cmd instanceof Mailcode_Commands_Command_ElseIf) |
|
| 346 | 346 | { |
| 347 | 347 | return $cmd; |
| 348 | 348 | } |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | |
| 369 | 369 | protected static function _checkCommand(Mailcode_Commands_Command $command) : void |
| 370 | 370 | { |
| 371 | - if($command->isValid()) |
|
| 371 | + if ($command->isValid()) |
|
| 372 | 372 | { |
| 373 | 373 | return; |
| 374 | 374 | } |
@@ -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 | } |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | $keyword = $info->getKeywordByIndex(1); |
| 63 | 63 | $container = $info->getVariableByIndex(2); |
| 64 | 64 | |
| 65 | - if($variable && $keyword && $container && $keyword->isForIn()) |
|
| 65 | + if ($variable && $keyword && $container && $keyword->isForIn()) |
|
| 66 | 66 | { |
| 67 | 67 | return; |
| 68 | 68 | } |
@@ -20,19 +20,19 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class Mailcode_Commands_Highlighter |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var Mailcode_Commands_Command |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * @var Mailcode_Commands_Command |
|
| 25 | + */ |
|
| 26 | 26 | protected $command; |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var string[] |
|
| 30 | - */ |
|
| 28 | + /** |
|
| 29 | + * @var string[] |
|
| 30 | + */ |
|
| 31 | 31 | protected $parts = array(); |
| 32 | 32 | |
| 33 | 33 | public function __construct(Mailcode_Commands_Command $command) |
| 34 | 34 | { |
| 35 | - $this->command = $command; |
|
| 35 | + $this->command = $command; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public function highlight() : string |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * @param string[] $classes |
|
| 73 | - * @param string $content |
|
| 74 | - * @return string |
|
| 75 | - */ |
|
| 71 | + /** |
|
| 72 | + * @param string[] $classes |
|
| 73 | + * @param string $content |
|
| 74 | + * @return string |
|
| 75 | + */ |
|
| 76 | 76 | protected function renderTag(array $classes, string $content) : string |
| 77 | 77 | { |
| 78 | 78 | $parts = array(); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | $this->parts[] = $this->renderTag(array('command-name'), $this->command->getName()); |
| 53 | 53 | |
| 54 | - if($this->command->hasType()) |
|
| 54 | + if ($this->command->hasType()) |
|
| 55 | 55 | { |
| 56 | 56 | $this->parts[] = ' '.$this->renderTag(array('command-type'), $this->command->getType()); |
| 57 | 57 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | protected function appendParams() : void |
| 64 | 64 | { |
| 65 | - if($this->command->hasParameters()) |
|
| 65 | + if ($this->command->hasParameters()) |
|
| 66 | 66 | { |
| 67 | 67 | $this->parts[] = ' '.$this->renderTag(array('params'), $this->command->getParamsString()); |
| 68 | 68 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | $parts = array(); |
| 79 | 79 | |
| 80 | - foreach($classes as $class) |
|
| 80 | + foreach ($classes as $class) |
|
| 81 | 81 | { |
| 82 | 82 | $parts[] = 'mailcode-'.$class; |
| 83 | 83 | } |