@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function createSyntax(string $name) : Mailcode_Translator_Syntax |
| 34 | 34 | { |
| 35 | - if($this->syntaxExists($name)) |
|
| 35 | + if ($this->syntaxExists($name)) |
|
| 36 | 36 | { |
| 37 | 37 | return new Mailcode_Translator_Syntax($name); |
| 38 | 38 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $names = $this->getSyntaxNames(); |
| 60 | 60 | $result = array(); |
| 61 | 61 | |
| 62 | - foreach($names as $name) |
|
| 62 | + foreach ($names as $name) |
|
| 63 | 63 | { |
| 64 | 64 | $result[] = $this->createSyntax($name); |
| 65 | 65 | } |
@@ -26,24 +26,24 @@ discard block |
||
| 26 | 26 | const VALIDATION_EMPTY = 48801; |
| 27 | 27 | const VALIDATION_UNQUOTED_STRING_LITERALS = 48802; |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 29 | + /** |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | 32 | protected $statement; |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @var OperationResult |
|
| 36 | - */ |
|
| 34 | + /** |
|
| 35 | + * @var OperationResult |
|
| 36 | + */ |
|
| 37 | 37 | protected $result; |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @var Mailcode_Parser_Statement_Tokenizer |
|
| 41 | - */ |
|
| 39 | + /** |
|
| 40 | + * @var Mailcode_Parser_Statement_Tokenizer |
|
| 41 | + */ |
|
| 42 | 42 | protected $tokenizer; |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var Mailcode_Parser_Statement_Info|NULL |
|
| 46 | - */ |
|
| 44 | + /** |
|
| 45 | + * @var Mailcode_Parser_Statement_Info|NULL |
|
| 46 | + */ |
|
| 47 | 47 | protected $info; |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | if($unknown) |
| 113 | 113 | { |
| 114 | 114 | $this->result->makeError( |
| 115 | - t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')', |
|
| 115 | + t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')', |
|
| 116 | 116 | self::VALIDATION_UNQUOTED_STRING_LITERALS |
| 117 | 117 | ); |
| 118 | 118 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | protected $freeform = false; |
| 53 | 53 | |
| 54 | - public function __construct(string $statement, bool $freeform=false) |
|
| 54 | + public function __construct(string $statement, bool $freeform = false) |
|
| 55 | 55 | { |
| 56 | 56 | $this->statement = $statement; |
| 57 | 57 | $this->result = new OperationResult($this); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | public function getInfo() : Mailcode_Parser_Statement_Info |
| 82 | 82 | { |
| 83 | - if($this->info instanceof Mailcode_Parser_Statement_Info) |
|
| 83 | + if ($this->info instanceof Mailcode_Parser_Statement_Info) |
|
| 84 | 84 | { |
| 85 | 85 | return $this->info; |
| 86 | 86 | } |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | protected function validate() : void |
| 94 | 94 | { |
| 95 | - if($this->freeform) |
|
| 95 | + if ($this->freeform) |
|
| 96 | 96 | { |
| 97 | 97 | return; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if(!$this->tokenizer->hasTokens()) |
|
| 100 | + if (!$this->tokenizer->hasTokens()) |
|
| 101 | 101 | { |
| 102 | 102 | $this->result->makeError( |
| 103 | 103 | t('Empty statement'), |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $unknown = $this->tokenizer->getFirstUnknown(); |
| 111 | 111 | |
| 112 | - if($unknown) |
|
| 112 | + if ($unknown) |
|
| 113 | 113 | { |
| 114 | 114 | $this->result->makeError( |
| 115 | 115 | t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')', |
@@ -37,44 +37,44 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | const META_URL_ENCODING = 'url_encoding'; |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @var string |
|
| 42 | - */ |
|
| 40 | + /** |
|
| 41 | + * @var string |
|
| 42 | + */ |
|
| 43 | 43 | protected $type = ''; |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var string |
|
| 47 | - */ |
|
| 45 | + /** |
|
| 46 | + * @var string |
|
| 47 | + */ |
|
| 48 | 48 | protected $paramsString = ''; |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @var string |
|
| 52 | - */ |
|
| 50 | + /** |
|
| 51 | + * @var string |
|
| 52 | + */ |
|
| 53 | 53 | protected $matchedText = ''; |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @var string |
|
| 57 | - */ |
|
| 55 | + /** |
|
| 56 | + * @var string |
|
| 57 | + */ |
|
| 58 | 58 | protected $hash = ''; |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @var OperationResult |
|
| 62 | - */ |
|
| 60 | + /** |
|
| 61 | + * @var OperationResult |
|
| 62 | + */ |
|
| 63 | 63 | protected $validationResult = null; |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @var \Mailcode\Mailcode |
|
| 67 | - */ |
|
| 65 | + /** |
|
| 66 | + * @var \Mailcode\Mailcode |
|
| 67 | + */ |
|
| 68 | 68 | protected $mailcode; |
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * @var \Mailcode\Mailcode_Parser_Statement |
|
| 72 | - */ |
|
| 70 | + /** |
|
| 71 | + * @var \Mailcode\Mailcode_Parser_Statement |
|
| 72 | + */ |
|
| 73 | 73 | protected $params; |
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * @var string[] |
|
| 77 | - */ |
|
| 75 | + /** |
|
| 76 | + * @var string[] |
|
| 77 | + */ |
|
| 78 | 78 | protected $validations = array( |
| 79 | 79 | 'params_empty', |
| 80 | 80 | 'params_keywords', |
@@ -83,24 +83,24 @@ discard block |
||
| 83 | 83 | 'type_unsupported' |
| 84 | 84 | ); |
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * @var string |
|
| 88 | - */ |
|
| 86 | + /** |
|
| 87 | + * @var string |
|
| 88 | + */ |
|
| 89 | 89 | protected $comment = ''; |
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @var Mailcode_Commands_LogicKeywords|NULL |
|
| 93 | - */ |
|
| 91 | + /** |
|
| 92 | + * @var Mailcode_Commands_LogicKeywords|NULL |
|
| 93 | + */ |
|
| 94 | 94 | protected $logicKeywords; |
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * @var Mailcode_Parser_Statement_Validator |
|
| 98 | - */ |
|
| 96 | + /** |
|
| 97 | + * @var Mailcode_Parser_Statement_Validator |
|
| 98 | + */ |
|
| 99 | 99 | protected $validator; |
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * @var boolean |
|
| 103 | - */ |
|
| 101 | + /** |
|
| 102 | + * @var boolean |
|
| 103 | + */ |
|
| 104 | 104 | private $validated = false; |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -130,13 +130,13 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * Sets the command's parent opening command, if any. |
|
| 135 | - * NOTE: This is set automatically by the parser, and |
|
| 136 | - * should not be called manually. |
|
| 137 | - * |
|
| 138 | - * @param Mailcode_Commands_Command $command |
|
| 139 | - */ |
|
| 133 | + /** |
|
| 134 | + * Sets the command's parent opening command, if any. |
|
| 135 | + * NOTE: This is set automatically by the parser, and |
|
| 136 | + * should not be called manually. |
|
| 137 | + * |
|
| 138 | + * @param Mailcode_Commands_Command $command |
|
| 139 | + */ |
|
| 140 | 140 | public function setParent(Mailcode_Commands_Command $command) : void |
| 141 | 141 | { |
| 142 | 142 | $this->parent = $command; |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | return $this->parent; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - /** |
|
| 156 | - * @return string The ID of the command = the name of the command class file. |
|
| 157 | - */ |
|
| 155 | + /** |
|
| 156 | + * @return string The ID of the command = the name of the command class file. |
|
| 157 | + */ |
|
| 158 | 158 | public function getID() : string |
| 159 | 159 | { |
| 160 | 160 | // account for commands with types: If_Variable should still return If. |
@@ -163,14 +163,14 @@ discard block |
||
| 163 | 163 | return array_shift($tokens); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - /** |
|
| 167 | - * Sets an optional comment that is not used anywhere, but |
|
| 168 | - * can be used by the application to track why a command is |
|
| 169 | - * used somewhere. |
|
| 170 | - * |
|
| 171 | - * @param string $comment |
|
| 172 | - * @return Mailcode_Commands_Command |
|
| 173 | - */ |
|
| 166 | + /** |
|
| 167 | + * Sets an optional comment that is not used anywhere, but |
|
| 168 | + * can be used by the application to track why a command is |
|
| 169 | + * used somewhere. |
|
| 170 | + * |
|
| 171 | + * @param string $comment |
|
| 172 | + * @return Mailcode_Commands_Command |
|
| 173 | + */ |
|
| 174 | 174 | public function setComment(string $comment) : Mailcode_Commands_Command |
| 175 | 175 | { |
| 176 | 176 | $this->comment = $comment; |
@@ -178,34 +178,34 @@ discard block |
||
| 178 | 178 | return $this; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - /** |
|
| 182 | - * Retrieves the previously set comment, if any. |
|
| 183 | - * |
|
| 184 | - * @return string |
|
| 185 | - */ |
|
| 181 | + /** |
|
| 182 | + * Retrieves the previously set comment, if any. |
|
| 183 | + * |
|
| 184 | + * @return string |
|
| 185 | + */ |
|
| 186 | 186 | public function getComment() : string |
| 187 | 187 | { |
| 188 | 188 | return $this->comment; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - /** |
|
| 192 | - * Checks whether this is a dummy command, which is only |
|
| 193 | - * used to access information on the command type. It cannot |
|
| 194 | - * be used as an actual live command. |
|
| 195 | - * |
|
| 196 | - * @return bool |
|
| 197 | - */ |
|
| 191 | + /** |
|
| 192 | + * Checks whether this is a dummy command, which is only |
|
| 193 | + * used to access information on the command type. It cannot |
|
| 194 | + * be used as an actual live command. |
|
| 195 | + * |
|
| 196 | + * @return bool |
|
| 197 | + */ |
|
| 198 | 198 | public function isDummy() : bool |
| 199 | 199 | { |
| 200 | 200 | return $this->type === '__dummy'; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - /** |
|
| 204 | - * Retrieves a hash of the actual matched command string, |
|
| 205 | - * which is used in collections to detect duplicate commands. |
|
| 206 | - * |
|
| 207 | - * @return string |
|
| 208 | - */ |
|
| 203 | + /** |
|
| 204 | + * Retrieves a hash of the actual matched command string, |
|
| 205 | + * which is used in collections to detect duplicate commands. |
|
| 206 | + * |
|
| 207 | + * @return string |
|
| 208 | + */ |
|
| 209 | 209 | public function getHash() : string |
| 210 | 210 | { |
| 211 | 211 | $this->requireNonDummy(); |
@@ -307,9 +307,9 @@ discard block |
||
| 307 | 307 | return $this->validationResult->isValid(); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - /** |
|
| 311 | - * @return string[] |
|
| 312 | - */ |
|
| 310 | + /** |
|
| 311 | + * @return string[] |
|
| 312 | + */ |
|
| 313 | 313 | abstract protected function getValidations() : array; |
| 314 | 314 | |
| 315 | 315 | protected function validateSyntax_params_empty() : void |
@@ -478,12 +478,12 @@ discard block |
||
| 478 | 478 | |
| 479 | 479 | abstract public function supportsURLEncoding() : bool; |
| 480 | 480 | |
| 481 | - /** |
|
| 482 | - * Whether the command allows using logic keywords like "and:" or "or:" |
|
| 483 | - * in the command parameters. |
|
| 484 | - * |
|
| 485 | - * @return bool |
|
| 486 | - */ |
|
| 481 | + /** |
|
| 482 | + * Whether the command allows using logic keywords like "and:" or "or:" |
|
| 483 | + * in the command parameters. |
|
| 484 | + * |
|
| 485 | + * @return bool |
|
| 486 | + */ |
|
| 487 | 487 | abstract public function supportsLogicKeywords() : bool; |
| 488 | 488 | |
| 489 | 489 | abstract public function generatesContent() : bool; |
@@ -529,22 +529,22 @@ discard block |
||
| 529 | 529 | return $normalizer->normalize(); |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - /** |
|
| 533 | - * Retrieves the names of all the command's supported types: the part |
|
| 534 | - * between the command name and the colon. Example: {command type: params}. |
|
| 535 | - * |
|
| 536 | - * @return string[] |
|
| 537 | - */ |
|
| 532 | + /** |
|
| 533 | + * Retrieves the names of all the command's supported types: the part |
|
| 534 | + * between the command name and the colon. Example: {command type: params}. |
|
| 535 | + * |
|
| 536 | + * @return string[] |
|
| 537 | + */ |
|
| 538 | 538 | public function getSupportedTypes() : array |
| 539 | 539 | { |
| 540 | 540 | return array(); |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - /** |
|
| 544 | - * Retrieves all variable names used in the command. |
|
| 545 | - * |
|
| 546 | - * @return Mailcode_Variables_Collection_Regular |
|
| 547 | - */ |
|
| 543 | + /** |
|
| 544 | + * Retrieves all variable names used in the command. |
|
| 545 | + * |
|
| 546 | + * @return Mailcode_Variables_Collection_Regular |
|
| 547 | + */ |
|
| 548 | 548 | public function getVariables() : Mailcode_Variables_Collection_Regular |
| 549 | 549 | { |
| 550 | 550 | return Mailcode::create()->findVariables($this->paramsString); |
@@ -569,26 +569,26 @@ discard block |
||
| 569 | 569 | ); |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | - /** |
|
| 573 | - * Sets a parameter for the translation backend. The backend can use |
|
| 574 | - * these to allow command-specific configurations. |
|
| 575 | - * |
|
| 576 | - * @param string $name |
|
| 577 | - * @param mixed $value |
|
| 578 | - * @return $this |
|
| 579 | - */ |
|
| 572 | + /** |
|
| 573 | + * Sets a parameter for the translation backend. The backend can use |
|
| 574 | + * these to allow command-specific configurations. |
|
| 575 | + * |
|
| 576 | + * @param string $name |
|
| 577 | + * @param mixed $value |
|
| 578 | + * @return $this |
|
| 579 | + */ |
|
| 580 | 580 | public function setTranslationParam(string $name, $value) |
| 581 | 581 | { |
| 582 | 582 | $this->translationParams[$name] = $value; |
| 583 | 583 | return $this; |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | - /** |
|
| 587 | - * Retrieves a previously set translation parameter. |
|
| 588 | - * |
|
| 589 | - * @param string $name |
|
| 590 | - * @return mixed |
|
| 591 | - */ |
|
| 586 | + /** |
|
| 587 | + * Retrieves a previously set translation parameter. |
|
| 588 | + * |
|
| 589 | + * @param string $name |
|
| 590 | + * @return mixed |
|
| 591 | + */ |
|
| 592 | 592 | public function getTranslationParam(string $name) |
| 593 | 593 | { |
| 594 | 594 | if(isset($this->translationParams[$name])) |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | protected $parent = null; |
| 116 | 116 | |
| 117 | - public function __construct(string $type='', string $paramsString='', string $matchedText='') |
|
| 117 | + public function __construct(string $type = '', string $paramsString = '', string $matchedText = '') |
|
| 118 | 118 | { |
| 119 | 119 | $this->type = $type; |
| 120 | 120 | $this->paramsString = html_entity_decode($paramsString); |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | { |
| 211 | 211 | $this->requireNonDummy(); |
| 212 | 212 | |
| 213 | - if($this->hash === '') { |
|
| 213 | + if ($this->hash === '') { |
|
| 214 | 214 | $this->hash = md5($this->matchedText); |
| 215 | 215 | } |
| 216 | 216 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | protected function requireNonDummy() : void |
| 221 | 221 | { |
| 222 | - if(!$this->isDummy()) |
|
| 222 | + if (!$this->isDummy()) |
|
| 223 | 223 | { |
| 224 | 224 | return; |
| 225 | 225 | } |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | protected function validate() : OperationResult |
| 240 | 240 | { |
| 241 | - if(!$this->validated) |
|
| 241 | + if (!$this->validated) |
|
| 242 | 242 | { |
| 243 | 243 | $this->requireNonDummy(); |
| 244 | 244 | $this->validateSyntax(); |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | |
| 252 | 252 | public function getValidationResult() : OperationResult |
| 253 | 253 | { |
| 254 | - if(isset($this->validationResult)) |
|
| 254 | + if (isset($this->validationResult)) |
|
| 255 | 255 | { |
| 256 | 256 | return $this->validationResult; |
| 257 | 257 | } |
@@ -267,10 +267,10 @@ discard block |
||
| 267 | 267 | { |
| 268 | 268 | $validations = $this->resolveValidations(); |
| 269 | 269 | |
| 270 | - foreach($validations as $validation) |
|
| 270 | + foreach ($validations as $validation) |
|
| 271 | 271 | { |
| 272 | 272 | // break off at the first validation issue |
| 273 | - if(!$this->validateSyntaxMethod($validation)) |
|
| 273 | + if (!$this->validateSyntaxMethod($validation)) |
|
| 274 | 274 | { |
| 275 | 275 | return; |
| 276 | 276 | } |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | { |
| 290 | 290 | $method = 'validateSyntax_'.$validation; |
| 291 | 291 | |
| 292 | - if(!method_exists($this, $method)) |
|
| 292 | + if (!method_exists($this, $method)) |
|
| 293 | 293 | { |
| 294 | 294 | throw new Mailcode_Exception( |
| 295 | 295 | 'Missing validation method ['.$validation.']', |
@@ -314,12 +314,12 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | protected function validateSyntax_params_empty() : void |
| 316 | 316 | { |
| 317 | - if(!$this->requiresParameters()) |
|
| 317 | + if (!$this->requiresParameters()) |
|
| 318 | 318 | { |
| 319 | 319 | return; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - if(empty($this->paramsString)) |
|
| 322 | + if (empty($this->paramsString)) |
|
| 323 | 323 | { |
| 324 | 324 | $this->validationResult->makeError( |
| 325 | 325 | t('Parameters have to be specified.'), |
@@ -331,14 +331,14 @@ discard block |
||
| 331 | 331 | |
| 332 | 332 | protected function validateSyntax_params_keywords() : void |
| 333 | 333 | { |
| 334 | - if(!$this->supportsLogicKeywords()) |
|
| 334 | + if (!$this->supportsLogicKeywords()) |
|
| 335 | 335 | { |
| 336 | 336 | return; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | $this->logicKeywords = new Mailcode_Commands_LogicKeywords($this, $this->paramsString); |
| 340 | 340 | |
| 341 | - if(!$this->logicKeywords->isValid()) |
|
| 341 | + if (!$this->logicKeywords->isValid()) |
|
| 342 | 342 | { |
| 343 | 343 | $this->validationResult->makeError( |
| 344 | 344 | t('Invalid parameters:').' '.$this->logicKeywords->getErrorMessage(), |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | |
| 354 | 354 | protected function validateSyntax_params_parse() : void |
| 355 | 355 | { |
| 356 | - if(!$this->requiresParameters()) |
|
| 356 | + if (!$this->requiresParameters()) |
|
| 357 | 357 | { |
| 358 | 358 | return; |
| 359 | 359 | } |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | $this->hasFreeformParameters() |
| 364 | 364 | ); |
| 365 | 365 | |
| 366 | - if(!$this->params->isValid()) |
|
| 366 | + if (!$this->params->isValid()) |
|
| 367 | 367 | { |
| 368 | 368 | $error = $this->params->getValidationResult(); |
| 369 | 369 | |
@@ -385,14 +385,14 @@ discard block |
||
| 385 | 385 | |
| 386 | 386 | protected function validateSyntax_type_supported() : void |
| 387 | 387 | { |
| 388 | - if(!$this->supportsType() || empty($this->type)) |
|
| 388 | + if (!$this->supportsType() || empty($this->type)) |
|
| 389 | 389 | { |
| 390 | 390 | return; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | $types = $this->getSupportedTypes(); |
| 394 | 394 | |
| 395 | - if(!in_array($this->type, $types)) |
|
| 395 | + if (!in_array($this->type, $types)) |
|
| 396 | 396 | { |
| 397 | 397 | $this->validationResult->makeError( |
| 398 | 398 | t('The command addon %1$s is not supported.', $this->type).' '. |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | |
| 407 | 407 | protected function validateSyntax_type_unsupported() : void |
| 408 | 408 | { |
| 409 | - if($this->supportsType() || empty($this->type)) |
|
| 409 | + if ($this->supportsType() || empty($this->type)) |
|
| 410 | 410 | { |
| 411 | 411 | return; |
| 412 | 412 | } |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | |
| 425 | 425 | public function getType() : string |
| 426 | 426 | { |
| 427 | - if($this->supportsType()) |
|
| 427 | + if ($this->supportsType()) |
|
| 428 | 428 | { |
| 429 | 429 | return $this->type; |
| 430 | 430 | } |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | |
| 445 | 445 | public function getHighlighted() : string |
| 446 | 446 | { |
| 447 | - if(!$this->isValid()) |
|
| 447 | + if (!$this->isValid()) |
|
| 448 | 448 | { |
| 449 | 449 | return ''; |
| 450 | 450 | } |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | |
| 456 | 456 | public function getParamsString() : string |
| 457 | 457 | { |
| 458 | - if($this->requiresParameters()) |
|
| 458 | + if ($this->requiresParameters()) |
|
| 459 | 459 | { |
| 460 | 460 | return $this->paramsString; |
| 461 | 461 | } |
@@ -492,22 +492,22 @@ discard block |
||
| 492 | 492 | |
| 493 | 493 | public final function getCommandType() : string |
| 494 | 494 | { |
| 495 | - if($this instanceof Mailcode_Commands_Command_Type_Closing) |
|
| 495 | + if ($this instanceof Mailcode_Commands_Command_Type_Closing) |
|
| 496 | 496 | { |
| 497 | 497 | return 'Closing'; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - if($this instanceof Mailcode_Commands_Command_Type_Opening) |
|
| 500 | + if ($this instanceof Mailcode_Commands_Command_Type_Opening) |
|
| 501 | 501 | { |
| 502 | 502 | return 'Opening'; |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | - if($this instanceof Mailcode_Commands_Command_Type_Sibling) |
|
| 505 | + if ($this instanceof Mailcode_Commands_Command_Type_Sibling) |
|
| 506 | 506 | { |
| 507 | 507 | return 'Sibling'; |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - if($this instanceof Mailcode_Commands_Command_Type_Standalone) |
|
| 510 | + if ($this instanceof Mailcode_Commands_Command_Type_Standalone) |
|
| 511 | 511 | { |
| 512 | 512 | return 'Standalone'; |
| 513 | 513 | } |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | |
| 558 | 558 | public function getLogicKeywords() : Mailcode_Commands_LogicKeywords |
| 559 | 559 | { |
| 560 | - if($this->supportsLogicKeywords() && isset($this->logicKeywords)) |
|
| 560 | + if ($this->supportsLogicKeywords() && isset($this->logicKeywords)) |
|
| 561 | 561 | { |
| 562 | 562 | return $this->logicKeywords; |
| 563 | 563 | } |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | */ |
| 592 | 592 | public function getTranslationParam(string $name) |
| 593 | 593 | { |
| 594 | - if(isset($this->translationParams[$name])) |
|
| 594 | + if (isset($this->translationParams[$name])) |
|
| 595 | 595 | { |
| 596 | 596 | return $this->translationParams[$name]; |
| 597 | 597 | } |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | * @param bool $encoding |
| 604 | 604 | * @return $this |
| 605 | 605 | */ |
| 606 | - public function setURLEncoding(bool $encoding=true) |
|
| 606 | + public function setURLEncoding(bool $encoding = true) |
|
| 607 | 607 | { |
| 608 | 608 | $this->requireURLEncoding(); |
| 609 | 609 | |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | * @return $this |
| 620 | 620 | * @throws Mailcode_Exception |
| 621 | 621 | */ |
| 622 | - public function setURLDecoding(bool $decode=true) |
|
| 622 | + public function setURLDecoding(bool $decode = true) |
|
| 623 | 623 | { |
| 624 | 624 | $this->requireURLEncoding(); |
| 625 | 625 | |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | |
| 631 | 631 | protected function requireURLEncoding() : void |
| 632 | 632 | { |
| 633 | - if($this->supportsURLEncoding()) { |
|
| 633 | + if ($this->supportsURLEncoding()) { |
|
| 634 | 634 | return; |
| 635 | 635 | } |
| 636 | 636 | |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | |
| 71 | 71 | protected function validateSyntax_urldeencode() : void |
| 72 | 72 | { |
| 73 | - if($this->isURLEncoded() && $this->getURLDecodeToken() !== null) |
|
| 73 | + if ($this->isURLEncoded() && $this->getURLDecodeToken() !== null) |
|
| 74 | 74 | { |
| 75 | 75 | $this->validationResult->makeError( |
| 76 | 76 | t('Cannot enable URL decoding and encoding at the same time.'), |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $tokens = $this->params->getInfo()->getTokens(); |
| 48 | 48 | $allowed = $this->resolveActiveTokens(); |
| 49 | 49 | |
| 50 | - if(count($tokens) > count($allowed)) |
|
| 50 | + if (count($tokens) > count($allowed)) |
|
| 51 | 51 | { |
| 52 | 52 | $this->validationResult->makeError( |
| 53 | 53 | t('Unknown parameters found:').' '. |
@@ -69,13 +69,13 @@ discard block |
||
| 69 | 69 | $allowed = array($this->getVariableToken()); |
| 70 | 70 | |
| 71 | 71 | $token = $this->getURLEncodeToken(); |
| 72 | - if($token) |
|
| 72 | + if ($token) |
|
| 73 | 73 | { |
| 74 | 74 | $allowed[] = $token; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | $token = $this->getURLDecodeToken(); |
| 78 | - if($token) |
|
| 78 | + if ($token) |
|
| 79 | 79 | { |
| 80 | 80 | $allowed[] = $token; |
| 81 | 81 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | { |
| 92 | 92 | $lang = $this->params->getInfo()->getStringLiteralByIndex(0); |
| 93 | 93 | |
| 94 | - if($lang) |
|
| 94 | + if ($lang) |
|
| 95 | 95 | { |
| 96 | 96 | $this->langToken = $lang; |
| 97 | 97 | return; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | { |
| 116 | 116 | // To keep PHPStan happy. If no token has been found, this |
| 117 | 117 | // method will not be called. |
| 118 | - if(!isset($this->langToken)) |
|
| 118 | + if (!isset($this->langToken)) |
|
| 119 | 119 | { |
| 120 | 120 | return; |
| 121 | 121 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $name = $this->langToken->getText(); |
| 124 | 124 | $translator = new Mailcode_Translator(); |
| 125 | 125 | |
| 126 | - if($translator->syntaxExists($name)) |
|
| 126 | + if ($translator->syntaxExists($name)) |
|
| 127 | 127 | { |
| 128 | 128 | return; |
| 129 | 129 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function getSyntaxName() : string |
| 148 | 148 | { |
| 149 | - if(isset($this->langToken)) |
|
| 149 | + if (isset($this->langToken)) |
|
| 150 | 150 | { |
| 151 | 151 | return $this->langToken->getText(); |
| 152 | 152 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | public function normalize() : string |
| 39 | 39 | { |
| 40 | - if(!$this->command->isValid()) |
|
| 40 | + if (!$this->command->isValid()) |
|
| 41 | 41 | { |
| 42 | 42 | return ''; |
| 43 | 43 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | private function addType() : void |
| 59 | 59 | { |
| 60 | - if(!$this->command->supportsType() || !$this->command->hasType()) |
|
| 60 | + if (!$this->command->supportsType() || !$this->command->hasType()) |
|
| 61 | 61 | { |
| 62 | 62 | return; |
| 63 | 63 | } |
@@ -67,12 +67,12 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | private function addParams(Mailcode_Commands_Command $command) : void |
| 69 | 69 | { |
| 70 | - if(!$command->requiresParameters()) |
|
| 70 | + if (!$command->requiresParameters()) |
|
| 71 | 71 | { |
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if($command->hasFreeformParameters()) |
|
| 75 | + if ($command->hasFreeformParameters()) |
|
| 76 | 76 | { |
| 77 | 77 | $params = $command->getParams()->getStatementString(); |
| 78 | 78 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $params = $command->getParams()->getNormalized(); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if(empty($params)) |
|
| 84 | + if (empty($params)) |
|
| 85 | 85 | { |
| 86 | 86 | return; |
| 87 | 87 | } |
@@ -92,14 +92,14 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | private function addLogicKeywords() : void |
| 94 | 94 | { |
| 95 | - if(!$this->command->supportsLogicKeywords()) |
|
| 95 | + if (!$this->command->supportsLogicKeywords()) |
|
| 96 | 96 | { |
| 97 | 97 | return; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $keywords = $this->command->getLogicKeywords()->getKeywords(); |
| 101 | 101 | |
| 102 | - foreach($keywords as $keyword) |
|
| 102 | + foreach ($keywords as $keyword) |
|
| 103 | 103 | { |
| 104 | 104 | $this->parts[] = ' '; |
| 105 | 105 | $this->parts[] = $keyword->getKeywordString(); // e.g. "if variable" |
@@ -75,8 +75,7 @@ |
||
| 75 | 75 | if($command->hasFreeformParameters()) |
| 76 | 76 | { |
| 77 | 77 | $params = $command->getParams()->getStatementString(); |
| 78 | - } |
|
| 79 | - else |
|
| 78 | + } else |
|
| 80 | 79 | { |
| 81 | 80 | $params = $command->getParams()->getNormalized(); |
| 82 | 81 | } |
@@ -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 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $this->instantiator->checkCommand($cmd); |
| 91 | 91 | |
| 92 | - if($cmd instanceof Mailcode_Commands_Command_Code) |
|
| 92 | + if ($cmd instanceof Mailcode_Commands_Command_Code) |
|
| 93 | 93 | { |
| 94 | 94 | return $cmd; |
| 95 | 95 | } |
@@ -12,5 +12,5 @@ |
||
| 12 | 12 | * @param bool $decode |
| 13 | 13 | * @return $this |
| 14 | 14 | */ |
| 15 | - public function setURLDecoding(bool $decode=true); |
|
| 15 | + public function setURLDecoding(bool $decode = true); |
|
| 16 | 16 | } |