@@ -313,9 +313,9 @@ |
||
| 313 | 313 | { |
| 314 | 314 | $tokens = $this->tokenizer->getTokens(); |
| 315 | 315 | |
| 316 | - foreach($tokens as $token) |
|
| 316 | + foreach ($tokens as $token) |
|
| 317 | 317 | { |
| 318 | - if($token->getName() === $name) |
|
| 318 | + if ($token->getName() === $name) |
|
| 319 | 319 | { |
| 320 | 320 | return $token; |
| 321 | 321 | } |
@@ -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 |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | { |
| 13 | 13 | $next = $this->tokensTemporary[$i + 1] ?? null; |
| 14 | 14 | |
| 15 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_ParamName && $next) { |
|
| 15 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_ParamName && $next) { |
|
| 16 | 16 | $next->registerNameToken($token); |
| 17 | 17 | } |
| 18 | 18 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | $matches = array(); |
| 12 | 12 | preg_match_all('/([a-z][a-z0-9-]+)\s*=/iU', $this->tokenized, $matches, PREG_PATTERN_ORDER); |
| 13 | 13 | |
| 14 | - foreach($matches[0] as $match) |
|
| 14 | + foreach ($matches[0] as $match) |
|
| 15 | 15 | { |
| 16 | 16 | $this->registerToken('ParamName', $match); |
| 17 | 17 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | ->getInfo() |
| 45 | 45 | ->getTokenByParamName(CountInterface::PARAMETER_NAME); |
| 46 | 46 | |
| 47 | - if($token === null) |
|
| 47 | + if ($token === null) |
|
| 48 | 48 | { |
| 49 | 49 | $this->countEnabled = false; |
| 50 | 50 | return; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $this->validationResult->makeError( |
| 60 | - t('Invalid count subject:') . ' ' . t('Expected a variable.'), |
|
| 60 | + t('Invalid count subject:').' '.t('Expected a variable.'), |
|
| 61 | 61 | CountInterface::VALIDATION_COUNT_CODE_WRONG_TYPE |
| 62 | 62 | ); |
| 63 | 63 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | public function getCountVariable(): ?Mailcode_Variables_Variable |
| 71 | 71 | { |
| 72 | - if($this->countToken !== null) |
|
| 72 | + if ($this->countToken !== null) |
|
| 73 | 73 | { |
| 74 | 74 | return $this->countToken->getVariable(); |
| 75 | 75 | } |
@@ -88,15 +88,15 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | $info = $this->requireParams()->getInfo(); |
| 90 | 90 | |
| 91 | - if(isset($this->countToken)) { |
|
| 91 | + if (isset($this->countToken)) { |
|
| 92 | 92 | $info->removeToken($this->countToken); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if(is_string($variable)) { |
|
| 95 | + if (is_string($variable)) { |
|
| 96 | 96 | $variable = Mailcode_Factory::var()->fullName($variable); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if($variable !== null) { |
|
| 99 | + if ($variable !== null) { |
|
| 100 | 100 | $this->countEnabled = true; |
| 101 | 101 | $this->countToken = $info->addVariable($variable); |
| 102 | 102 | $info->setParamName($this->countToken, CountInterface::PARAMETER_NAME); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | ->getInfo() |
| 48 | 48 | ->getTokenByParamName(BreakAtInterface::PARAMETER_NAME); |
| 49 | 49 | |
| 50 | - if($this->breakAtToken === null) { |
|
| 50 | + if ($this->breakAtToken === null) { |
|
| 51 | 51 | $this->breakAtEnabled = false; |
| 52 | 52 | return; |
| 53 | 53 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | if (!$this->breakAtToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number && |
| 56 | 56 | !$this->breakAtToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) { |
| 57 | 57 | $this->validationResult->makeError( |
| 58 | - t('Invalid break-at value:') . ' ' . t('Expected a number or variable.'), |
|
| 58 | + t('Invalid break-at value:').' '.t('Expected a number or variable.'), |
|
| 59 | 59 | BreakAtInterface::VALIDATION_BREAK_AT_CODE_WRONG_TYPE |
| 60 | 60 | ); |
| 61 | 61 | return; |
@@ -80,19 +80,19 @@ discard block |
||
| 80 | 80 | public function getBreakAt() |
| 81 | 81 | { |
| 82 | 82 | $token = $this->getBreakAtToken(); |
| 83 | - if($token === null) { |
|
| 83 | + if ($token === null) { |
|
| 84 | 84 | return null; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) { |
|
| 87 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) { |
|
| 88 | 88 | return $token->getVariable(); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number) { |
|
| 91 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number) { |
|
| 92 | 92 | return (int)$token->getValue(); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) { |
|
| 95 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) { |
|
| 96 | 96 | return (int)$token->getText(); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -109,29 +109,29 @@ discard block |
||
| 109 | 109 | { |
| 110 | 110 | $info = $this->requireParams()->getInfo(); |
| 111 | 111 | |
| 112 | - if(isset($this->breakAtToken)) { |
|
| 112 | + if (isset($this->breakAtToken)) { |
|
| 113 | 113 | $info->removeToken($this->breakAtToken); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $this->breakAtEnabled = false; |
| 117 | 117 | $this->breakAtToken = null; |
| 118 | 118 | |
| 119 | - if($breakAt === null) { |
|
| 119 | + if ($breakAt === null) { |
|
| 120 | 120 | return $this; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | $token = null; |
| 124 | 124 | |
| 125 | - if(is_numeric($breakAt)) |
|
| 125 | + if (is_numeric($breakAt)) |
|
| 126 | 126 | { |
| 127 | 127 | $token = $info->addNumber((string)(int)$breakAt); |
| 128 | 128 | } |
| 129 | - else if($breakAt instanceof Mailcode_Variables_Variable) |
|
| 129 | + else if ($breakAt instanceof Mailcode_Variables_Variable) |
|
| 130 | 130 | { |
| 131 | 131 | $token = $info->addVariable($breakAt); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if($token !== null) |
|
| 134 | + if ($token !== null) |
|
| 135 | 135 | { |
| 136 | 136 | $info->setParamName($token, BreakAtInterface::PARAMETER_NAME); |
| 137 | 137 | |
@@ -125,8 +125,7 @@ |
||
| 125 | 125 | if(is_numeric($breakAt)) |
| 126 | 126 | { |
| 127 | 127 | $token = $info->addNumber((string)(int)$breakAt); |
| 128 | - } |
|
| 129 | - else if($breakAt instanceof Mailcode_Variables_Variable) |
|
| 128 | + } else if($breakAt instanceof Mailcode_Variables_Variable) |
|
| 130 | 129 | { |
| 131 | 130 | $token = $info->addVariable($breakAt); |
| 132 | 131 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | if (!$this->timezoneToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral && |
| 48 | 48 | !$this->timezoneToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) { |
| 49 | 49 | $this->validationResult->makeError( |
| 50 | - t('Invalid timezone:') . ' ' . t('Expected a string or variable.'), |
|
| 50 | + t('Invalid timezone:').' '.t('Expected a string or variable.'), |
|
| 51 | 51 | TimezoneInterface::VALIDATION_TIMEZONE_CODE_WRONG_TYPE |
| 52 | 52 | ); |
| 53 | 53 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function getTimezoneToken(): Mailcode_Parser_Statement_Tokenizer_Token |
| 64 | 64 | { |
| 65 | - if(!isset($this->timezoneToken)) { |
|
| 65 | + if (!isset($this->timezoneToken)) { |
|
| 66 | 66 | $this->timezoneToken = $this->createTimeZoneToken(); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $default = Mailcode_Commands_Command_ShowDate::getDefaultTimezone(); |
| 80 | 80 | $info = $this->requireParams()->getInfo(); |
| 81 | 81 | |
| 82 | - if($default instanceof Mailcode_Variables_Variable) { |
|
| 82 | + if ($default instanceof Mailcode_Variables_Variable) { |
|
| 83 | 83 | $token = $info->addVariable($default); |
| 84 | 84 | } else { |
| 85 | 85 | $token = $info->addStringLiteral($default); |
@@ -100,17 +100,17 @@ discard block |
||
| 100 | 100 | $token = null; |
| 101 | 101 | |
| 102 | 102 | $existing = $info->getTokenByParamName(TimezoneInterface::PARAMETER_NAME); |
| 103 | - if($existing) { |
|
| 103 | + if ($existing) { |
|
| 104 | 104 | $info->removeToken($existing); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if($timezone instanceof Mailcode_Variables_Variable) { |
|
| 107 | + if ($timezone instanceof Mailcode_Variables_Variable) { |
|
| 108 | 108 | $token = $info->addVariable($timezone); |
| 109 | - } else if(is_string($timezone)) { |
|
| 109 | + } else if (is_string($timezone)) { |
|
| 110 | 110 | $token = $info->addStringLiteral($timezone); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if($token !== null) { |
|
| 113 | + if ($token !== null) { |
|
| 114 | 114 | $info->setParamName($token, TimezoneInterface::PARAMETER_NAME); |
| 115 | 115 | } |
| 116 | 116 | |
@@ -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); |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | */ |
| 60 | 60 | public function excludeTags(array $tagNames) : self |
| 61 | 61 | { |
| 62 | - foreach($tagNames as $tagName) |
|
| 62 | + foreach ($tagNames as $tagName) |
|
| 63 | 63 | { |
| 64 | 64 | $this->excludeTag((string)$tagName); |
| 65 | 65 | } |