@@ -28,21 +28,21 @@ discard block |
||
| 28 | 28 | public const ERROR_INVALID_DUMMY_COMMAND_TYPE = 45903; |
| 29 | 29 | public const ERROR_INVALID_COMMAND_CLASS = 45904; |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var Mailcode_Commands_Command[] |
|
| 33 | - */ |
|
| 31 | + /** |
|
| 32 | + * @var Mailcode_Commands_Command[] |
|
| 33 | + */ |
|
| 34 | 34 | private array $commands = array(); |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var array<string,Mailcode_Commands_Command> |
|
| 38 | - */ |
|
| 36 | + /** |
|
| 37 | + * @var array<string,Mailcode_Commands_Command> |
|
| 38 | + */ |
|
| 39 | 39 | private static array $dummyCommands = array(); |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Retrieves a list of all available command IDs. |
|
| 43 | - * |
|
| 44 | - * @return string[] |
|
| 45 | - */ |
|
| 41 | + /** |
|
| 42 | + * Retrieves a list of all available command IDs. |
|
| 43 | + * |
|
| 44 | + * @return string[] |
|
| 45 | + */ |
|
| 46 | 46 | public function getIDs() : array |
| 47 | 47 | { |
| 48 | 48 | static $ids = array(); |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | return $result; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Gets an available command by its ID. |
|
| 93 | - * |
|
| 94 | - * @param string $id |
|
| 95 | - * @return Mailcode_Commands_Command |
|
| 96 | - */ |
|
| 91 | + /** |
|
| 92 | + * Gets an available command by its ID. |
|
| 93 | + * |
|
| 94 | + * @param string $id |
|
| 95 | + * @return Mailcode_Commands_Command |
|
| 96 | + */ |
|
| 97 | 97 | public function getByID(string $id) : Mailcode_Commands_Command |
| 98 | 98 | { |
| 99 | 99 | static $instances = array(); |
@@ -106,15 +106,15 @@ discard block |
||
| 106 | 106 | return $instances[$id]; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Retrieves the ID of a command by its name. |
|
| 111 | - * |
|
| 112 | - * @param string $name |
|
| 113 | - * @throws Mailcode_Exception |
|
| 114 | - * @return string |
|
| 115 | - * |
|
| 116 | - * @see Mailcode_Commands::ERROR_COMMAND_NAME_DOES_NOT_EXIST |
|
| 117 | - */ |
|
| 109 | + /** |
|
| 110 | + * Retrieves the ID of a command by its name. |
|
| 111 | + * |
|
| 112 | + * @param string $name |
|
| 113 | + * @throws Mailcode_Exception |
|
| 114 | + * @return string |
|
| 115 | + * |
|
| 116 | + * @see Mailcode_Commands::ERROR_COMMAND_NAME_DOES_NOT_EXIST |
|
| 117 | + */ |
|
| 118 | 118 | public function getIDByName(string $name) : string |
| 119 | 119 | { |
| 120 | 120 | $items = $this->getAll(); |
@@ -225,14 +225,14 @@ discard block |
||
| 225 | 225 | return $class; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - /** |
|
| 229 | - * Translates the command type to the expected class naming scheme. |
|
| 230 | - * |
|
| 231 | - * Example: not-empty => NotEmpty |
|
| 232 | - * |
|
| 233 | - * @param string $type |
|
| 234 | - * @return string |
|
| 235 | - */ |
|
| 228 | + /** |
|
| 229 | + * Translates the command type to the expected class naming scheme. |
|
| 230 | + * |
|
| 231 | + * Example: not-empty => NotEmpty |
|
| 232 | + * |
|
| 233 | + * @param string $type |
|
| 234 | + * @return string |
|
| 235 | + */ |
|
| 236 | 236 | private function adjustTypeName(string $type) : string |
| 237 | 237 | { |
| 238 | 238 | $type = str_replace('-', ' ', $type); |
@@ -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; |
@@ -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; |
@@ -20,15 +20,15 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class Mailcode_Commands_Command_ShowDate extends Mailcode_Commands_ShowBase |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * The date format string. |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 23 | + /** |
|
| 24 | + * The date format string. |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | 27 | private string $formatString; |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var Mailcode_Date_FormatInfo |
|
| 31 | - */ |
|
| 29 | + /** |
|
| 30 | + * @var Mailcode_Date_FormatInfo |
|
| 31 | + */ |
|
| 32 | 32 | private Mailcode_Date_FormatInfo $formatInfo; |
| 33 | 33 | |
| 34 | 34 | public function getName() : string |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | ); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Retrieves the format string used to format the date. |
|
| 94 | - * |
|
| 95 | - * @return string A PHP compatible date format string. |
|
| 96 | - */ |
|
| 92 | + /** |
|
| 93 | + * Retrieves the format string used to format the date. |
|
| 94 | + * |
|
| 95 | + * @return string A PHP compatible date format string. |
|
| 96 | + */ |
|
| 97 | 97 | public function getFormatString() : string |
| 98 | 98 | { |
| 99 | 99 | return $this->formatString; |
@@ -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(); |