@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | 'ExtractTokens' |
40 | 40 | ); |
41 | 41 | |
42 | - /** |
|
43 | - * @var Mailcode_Parser_Statement |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var Mailcode_Parser_Statement |
|
44 | + */ |
|
45 | 45 | protected Mailcode_Parser_Statement $statement; |
46 | 46 | |
47 | - /** |
|
48 | - * @var string |
|
49 | - */ |
|
47 | + /** |
|
48 | + * @var string |
|
49 | + */ |
|
50 | 50 | protected string $tokenized = ''; |
51 | 51 | |
52 | 52 | /** |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | */ |
55 | 55 | protected array $tokensOrdered = array(); |
56 | 56 | |
57 | - /** |
|
58 | - * @var string[] |
|
59 | - */ |
|
57 | + /** |
|
58 | + * @var string[] |
|
59 | + */ |
|
60 | 60 | protected static array $ids = array(); |
61 | 61 | |
62 | 62 | /** |
@@ -76,12 +76,12 @@ discard block |
||
76 | 76 | return $this->statement->getSourceCommand(); |
77 | 77 | } |
78 | 78 | |
79 | - /** |
|
80 | - * Retrieves all tokens detected in the statement string, in |
|
81 | - * the order they were found. |
|
82 | - * |
|
83 | - * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
84 | - */ |
|
79 | + /** |
|
80 | + * Retrieves all tokens detected in the statement string, in |
|
81 | + * the order they were found. |
|
82 | + * |
|
83 | + * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
84 | + */ |
|
85 | 85 | public function getTokens() : array |
86 | 86 | { |
87 | 87 | return $this->tokensOrdered; |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | return !empty($this->tokensOrdered); |
93 | 93 | } |
94 | 94 | |
95 | - /** |
|
96 | - * Whether there were any unknown tokens in the statement. |
|
97 | - * |
|
98 | - * @return bool |
|
99 | - */ |
|
95 | + /** |
|
96 | + * Whether there were any unknown tokens in the statement. |
|
97 | + * |
|
98 | + * @return bool |
|
99 | + */ |
|
100 | 100 | public function hasUnknown() : bool |
101 | 101 | { |
102 | 102 | $unknown = $this->getUnknown(); |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | return !empty($unknown); |
105 | 105 | } |
106 | 106 | |
107 | - /** |
|
108 | - * Retrieves all unknown content tokens, if any. |
|
109 | - * |
|
110 | - * @return Mailcode_Parser_Statement_Tokenizer_Token_Unknown[] |
|
111 | - */ |
|
107 | + /** |
|
108 | + * Retrieves all unknown content tokens, if any. |
|
109 | + * |
|
110 | + * @return Mailcode_Parser_Statement_Tokenizer_Token_Unknown[] |
|
111 | + */ |
|
112 | 112 | public function getUnknown() : array |
113 | 113 | { |
114 | 114 | $result = array(); |
@@ -293,13 +293,13 @@ discard block |
||
293 | 293 | return $token; |
294 | 294 | } |
295 | 295 | |
296 | - /** |
|
297 | - * Generates a unique alphabet-based ID without numbers |
|
298 | - * to use as token name, to avoid conflicts with the |
|
299 | - * numbers detection. |
|
300 | - * |
|
301 | - * @return string |
|
302 | - */ |
|
296 | + /** |
|
297 | + * Generates a unique alphabet-based ID without numbers |
|
298 | + * to use as token name, to avoid conflicts with the |
|
299 | + * numbers detection. |
|
300 | + * |
|
301 | + * @return string |
|
302 | + */ |
|
303 | 303 | protected function generateID() : string |
304 | 304 | { |
305 | 305 | static $alphas; |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | { |
114 | 114 | $result = array(); |
115 | 115 | |
116 | - foreach($this->tokensOrdered as $token) |
|
116 | + foreach ($this->tokensOrdered as $token) |
|
117 | 117 | { |
118 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
118 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
119 | 119 | { |
120 | 120 | $result[] = $token; |
121 | 121 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | { |
129 | 129 | $unknown = $this->getUnknown(); |
130 | 130 | |
131 | - if(!empty($unknown)) |
|
131 | + if (!empty($unknown)) |
|
132 | 132 | { |
133 | 133 | return array_shift($unknown); |
134 | 134 | } |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | { |
141 | 141 | $parts = array(); |
142 | 142 | |
143 | - foreach($this->tokensOrdered as $token) |
|
143 | + foreach ($this->tokensOrdered as $token) |
|
144 | 144 | { |
145 | 145 | $string = $token->getNormalized(); |
146 | 146 | |
147 | - if($string !== '') |
|
147 | + if ($string !== '') |
|
148 | 148 | { |
149 | 149 | $parts[] = $string; |
150 | 150 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $statement = trim($statement); |
169 | 169 | $tokens = array(); |
170 | 170 | |
171 | - foreach($this->tokenCategories as $tokenCategory) |
|
171 | + foreach ($this->tokenCategories as $tokenCategory) |
|
172 | 172 | { |
173 | 173 | $processor = $this->createProcessor($tokenCategory, $statement, $tokens); |
174 | 174 | $processor->process(); |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | $instance = new $class($this, $statement, $tokens); |
196 | 196 | |
197 | - if($instance instanceof Mailcode_Parser_Statement_Tokenizer_Process) |
|
197 | + if ($instance instanceof Mailcode_Parser_Statement_Tokenizer_Process) |
|
198 | 198 | { |
199 | 199 | return $instance; |
200 | 200 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @param mixed $subject |
216 | 216 | * @return Mailcode_Parser_Statement_Tokenizer_Token |
217 | 217 | */ |
218 | - public function createToken(string $type, string $matchedText, $subject=null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
218 | + public function createToken(string $type, string $matchedText, $subject = null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
219 | 219 | { |
220 | 220 | $tokenID = $this->generateID(); |
221 | 221 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | |
224 | 224 | $token = new $class($tokenID, $matchedText, $subject, $this->getSourceCommand()); |
225 | 225 | |
226 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token) |
|
226 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token) |
|
227 | 227 | { |
228 | 228 | return $token; |
229 | 229 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | $token = $this->appendToken('Keyword', $name); |
246 | 246 | |
247 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
247 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
248 | 248 | { |
249 | 249 | return $token; |
250 | 250 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | |
264 | 264 | foreach ($this->tokensOrdered as $checkToken) |
265 | 265 | { |
266 | - if($checkToken->getID() !== $tokenID) |
|
266 | + if ($checkToken->getID() !== $tokenID) |
|
267 | 267 | { |
268 | 268 | $keep[] = $checkToken; |
269 | 269 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param mixed $subject |
283 | 283 | * @return Mailcode_Parser_Statement_Tokenizer_Token |
284 | 284 | */ |
285 | - protected function appendToken(string $type, string $matchedText, $subject=null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
285 | + protected function appendToken(string $type, string $matchedText, $subject = null) : Mailcode_Parser_Statement_Tokenizer_Token |
|
286 | 286 | { |
287 | 287 | $token = $this->createToken($type, $matchedText, $subject); |
288 | 288 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | { |
305 | 305 | static $alphas; |
306 | 306 | |
307 | - if(!isset($alphas)) |
|
307 | + if (!isset($alphas)) |
|
308 | 308 | { |
309 | 309 | $alphas = range('A', 'Z'); |
310 | 310 | } |
@@ -313,12 +313,12 @@ discard block |
||
313 | 313 | |
314 | 314 | $result = ''; |
315 | 315 | |
316 | - for($i=0; $i < $amount; $i++) |
|
316 | + for ($i = 0; $i < $amount; $i++) |
|
317 | 317 | { |
318 | 318 | $result .= $alphas[array_rand($alphas)]; |
319 | 319 | } |
320 | 320 | |
321 | - if(!in_array($result, self::$ids)) |
|
321 | + if (!in_array($result, self::$ids)) |
|
322 | 322 | { |
323 | 323 | self::$ids[] = $result; |
324 | 324 | return $result; |
@@ -35,14 +35,14 @@ |
||
35 | 35 | */ |
36 | 36 | private ?Mailcode_Factory_CommandSets_Set_Misc $misc = null; |
37 | 37 | |
38 | - /** |
|
39 | - * @var Mailcode_Factory_CommandSets_Set_Set|NULL |
|
40 | - */ |
|
38 | + /** |
|
39 | + * @var Mailcode_Factory_CommandSets_Set_Set|NULL |
|
40 | + */ |
|
41 | 41 | private ?Mailcode_Factory_CommandSets_Set_Set $set = null; |
42 | 42 | |
43 | - /** |
|
44 | - * @var Mailcode_Factory_CommandSets_Set_ElseIf|NULL |
|
45 | - */ |
|
43 | + /** |
|
44 | + * @var Mailcode_Factory_CommandSets_Set_ElseIf|NULL |
|
45 | + */ |
|
46 | 46 | private ?Mailcode_Factory_CommandSets_Set_ElseIf $elseIf = null; |
47 | 47 | |
48 | 48 | public function if() : Mailcode_Factory_CommandSets_Set_If |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | */ |
46 | 46 | private ?Mailcode_Factory_CommandSets_Set_ElseIf $elseIf = null; |
47 | 47 | |
48 | - public function if() : Mailcode_Factory_CommandSets_Set_If |
|
48 | + public function if () : Mailcode_Factory_CommandSets_Set_If |
|
49 | 49 | { |
50 | - if(!isset($this->if)) |
|
50 | + if (!isset($this->if)) |
|
51 | 51 | { |
52 | 52 | $this->if = new Mailcode_Factory_CommandSets_Set_If(); |
53 | 53 | } |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | return $this->if; |
56 | 56 | } |
57 | 57 | |
58 | - public function elseIf() : Mailcode_Factory_CommandSets_Set_ElseIf |
|
58 | + public function elseIf () : Mailcode_Factory_CommandSets_Set_ElseIf |
|
59 | 59 | { |
60 | - if(!isset($this->elseIf)) |
|
60 | + if (!isset($this->elseIf)) |
|
61 | 61 | { |
62 | 62 | $this->elseIf = new Mailcode_Factory_CommandSets_Set_ElseIf(); |
63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | public function show() : Mailcode_Factory_CommandSets_Set_Show |
69 | 69 | { |
70 | - if(!isset($this->show)) |
|
70 | + if (!isset($this->show)) |
|
71 | 71 | { |
72 | 72 | $this->show = new Mailcode_Factory_CommandSets_Set_Show(); |
73 | 73 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | public function misc() : Mailcode_Factory_CommandSets_Set_Misc |
79 | 79 | { |
80 | - if(!isset($this->misc)) |
|
80 | + if (!isset($this->misc)) |
|
81 | 81 | { |
82 | 82 | $this->misc = new Mailcode_Factory_CommandSets_Set_Misc(); |
83 | 83 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | public function set() : Mailcode_Factory_CommandSets_Set_Set |
89 | 89 | { |
90 | - if(!isset($this->set)) |
|
90 | + if (!isset($this->set)) |
|
91 | 91 | { |
92 | 92 | $this->set = new Mailcode_Factory_CommandSets_Set_Set(); |
93 | 93 | } |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | |
39 | 39 | $keywords = $this->params->getInfo()->getKeywords(); |
40 | 40 | |
41 | - foreach($keywords as $keyword) |
|
41 | + foreach ($keywords as $keyword) |
|
42 | 42 | { |
43 | - if($keyword->isNoHTML()) |
|
43 | + if ($keyword->isNoHTML()) |
|
44 | 44 | { |
45 | 45 | $this->noHTMLToken = $keyword; |
46 | 46 | break; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return $this |
56 | 56 | * @throws Mailcode_Exception |
57 | 57 | */ |
58 | - public function setHTMLEnabled(bool $enabled=true) : self |
|
58 | + public function setHTMLEnabled(bool $enabled = true) : self |
|
59 | 59 | { |
60 | 60 | $this->params->getInfo()->setKeywordEnabled(Mailcode_Commands_Keywords::TYPE_NOHTML, !$enabled); |
61 | 61 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | ->getInfo() |
38 | 38 | ->getTokenByIndex(0); |
39 | 39 | |
40 | - if($contentIDToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number) |
|
40 | + if ($contentIDToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number) |
|
41 | 41 | { |
42 | 42 | $this->contentIDToken = $contentIDToken; |
43 | 43 | $this->loadContent(); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | public function getContentID() : int |
54 | 54 | { |
55 | - if(isset($this->contentIDToken)) |
|
55 | + if (isset($this->contentIDToken)) |
|
56 | 56 | { |
57 | 57 | return (int)$this->contentIDToken->getValue(); |
58 | 58 | } |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | public const ERROR_UNKNOWN_COMMAND_TYPE = 50401; |
25 | 25 | public const ERROR_INVALID_COMMAND_INSTANCE = 50402; |
26 | 26 | |
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | 30 | protected string $typeID; |
31 | 31 | |
32 | 32 | public function __construct(string $typeID) |
@@ -34,22 +34,22 @@ discard block |
||
34 | 34 | $this->typeID = $typeID; |
35 | 35 | } |
36 | 36 | |
37 | - /** |
|
38 | - * Retrieves the syntax' type ID, e.g. "ApacheVelocity". |
|
39 | - * @return string |
|
40 | - */ |
|
37 | + /** |
|
38 | + * Retrieves the syntax' type ID, e.g. "ApacheVelocity". |
|
39 | + * @return string |
|
40 | + */ |
|
41 | 41 | public function getTypeID() : string |
42 | 42 | { |
43 | 43 | return $this->typeID; |
44 | 44 | } |
45 | 45 | |
46 | - /** |
|
47 | - * Translates a single command to the target syntax. |
|
48 | - * |
|
49 | - * @param Mailcode_Commands_Command $command |
|
50 | - * @throws Mailcode_Translator_Exception |
|
51 | - * @return string |
|
52 | - */ |
|
46 | + /** |
|
47 | + * Translates a single command to the target syntax. |
|
48 | + * |
|
49 | + * @param Mailcode_Commands_Command $command |
|
50 | + * @throws Mailcode_Translator_Exception |
|
51 | + * @return string |
|
52 | + */ |
|
53 | 53 | public function translateCommand(Mailcode_Commands_Command $command) : string |
54 | 54 | { |
55 | 55 | return $this->createTranslator($command)->translate($command); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $command->getID() |
64 | 64 | ); |
65 | 65 | |
66 | - if(!class_exists($class)) |
|
66 | + if (!class_exists($class)) |
|
67 | 67 | { |
68 | 68 | throw new Mailcode_Translator_Exception( |
69 | 69 | sprintf('Unknown command %s in translator', $command->getID()), |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | $translator = new $class($command); |
79 | 79 | |
80 | - if($translator instanceof Mailcode_Translator_Command) |
|
80 | + if ($translator instanceof Mailcode_Translator_Command) |
|
81 | 81 | { |
82 | 82 | return $translator; |
83 | 83 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | { |
106 | 106 | $subject = $safeguard->makeSafe(); |
107 | 107 | |
108 | - if(!$safeguard->hasPlaceholders()) |
|
108 | + if (!$safeguard->hasPlaceholders()) |
|
109 | 109 | { |
110 | 110 | return $subject; |
111 | 111 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | $replaces = array(); |
116 | 116 | |
117 | - foreach($placeholders as $placeholder) |
|
117 | + foreach ($placeholders as $placeholder) |
|
118 | 118 | { |
119 | 119 | $command = $placeholder->getCommand(); |
120 | 120 |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | public const URL_ENCODING_DECODE = 'decode'; |
29 | 29 | |
30 | 30 | /** |
31 | - * @var Mailcode_Factory_CommandSets|NULL |
|
32 | - */ |
|
31 | + * @var Mailcode_Factory_CommandSets|NULL |
|
32 | + */ |
|
33 | 33 | private static ?Mailcode_Factory_CommandSets $commandSets = null; |
34 | 34 | |
35 | 35 | /** |
@@ -83,33 +83,33 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | - * Creates a renderer instance, which can be used to easily |
|
87 | - * create and convert commands to strings. |
|
88 | - * |
|
89 | - * @return Mailcode_Renderer |
|
90 | - */ |
|
86 | + * Creates a renderer instance, which can be used to easily |
|
87 | + * create and convert commands to strings. |
|
88 | + * |
|
89 | + * @return Mailcode_Renderer |
|
90 | + */ |
|
91 | 91 | public static function createRenderer() : Mailcode_Renderer |
92 | 92 | { |
93 | 93 | return new Mailcode_Renderer(); |
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Creates a printer instance, which works like the renderer, |
|
98 | - * but outputs the generated strings to standard output. |
|
99 | - * |
|
100 | - * @return Mailcode_Printer |
|
101 | - */ |
|
96 | + /** |
|
97 | + * Creates a printer instance, which works like the renderer, |
|
98 | + * but outputs the generated strings to standard output. |
|
99 | + * |
|
100 | + * @return Mailcode_Printer |
|
101 | + */ |
|
102 | 102 | public static function createPrinter() : Mailcode_Printer |
103 | 103 | { |
104 | 104 | return new Mailcode_Printer(); |
105 | 105 | } |
106 | 106 | |
107 | - /** |
|
108 | - * Gets/creates the global instance of the date format info |
|
109 | - * class, used to handle date formatting aspects. |
|
110 | - * |
|
111 | - * @return Mailcode_Date_FormatInfo |
|
112 | - */ |
|
107 | + /** |
|
108 | + * Gets/creates the global instance of the date format info |
|
109 | + * class, used to handle date formatting aspects. |
|
110 | + * |
|
111 | + * @return Mailcode_Date_FormatInfo |
|
112 | + */ |
|
113 | 113 | public static function createDateInfo() : Mailcode_Date_FormatInfo |
114 | 114 | { |
115 | 115 | return Mailcode_Date_FormatInfo::getInstance(); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return Mailcode_Factory_CommandSets_Set_If |
59 | 59 | */ |
60 | - public static function if() : Mailcode_Factory_CommandSets_Set_If |
|
60 | + public static function if () : Mailcode_Factory_CommandSets_Set_If |
|
61 | 61 | { |
62 | 62 | return self::getSets()->if(); |
63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return Mailcode_Factory_CommandSets_Set_ElseIf |
69 | 69 | */ |
70 | - public static function elseIf() : Mailcode_Factory_CommandSets_Set_ElseIf |
|
70 | + public static function elseIf () : Mailcode_Factory_CommandSets_Set_ElseIf |
|
71 | 71 | { |
72 | 72 | return self::getSets()->elseIf(); |
73 | 73 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | protected static function getSets() : Mailcode_Factory_CommandSets |
119 | 119 | { |
120 | - if(!isset(self::$commandSets)) |
|
120 | + if (!isset(self::$commandSets)) |
|
121 | 121 | { |
122 | 122 | self::$commandSets = new Mailcode_Factory_CommandSets(); |
123 | 123 | } |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | { |
33 | 33 | $result = array(); |
34 | 34 | |
35 | - foreach($commands as $command) |
|
35 | + foreach ($commands as $command) |
|
36 | 36 | { |
37 | - if($command instanceof Mailcode_Commands_ShowBase) |
|
37 | + if ($command instanceof Mailcode_Commands_ShowBase) |
|
38 | 38 | { |
39 | 39 | $result[] = $command; |
40 | 40 | } |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | { |
57 | 57 | $result = array(); |
58 | 58 | |
59 | - foreach($commands as $command) |
|
59 | + foreach ($commands as $command) |
|
60 | 60 | { |
61 | - if($command instanceof Mailcode_Interfaces_Commands_ListVariables) |
|
61 | + if ($command instanceof Mailcode_Interfaces_Commands_ListVariables) |
|
62 | 62 | { |
63 | 63 | $result[] = $command; |
64 | 64 | } |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | { |
78 | 78 | $result = array(); |
79 | 79 | |
80 | - foreach($commands as $command) |
|
80 | + foreach ($commands as $command) |
|
81 | 81 | { |
82 | - if($command instanceof Mailcode_Commands_Command_ShowVariable) |
|
82 | + if ($command instanceof Mailcode_Commands_Command_ShowVariable) |
|
83 | 83 | { |
84 | 84 | $result[] = $command; |
85 | 85 | } |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | { |
99 | 99 | $result = array(); |
100 | 100 | |
101 | - foreach($commands as $command) |
|
101 | + foreach ($commands as $command) |
|
102 | 102 | { |
103 | - if($command instanceof Mailcode_Commands_Command_For) |
|
103 | + if ($command instanceof Mailcode_Commands_Command_For) |
|
104 | 104 | { |
105 | 105 | $result[] = $command; |
106 | 106 | } |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | { |
120 | 120 | $result = array(); |
121 | 121 | |
122 | - foreach($commands as $command) |
|
122 | + foreach ($commands as $command) |
|
123 | 123 | { |
124 | - if($command instanceof Mailcode_Commands_Command_ShowDate) |
|
124 | + if ($command instanceof Mailcode_Commands_Command_ShowDate) |
|
125 | 125 | { |
126 | 126 | $result[] = $command; |
127 | 127 | } |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | { |
141 | 141 | $result = array(); |
142 | 142 | |
143 | - foreach($commands as $command) |
|
143 | + foreach ($commands as $command) |
|
144 | 144 | { |
145 | - if($command instanceof Mailcode_Commands_Command_If) |
|
145 | + if ($command instanceof Mailcode_Commands_Command_If) |
|
146 | 146 | { |
147 | 147 | $result[] = $command; |
148 | 148 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function normalize() : string |
39 | 39 | { |
40 | - if(!$this->command->isValid()) |
|
40 | + if (!$this->command->isValid()) |
|
41 | 41 | { |
42 | 42 | return ''; |
43 | 43 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | private function addType() : void |
59 | 59 | { |
60 | - if(!$this->command->supportsType() || !$this->command->hasType()) |
|
60 | + if (!$this->command->supportsType() || !$this->command->hasType()) |
|
61 | 61 | { |
62 | 62 | return; |
63 | 63 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | $params = $this->getParamsString($command); |
71 | 71 | |
72 | - if(empty($params)) |
|
72 | + if (empty($params)) |
|
73 | 73 | { |
74 | 74 | return; |
75 | 75 | } |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | { |
88 | 88 | $params = $this->getParamsStatement($command); |
89 | 89 | |
90 | - if($params === null) |
|
90 | + if ($params === null) |
|
91 | 91 | { |
92 | 92 | return ''; |
93 | 93 | } |
94 | 94 | |
95 | - if($command->hasFreeformParameters()) |
|
95 | + if ($command->hasFreeformParameters()) |
|
96 | 96 | { |
97 | 97 | return $params->getStatementString(); |
98 | 98 | } |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | |
103 | 103 | private function addLogicKeywords() : void |
104 | 104 | { |
105 | - if(!$this->command->supportsLogicKeywords()) |
|
105 | + if (!$this->command->supportsLogicKeywords()) |
|
106 | 106 | { |
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
110 | 110 | $keywords = $this->command->getLogicKeywords()->getKeywords(); |
111 | 111 | |
112 | - foreach($keywords as $keyword) |
|
112 | + foreach ($keywords as $keyword) |
|
113 | 113 | { |
114 | 114 | $this->parts[] = ' '; |
115 | 115 | $this->parts[] = $keyword->getKeywordString(); // e.g. "if variable" |
@@ -45,44 +45,44 @@ discard block |
||
45 | 45 | |
46 | 46 | public const META_URL_ENCODING = 'url_encoding'; |
47 | 47 | |
48 | - /** |
|
49 | - * @var string |
|
50 | - */ |
|
48 | + /** |
|
49 | + * @var string |
|
50 | + */ |
|
51 | 51 | protected string $type = ''; |
52 | 52 | |
53 | - /** |
|
54 | - * @var string |
|
55 | - */ |
|
53 | + /** |
|
54 | + * @var string |
|
55 | + */ |
|
56 | 56 | protected string $paramsString = ''; |
57 | 57 | |
58 | - /** |
|
59 | - * @var string |
|
60 | - */ |
|
58 | + /** |
|
59 | + * @var string |
|
60 | + */ |
|
61 | 61 | protected string $matchedText = ''; |
62 | 62 | |
63 | - /** |
|
64 | - * @var string |
|
65 | - */ |
|
63 | + /** |
|
64 | + * @var string |
|
65 | + */ |
|
66 | 66 | protected string $hash = ''; |
67 | 67 | |
68 | - /** |
|
69 | - * @var OperationResult |
|
70 | - */ |
|
68 | + /** |
|
69 | + * @var OperationResult |
|
70 | + */ |
|
71 | 71 | protected OperationResult $validationResult; |
72 | 72 | |
73 | - /** |
|
74 | - * @var Mailcode |
|
75 | - */ |
|
73 | + /** |
|
74 | + * @var Mailcode |
|
75 | + */ |
|
76 | 76 | protected Mailcode $mailcode; |
77 | 77 | |
78 | - /** |
|
79 | - * @var Mailcode_Parser_Statement|NULL |
|
80 | - */ |
|
78 | + /** |
|
79 | + * @var Mailcode_Parser_Statement|NULL |
|
80 | + */ |
|
81 | 81 | protected ?Mailcode_Parser_Statement $params = null; |
82 | 82 | |
83 | - /** |
|
84 | - * @var string[] |
|
85 | - */ |
|
83 | + /** |
|
84 | + * @var string[] |
|
85 | + */ |
|
86 | 86 | protected array $validations = array( |
87 | 87 | Mailcode_Interfaces_Commands_Validation_EmptyParams::VALIDATION_NAME_EMPTY_PARAMS, |
88 | 88 | Mailcode_Interfaces_Commands_Validation_ParamKeywords::VALIDATION_NAME_KEYWORDS, |
@@ -91,24 +91,24 @@ discard block |
||
91 | 91 | Mailcode_Interfaces_Commands_Validation_TypeUnsupported::VALIDATION_NAME_TYPE_UNSUPPORTED |
92 | 92 | ); |
93 | 93 | |
94 | - /** |
|
95 | - * @var string |
|
96 | - */ |
|
94 | + /** |
|
95 | + * @var string |
|
96 | + */ |
|
97 | 97 | protected string $comment = ''; |
98 | 98 | |
99 | - /** |
|
100 | - * @var Mailcode_Commands_LogicKeywords|NULL |
|
101 | - */ |
|
99 | + /** |
|
100 | + * @var Mailcode_Commands_LogicKeywords|NULL |
|
101 | + */ |
|
102 | 102 | protected ?Mailcode_Commands_LogicKeywords $logicKeywords = null; |
103 | 103 | |
104 | - /** |
|
105 | - * @var Mailcode_Parser_Statement_Validator|NULL |
|
106 | - */ |
|
104 | + /** |
|
105 | + * @var Mailcode_Parser_Statement_Validator|NULL |
|
106 | + */ |
|
107 | 107 | protected ?Mailcode_Parser_Statement_Validator $validator = null; |
108 | 108 | |
109 | - /** |
|
110 | - * @var boolean |
|
111 | - */ |
|
109 | + /** |
|
110 | + * @var boolean |
|
111 | + */ |
|
112 | 112 | private bool $validated = false; |
113 | 113 | |
114 | 114 | /** |
@@ -143,13 +143,13 @@ discard block |
||
143 | 143 | |
144 | 144 | } |
145 | 145 | |
146 | - /** |
|
147 | - * Sets the command's parent opening command, if any. |
|
148 | - * NOTE: This is set automatically by the parser, and |
|
149 | - * should not be called manually. |
|
150 | - * |
|
151 | - * @param Mailcode_Commands_Command $command |
|
152 | - */ |
|
146 | + /** |
|
147 | + * Sets the command's parent opening command, if any. |
|
148 | + * NOTE: This is set automatically by the parser, and |
|
149 | + * should not be called manually. |
|
150 | + * |
|
151 | + * @param Mailcode_Commands_Command $command |
|
152 | + */ |
|
153 | 153 | public function setParent(Mailcode_Commands_Command $command) : void |
154 | 154 | { |
155 | 155 | $this->parent = $command; |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | return $this->validationResult->isValid(); |
296 | 296 | } |
297 | 297 | |
298 | - /** |
|
299 | - * @return string[] |
|
300 | - */ |
|
298 | + /** |
|
299 | + * @return string[] |
|
300 | + */ |
|
301 | 301 | abstract protected function getValidations() : array; |
302 | 302 | |
303 | 303 | protected function _validateNesting() : void |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | private int $instanceID; |
133 | 133 | |
134 | - public function __construct(string $type='', string $paramsString='', string $matchedText='') |
|
134 | + public function __construct(string $type = '', string $paramsString = '', string $matchedText = '') |
|
135 | 135 | { |
136 | 136 | self::$instanceCounter++; |
137 | 137 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | { |
223 | 223 | $this->requireNonDummy(); |
224 | 224 | |
225 | - if($this->hash === '') { |
|
225 | + if ($this->hash === '') { |
|
226 | 226 | $this->hash = md5($this->matchedText); |
227 | 227 | } |
228 | 228 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | protected function requireNonDummy() : void |
233 | 233 | { |
234 | - if(!$this->isDummy()) |
|
234 | + if (!$this->isDummy()) |
|
235 | 235 | { |
236 | 236 | return; |
237 | 237 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | |
251 | 251 | protected function validate() : OperationResult |
252 | 252 | { |
253 | - if(!$this->validated) |
|
253 | + if (!$this->validated) |
|
254 | 254 | { |
255 | 255 | $this->requireNonDummy(); |
256 | 256 | $this->validateSyntax(); |
@@ -270,10 +270,10 @@ discard block |
||
270 | 270 | { |
271 | 271 | $validations = $this->resolveValidations(); |
272 | 272 | |
273 | - foreach($validations as $validation) |
|
273 | + foreach ($validations as $validation) |
|
274 | 274 | { |
275 | 275 | // break off at the first validation issue |
276 | - if(!$this->validateSyntaxMethod($validation)) |
|
276 | + if (!$this->validateSyntaxMethod($validation)) |
|
277 | 277 | { |
278 | 278 | return; |
279 | 279 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | { |
293 | 293 | $method = 'validateSyntax_'.$validation; |
294 | 294 | |
295 | - if(!method_exists($this, $method)) |
|
295 | + if (!method_exists($this, $method)) |
|
296 | 296 | { |
297 | 297 | throw new Mailcode_Exception( |
298 | 298 | 'Missing validation method ['.$validation.']', |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | |
323 | 323 | public function validateNesting() : OperationResult |
324 | 324 | { |
325 | - if($this->nestingValidated) |
|
325 | + if ($this->nestingValidated) |
|
326 | 326 | { |
327 | 327 | return $this->validationResult; |
328 | 328 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | |
347 | 347 | public function getType() : string |
348 | 348 | { |
349 | - if($this->supportsType()) |
|
349 | + if ($this->supportsType()) |
|
350 | 350 | { |
351 | 351 | return $this->type; |
352 | 352 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | |
367 | 367 | public function getHighlighted() : string |
368 | 368 | { |
369 | - if(!$this->isValid()) |
|
369 | + if (!$this->isValid()) |
|
370 | 370 | { |
371 | 371 | return ''; |
372 | 372 | } |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | |
378 | 378 | public function getParamsString() : string |
379 | 379 | { |
380 | - if($this->requiresParameters()) |
|
380 | + if ($this->requiresParameters()) |
|
381 | 381 | { |
382 | 382 | return $this->paramsString; |
383 | 383 | } |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | |
393 | 393 | public function requireParams() : Mailcode_Parser_Statement |
394 | 394 | { |
395 | - if(isset($this->params)) |
|
395 | + if (isset($this->params)) |
|
396 | 396 | { |
397 | 397 | return $this->params; |
398 | 398 | } |
@@ -422,22 +422,22 @@ discard block |
||
422 | 422 | |
423 | 423 | public final function getCommandType() : string |
424 | 424 | { |
425 | - if($this instanceof Mailcode_Commands_Command_Type_Closing) |
|
425 | + if ($this instanceof Mailcode_Commands_Command_Type_Closing) |
|
426 | 426 | { |
427 | 427 | return 'Closing'; |
428 | 428 | } |
429 | 429 | |
430 | - if($this instanceof Mailcode_Commands_Command_Type_Opening) |
|
430 | + if ($this instanceof Mailcode_Commands_Command_Type_Opening) |
|
431 | 431 | { |
432 | 432 | return 'Opening'; |
433 | 433 | } |
434 | 434 | |
435 | - if($this instanceof Mailcode_Commands_Command_Type_Sibling) |
|
435 | + if ($this instanceof Mailcode_Commands_Command_Type_Sibling) |
|
436 | 436 | { |
437 | 437 | return 'Sibling'; |
438 | 438 | } |
439 | 439 | |
440 | - if($this instanceof Mailcode_Commands_Command_Type_Standalone) |
|
440 | + if ($this instanceof Mailcode_Commands_Command_Type_Standalone) |
|
441 | 441 | { |
442 | 442 | return 'Standalone'; |
443 | 443 | } |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | |
475 | 475 | public function getLogicKeywords() : Mailcode_Commands_LogicKeywords |
476 | 476 | { |
477 | - if(isset($this->logicKeywords) && $this->supportsLogicKeywords()) |
|
477 | + if (isset($this->logicKeywords) && $this->supportsLogicKeywords()) |
|
478 | 478 | { |
479 | 479 | return $this->logicKeywords; |
480 | 480 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | |
495 | 495 | public function getTranslationParam(string $name) |
496 | 496 | { |
497 | - if(isset($this->translationParams[$name])) |
|
497 | + if (isset($this->translationParams[$name])) |
|
498 | 498 | { |
499 | 499 | return $this->translationParams[$name]; |
500 | 500 | } |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | return null; |
503 | 503 | } |
504 | 504 | |
505 | - public function setURLEncoding(bool $encoding=true) |
|
505 | + public function setURLEncoding(bool $encoding = true) |
|
506 | 506 | { |
507 | 507 | $this->requireURLEncoding(); |
508 | 508 | |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | return $this; |
514 | 514 | } |
515 | 515 | |
516 | - public function setURLDecoding(bool $decode=true) |
|
516 | + public function setURLDecoding(bool $decode = true) |
|
517 | 517 | { |
518 | 518 | $this->requireURLEncoding(); |
519 | 519 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | |
527 | 527 | protected function requireURLEncoding() : void |
528 | 528 | { |
529 | - if($this->supportsURLEncoding()) { |
|
529 | + if ($this->supportsURLEncoding()) { |
|
530 | 530 | return; |
531 | 531 | } |
532 | 532 | |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | |
553 | 553 | protected function getValidator() : Mailcode_Parser_Statement_Validator |
554 | 554 | { |
555 | - if(isset($this->validator)) |
|
555 | + if (isset($this->validator)) |
|
556 | 556 | { |
557 | 557 | return $this->validator; |
558 | 558 | } |