@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function getTextToken() : Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral |
| 68 | 68 | { |
| 69 | - if(isset($this->textToken)) |
|
| 69 | + if (isset($this->textToken)) |
|
| 70 | 70 | { |
| 71 | 71 | return $this->textToken; |
| 72 | 72 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | public function setText(string $text) : self |
| 87 | 87 | { |
| 88 | - if(isset($this->textToken)) |
|
| 88 | + if (isset($this->textToken)) |
|
| 89 | 89 | { |
| 90 | 90 | $this->textToken->setText($text); |
| 91 | 91 | return $this; |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | ->getInfo() |
| 105 | 105 | ->getStringLiterals(); |
| 106 | 106 | |
| 107 | - if(empty($strings)) |
|
| 107 | + if (empty($strings)) |
|
| 108 | 108 | { |
| 109 | 109 | $this->getValidationResult()->makeError( |
| 110 | 110 | t('No text to encode has been specified.'), |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | ->getInfo() |
| 123 | 123 | ->getKeywords(); |
| 124 | 124 | |
| 125 | - if(!empty($keywords)) |
|
| 125 | + if (!empty($keywords)) |
|
| 126 | 126 | { |
| 127 | 127 | return; |
| 128 | 128 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $this->instantiator->checkCommand($cmd); |
| 45 | 45 | |
| 46 | - if($cmd instanceof Mailcode_Commands_Command_ShowEncoded) |
|
| 46 | + if ($cmd instanceof Mailcode_Commands_Command_ShowEncoded) |
|
| 47 | 47 | { |
| 48 | 48 | return $cmd; |
| 49 | 49 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $params = array(); |
| 62 | 62 | $params[] = $this->instantiator->quoteString($subject); |
| 63 | 63 | |
| 64 | - foreach($encodings as $keyword) |
|
| 64 | + foreach ($encodings as $keyword) |
|
| 65 | 65 | { |
| 66 | 66 | $params[] = $this->instantiator->filterKeyword($keyword); |
| 67 | 67 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $params = $this->collectParams(); |
| 54 | 54 | $result = array(); |
| 55 | 55 | |
| 56 | - foreach($params as $param) |
|
| 56 | + foreach ($params as $param) |
|
| 57 | 57 | { |
| 58 | 58 | $result[$param->getName()] = $param->getValue(); |
| 59 | 59 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $params = $this->collectParams(); |
| 70 | 70 | $result = array(); |
| 71 | 71 | |
| 72 | - foreach($params as $param) |
|
| 72 | + foreach ($params as $param) |
|
| 73 | 73 | { |
| 74 | 74 | $result[] = $param->getToken(); |
| 75 | 75 | } |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $result = array(); |
| 91 | 91 | |
| 92 | - foreach($literals as $literal) |
|
| 92 | + foreach ($literals as $literal) |
|
| 93 | 93 | { |
| 94 | 94 | $text = $literal->getText(); |
| 95 | 95 | |
| 96 | - if(strpos($text, '=') !== false) |
|
| 96 | + if (strpos($text, '=') !== false) |
|
| 97 | 97 | { |
| 98 | 98 | $param = new QueryParam($literal); |
| 99 | 99 | $result[$param->getName()] = $param; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | { |
| 108 | 108 | $params = $this->collectParams(); |
| 109 | 109 | |
| 110 | - if(isset($params[$name])) |
|
| 110 | + if (isset($params[$name])) |
|
| 111 | 111 | { |
| 112 | 112 | return $params[$name]->getValue(); |
| 113 | 113 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | { |
| 127 | 127 | $params = $this->collectParams(); |
| 128 | 128 | |
| 129 | - if(isset($params[$name])) |
|
| 129 | + if (isset($params[$name])) |
|
| 130 | 130 | { |
| 131 | 131 | $params[$name]->setValue($value); |
| 132 | 132 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | { |
| 150 | 150 | $params = $this->collectParams(); |
| 151 | 151 | |
| 152 | - if(isset($params[$name])) |
|
| 152 | + if (isset($params[$name])) |
|
| 153 | 153 | { |
| 154 | 154 | $this->requireParams() |
| 155 | 155 | ->getInfo() |
@@ -129,8 +129,7 @@ |
||
| 129 | 129 | if(isset($params[$name])) |
| 130 | 130 | { |
| 131 | 131 | $params[$name]->setValue($value); |
| 132 | - } |
|
| 133 | - else |
|
| 132 | + } else |
|
| 134 | 133 | { |
| 135 | 134 | $this->addParam($name, $value); |
| 136 | 135 | } |
@@ -42,14 +42,14 @@ discard block |
||
| 42 | 42 | Mailcode_Parser_Statement_Tokenizer_Process_ExtractTokens::class |
| 43 | 43 | ); |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var Mailcode_Parser_Statement |
|
| 47 | - */ |
|
| 45 | + /** |
|
| 46 | + * @var Mailcode_Parser_Statement |
|
| 47 | + */ |
|
| 48 | 48 | protected Mailcode_Parser_Statement $statement; |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @var string |
|
| 52 | - */ |
|
| 50 | + /** |
|
| 51 | + * @var string |
|
| 52 | + */ |
|
| 53 | 53 | protected string $tokenized = ''; |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | protected array $tokensOrdered = array(); |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @var string[] |
|
| 62 | - */ |
|
| 60 | + /** |
|
| 61 | + * @var string[] |
|
| 62 | + */ |
|
| 63 | 63 | protected static array $ids = array(); |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | return $this->statement->getSourceCommand(); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Retrieves all tokens detected in the statement string, in |
|
| 84 | - * the order they were found. |
|
| 85 | - * |
|
| 86 | - * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
| 87 | - */ |
|
| 82 | + /** |
|
| 83 | + * Retrieves all tokens detected in the statement string, in |
|
| 84 | + * the order they were found. |
|
| 85 | + * |
|
| 86 | + * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
| 87 | + */ |
|
| 88 | 88 | public function getTokens() : array |
| 89 | 89 | { |
| 90 | 90 | return $this->tokensOrdered; |
@@ -95,11 +95,11 @@ discard block |
||
| 95 | 95 | return !empty($this->tokensOrdered); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Whether there were any unknown tokens in the statement. |
|
| 100 | - * |
|
| 101 | - * @return bool |
|
| 102 | - */ |
|
| 98 | + /** |
|
| 99 | + * Whether there were any unknown tokens in the statement. |
|
| 100 | + * |
|
| 101 | + * @return bool |
|
| 102 | + */ |
|
| 103 | 103 | public function hasUnknown() : bool |
| 104 | 104 | { |
| 105 | 105 | $unknown = $this->getUnknown(); |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | return !empty($unknown); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Retrieves all unknown content tokens, if any. |
|
| 112 | - * |
|
| 113 | - * @return Mailcode_Parser_Statement_Tokenizer_Token_Unknown[] |
|
| 114 | - */ |
|
| 110 | + /** |
|
| 111 | + * Retrieves all unknown content tokens, if any. |
|
| 112 | + * |
|
| 113 | + * @return Mailcode_Parser_Statement_Tokenizer_Token_Unknown[] |
|
| 114 | + */ |
|
| 115 | 115 | public function getUnknown() : array |
| 116 | 116 | { |
| 117 | 117 | $result = array(); |
@@ -347,13 +347,13 @@ discard block |
||
| 347 | 347 | return $this; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - /** |
|
| 351 | - * Generates a unique alphabet-based ID without numbers |
|
| 352 | - * to use as token name, to avoid conflicts with the |
|
| 353 | - * numbers detection. |
|
| 354 | - * |
|
| 355 | - * @return string |
|
| 356 | - */ |
|
| 350 | + /** |
|
| 351 | + * Generates a unique alphabet-based ID without numbers |
|
| 352 | + * to use as token name, to avoid conflicts with the |
|
| 353 | + * numbers detection. |
|
| 354 | + * |
|
| 355 | + * @return string |
|
| 356 | + */ |
|
| 357 | 357 | protected function generateID() : string |
| 358 | 358 | { |
| 359 | 359 | static $alphas; |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | $result = array(); |
| 121 | 121 | |
| 122 | - foreach($this->tokensOrdered as $token) |
|
| 122 | + foreach ($this->tokensOrdered as $token) |
|
| 123 | 123 | { |
| 124 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
| 124 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
| 125 | 125 | { |
| 126 | 126 | $result[] = $token; |
| 127 | 127 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $unknown = $this->getUnknown(); |
| 136 | 136 | |
| 137 | - if(!empty($unknown)) |
|
| 137 | + if (!empty($unknown)) |
|
| 138 | 138 | { |
| 139 | 139 | return array_shift($unknown); |
| 140 | 140 | } |
@@ -146,11 +146,11 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | $parts = array(); |
| 148 | 148 | |
| 149 | - foreach($this->tokensOrdered as $token) |
|
| 149 | + foreach ($this->tokensOrdered as $token) |
|
| 150 | 150 | { |
| 151 | 151 | $string = $token->getNormalized(); |
| 152 | 152 | |
| 153 | - if($string !== '') |
|
| 153 | + if ($string !== '') |
|
| 154 | 154 | { |
| 155 | 155 | $parts[] = $string; |
| 156 | 156 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | $statement = trim($statement); |
| 176 | 176 | $tokens = array(); |
| 177 | 177 | |
| 178 | - foreach($this->tokenClasses as $tokenClass) |
|
| 178 | + foreach ($this->tokenClasses as $tokenClass) |
|
| 179 | 179 | { |
| 180 | 180 | $processor = $this->createProcessor($tokenClass, $statement, $tokens); |
| 181 | 181 | $processor->process(); |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | { |
| 200 | 200 | $instance = new $className($this, $statement, $tokens); |
| 201 | 201 | |
| 202 | - if($instance instanceof Mailcode_Parser_Statement_Tokenizer_Process) |
|
| 202 | + if ($instance instanceof Mailcode_Parser_Statement_Tokenizer_Process) |
|
| 203 | 203 | { |
| 204 | 204 | return $instance; |
| 205 | 205 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * @param mixed $subject |
| 221 | 221 | * @return Mailcode_Parser_Statement_Tokenizer_Token |
| 222 | 222 | */ |
| 223 | - public function createToken(string $type, string $matchedText, $subject=null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
| 223 | + public function createToken(string $type, string $matchedText, $subject = null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
| 224 | 224 | { |
| 225 | 225 | $tokenID = $this->generateID(); |
| 226 | 226 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | $token = new $class($tokenID, $matchedText, $subject, $this->getSourceCommand()); |
| 230 | 230 | |
| 231 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token) |
|
| 231 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token) |
|
| 232 | 232 | { |
| 233 | 233 | return $token; |
| 234 | 234 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | |
| 250 | 250 | $token = $this->createToken('Keyword', $name); |
| 251 | 251 | |
| 252 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 252 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 253 | 253 | { |
| 254 | 254 | return $token; |
| 255 | 255 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | { |
| 275 | 275 | $token = $this->createToken('StringLiteral', SpecialChars::encodeAll($text)); |
| 276 | 276 | |
| 277 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
| 277 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
| 278 | 278 | { |
| 279 | 279 | return $token; |
| 280 | 280 | } |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | |
| 313 | 313 | foreach ($this->tokensOrdered as $checkToken) |
| 314 | 314 | { |
| 315 | - if($checkToken->getID() === $tokenID) |
|
| 315 | + if ($checkToken->getID() === $tokenID) |
|
| 316 | 316 | { |
| 317 | 317 | $removed = true; |
| 318 | 318 | continue; |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | $this->tokensOrdered = $keep; |
| 325 | 325 | |
| 326 | - if($removed) |
|
| 326 | + if ($removed) |
|
| 327 | 327 | { |
| 328 | 328 | $this->eventHandler->handleTokenRemoved($token); |
| 329 | 329 | } |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | { |
| 369 | 369 | static $alphas; |
| 370 | 370 | |
| 371 | - if(!isset($alphas)) |
|
| 371 | + if (!isset($alphas)) |
|
| 372 | 372 | { |
| 373 | 373 | $alphas = range('A', 'Z'); |
| 374 | 374 | } |
@@ -377,12 +377,12 @@ discard block |
||
| 377 | 377 | |
| 378 | 378 | $result = ''; |
| 379 | 379 | |
| 380 | - for($i=0; $i < $amount; $i++) |
|
| 380 | + for ($i = 0; $i < $amount; $i++) |
|
| 381 | 381 | { |
| 382 | 382 | $result .= $alphas[array_rand($alphas)]; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - if(!in_array($result, self::$ids)) |
|
| 385 | + if (!in_array($result, self::$ids)) |
|
| 386 | 386 | { |
| 387 | 387 | self::$ids[] = $result; |
| 388 | 388 | return $result; |
@@ -30,10 +30,10 @@ discard block |
||
| 30 | 30 | public const VALIDATION_INVALID_DECIMAL_SEPARATOR = 72209; |
| 31 | 31 | public const VALIDATION_SEPARATORS_SAME_CHARACTER = 72210; |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * The default number format string. |
|
| 35 | - * @var string |
|
| 36 | - */ |
|
| 33 | + /** |
|
| 34 | + * The default number format string. |
|
| 35 | + * @var string |
|
| 36 | + */ |
|
| 37 | 37 | private string $formatString = Mailcode_Number_Info::DEFAULT_FORMAT; |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -62,18 +62,18 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | protected function validateSyntax_check_format() : void |
| 64 | 64 | { |
| 65 | - $tokens = $this->requireParams() |
|
| 66 | - ->getInfo() |
|
| 67 | - ->getStringLiterals(); |
|
| 65 | + $tokens = $this->requireParams() |
|
| 66 | + ->getInfo() |
|
| 67 | + ->getStringLiterals(); |
|
| 68 | 68 | |
| 69 | - // no format specified? Use the default one. |
|
| 70 | - if(empty($tokens)) |
|
| 71 | - { |
|
| 72 | - return; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - $token = array_pop($tokens); |
|
| 76 | - $this->parseFormatString($token->getText()); |
|
| 69 | + // no format specified? Use the default one. |
|
| 70 | + if(empty($tokens)) |
|
| 71 | + { |
|
| 72 | + return; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + $token = array_pop($tokens); |
|
| 76 | + $this->parseFormatString($token->getText()); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | protected function validateSyntax_absolute() : void |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | ); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * Retrieves the format string used to format the number. |
|
| 113 | - * |
|
| 114 | - * @return string |
|
| 115 | - */ |
|
| 111 | + /** |
|
| 112 | + * Retrieves the format string used to format the number. |
|
| 113 | + * |
|
| 114 | + * @return string |
|
| 115 | + */ |
|
| 116 | 116 | public function getFormatString() : string |
| 117 | 117 | { |
| 118 | 118 | return $this->formatString; |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | if($absolute === true && !isset($this->absoluteKeyword)) |
| 135 | 135 | { |
| 136 | - $this->requireParams() |
|
| 137 | - ->getInfo() |
|
| 138 | - ->addKeyword(Mailcode_Commands_Keywords::TYPE_ABSOLUTE); |
|
| 136 | + $this->requireParams() |
|
| 137 | + ->getInfo() |
|
| 138 | + ->addKeyword(Mailcode_Commands_Keywords::TYPE_ABSOLUTE); |
|
| 139 | 139 | |
| 140 | - $this->validateSyntax_absolute(); |
|
| 140 | + $this->validateSyntax_absolute(); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | return $this; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | ->getStringLiterals(); |
| 68 | 68 | |
| 69 | 69 | // no format specified? Use the default one. |
| 70 | - if(empty($tokens)) |
|
| 70 | + if (empty($tokens)) |
|
| 71 | 71 | { |
| 72 | 72 | return; |
| 73 | 73 | } |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | ->getInfo() |
| 83 | 83 | ->getKeywords(); |
| 84 | 84 | |
| 85 | - foreach($keywords as $keyword) |
|
| 85 | + foreach ($keywords as $keyword) |
|
| 86 | 86 | { |
| 87 | - if($keyword->getKeyword() === Mailcode_Commands_Keywords::TYPE_ABSOLUTE) |
|
| 87 | + if ($keyword->getKeyword() === Mailcode_Commands_Keywords::TYPE_ABSOLUTE) |
|
| 88 | 88 | { |
| 89 | 89 | $this->absoluteKeyword = $keyword; |
| 90 | 90 | break; |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | $result = new Mailcode_Number_Info($format); |
| 98 | 98 | |
| 99 | - if($result->isValid()) |
|
| 99 | + if ($result->isValid()) |
|
| 100 | 100 | { |
| 101 | 101 | $this->formatString = $format; |
| 102 | 102 | return; |
@@ -125,13 +125,13 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | public function setAbsolute(bool $absolute) : Mailcode_Commands_Command_ShowNumber |
| 127 | 127 | { |
| 128 | - if($absolute === false && isset($this->absoluteKeyword)) |
|
| 128 | + if ($absolute === false && isset($this->absoluteKeyword)) |
|
| 129 | 129 | { |
| 130 | 130 | $this->requireParams()->getInfo()->removeKeyword($this->absoluteKeyword->getKeyword()); |
| 131 | 131 | $this->absoluteKeyword = null; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if($absolute === true && !isset($this->absoluteKeyword)) |
|
| 134 | + if ($absolute === true && !isset($this->absoluteKeyword)) |
|
| 135 | 135 | { |
| 136 | 136 | $this->requireParams() |
| 137 | 137 | ->getInfo() |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $tokens = $this->requireParams()->getInfo()->getTokens(); |
| 59 | 59 | $allowed = $this->resolveActiveTokens(); |
| 60 | 60 | |
| 61 | - if(count($tokens) > count($allowed)) |
|
| 61 | + if (count($tokens) > count($allowed)) |
|
| 62 | 62 | { |
| 63 | 63 | $this->validationResult->makeError( |
| 64 | 64 | t('Unknown parameters found:').' '. |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | $encodings = $this->getSupportedEncodings(); |
| 83 | 83 | |
| 84 | - foreach($encodings as $keyword) |
|
| 84 | + foreach ($encodings as $keyword) |
|
| 85 | 85 | { |
| 86 | 86 | $token = $this->getEncodingToken($keyword); |
| 87 | - if($token) |
|
| 87 | + if ($token) |
|
| 88 | 88 | { |
| 89 | 89 | $allowed[] = $token; |
| 90 | 90 | } |
@@ -21,14 +21,14 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class Mailcode_Parser_Statement_Info |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * @var Mailcode_Parser_Statement_Tokenizer |
|
| 26 | - */ |
|
| 24 | + /** |
|
| 25 | + * @var Mailcode_Parser_Statement_Tokenizer |
|
| 26 | + */ |
|
| 27 | 27 | protected $tokenizer; |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var Mailcode_Parser_Statement_Tokenizer_Token[] |
|
| 31 | - */ |
|
| 29 | + /** |
|
| 30 | + * @var Mailcode_Parser_Statement_Tokenizer_Token[] |
|
| 31 | + */ |
|
| 32 | 32 | protected $tokens = array(); |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -48,21 +48,21 @@ discard block |
||
| 48 | 48 | $this->variables = new Mailcode_Parser_Statement_Info_Variables($this, $this->tokenizer); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Whether the whole statement is a variable being assigned a value. |
|
| 53 | - * |
|
| 54 | - * @return bool |
|
| 55 | - */ |
|
| 51 | + /** |
|
| 52 | + * Whether the whole statement is a variable being assigned a value. |
|
| 53 | + * |
|
| 54 | + * @return bool |
|
| 55 | + */ |
|
| 56 | 56 | public function isVariableAssignment() : bool |
| 57 | 57 | { |
| 58 | 58 | return $this->variables->isAssignment(); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Whether the whole statement is a variable being compared to something. |
|
| 63 | - * |
|
| 64 | - * @return bool |
|
| 65 | - */ |
|
| 61 | + /** |
|
| 62 | + * Whether the whole statement is a variable being compared to something. |
|
| 63 | + * |
|
| 64 | + * @return bool |
|
| 65 | + */ |
|
| 66 | 66 | public function isVariableComparison() : bool |
| 67 | 67 | { |
| 68 | 68 | return $this->variables->isComparison(); |
@@ -79,27 +79,27 @@ discard block |
||
| 79 | 79 | return $this->variables->getAll(); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Retrieves a variable by its position in the command's parameters. |
|
| 84 | - * Returns null if there is no parameter at the specified index, or |
|
| 85 | - * if it is of another type. |
|
| 86 | - * |
|
| 87 | - * @param int $index Zero-based index. |
|
| 88 | - * @return Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL |
|
| 89 | - */ |
|
| 82 | + /** |
|
| 83 | + * Retrieves a variable by its position in the command's parameters. |
|
| 84 | + * Returns null if there is no parameter at the specified index, or |
|
| 85 | + * if it is of another type. |
|
| 86 | + * |
|
| 87 | + * @param int $index Zero-based index. |
|
| 88 | + * @return Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL |
|
| 89 | + */ |
|
| 90 | 90 | public function getVariableByIndex(int $index) : ?Mailcode_Parser_Statement_Tokenizer_Token_Variable |
| 91 | 91 | { |
| 92 | 92 | return $this->variables->getByIndex($index); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Retrieves a string literal by its position in the command's parameters. |
|
| 97 | - * Returns null if there is no parameter at the specified index, or |
|
| 98 | - * if it is of another type. |
|
| 99 | - * |
|
| 100 | - * @param int $index Zero-based index. |
|
| 101 | - * @return Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral|NULL |
|
| 102 | - */ |
|
| 95 | + /** |
|
| 96 | + * Retrieves a string literal by its position in the command's parameters. |
|
| 97 | + * Returns null if there is no parameter at the specified index, or |
|
| 98 | + * if it is of another type. |
|
| 99 | + * |
|
| 100 | + * @param int $index Zero-based index. |
|
| 101 | + * @return Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral|NULL |
|
| 102 | + */ |
|
| 103 | 103 | public function getStringLiteralByIndex(int $index) : ?Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral |
| 104 | 104 | { |
| 105 | 105 | $token = $this->getTokenByIndex($index); |
@@ -112,27 +112,27 @@ discard block |
||
| 112 | 112 | return null; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Retrieves a keyword by its position in the command's parameters. |
|
| 117 | - * Returns null if there is no parameter at the specified index, or |
|
| 118 | - * if it is of another type. |
|
| 119 | - * |
|
| 120 | - * @param int $index Zero-based index. |
|
| 121 | - * @return Mailcode_Parser_Statement_Tokenizer_Token_Keyword|NULL |
|
| 122 | - */ |
|
| 115 | + /** |
|
| 116 | + * Retrieves a keyword by its position in the command's parameters. |
|
| 117 | + * Returns null if there is no parameter at the specified index, or |
|
| 118 | + * if it is of another type. |
|
| 119 | + * |
|
| 120 | + * @param int $index Zero-based index. |
|
| 121 | + * @return Mailcode_Parser_Statement_Tokenizer_Token_Keyword|NULL |
|
| 122 | + */ |
|
| 123 | 123 | public function getKeywordByIndex(int $index) : ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword |
| 124 | 124 | { |
| 125 | 125 | return $this->keywords->getByIndex($index); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - /** |
|
| 129 | - * Retrieves an operand by its position in the command's parameters. |
|
| 130 | - * Returns null if there is no parameter at the specified index, or |
|
| 131 | - * if it is of another type. |
|
| 132 | - * |
|
| 133 | - * @param int $index Zero-based index. |
|
| 134 | - * @return Mailcode_Parser_Statement_Tokenizer_Token_Operand|NULL |
|
| 135 | - */ |
|
| 128 | + /** |
|
| 129 | + * Retrieves an operand by its position in the command's parameters. |
|
| 130 | + * Returns null if there is no parameter at the specified index, or |
|
| 131 | + * if it is of another type. |
|
| 132 | + * |
|
| 133 | + * @param int $index Zero-based index. |
|
| 134 | + * @return Mailcode_Parser_Statement_Tokenizer_Token_Operand|NULL |
|
| 135 | + */ |
|
| 136 | 136 | public function getOperandByIndex(int $index) : ?Mailcode_Parser_Statement_Tokenizer_Token_Operand |
| 137 | 137 | { |
| 138 | 138 | $token = $this->getTokenByIndex($index); |
@@ -145,14 +145,14 @@ discard block |
||
| 145 | 145 | return null; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Retrieves a parameter token by its position in the command's parameters, |
|
| 150 | - * regardless of its type. Returns null if there is no parameter at the |
|
| 151 | - * specified index. |
|
| 152 | - * |
|
| 153 | - * @param int $index Zero-based index. |
|
| 154 | - * @return Mailcode_Parser_Statement_Tokenizer_Token|NULL |
|
| 155 | - */ |
|
| 148 | + /** |
|
| 149 | + * Retrieves a parameter token by its position in the command's parameters, |
|
| 150 | + * regardless of its type. Returns null if there is no parameter at the |
|
| 151 | + * specified index. |
|
| 152 | + * |
|
| 153 | + * @param int $index Zero-based index. |
|
| 154 | + * @return Mailcode_Parser_Statement_Tokenizer_Token|NULL |
|
| 155 | + */ |
|
| 156 | 156 | public function getTokenByIndex(int $index) : ?Mailcode_Parser_Statement_Tokenizer_Token |
| 157 | 157 | { |
| 158 | 158 | $tokens = $this->tokenizer->getTokens(); |
@@ -172,19 +172,19 @@ discard block |
||
| 172 | 172 | return isset($tokens[$index]); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * Retrieves all tokens. |
|
| 177 | - * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
| 178 | - */ |
|
| 175 | + /** |
|
| 176 | + * Retrieves all tokens. |
|
| 177 | + * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
| 178 | + */ |
|
| 179 | 179 | public function getTokens() : array |
| 180 | 180 | { |
| 181 | 181 | return $this->tokenizer->getTokens(); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - /** |
|
| 185 | - * Retrieves all string literals that were found in the command. |
|
| 186 | - * @return Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral[] |
|
| 187 | - */ |
|
| 184 | + /** |
|
| 185 | + * Retrieves all string literals that were found in the command. |
|
| 186 | + * @return Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral[] |
|
| 187 | + */ |
|
| 188 | 188 | public function getStringLiterals() : array |
| 189 | 189 | { |
| 190 | 190 | $result = array(); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | { |
| 105 | 105 | $token = $this->getTokenByIndex($index); |
| 106 | 106 | |
| 107 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
| 107 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
| 108 | 108 | { |
| 109 | 109 | return $token; |
| 110 | 110 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | { |
| 138 | 138 | $token = $this->getTokenByIndex($index); |
| 139 | 139 | |
| 140 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand) |
|
| 140 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand) |
|
| 141 | 141 | { |
| 142 | 142 | return $token; |
| 143 | 143 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | { |
| 158 | 158 | $tokens = $this->tokenizer->getTokens(); |
| 159 | 159 | |
| 160 | - if(isset($tokens[$index])) |
|
| 160 | + if (isset($tokens[$index])) |
|
| 161 | 161 | { |
| 162 | 162 | return $tokens[$index]; |
| 163 | 163 | } |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | $result = array(); |
| 191 | 191 | $tokens = $this->tokenizer->getTokens(); |
| 192 | 192 | |
| 193 | - foreach($tokens as $token) |
|
| 193 | + foreach ($tokens as $token) |
|
| 194 | 194 | { |
| 195 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
| 195 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) |
|
| 196 | 196 | { |
| 197 | 197 | $result[] = $token; |
| 198 | 198 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | private function addListener(string $eventName, callable $listener) : void |
| 154 | 154 | { |
| 155 | - if(!isset($this->listeners[$eventName])) |
|
| 155 | + if (!isset($this->listeners[$eventName])) |
|
| 156 | 156 | { |
| 157 | 157 | $this->listeners[$eventName] = array(); |
| 158 | 158 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | { |
| 197 | 197 | $this->triggerEvent(self::EVENT_TOKEN_REMOVED, $token); |
| 198 | 198 | |
| 199 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 199 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 200 | 200 | { |
| 201 | 201 | $this->triggerKeywordRemoved($token->getKeyword()); |
| 202 | 202 | } |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | { |
| 223 | 223 | $this->triggerEvent(self::EVENT_TOKEN_ADDED, $token); |
| 224 | 224 | |
| 225 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 225 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 226 | 226 | { |
| 227 | 227 | $this->triggerKeywordAdded($token->getKeyword()); |
| 228 | 228 | } |
@@ -261,12 +261,12 @@ discard block |
||
| 261 | 261 | */ |
| 262 | 262 | private function triggerEvent(string $eventName, ...$listenerArgs) : void |
| 263 | 263 | { |
| 264 | - if(!isset($this->listeners[$eventName])) |
|
| 264 | + if (!isset($this->listeners[$eventName])) |
|
| 265 | 265 | { |
| 266 | 266 | return; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - foreach($this->listeners[$eventName] as $listener) |
|
| 269 | + foreach ($this->listeners[$eventName] as $listener) |
|
| 270 | 270 | { |
| 271 | 271 | $listener($this->tokenizer, ...$listenerArgs); |
| 272 | 272 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | { |
| 46 | 46 | $token = $this->getTrackingIDToken(); |
| 47 | 47 | |
| 48 | - if($token === null) |
|
| 48 | + if ($token === null) |
|
| 49 | 49 | { |
| 50 | 50 | return ''; |
| 51 | 51 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | private function filterTrackingID(string $trackingID) : string |
| 60 | 60 | { |
| 61 | - if(empty($trackingID)) |
|
| 61 | + if (empty($trackingID)) |
|
| 62 | 62 | { |
| 63 | 63 | return AutoTrackingID::generate($this); |
| 64 | 64 | } |
@@ -75,19 +75,19 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | private function initTrackingToken() : void |
| 77 | 77 | { |
| 78 | - if(!$this->isTrackingEnabled()) |
|
| 78 | + if (!$this->isTrackingEnabled()) |
|
| 79 | 79 | { |
| 80 | 80 | $this->clearTrackingIDToken(); |
| 81 | 81 | return; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if(isset($this->trackingIDToken)) |
|
| 84 | + if (isset($this->trackingIDToken)) |
|
| 85 | 85 | { |
| 86 | 86 | return; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $token = $this->detectToken(); |
| 90 | - if($token === null) |
|
| 90 | + if ($token === null) |
|
| 91 | 91 | { |
| 92 | 92 | $token = $this->requireParams() |
| 93 | 93 | ->getInfo() |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | $this->trackingIDToken = null; |
| 103 | 103 | |
| 104 | 104 | $token = $this->detectToken(); |
| 105 | - if($token !== null) |
|
| 105 | + if ($token !== null) |
|
| 106 | 106 | { |
| 107 | 107 | $this->requireParams() |
| 108 | 108 | ->getInfo() |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | { |
| 115 | 115 | $token = $this->getTrackingIDToken(); |
| 116 | 116 | |
| 117 | - if($token !== null) |
|
| 117 | + if ($token !== null) |
|
| 118 | 118 | { |
| 119 | 119 | $token->setText($this->filterTrackingID($trackingID)); |
| 120 | 120 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | ->getInfo() |
| 129 | 129 | ->getStringLiterals(); |
| 130 | 130 | |
| 131 | - if(empty($literals)) |
|
| 131 | + if (empty($literals)) |
|
| 132 | 132 | { |
| 133 | 133 | return null; |
| 134 | 134 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | $id = $trackingID->getText(); |
| 139 | 139 | |
| 140 | - if(strpos($id, '=') === false) |
|
| 140 | + if (strpos($id, '=') === false) |
|
| 141 | 141 | { |
| 142 | 142 | return $trackingID; |
| 143 | 143 | } |