@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | return $this->getSign(); |
31 | 31 | } |
32 | 32 | |
33 | - /** |
|
34 | - * Retrieves all known comparison operator signs. |
|
35 | - * @return string[] |
|
36 | - */ |
|
33 | + /** |
|
34 | + * Retrieves all known comparison operator signs. |
|
35 | + * @return string[] |
|
36 | + */ |
|
37 | 37 | public static function getComparisonSigns() : array |
38 | 38 | { |
39 | 39 | return array( |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | ); |
47 | 47 | } |
48 | 48 | |
49 | - /** |
|
50 | - * Retrieves all known arithmetic operator signs. |
|
51 | - * @return string[] |
|
52 | - */ |
|
49 | + /** |
|
50 | + * Retrieves all known arithmetic operator signs. |
|
51 | + * @return string[] |
|
52 | + */ |
|
53 | 53 | public static function getArithmeticSigns() : array |
54 | 54 | { |
55 | 55 | return array( |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | ); |
61 | 61 | } |
62 | 62 | |
63 | - /** |
|
64 | - * Whether the operator is comparison related (equals, not equals, smaller, greater...). |
|
65 | - * |
|
66 | - * @return bool |
|
67 | - */ |
|
63 | + /** |
|
64 | + * Whether the operator is comparison related (equals, not equals, smaller, greater...). |
|
65 | + * |
|
66 | + * @return bool |
|
67 | + */ |
|
68 | 68 | public function isComparator() : bool |
69 | 69 | { |
70 | 70 | return |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | $this->isSmallerOrEquals(); |
77 | 77 | } |
78 | 78 | |
79 | - /** |
|
80 | - * Whether the operator is calculation related (minus, plus, divide, multiply). |
|
81 | - * |
|
82 | - * @return bool |
|
83 | - */ |
|
79 | + /** |
|
80 | + * Whether the operator is calculation related (minus, plus, divide, multiply). |
|
81 | + * |
|
82 | + * @return bool |
|
83 | + */ |
|
84 | 84 | public function isCalculator() : bool |
85 | 85 | { |
86 | 86 | return |
@@ -35,13 +35,13 @@ |
||
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | - /** |
|
39 | - * Resolves the string with which this location needs to be |
|
40 | - * replaced. |
|
41 | - * |
|
42 | - * @param Mailcode_Parser_Safeguard_Formatter_Location $location |
|
43 | - * @return string |
|
44 | - */ |
|
38 | + /** |
|
39 | + * Resolves the string with which this location needs to be |
|
40 | + * replaced. |
|
41 | + * |
|
42 | + * @param Mailcode_Parser_Safeguard_Formatter_Location $location |
|
43 | + * @return string |
|
44 | + */ |
|
45 | 45 | private function resolveReplacement(Mailcode_Parser_Safeguard_Formatter_Location $location) : string |
46 | 46 | { |
47 | 47 | if($location->requiresAdjustment()) |
@@ -23,14 +23,14 @@ |
||
23 | 23 | */ |
24 | 24 | class Mailcode_Parser_Safeguard_Formatter_Type_SingleLines extends Mailcode_Parser_Safeguard_Formatter_FormatType |
25 | 25 | { |
26 | - /** |
|
27 | - * @var string |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var string |
|
28 | + */ |
|
29 | 29 | private $eol; |
30 | 30 | |
31 | - /** |
|
32 | - * @var int |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var int |
|
33 | + */ |
|
34 | 34 | private $eolLength; |
35 | 35 | |
36 | 36 | protected function initFormatting() : void |
@@ -25,14 +25,14 @@ |
||
25 | 25 | */ |
26 | 26 | class Mailcode_Parser_Safeguard_Formatter_Type_SingleLines_Location extends Mailcode_Parser_Safeguard_Formatter_Location |
27 | 27 | { |
28 | - /** |
|
29 | - * @var int |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var int |
|
30 | + */ |
|
31 | 31 | protected $eolLength; |
32 | 32 | |
33 | - /** |
|
34 | - * @var string |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var string |
|
35 | + */ |
|
36 | 36 | protected $eol; |
37 | 37 | |
38 | 38 | protected function init() : void |
@@ -25,11 +25,11 @@ |
||
25 | 25 | return PHP_INT_MAX; |
26 | 26 | } |
27 | 27 | |
28 | - /** |
|
29 | - * Formats the specified string according to the formatter. |
|
30 | - * Retrieve the updated string from the string container used |
|
31 | - * to create the formatter, or use `getSubjectString()`. |
|
32 | - */ |
|
28 | + /** |
|
29 | + * Formats the specified string according to the formatter. |
|
30 | + * Retrieve the updated string from the string container used |
|
31 | + * to create the formatter, or use `getSubjectString()`. |
|
32 | + */ |
|
33 | 33 | public function format() : void |
34 | 34 | { |
35 | 35 | $locations = $this->resolveLocations(); |
@@ -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 | /** |
@@ -52,21 +52,21 @@ discard block |
||
52 | 52 | $this->tokenizer->onTokensChanged(array($this, 'handleTokensChanged')); |
53 | 53 | } |
54 | 54 | |
55 | - /** |
|
56 | - * Whether the whole statement is a variable being assigned a value. |
|
57 | - * |
|
58 | - * @return bool |
|
59 | - */ |
|
55 | + /** |
|
56 | + * Whether the whole statement is a variable being assigned a value. |
|
57 | + * |
|
58 | + * @return bool |
|
59 | + */ |
|
60 | 60 | public function isVariableAssignment() : bool |
61 | 61 | { |
62 | 62 | return $this->variables->isAssignment(); |
63 | 63 | } |
64 | 64 | |
65 | - /** |
|
66 | - * Whether the whole statement is a variable being compared to something. |
|
67 | - * |
|
68 | - * @return bool |
|
69 | - */ |
|
65 | + /** |
|
66 | + * Whether the whole statement is a variable being compared to something. |
|
67 | + * |
|
68 | + * @return bool |
|
69 | + */ |
|
70 | 70 | public function isVariableComparison() : bool |
71 | 71 | { |
72 | 72 | return $this->variables->isComparison(); |
@@ -83,27 +83,27 @@ discard block |
||
83 | 83 | return $this->variables->getAll(); |
84 | 84 | } |
85 | 85 | |
86 | - /** |
|
87 | - * Retrieves a variable by its position in the command's parameters. |
|
88 | - * Returns null if there is no parameter at the specified index, or |
|
89 | - * if it is of another type. |
|
90 | - * |
|
91 | - * @param int $index Zero-based index. |
|
92 | - * @return Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL |
|
93 | - */ |
|
86 | + /** |
|
87 | + * Retrieves a variable by its position in the command's parameters. |
|
88 | + * Returns null if there is no parameter at the specified index, or |
|
89 | + * if it is of another type. |
|
90 | + * |
|
91 | + * @param int $index Zero-based index. |
|
92 | + * @return Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL |
|
93 | + */ |
|
94 | 94 | public function getVariableByIndex(int $index) : ?Mailcode_Parser_Statement_Tokenizer_Token_Variable |
95 | 95 | { |
96 | 96 | return $this->variables->getByIndex($index); |
97 | 97 | } |
98 | 98 | |
99 | - /** |
|
100 | - * Retrieves a string literal by its position in the command's parameters. |
|
101 | - * Returns null if there is no parameter at the specified index, or |
|
102 | - * if it is of another type. |
|
103 | - * |
|
104 | - * @param int $index Zero-based index. |
|
105 | - * @return Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral|NULL |
|
106 | - */ |
|
99 | + /** |
|
100 | + * Retrieves a string literal by its position in the command's parameters. |
|
101 | + * Returns null if there is no parameter at the specified index, or |
|
102 | + * if it is of another type. |
|
103 | + * |
|
104 | + * @param int $index Zero-based index. |
|
105 | + * @return Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral|NULL |
|
106 | + */ |
|
107 | 107 | public function getStringLiteralByIndex(int $index) : ?Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral |
108 | 108 | { |
109 | 109 | $token = $this->getTokenByIndex($index); |
@@ -116,27 +116,27 @@ discard block |
||
116 | 116 | return null; |
117 | 117 | } |
118 | 118 | |
119 | - /** |
|
120 | - * Retrieves a keyword by its position in the command's parameters. |
|
121 | - * Returns null if there is no parameter at the specified index, or |
|
122 | - * if it is of another type. |
|
123 | - * |
|
124 | - * @param int $index Zero-based index. |
|
125 | - * @return Mailcode_Parser_Statement_Tokenizer_Token_Keyword|NULL |
|
126 | - */ |
|
119 | + /** |
|
120 | + * Retrieves a keyword by its position in the command's parameters. |
|
121 | + * Returns null if there is no parameter at the specified index, or |
|
122 | + * if it is of another type. |
|
123 | + * |
|
124 | + * @param int $index Zero-based index. |
|
125 | + * @return Mailcode_Parser_Statement_Tokenizer_Token_Keyword|NULL |
|
126 | + */ |
|
127 | 127 | public function getKeywordByIndex(int $index) : ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword |
128 | 128 | { |
129 | 129 | return $this->keywords->getByIndex($index); |
130 | 130 | } |
131 | 131 | |
132 | - /** |
|
133 | - * Retrieves an operand by its position in the command's parameters. |
|
134 | - * Returns null if there is no parameter at the specified index, or |
|
135 | - * if it is of another type. |
|
136 | - * |
|
137 | - * @param int $index Zero-based index. |
|
138 | - * @return Mailcode_Parser_Statement_Tokenizer_Token_Operand|NULL |
|
139 | - */ |
|
132 | + /** |
|
133 | + * Retrieves an operand by its position in the command's parameters. |
|
134 | + * Returns null if there is no parameter at the specified index, or |
|
135 | + * if it is of another type. |
|
136 | + * |
|
137 | + * @param int $index Zero-based index. |
|
138 | + * @return Mailcode_Parser_Statement_Tokenizer_Token_Operand|NULL |
|
139 | + */ |
|
140 | 140 | public function getOperandByIndex(int $index) : ?Mailcode_Parser_Statement_Tokenizer_Token_Operand |
141 | 141 | { |
142 | 142 | $token = $this->getTokenByIndex($index); |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | return null; |
150 | 150 | } |
151 | 151 | |
152 | - /** |
|
153 | - * Retrieves a parameter token by its position in the command's parameters, |
|
154 | - * regardless of its type. Returns null if there is no parameter at the |
|
155 | - * specified index. |
|
156 | - * |
|
157 | - * @param int $index Zero-based index. |
|
158 | - * @return Mailcode_Parser_Statement_Tokenizer_Token|NULL |
|
159 | - */ |
|
152 | + /** |
|
153 | + * Retrieves a parameter token by its position in the command's parameters, |
|
154 | + * regardless of its type. Returns null if there is no parameter at the |
|
155 | + * specified index. |
|
156 | + * |
|
157 | + * @param int $index Zero-based index. |
|
158 | + * @return Mailcode_Parser_Statement_Tokenizer_Token|NULL |
|
159 | + */ |
|
160 | 160 | public function getTokenByIndex(int $index) : ?Mailcode_Parser_Statement_Tokenizer_Token |
161 | 161 | { |
162 | 162 | if(isset($this->tokens[$index])) |
@@ -172,19 +172,19 @@ discard block |
||
172 | 172 | return isset($this->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->tokens; |
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(); |
@@ -176,27 +176,27 @@ |
||
176 | 176 | * @return array<string,string> |
177 | 177 | * @throws Mailcode_Exception |
178 | 178 | */ |
179 | - private function parseVarName() : array |
|
180 | - { |
|
181 | - $tokens = explode('.', ltrim($this->variable->getFullName(), '$')); |
|
182 | - |
|
183 | - if(count($tokens) === 2) |
|
184 | - { |
|
185 | - return array( |
|
186 | - 'path' => $tokens[0], |
|
187 | - 'name' => $tokens[1] |
|
188 | - ); |
|
189 | - } |
|
190 | - |
|
191 | - throw new Mailcode_Exception( |
|
192 | - 'Invalid variable name for a list property.', |
|
193 | - sprintf( |
|
194 | - 'Exactly 2 parts are required, variable [%s] has [%s].', |
|
195 | - $this->variable->getFullName(), |
|
196 | - count($tokens) |
|
197 | - ), |
|
198 | - self::ERROR_INVALID_LIST_VARIABLE_NAME |
|
199 | - ); |
|
200 | - } |
|
179 | + private function parseVarName() : array |
|
180 | + { |
|
181 | + $tokens = explode('.', ltrim($this->variable->getFullName(), '$')); |
|
182 | + |
|
183 | + if(count($tokens) === 2) |
|
184 | + { |
|
185 | + return array( |
|
186 | + 'path' => $tokens[0], |
|
187 | + 'name' => $tokens[1] |
|
188 | + ); |
|
189 | + } |
|
190 | + |
|
191 | + throw new Mailcode_Exception( |
|
192 | + 'Invalid variable name for a list property.', |
|
193 | + sprintf( |
|
194 | + 'Exactly 2 parts are required, variable [%s] has [%s].', |
|
195 | + $this->variable->getFullName(), |
|
196 | + count($tokens) |
|
197 | + ), |
|
198 | + self::ERROR_INVALID_LIST_VARIABLE_NAME |
|
199 | + ); |
|
200 | + } |
|
201 | 201 | } |
202 | 202 |
@@ -24,9 +24,9 @@ |
||
24 | 24 | */ |
25 | 25 | trait Mailcode_Traits_Commands_Validation_Variable |
26 | 26 | { |
27 | - /** |
|
28 | - * @var Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL |
|
29 | + */ |
|
30 | 30 | protected $variableToken; |
31 | 31 | |
32 | 32 | protected function validateSyntax_variable() : void |
@@ -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 $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) |
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 exluded tag names at once. |
|
56 | - * |
|
57 | - * @param string[] $tagNames |
|
58 | - * @return $this |
|
59 | - */ |
|
54 | + /** |
|
55 | + * Adds several exluded tag names at once. |
|
56 | + * |
|
57 | + * @param string[] $tagNames |
|
58 | + * @return $this |
|
59 | + */ |
|
60 | 60 | public function excludeTags(array $tagNames) |
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 exlusion list. |
|
72 | - * |
|
73 | - * @param string $tagName |
|
74 | - * @return bool |
|
75 | - */ |
|
70 | + /** |
|
71 | + * Whether the specified tag name is in the exlusion 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); |