@@ -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 | } |
@@ -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 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | protected function validateSyntax_params_parse() : void |
| 35 | 35 | { |
| 36 | - if(!$this->requiresParameters()) |
|
| 36 | + if (!$this->requiresParameters()) |
|
| 37 | 37 | { |
| 38 | 38 | return; |
| 39 | 39 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $this->hasFreeformParameters() |
| 44 | 44 | ); |
| 45 | 45 | |
| 46 | - if(!$this->params->isValid()) |
|
| 46 | + if (!$this->params->isValid()) |
|
| 47 | 47 | { |
| 48 | 48 | $error = $this->params->getValidationResult(); |
| 49 | 49 | |
@@ -29,12 +29,12 @@ |
||
| 29 | 29 | |
| 30 | 30 | protected function validateSyntax_params_empty() : void |
| 31 | 31 | { |
| 32 | - if(!$this->requiresParameters()) |
|
| 32 | + if (!$this->requiresParameters()) |
|
| 33 | 33 | { |
| 34 | 34 | return; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if(empty($this->paramsString)) |
|
| 37 | + if (empty($this->paramsString)) |
|
| 38 | 38 | { |
| 39 | 39 | $this->validationResult->makeError( |
| 40 | 40 | t('Parameters have to be specified.'), |
@@ -35,14 +35,14 @@ |
||
| 35 | 35 | |
| 36 | 36 | protected function validateSyntax_type_supported() : void |
| 37 | 37 | { |
| 38 | - if(!$this->supportsType() || empty($this->type)) |
|
| 38 | + if (!$this->supportsType() || empty($this->type)) |
|
| 39 | 39 | { |
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $types = $this->getSupportedTypes(); |
| 44 | 44 | |
| 45 | - if(!in_array($this->type, $types)) |
|
| 45 | + if (!in_array($this->type, $types)) |
|
| 46 | 46 | { |
| 47 | 47 | $this->validationResult->makeError( |
| 48 | 48 | t('The command addon %1$s is not supported.', $this->type).' '. |
@@ -31,14 +31,14 @@ |
||
| 31 | 31 | |
| 32 | 32 | protected function validateSyntax_params_keywords() : void |
| 33 | 33 | { |
| 34 | - if(!$this->supportsLogicKeywords()) |
|
| 34 | + if (!$this->supportsLogicKeywords()) |
|
| 35 | 35 | { |
| 36 | 36 | return; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | $this->logicKeywords = new Mailcode_Commands_LogicKeywords($this, $this->paramsString); |
| 40 | 40 | |
| 41 | - if(!$this->logicKeywords->isValid()) |
|
| 41 | + if (!$this->logicKeywords->isValid()) |
|
| 42 | 42 | { |
| 43 | 43 | $this->validationResult->makeError( |
| 44 | 44 | t('Invalid parameters:').' '.$this->logicKeywords->getErrorMessage(), |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | protected function validateSyntax_type_unsupported() : void |
| 32 | 32 | { |
| 33 | - if($this->supportsType() || empty($this->type)) |
|
| 33 | + if ($this->supportsType() || empty($this->type)) |
|
| 34 | 34 | { |
| 35 | 35 | return; |
| 36 | 36 | } |