@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | Mailcode_Parser_Statement_Tokenizer_Process_SetNames::class, |
| 52 | 52 | ); |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @var Mailcode_Parser_Statement |
|
| 56 | - */ |
|
| 54 | + /** |
|
| 55 | + * @var Mailcode_Parser_Statement |
|
| 56 | + */ |
|
| 57 | 57 | protected Mailcode_Parser_Statement $statement; |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @var string |
|
| 61 | - */ |
|
| 59 | + /** |
|
| 60 | + * @var string |
|
| 61 | + */ |
|
| 62 | 62 | protected string $tokenized = ''; |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | protected array $tokensOrdered = array(); |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @var string[] |
|
| 71 | - */ |
|
| 69 | + /** |
|
| 70 | + * @var string[] |
|
| 71 | + */ |
|
| 72 | 72 | protected static array $ids = array(); |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | return $this->statement->getSourceCommand(); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Retrieves all tokens detected in the statement string, in |
|
| 96 | - * the order they were found. |
|
| 97 | - * |
|
| 98 | - * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
| 99 | - */ |
|
| 94 | + /** |
|
| 95 | + * Retrieves all tokens detected in the statement string, in |
|
| 96 | + * the order they were found. |
|
| 97 | + * |
|
| 98 | + * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
| 99 | + */ |
|
| 100 | 100 | public function getTokens() : array |
| 101 | 101 | { |
| 102 | 102 | return $this->tokensOrdered; |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | return !empty($this->tokensOrdered); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Whether there were any unknown tokens in the statement. |
|
| 112 | - * |
|
| 113 | - * @return bool |
|
| 114 | - */ |
|
| 110 | + /** |
|
| 111 | + * Whether there were any unknown tokens in the statement. |
|
| 112 | + * |
|
| 113 | + * @return bool |
|
| 114 | + */ |
|
| 115 | 115 | public function hasUnknown() : bool |
| 116 | 116 | { |
| 117 | 117 | $unknown = $this->getUnknown(); |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | return !empty($unknown); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * Retrieves all unknown content tokens, if any. |
|
| 124 | - * |
|
| 125 | - * @return Mailcode_Parser_Statement_Tokenizer_Token_Unknown[] |
|
| 126 | - */ |
|
| 122 | + /** |
|
| 123 | + * Retrieves all unknown content tokens, if any. |
|
| 124 | + * |
|
| 125 | + * @return Mailcode_Parser_Statement_Tokenizer_Token_Unknown[] |
|
| 126 | + */ |
|
| 127 | 127 | public function getUnknown() : array |
| 128 | 128 | { |
| 129 | 129 | $result = array(); |
@@ -410,13 +410,13 @@ discard block |
||
| 410 | 410 | return $this; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - /** |
|
| 414 | - * Generates a unique alphabet-based ID without numbers |
|
| 415 | - * to use as token name, to avoid conflicts with the |
|
| 416 | - * numbers detection. |
|
| 417 | - * |
|
| 418 | - * @return string |
|
| 419 | - */ |
|
| 413 | + /** |
|
| 414 | + * Generates a unique alphabet-based ID without numbers |
|
| 415 | + * to use as token name, to avoid conflicts with the |
|
| 416 | + * numbers detection. |
|
| 417 | + * |
|
| 418 | + * @return string |
|
| 419 | + */ |
|
| 420 | 420 | protected function generateID() : string |
| 421 | 421 | { |
| 422 | 422 | static $alphas; |
@@ -35,11 +35,11 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | - * Retrieves the text with the surrounding quotes, |
|
| 39 | - * and special characters escaped for Mailcode. |
|
| 40 | - * |
|
| 41 | - * @return string |
|
| 42 | - */ |
|
| 38 | + * Retrieves the text with the surrounding quotes, |
|
| 39 | + * and special characters escaped for Mailcode. |
|
| 40 | + * |
|
| 41 | + * @return string |
|
| 42 | + */ |
|
| 43 | 43 | public function getNormalized() : string |
| 44 | 44 | { |
| 45 | 45 | return '"'.SpecialChars::escape($this->text).'"'; |
@@ -50,21 +50,21 @@ discard block |
||
| 50 | 50 | return true; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Retrieves the text with the surrounding quotes. |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 53 | + /** |
|
| 54 | + * Retrieves the text with the surrounding quotes. |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | 57 | public function getValue() : string |
| 58 | 58 | { |
| 59 | 59 | return $this->getNormalized(); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Retrieves the text without the surrounding quotes, |
|
| 64 | - * and special Mailcode characters not escaped. |
|
| 65 | - * |
|
| 66 | - * @return string |
|
| 67 | - */ |
|
| 62 | + /** |
|
| 63 | + * Retrieves the text without the surrounding quotes, |
|
| 64 | + * and special Mailcode characters not escaped. |
|
| 65 | + * |
|
| 66 | + * @return string |
|
| 67 | + */ |
|
| 68 | 68 | public function getText() : string |
| 69 | 69 | { |
| 70 | 70 | return SpecialChars::decode($this->text); |
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | return true; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Retrieves all known comparison operator signs. |
|
| 40 | - * @return string[] |
|
| 41 | - */ |
|
| 38 | + /** |
|
| 39 | + * Retrieves all known comparison operator signs. |
|
| 40 | + * @return string[] |
|
| 41 | + */ |
|
| 42 | 42 | public static function getComparisonSigns() : array |
| 43 | 43 | { |
| 44 | 44 | return array( |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | ); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Retrieves all known arithmetic operator signs. |
|
| 56 | - * @return string[] |
|
| 57 | - */ |
|
| 54 | + /** |
|
| 55 | + * Retrieves all known arithmetic operator signs. |
|
| 56 | + * @return string[] |
|
| 57 | + */ |
|
| 58 | 58 | public static function getArithmeticSigns() : array |
| 59 | 59 | { |
| 60 | 60 | return array( |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | ); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Whether the operator is comparison related (equals, not equals, smaller, greater...). |
|
| 70 | - * |
|
| 71 | - * @return bool |
|
| 72 | - */ |
|
| 68 | + /** |
|
| 69 | + * Whether the operator is comparison related (equals, not equals, smaller, greater...). |
|
| 70 | + * |
|
| 71 | + * @return bool |
|
| 72 | + */ |
|
| 73 | 73 | public function isComparator() : bool |
| 74 | 74 | { |
| 75 | 75 | return |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | $this->isSmallerOrEquals(); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Whether the operator is calculation related (minus, plus, divide, multiply). |
|
| 86 | - * |
|
| 87 | - * @return bool |
|
| 88 | - */ |
|
| 84 | + /** |
|
| 85 | + * Whether the operator is calculation related (minus, plus, divide, multiply). |
|
| 86 | + * |
|
| 87 | + * @return bool |
|
| 88 | + */ |
|
| 89 | 89 | public function isCalculator() : bool |
| 90 | 90 | { |
| 91 | 91 | return |
@@ -23,25 +23,25 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | trait Mailcode_Traits_Formatting_HTMLHighlighting |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * Stored this way, so we can use isset() instead |
|
| 28 | - * of using in_array, which is some magnitudes slower. |
|
| 29 | - * The boolean value is not used otherwise. |
|
| 30 | - * |
|
| 31 | - * @var array<string,bool> |
|
| 32 | - */ |
|
| 26 | + /** |
|
| 27 | + * Stored this way, so we can use isset() instead |
|
| 28 | + * of using in_array, which is some magnitudes slower. |
|
| 29 | + * The boolean value is not used otherwise. |
|
| 30 | + * |
|
| 31 | + * @var array<string,bool> |
|
| 32 | + */ |
|
| 33 | 33 | private array $excludeTags = array( |
| 34 | 34 | 'style' => true, // NOTE: style tags are excluded natively on the parser level. |
| 35 | 35 | 'script' => true |
| 36 | 36 | ); |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Adds an HTML tag name to the list of tags within which |
|
| 40 | - * commands may not be highlighted. |
|
| 41 | - * |
|
| 42 | - * @param string $tagName Case-insensitive. |
|
| 43 | - * @return $this |
|
| 44 | - */ |
|
| 38 | + /** |
|
| 39 | + * Adds an HTML tag name to the list of tags within which |
|
| 40 | + * commands may not be highlighted. |
|
| 41 | + * |
|
| 42 | + * @param string $tagName Case-insensitive. |
|
| 43 | + * @return $this |
|
| 44 | + */ |
|
| 45 | 45 | public function excludeTag(string $tagName) : self |
| 46 | 46 | { |
| 47 | 47 | $tagName = strtolower($tagName); |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | return $this; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Adds several excluded tag names at once. |
|
| 56 | - * |
|
| 57 | - * @param string[] $tagNames |
|
| 58 | - * @return $this |
|
| 59 | - */ |
|
| 54 | + /** |
|
| 55 | + * Adds several excluded tag names at once. |
|
| 56 | + * |
|
| 57 | + * @param string[] $tagNames |
|
| 58 | + * @return $this |
|
| 59 | + */ |
|
| 60 | 60 | public function excludeTags(array $tagNames) : self |
| 61 | 61 | { |
| 62 | 62 | foreach($tagNames as $tagName) |
@@ -67,12 +67,12 @@ discard block |
||
| 67 | 67 | return $this; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Whether the specified tag name is in the exclusion list. |
|
| 72 | - * |
|
| 73 | - * @param string $tagName |
|
| 74 | - * @return bool |
|
| 75 | - */ |
|
| 70 | + /** |
|
| 71 | + * Whether the specified tag name is in the exclusion list. |
|
| 72 | + * |
|
| 73 | + * @param string $tagName |
|
| 74 | + * @return bool |
|
| 75 | + */ |
|
| 76 | 76 | public function isTagExcluded(string $tagName) : bool |
| 77 | 77 | { |
| 78 | 78 | $tagName = strtolower($tagName); |
@@ -31,29 +31,29 @@ discard block |
||
| 31 | 31 | public const PACKAGE_NAME = 'Mailcode'; |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | - * @var Mailcode_Parser|NULL |
|
| 35 | - */ |
|
| 34 | + * @var Mailcode_Parser|NULL |
|
| 35 | + */ |
|
| 36 | 36 | protected $parser = null; |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var Mailcode_Commands|NULL |
|
| 40 | - */ |
|
| 38 | + /** |
|
| 39 | + * @var Mailcode_Commands|NULL |
|
| 40 | + */ |
|
| 41 | 41 | protected $commands = null; |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @var Mailcode_Variables|NULL |
|
| 45 | - */ |
|
| 43 | + /** |
|
| 44 | + * @var Mailcode_Variables|NULL |
|
| 45 | + */ |
|
| 46 | 46 | protected $variables = null; |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var Mailcode_Translator|NULL |
|
| 50 | - */ |
|
| 48 | + /** |
|
| 49 | + * @var Mailcode_Translator|NULL |
|
| 50 | + */ |
|
| 51 | 51 | protected $translator = null; |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Creates a new mailcode instance. |
|
| 55 | - * @return Mailcode |
|
| 56 | - */ |
|
| 53 | + /** |
|
| 54 | + * Creates a new mailcode instance. |
|
| 55 | + * @return Mailcode |
|
| 56 | + */ |
|
| 57 | 57 | public static function create() : Mailcode |
| 58 | 58 | { |
| 59 | 59 | return new Mailcode(); |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | - * Parses the string to detect all commands contained within. |
|
| 69 | - * |
|
| 70 | - * @param string $string |
|
| 71 | - * @return Mailcode_Collection |
|
| 72 | - */ |
|
| 68 | + * Parses the string to detect all commands contained within. |
|
| 69 | + * |
|
| 70 | + * @param string $string |
|
| 71 | + * @return Mailcode_Collection |
|
| 72 | + */ |
|
| 73 | 73 | public function parseString(string $string) : Mailcode_Collection |
| 74 | 74 | { |
| 75 | 75 | return $this->getParser() |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | ->getCollection(); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Retrieves the string parser instance used to detect commands. |
|
| 82 | - * |
|
| 83 | - * @return Mailcode_Parser |
|
| 84 | - */ |
|
| 80 | + /** |
|
| 81 | + * Retrieves the string parser instance used to detect commands. |
|
| 82 | + * |
|
| 83 | + * @return Mailcode_Parser |
|
| 84 | + */ |
|
| 85 | 85 | public function getParser() : Mailcode_Parser |
| 86 | 86 | { |
| 87 | 87 | if(!isset($this->parser)) |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | return $this->parser; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Retrieves the commands collection, which is used to |
|
| 97 | - * access information on the available commands. |
|
| 98 | - * |
|
| 99 | - * @return Mailcode_Commands |
|
| 100 | - */ |
|
| 95 | + /** |
|
| 96 | + * Retrieves the commands collection, which is used to |
|
| 97 | + * access information on the available commands. |
|
| 98 | + * |
|
| 99 | + * @return Mailcode_Commands |
|
| 100 | + */ |
|
| 101 | 101 | public function getCommands() : Mailcode_Commands |
| 102 | 102 | { |
| 103 | 103 | if(!isset($this->commands)) |
@@ -140,12 +140,12 @@ discard block |
||
| 140 | 140 | return $this->variables; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * Creates the translator, which can be used to convert commands |
|
| 145 | - * to another supported syntax. |
|
| 146 | - * |
|
| 147 | - * @return Mailcode_Translator |
|
| 148 | - */ |
|
| 143 | + /** |
|
| 144 | + * Creates the translator, which can be used to convert commands |
|
| 145 | + * to another supported syntax. |
|
| 146 | + * |
|
| 147 | + * @return Mailcode_Translator |
|
| 148 | + */ |
|
| 149 | 149 | public function createTranslator() : Mailcode_Translator |
| 150 | 150 | { |
| 151 | 151 | if(!isset($this->translator)) |
@@ -156,12 +156,12 @@ discard block |
||
| 156 | 156 | return $this->translator; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Creates the styler, which can be used to retrieve the |
|
| 161 | - * CSS required to style the highlighted commands in HTML. |
|
| 162 | - * |
|
| 163 | - * @return Mailcode_Styler |
|
| 164 | - */ |
|
| 159 | + /** |
|
| 160 | + * Creates the styler, which can be used to retrieve the |
|
| 161 | + * CSS required to style the highlighted commands in HTML. |
|
| 162 | + * |
|
| 163 | + * @return Mailcode_Styler |
|
| 164 | + */ |
|
| 165 | 165 | public function createStyler() : Mailcode_Styler |
| 166 | 166 | { |
| 167 | 167 | return new Mailcode_Styler(); |
@@ -32,34 +32,34 @@ |
||
| 32 | 32 | public const VALIDATION_ERROR_PATH_UNDERSCORE = 48203; |
| 33 | 33 | public const VALIDATION_ERROR_NAME_UNDERSCORE = 48204; |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 35 | + /** |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | 38 | protected string $path; |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @var string |
|
| 42 | - */ |
|
| 40 | + /** |
|
| 41 | + * @var string |
|
| 42 | + */ |
|
| 43 | 43 | protected string $name; |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var string |
|
| 47 | - */ |
|
| 45 | + /** |
|
| 46 | + * @var string |
|
| 47 | + */ |
|
| 48 | 48 | protected string $matchedText; |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @var string |
|
| 52 | - */ |
|
| 50 | + /** |
|
| 51 | + * @var string |
|
| 52 | + */ |
|
| 53 | 53 | protected string $hash = ''; |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @var OperationResult|NULL |
|
| 57 | - */ |
|
| 55 | + /** |
|
| 56 | + * @var OperationResult|NULL |
|
| 57 | + */ |
|
| 58 | 58 | protected ?OperationResult $validationResult = null; |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @var array<string> |
|
| 62 | - */ |
|
| 60 | + /** |
|
| 61 | + * @var array<string> |
|
| 62 | + */ |
|
| 63 | 63 | protected array $validations = array( |
| 64 | 64 | 'number_path', |
| 65 | 65 | 'number_name', |