@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | return $this->getOperand(); |
31 | 31 | } |
32 | 32 | |
33 | - /** |
|
34 | - * Whether the operator is comparison related (equals, not equals, smaller, greater...). |
|
35 | - * |
|
36 | - * @return bool |
|
37 | - */ |
|
33 | + /** |
|
34 | + * Whether the operator is comparison related (equals, not equals, smaller, greater...). |
|
35 | + * |
|
36 | + * @return bool |
|
37 | + */ |
|
38 | 38 | public function isComparator() : bool |
39 | 39 | { |
40 | 40 | return |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | $this->isSmallerOrEquals(); |
47 | 47 | } |
48 | 48 | |
49 | - /** |
|
50 | - * Whether the operator is calculation related (minus, plus, divide, multiply). |
|
51 | - * |
|
52 | - * @return bool |
|
53 | - */ |
|
49 | + /** |
|
50 | + * Whether the operator is calculation related (minus, plus, divide, multiply). |
|
51 | + * |
|
52 | + * @return bool |
|
53 | + */ |
|
54 | 54 | public function isCalculator() : bool |
55 | 55 | { |
56 | 56 | return |
@@ -24,7 +24,7 @@ |
||
24 | 24 | |
25 | 25 | public function getVariable() : Mailcode_Variables_Variable |
26 | 26 | { |
27 | - if($this->subject instanceof Mailcode_Variables_Variable) |
|
27 | + if ($this->subject instanceof Mailcode_Variables_Variable) |
|
28 | 28 | { |
29 | 29 | return $this->subject; |
30 | 30 | } |
@@ -20,26 +20,26 @@ |
||
20 | 20 | */ |
21 | 21 | abstract class Mailcode_Parser_Statement_Tokenizer_Token |
22 | 22 | { |
23 | - /** |
|
24 | - * @var string |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var string |
|
25 | + */ |
|
26 | 26 | protected $tokenID; |
27 | 27 | |
28 | - /** |
|
29 | - * @var string |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var string |
|
30 | + */ |
|
31 | 31 | protected $matchedText; |
32 | 32 | |
33 | - /** |
|
34 | - * @var mixed |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var mixed |
|
35 | + */ |
|
36 | 36 | protected $subject; |
37 | 37 | |
38 | - /** |
|
39 | - * @param string $tokenID |
|
40 | - * @param string $matchedText |
|
41 | - * @param mixed $subject |
|
42 | - */ |
|
38 | + /** |
|
39 | + * @param string $tokenID |
|
40 | + * @param string $matchedText |
|
41 | + * @param mixed $subject |
|
42 | + */ |
|
43 | 43 | public function __construct(string $tokenID, string $matchedText, $subject=null) |
44 | 44 | { |
45 | 45 | $this->tokenID = $tokenID; |
@@ -40,7 +40,7 @@ |
||
40 | 40 | * @param string $matchedText |
41 | 41 | * @param mixed $subject |
42 | 42 | */ |
43 | - public function __construct(string $tokenID, string $matchedText, $subject=null) |
|
43 | + public function __construct(string $tokenID, string $matchedText, $subject = null) |
|
44 | 44 | { |
45 | 45 | $this->tokenID = $tokenID; |
46 | 46 | $this->matchedText = $matchedText; |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | { |
24 | 24 | const ERROR_TOKENIZE_METHOD_MISSING = 49801; |
25 | 25 | |
26 | - /** |
|
27 | - * @var string[] |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var string[] |
|
28 | + */ |
|
29 | 29 | protected $operands = array( |
30 | 30 | '==', |
31 | 31 | '<=', |
@@ -40,16 +40,16 @@ discard block |
||
40 | 40 | '<' |
41 | 41 | ); |
42 | 42 | |
43 | - /** |
|
44 | - * @var string[] |
|
45 | - */ |
|
43 | + /** |
|
44 | + * @var string[] |
|
45 | + */ |
|
46 | 46 | protected $keywords = array( |
47 | 47 | 'in:' |
48 | 48 | ); |
49 | 49 | |
50 | - /** |
|
51 | - * @var string |
|
52 | - */ |
|
50 | + /** |
|
51 | + * @var string |
|
52 | + */ |
|
53 | 53 | protected $delimiter = '§§'; |
54 | 54 | |
55 | 55 | /** |
@@ -65,19 +65,19 @@ discard block |
||
65 | 65 | 'extract_tokens' |
66 | 66 | ); |
67 | 67 | |
68 | - /** |
|
69 | - * @var Mailcode_Parser_Statement |
|
70 | - */ |
|
68 | + /** |
|
69 | + * @var Mailcode_Parser_Statement |
|
70 | + */ |
|
71 | 71 | protected $statement; |
72 | 72 | |
73 | - /** |
|
74 | - * @var string |
|
75 | - */ |
|
73 | + /** |
|
74 | + * @var string |
|
75 | + */ |
|
76 | 76 | protected $tokenized; |
77 | 77 | |
78 | - /** |
|
79 | - * @var Mailcode_Parser_Statement_Tokenizer_Token[] |
|
80 | - */ |
|
78 | + /** |
|
79 | + * @var Mailcode_Parser_Statement_Tokenizer_Token[] |
|
80 | + */ |
|
81 | 81 | protected $tokensTemporary = array(); |
82 | 82 | |
83 | 83 | /** |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | */ |
86 | 86 | protected $tokensOrdered = array(); |
87 | 87 | |
88 | - /** |
|
89 | - * @var string[] |
|
90 | - */ |
|
88 | + /** |
|
89 | + * @var string[] |
|
90 | + */ |
|
91 | 91 | protected static $ids = array(); |
92 | 92 | |
93 | 93 | public function __construct(Mailcode_Parser_Statement $statement) |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | $this->tokenize($statement->getStatementString()); |
98 | 98 | } |
99 | 99 | |
100 | - /** |
|
101 | - * Retrieves all tokens detected in the statement string, in |
|
102 | - * the order they were found. |
|
103 | - * |
|
104 | - * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
105 | - */ |
|
100 | + /** |
|
101 | + * Retrieves all tokens detected in the statement string, in |
|
102 | + * the order they were found. |
|
103 | + * |
|
104 | + * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
105 | + */ |
|
106 | 106 | public function getTokens() |
107 | 107 | { |
108 | 108 | return $this->tokensOrdered; |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | return !empty($this->tokensOrdered); |
114 | 114 | } |
115 | 115 | |
116 | - /** |
|
117 | - * Whether there were any unknown tokens in the statement. |
|
118 | - * |
|
119 | - * @return bool |
|
120 | - */ |
|
116 | + /** |
|
117 | + * Whether there were any unknown tokens in the statement. |
|
118 | + * |
|
119 | + * @return bool |
|
120 | + */ |
|
121 | 121 | public function hasUnknown() : bool |
122 | 122 | { |
123 | 123 | $unknown = $this->getUnknown(); |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | return !empty($unknown); |
126 | 126 | } |
127 | 127 | |
128 | - /** |
|
129 | - * Retrieves all unknown content tokens, if any. |
|
130 | - * |
|
131 | - * @return \Mailcode\Mailcode_Parser_Statement_Tokenizer_Token_Unknown[] |
|
132 | - */ |
|
128 | + /** |
|
129 | + * Retrieves all unknown content tokens, if any. |
|
130 | + * |
|
131 | + * @return \Mailcode\Mailcode_Parser_Statement_Tokenizer_Token_Unknown[] |
|
132 | + */ |
|
133 | 133 | public function getUnknown() |
134 | 134 | { |
135 | 135 | $result = array(); |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | - /** |
|
203 | - * Registers a token to add in the statement string. |
|
204 | - * |
|
205 | - * @param string $type |
|
206 | - * @param string $matchedText |
|
207 | - * @param mixed $subject |
|
208 | - */ |
|
202 | + /** |
|
203 | + * Registers a token to add in the statement string. |
|
204 | + * |
|
205 | + * @param string $type |
|
206 | + * @param string $matchedText |
|
207 | + * @param mixed $subject |
|
208 | + */ |
|
209 | 209 | protected function registerToken(string $type, string $matchedText, $subject=null) : void |
210 | 210 | { |
211 | 211 | $tokenID = $this->generateID(); |
@@ -317,13 +317,13 @@ discard block |
||
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
320 | - /** |
|
321 | - * Generates a unique alphabet-based ID without numbers |
|
322 | - * to use as token name, to avoid conflicts with the |
|
323 | - * numbers detection. |
|
324 | - * |
|
325 | - * @return string |
|
326 | - */ |
|
320 | + /** |
|
321 | + * Generates a unique alphabet-based ID without numbers |
|
322 | + * to use as token name, to avoid conflicts with the |
|
323 | + * numbers detection. |
|
324 | + * |
|
325 | + * @return string |
|
326 | + */ |
|
327 | 327 | protected function generateID() : string |
328 | 328 | { |
329 | 329 | static $alphas; |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | { |
135 | 135 | $result = array(); |
136 | 136 | |
137 | - foreach($this->tokensOrdered as $token) |
|
137 | + foreach ($this->tokensOrdered as $token) |
|
138 | 138 | { |
139 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
139 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Unknown) |
|
140 | 140 | { |
141 | 141 | $result[] = $token; |
142 | 142 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | { |
150 | 150 | $unknown = $this->getUnknown(); |
151 | 151 | |
152 | - if(!empty($unknown)) |
|
152 | + if (!empty($unknown)) |
|
153 | 153 | { |
154 | 154 | return array_shift($unknown); |
155 | 155 | } |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | { |
162 | 162 | $parts = array(); |
163 | 163 | |
164 | - foreach($this->tokensOrdered as $token) |
|
164 | + foreach ($this->tokensOrdered as $token) |
|
165 | 165 | { |
166 | 166 | $string = $token->getNormalized(); |
167 | 167 | |
168 | - if(!empty($string)) |
|
168 | + if (!empty($string)) |
|
169 | 169 | { |
170 | 170 | $parts[] = $string; |
171 | 171 | } |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | { |
179 | 179 | $this->tokenized = trim($statement); |
180 | 180 | |
181 | - foreach($this->tokenCategories as $token) |
|
181 | + foreach ($this->tokenCategories as $token) |
|
182 | 182 | { |
183 | 183 | $method = 'tokenize_'.$token; |
184 | 184 | |
185 | - if(!method_exists($this, $method)) |
|
185 | + if (!method_exists($this, $method)) |
|
186 | 186 | { |
187 | 187 | throw new Mailcode_Exception( |
188 | 188 | 'Unknown statement token.', |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * @param string $matchedText |
207 | 207 | * @param mixed $subject |
208 | 208 | */ |
209 | - protected function registerToken(string $type, string $matchedText, $subject=null) : void |
|
209 | + protected function registerToken(string $type, string $matchedText, $subject = null) : void |
|
210 | 210 | { |
211 | 211 | $tokenID = $this->generateID(); |
212 | 212 | |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | |
224 | 224 | protected function getTokenByID(string $tokenID) : ?Mailcode_Parser_Statement_Tokenizer_Token |
225 | 225 | { |
226 | - foreach($this->tokensTemporary as $token) |
|
226 | + foreach ($this->tokensTemporary as $token) |
|
227 | 227 | { |
228 | - if($token->getID() === $tokenID) |
|
228 | + if ($token->getID() === $tokenID) |
|
229 | 229 | { |
230 | 230 | return $token; |
231 | 231 | } |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | |
242 | 242 | protected function tokenize_keywords() : void |
243 | 243 | { |
244 | - foreach($this->keywords as $keyword) |
|
244 | + foreach ($this->keywords as $keyword) |
|
245 | 245 | { |
246 | - if(strstr($this->tokenized, $keyword)) |
|
246 | + if (strstr($this->tokenized, $keyword)) |
|
247 | 247 | { |
248 | 248 | $this->registerToken('Keyword', $keyword); |
249 | 249 | } |
@@ -257,12 +257,12 @@ discard block |
||
257 | 257 | // over that could not be tokenized. |
258 | 258 | $parts = \AppUtils\ConvertHelper::explodeTrim($this->delimiter, $this->tokenized); |
259 | 259 | |
260 | - foreach($parts as $part) |
|
260 | + foreach ($parts as $part) |
|
261 | 261 | { |
262 | 262 | $token = $this->getTokenByID($part); |
263 | 263 | |
264 | 264 | // if the entry is a token, simply add it. |
265 | - if($token) |
|
265 | + if ($token) |
|
266 | 266 | { |
267 | 267 | $this->tokensOrdered[] = $token; |
268 | 268 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | { |
279 | 279 | $vars = Mailcode::create()->findVariables($this->tokenized)->getGroupedByHash(); |
280 | 280 | |
281 | - foreach($vars as $var) |
|
281 | + foreach ($vars as $var) |
|
282 | 282 | { |
283 | 283 | $this->registerToken('Variable', $var->getMatchedText(), $var); |
284 | 284 | } |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | |
287 | 287 | protected function tokenize_operands() : void |
288 | 288 | { |
289 | - foreach($this->operands as $operand) |
|
289 | + foreach ($this->operands as $operand) |
|
290 | 290 | { |
291 | - if(strstr($this->tokenized, $operand)) |
|
291 | + if (strstr($this->tokenized, $operand)) |
|
292 | 292 | { |
293 | 293 | $this->registerToken('Operand', $operand); |
294 | 294 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | $matches = array(); |
301 | 301 | preg_match_all('/"(.*)"/sx', $this->tokenized, $matches, PREG_PATTERN_ORDER); |
302 | 302 | |
303 | - foreach($matches[0] as $match) |
|
303 | + foreach ($matches[0] as $match) |
|
304 | 304 | { |
305 | 305 | $this->registerToken('StringLiteral', $match); |
306 | 306 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $matches = array(); |
312 | 312 | preg_match_all('/-*[0-9]+\s*[.,]\s*[0-9]+|-*[0-9]+/sx', $this->tokenized, $matches, PREG_PATTERN_ORDER); |
313 | 313 | |
314 | - foreach($matches[0] as $match) |
|
314 | + foreach ($matches[0] as $match) |
|
315 | 315 | { |
316 | 316 | $this->registerToken('Number', $match); |
317 | 317 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | { |
329 | 329 | static $alphas; |
330 | 330 | |
331 | - if(!isset($alphas)) |
|
331 | + if (!isset($alphas)) |
|
332 | 332 | { |
333 | 333 | $alphas = range('A', 'Z'); |
334 | 334 | } |
@@ -337,12 +337,12 @@ discard block |
||
337 | 337 | |
338 | 338 | $result = ''; |
339 | 339 | |
340 | - for($i=0; $i < $amount; $i++) |
|
340 | + for ($i = 0; $i < $amount; $i++) |
|
341 | 341 | { |
342 | 342 | $result .= $alphas[array_rand($alphas)]; |
343 | 343 | } |
344 | 344 | |
345 | - if(!in_array($result, self::$ids)) |
|
345 | + if (!in_array($result, self::$ids)) |
|
346 | 346 | { |
347 | 347 | self::$ids[] = $result; |
348 | 348 | return $result; |
@@ -20,18 +20,18 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class Mailcode_Factory_Exception extends Mailcode_Exception |
22 | 22 | { |
23 | - /** |
|
24 | - * @var Mailcode_Commands_Command|NULL |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var Mailcode_Commands_Command|NULL |
|
25 | + */ |
|
26 | 26 | protected $command; |
27 | 27 | |
28 | - /** |
|
29 | - * @param string $message |
|
30 | - * @param string|NULL $details |
|
31 | - * @param int|NULL $code |
|
32 | - * @param \Exception|NULL $previous |
|
33 | - * @param Mailcode_Commands_Command|NULL $command |
|
34 | - */ |
|
28 | + /** |
|
29 | + * @param string $message |
|
30 | + * @param string|NULL $details |
|
31 | + * @param int|NULL $code |
|
32 | + * @param \Exception|NULL $previous |
|
33 | + * @param Mailcode_Commands_Command|NULL $command |
|
34 | + */ |
|
35 | 35 | public function __construct(string $message, $details=null, $code=null, $previous=null, Mailcode_Commands_Command $command=null) |
36 | 36 | { |
37 | 37 | parent::__construct($message, $details, $code, $previous); |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | $this->command = $command; |
40 | 40 | } |
41 | 41 | |
42 | - /** |
|
43 | - * Retrieves the erroneous command, if any. |
|
44 | - * |
|
45 | - * @return Mailcode_Commands_Command|NULL |
|
46 | - */ |
|
42 | + /** |
|
43 | + * Retrieves the erroneous command, if any. |
|
44 | + * |
|
45 | + * @return Mailcode_Commands_Command|NULL |
|
46 | + */ |
|
47 | 47 | public function getCommand() : ?Mailcode_Commands_Command |
48 | 48 | { |
49 | 49 | return $this->command; |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * @param \Exception|NULL $previous |
33 | 33 | * @param Mailcode_Commands_Command|NULL $command |
34 | 34 | */ |
35 | - public function __construct(string $message, $details=null, $code=null, $previous=null, Mailcode_Commands_Command $command=null) |
|
35 | + public function __construct(string $message, $details = null, $code = null, $previous = null, Mailcode_Commands_Command $command = null) |
|
36 | 36 | { |
37 | 37 | parent::__construct($message, $details, $code, $previous); |
38 | 38 |
@@ -30,53 +30,53 @@ discard block |
||
30 | 30 | const VALIDATION_UNKNOWN_COMMAND_NAME = 48304; |
31 | 31 | const VALIDATION_INVALID_PARAMS_STATEMENT = 48305; |
32 | 32 | |
33 | - /** |
|
34 | - * @var string |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var string |
|
35 | + */ |
|
36 | 36 | protected $type = ''; |
37 | 37 | |
38 | - /** |
|
39 | - * @var string |
|
40 | - */ |
|
38 | + /** |
|
39 | + * @var string |
|
40 | + */ |
|
41 | 41 | protected $paramsString = ''; |
42 | 42 | |
43 | - /** |
|
44 | - * @var string |
|
45 | - */ |
|
43 | + /** |
|
44 | + * @var string |
|
45 | + */ |
|
46 | 46 | protected $matchedText = ''; |
47 | 47 | |
48 | - /** |
|
49 | - * @var string |
|
50 | - */ |
|
48 | + /** |
|
49 | + * @var string |
|
50 | + */ |
|
51 | 51 | protected $hash = ''; |
52 | 52 | |
53 | - /** |
|
54 | - * @var \AppUtils\OperationResult |
|
55 | - */ |
|
53 | + /** |
|
54 | + * @var \AppUtils\OperationResult |
|
55 | + */ |
|
56 | 56 | protected $validationResult = null; |
57 | 57 | |
58 | - /** |
|
59 | - * @var \Mailcode\Mailcode |
|
60 | - */ |
|
58 | + /** |
|
59 | + * @var \Mailcode\Mailcode |
|
60 | + */ |
|
61 | 61 | protected $mailcode; |
62 | 62 | |
63 | - /** |
|
64 | - * @var \Mailcode\Mailcode_Parser_Statement |
|
65 | - */ |
|
63 | + /** |
|
64 | + * @var \Mailcode\Mailcode_Parser_Statement |
|
65 | + */ |
|
66 | 66 | protected $params; |
67 | 67 | |
68 | - /** |
|
69 | - * @var string[] |
|
70 | - */ |
|
68 | + /** |
|
69 | + * @var string[] |
|
70 | + */ |
|
71 | 71 | protected $validations = array( |
72 | 72 | 'params', |
73 | 73 | 'type_supported', |
74 | 74 | 'type_unsupported' |
75 | 75 | ); |
76 | 76 | |
77 | - /** |
|
78 | - * @var string |
|
79 | - */ |
|
77 | + /** |
|
78 | + * @var string |
|
79 | + */ |
|
80 | 80 | protected $comment = ''; |
81 | 81 | |
82 | 82 | public function __construct(string $type='', string $paramsString='', string $matchedText='') |
@@ -94,23 +94,23 @@ discard block |
||
94 | 94 | |
95 | 95 | } |
96 | 96 | |
97 | - /** |
|
98 | - * @return string The ID of the command = the name of the command class file. |
|
99 | - */ |
|
97 | + /** |
|
98 | + * @return string The ID of the command = the name of the command class file. |
|
99 | + */ |
|
100 | 100 | public function getID() : string |
101 | 101 | { |
102 | 102 | $tokens = explode('_', get_class($this)); |
103 | 103 | return array_pop($tokens); |
104 | 104 | } |
105 | 105 | |
106 | - /** |
|
107 | - * Sets an optional comment that is not used anywhere, but |
|
108 | - * can be used by the application to track why a command is |
|
109 | - * used somewhere. |
|
110 | - * |
|
111 | - * @param string $comment |
|
112 | - * @return Mailcode_Commands_Command |
|
113 | - */ |
|
106 | + /** |
|
107 | + * Sets an optional comment that is not used anywhere, but |
|
108 | + * can be used by the application to track why a command is |
|
109 | + * used somewhere. |
|
110 | + * |
|
111 | + * @param string $comment |
|
112 | + * @return Mailcode_Commands_Command |
|
113 | + */ |
|
114 | 114 | public function setComment(string $comment) : Mailcode_Commands_Command |
115 | 115 | { |
116 | 116 | $this->comment = $comment; |
@@ -118,34 +118,34 @@ discard block |
||
118 | 118 | return $this; |
119 | 119 | } |
120 | 120 | |
121 | - /** |
|
122 | - * Retrieves the previously set comment, if any. |
|
123 | - * |
|
124 | - * @return string |
|
125 | - */ |
|
121 | + /** |
|
122 | + * Retrieves the previously set comment, if any. |
|
123 | + * |
|
124 | + * @return string |
|
125 | + */ |
|
126 | 126 | public function getComment() : string |
127 | 127 | { |
128 | 128 | return $this->comment; |
129 | 129 | } |
130 | 130 | |
131 | - /** |
|
132 | - * Checks whether this is a dummy command, which is only |
|
133 | - * used to access information on the command type. It cannot |
|
134 | - * be used as an actual live command. |
|
135 | - * |
|
136 | - * @return bool |
|
137 | - */ |
|
131 | + /** |
|
132 | + * Checks whether this is a dummy command, which is only |
|
133 | + * used to access information on the command type. It cannot |
|
134 | + * be used as an actual live command. |
|
135 | + * |
|
136 | + * @return bool |
|
137 | + */ |
|
138 | 138 | public function isDummy() : bool |
139 | 139 | { |
140 | 140 | return $this->type === '__dummy'; |
141 | 141 | } |
142 | 142 | |
143 | - /** |
|
144 | - * Retrieves a hash of the actual matched command string, |
|
145 | - * which is used in collections to detect duplicate commands. |
|
146 | - * |
|
147 | - * @return string |
|
148 | - */ |
|
143 | + /** |
|
144 | + * Retrieves a hash of the actual matched command string, |
|
145 | + * which is used in collections to detect duplicate commands. |
|
146 | + * |
|
147 | + * @return string |
|
148 | + */ |
|
149 | 149 | public function getHash() : string |
150 | 150 | { |
151 | 151 | $this->requireNonDummy(); |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
240 | - /** |
|
241 | - * @return string[] |
|
242 | - */ |
|
240 | + /** |
|
241 | + * @return string[] |
|
242 | + */ |
|
243 | 243 | abstract protected function getValidations() : array; |
244 | 244 | |
245 | 245 | protected function validateSyntax_params() : void |
@@ -394,22 +394,22 @@ discard block |
||
394 | 394 | return implode('', $parts); |
395 | 395 | } |
396 | 396 | |
397 | - /** |
|
398 | - * Retrieves the names of all the command's supported types: the part |
|
399 | - * between the command name and the colon. Example: {command type: params}. |
|
400 | - * |
|
401 | - * @return string[] |
|
402 | - */ |
|
397 | + /** |
|
398 | + * Retrieves the names of all the command's supported types: the part |
|
399 | + * between the command name and the colon. Example: {command type: params}. |
|
400 | + * |
|
401 | + * @return string[] |
|
402 | + */ |
|
403 | 403 | public function getSupportedTypes() : array |
404 | 404 | { |
405 | 405 | return array(); |
406 | 406 | } |
407 | 407 | |
408 | - /** |
|
409 | - * Retrieves all variable names used in the command. |
|
410 | - * |
|
411 | - * @return Mailcode_Variables_Collection_Regular |
|
412 | - */ |
|
408 | + /** |
|
409 | + * Retrieves all variable names used in the command. |
|
410 | + * |
|
411 | + * @return Mailcode_Variables_Collection_Regular |
|
412 | + */ |
|
413 | 413 | public function getVariables() : Mailcode_Variables_Collection_Regular |
414 | 414 | { |
415 | 415 | return Mailcode::create()->findVariables($this->paramsString); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | protected $comment = ''; |
81 | 81 | |
82 | - public function __construct(string $type='', string $paramsString='', string $matchedText='') |
|
82 | + public function __construct(string $type = '', string $paramsString = '', string $matchedText = '') |
|
83 | 83 | { |
84 | 84 | $this->type = $type; |
85 | 85 | $this->paramsString = html_entity_decode($paramsString); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | { |
151 | 151 | $this->requireNonDummy(); |
152 | 152 | |
153 | - if($this->hash === '') { |
|
153 | + if ($this->hash === '') { |
|
154 | 154 | $this->hash = md5($this->matchedText); |
155 | 155 | } |
156 | 156 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | protected function requireNonDummy() : void |
161 | 161 | { |
162 | - if(!$this->isDummy()) |
|
162 | + if (!$this->isDummy()) |
|
163 | 163 | { |
164 | 164 | return; |
165 | 165 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | { |
181 | 181 | $this->requireNonDummy(); |
182 | 182 | |
183 | - if(isset($this->validationResult)) |
|
183 | + if (isset($this->validationResult)) |
|
184 | 184 | { |
185 | 185 | return $this->validationResult; |
186 | 186 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | public function getValidationResult() : \AppUtils\OperationResult |
196 | 196 | { |
197 | - if(isset($this->validationResult)) |
|
197 | + if (isset($this->validationResult)) |
|
198 | 198 | { |
199 | 199 | return $this->validationResult; |
200 | 200 | } |
@@ -210,11 +210,11 @@ discard block |
||
210 | 210 | { |
211 | 211 | $validations = array_merge($this->validations, $this->getValidations()); |
212 | 212 | |
213 | - foreach($validations as $validation) |
|
213 | + foreach ($validations as $validation) |
|
214 | 214 | { |
215 | 215 | $method = 'validateSyntax_'.$validation; |
216 | 216 | |
217 | - if(!method_exists($this, $method)) |
|
217 | + if (!method_exists($this, $method)) |
|
218 | 218 | { |
219 | 219 | throw new Mailcode_Exception( |
220 | 220 | 'Missing validation method', |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $this->$method(); |
231 | 231 | |
232 | 232 | // break off at the first validation issue |
233 | - if(!$this->validationResult->isValid()) |
|
233 | + if (!$this->validationResult->isValid()) |
|
234 | 234 | { |
235 | 235 | return; |
236 | 236 | } |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | |
245 | 245 | protected function validateSyntax_params() : void |
246 | 246 | { |
247 | - if(!$this->requiresParameters()) |
|
247 | + if (!$this->requiresParameters()) |
|
248 | 248 | { |
249 | 249 | return; |
250 | 250 | } |
251 | 251 | |
252 | - if(empty($this->paramsString)) |
|
252 | + if (empty($this->paramsString)) |
|
253 | 253 | { |
254 | 254 | $this->validationResult->makeError( |
255 | 255 | t('Parameters have to be specified.'), |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | |
261 | 261 | $this->params = $this->mailcode->getParser()->createStatement($this->paramsString); |
262 | 262 | |
263 | - if(!$this->params->isValid()) |
|
263 | + if (!$this->params->isValid()) |
|
264 | 264 | { |
265 | 265 | $error = $this->params->getValidationResult(); |
266 | 266 | |
@@ -273,14 +273,14 @@ discard block |
||
273 | 273 | |
274 | 274 | protected function validateSyntax_type_supported() : void |
275 | 275 | { |
276 | - if(!$this->supportsType() || empty($this->type)) |
|
276 | + if (!$this->supportsType() || empty($this->type)) |
|
277 | 277 | { |
278 | 278 | return; |
279 | 279 | } |
280 | 280 | |
281 | 281 | $types = $this->getSupportedTypes(); |
282 | 282 | |
283 | - if(!in_array($this->type, $types)) |
|
283 | + if (!in_array($this->type, $types)) |
|
284 | 284 | { |
285 | 285 | $this->validationResult->makeError( |
286 | 286 | t('The command addon %1$s is not supported.', $this->type).' '. |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | |
295 | 295 | protected function validateSyntax_type_unsupported() : void |
296 | 296 | { |
297 | - if($this->supportsType() || empty($this->type)) |
|
297 | + if ($this->supportsType() || empty($this->type)) |
|
298 | 298 | { |
299 | 299 | return; |
300 | 300 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | |
313 | 313 | public function getType() : string |
314 | 314 | { |
315 | - if($this->supportsType()) |
|
315 | + if ($this->supportsType()) |
|
316 | 316 | { |
317 | 317 | return $this->type; |
318 | 318 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | |
333 | 333 | public function getHighlighted() : string |
334 | 334 | { |
335 | - if(!$this->isValid()) |
|
335 | + if (!$this->isValid()) |
|
336 | 336 | { |
337 | 337 | return ''; |
338 | 338 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | |
344 | 344 | public function getParamsString() : string |
345 | 345 | { |
346 | - if($this->requiresParameters()) |
|
346 | + if ($this->requiresParameters()) |
|
347 | 347 | { |
348 | 348 | return $this->paramsString; |
349 | 349 | } |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | |
371 | 371 | public function getNormalized() : string |
372 | 372 | { |
373 | - if(!$this->isValid()) |
|
373 | + if (!$this->isValid()) |
|
374 | 374 | { |
375 | 375 | return ''; |
376 | 376 | } |
@@ -378,12 +378,12 @@ discard block |
||
378 | 378 | $parts = array(); |
379 | 379 | $parts[] = '{'.$this->getName(); |
380 | 380 | |
381 | - if($this->supportsType() && $this->hasType()) |
|
381 | + if ($this->supportsType() && $this->hasType()) |
|
382 | 382 | { |
383 | 383 | $parts[] = ' '.$this->getType(); |
384 | 384 | } |
385 | 385 | |
386 | - if($this->requiresParameters() && isset($this->params)) |
|
386 | + if ($this->requiresParameters() && isset($this->params)) |
|
387 | 387 | { |
388 | 388 | $parts[] = ': '; |
389 | 389 | $parts[] = $this->params->getNormalized(); |
@@ -21,17 +21,17 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class Mailcode_Renderer |
23 | 23 | { |
24 | - /** |
|
25 | - * @var boolean |
|
26 | - */ |
|
24 | + /** |
|
25 | + * @var boolean |
|
26 | + */ |
|
27 | 27 | protected $highlighted = false; |
28 | 28 | |
29 | - /** |
|
30 | - * Sets whether to output highlighted commands instead of the default plain text. |
|
31 | - * |
|
32 | - * @param bool $highlighted |
|
33 | - * @return Mailcode_Renderer |
|
34 | - */ |
|
29 | + /** |
|
30 | + * Sets whether to output highlighted commands instead of the default plain text. |
|
31 | + * |
|
32 | + * @param bool $highlighted |
|
33 | + * @return Mailcode_Renderer |
|
34 | + */ |
|
35 | 35 | public function setOutputHighlighted(bool $highlighted=true) : Mailcode_Renderer |
36 | 36 | { |
37 | 37 | $this->highlighted = $highlighted; |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | return $this; |
40 | 40 | } |
41 | 41 | |
42 | - /** |
|
43 | - * Converts a show variable command to string. |
|
44 | - * |
|
45 | - * @param string $variableName The variable name, with or without $ sign. |
|
46 | - * @return string |
|
47 | - */ |
|
42 | + /** |
|
43 | + * Converts a show variable command to string. |
|
44 | + * |
|
45 | + * @param string $variableName The variable name, with or without $ sign. |
|
46 | + * @return string |
|
47 | + */ |
|
48 | 48 | public function showVar(string $variableName) : string |
49 | 49 | { |
50 | 50 | return $this->command2string(Mailcode_Factory::showVar($variableName)); |
@@ -62,7 +62,9 @@ discard block |
||
62 | 62 | |
63 | 63 | public function if(string $condition, string $type='') : string |
64 | 64 | { |
65 | - return $this->command2string(Mailcode_Factory::if($condition, $type)); |
|
65 | + return $this->command2string(Mailcode_Factory::if($condition, $type) { |
|
66 | + ); |
|
67 | + } |
|
66 | 68 | } |
67 | 69 | |
68 | 70 | public function ifVar(string $variable, string $operand, string $value, bool $quoteValue=false) : string |
@@ -97,7 +99,9 @@ discard block |
||
97 | 99 | |
98 | 100 | public function elseIf(string $condition, string $type='') : string |
99 | 101 | { |
100 | - return $this->command2string(Mailcode_Factory::elseIf($condition, $type)); |
|
102 | + return $this->command2string(Mailcode_Factory::elseIf($condition, $type) { |
|
103 | + ); |
|
104 | + } |
|
101 | 105 | } |
102 | 106 | |
103 | 107 | public function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue=false) : string |
@@ -130,10 +134,12 @@ discard block |
||
130 | 134 | return $this->command2string(Mailcode_Factory::elseIfVarNotEqualsString($variable, $value)); |
131 | 135 | } |
132 | 136 | |
133 | - public function else() : string |
|
137 | + public function else { |
|
138 | + () : string |
|
134 | 139 | { |
135 | 140 | return $this->command2string(Mailcode_Factory::else()); |
136 | 141 | } |
142 | + } |
|
137 | 143 | |
138 | 144 | public function end() : string |
139 | 145 | { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param bool $highlighted |
33 | 33 | * @return Mailcode_Renderer |
34 | 34 | */ |
35 | - public function setOutputHighlighted(bool $highlighted=true) : Mailcode_Renderer |
|
35 | + public function setOutputHighlighted(bool $highlighted = true) : Mailcode_Renderer |
|
36 | 36 | { |
37 | 37 | $this->highlighted = $highlighted; |
38 | 38 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | return $this->command2string(Mailcode_Factory::showSnippet($snippetName)); |
56 | 56 | } |
57 | 57 | |
58 | - public function setVar(string $variableName, string $value, bool $quoteValue=false) : string |
|
58 | + public function setVar(string $variableName, string $value, bool $quoteValue = false) : string |
|
59 | 59 | { |
60 | 60 | return $this->command2string(Mailcode_Factory::setVar($variableName, $value, $quoteValue)); |
61 | 61 | } |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | return $this->command2string(Mailcode_Factory::setVarString($variableName, $value)); |
66 | 66 | } |
67 | 67 | |
68 | - public function if(string $condition, string $type='') : string |
|
68 | + public function if (string $condition, string $type = '') : string |
|
69 | 69 | { |
70 | - return $this->command2string(Mailcode_Factory::if($condition, $type)); |
|
70 | + return $this->command2string(Mailcode_Factory::if ($condition, $type)); |
|
71 | 71 | } |
72 | 72 | |
73 | - public function ifVar(string $variable, string $operand, string $value, bool $quoteValue=false) : string |
|
73 | + public function ifVar(string $variable, string $operand, string $value, bool $quoteValue = false) : string |
|
74 | 74 | { |
75 | 75 | return $this->command2string(Mailcode_Factory::ifVar($variable, $operand, $value, $quoteValue)); |
76 | 76 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | return $this->command2string(Mailcode_Factory::ifVarString($variable, $operand, $value)); |
81 | 81 | } |
82 | 82 | |
83 | - public function ifVarEquals(string $variable, string $value, bool $quoteValue=false) : string |
|
83 | + public function ifVarEquals(string $variable, string $value, bool $quoteValue = false) : string |
|
84 | 84 | { |
85 | 85 | return $this->command2string(Mailcode_Factory::ifVarEquals($variable, $value, $quoteValue)); |
86 | 86 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | return $this->command2string(Mailcode_Factory::ifVarEqualsString($variable, $value)); |
91 | 91 | } |
92 | 92 | |
93 | - public function ifVarNotEquals(string $variable, string $value, bool $quoteValue=false) : string |
|
93 | + public function ifVarNotEquals(string $variable, string $value, bool $quoteValue = false) : string |
|
94 | 94 | { |
95 | 95 | return $this->command2string(Mailcode_Factory::ifVarNotEquals($variable, $value, $quoteValue)); |
96 | 96 | } |
@@ -100,12 +100,12 @@ discard block |
||
100 | 100 | return $this->command2string(Mailcode_Factory::ifVarNotEqualsString($variable, $value)); |
101 | 101 | } |
102 | 102 | |
103 | - public function elseIf(string $condition, string $type='') : string |
|
103 | + public function elseIf (string $condition, string $type = '') : string |
|
104 | 104 | { |
105 | - return $this->command2string(Mailcode_Factory::elseIf($condition, $type)); |
|
105 | + return $this->command2string(Mailcode_Factory::elseIf ($condition, $type)); |
|
106 | 106 | } |
107 | 107 | |
108 | - public function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue=false) : string |
|
108 | + public function elseIfVar(string $variable, string $operand, string $value, bool $quoteValue = false) : string |
|
109 | 109 | { |
110 | 110 | return $this->command2string(Mailcode_Factory::elseIfVar($variable, $operand, $value, $quoteValue)); |
111 | 111 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | return $this->command2string(Mailcode_Factory::elseIfVarString($variable, $operand, $value)); |
116 | 116 | } |
117 | 117 | |
118 | - public function elseIfVarEquals(string $variable, string $value, bool $quoteValue=false) : string |
|
118 | + public function elseIfVarEquals(string $variable, string $value, bool $quoteValue = false) : string |
|
119 | 119 | { |
120 | 120 | return $this->command2string(Mailcode_Factory::elseIfVarEquals($variable, $value, $quoteValue)); |
121 | 121 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | return $this->command2string(Mailcode_Factory::elseIfVarEqualsString($variable, $value)); |
126 | 126 | } |
127 | 127 | |
128 | - public function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue=false) : string |
|
128 | + public function elseIfVarNotEquals(string $variable, string $value, bool $quoteValue = false) : string |
|
129 | 129 | { |
130 | 130 | return $this->command2string(Mailcode_Factory::elseIfVarNotEquals($variable, $value, $quoteValue)); |
131 | 131 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | |
153 | 153 | protected function command2string(Mailcode_Commands_Command $command) : string |
154 | 154 | { |
155 | - if($this->highlighted) |
|
155 | + if ($this->highlighted) |
|
156 | 156 | { |
157 | 157 | return $command->getHighlighted(); |
158 | 158 | } |
@@ -22,17 +22,17 @@ |
||
22 | 22 | { |
23 | 23 | const REGEX_VARIABLE_NAME = '/\$\s*([A-Z0-9_]+)\s*\.\s*([A-Z0-9_]+)|\$\s*([A-Z0-9_]+)/six'; |
24 | 24 | |
25 | - /** |
|
26 | - * @var Mailcode_Variables_Collection_Regular |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var Mailcode_Variables_Collection_Regular |
|
27 | + */ |
|
28 | 28 | protected $collection; |
29 | 29 | |
30 | - /** |
|
31 | - * Parses the specified string to find all variable names contained within, if any. |
|
32 | - * |
|
33 | - * @param string $subject |
|
34 | - * @return Mailcode_Variables_Collection_Regular |
|
35 | - */ |
|
30 | + /** |
|
31 | + * Parses the specified string to find all variable names contained within, if any. |
|
32 | + * |
|
33 | + * @param string $subject |
|
34 | + * @return Mailcode_Variables_Collection_Regular |
|
35 | + */ |
|
36 | 36 | public function parseString(string $subject) : Mailcode_Variables_Collection_Regular |
37 | 37 | { |
38 | 38 | $this->collection = new Mailcode_Variables_Collection_Regular(); |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | $matches = array(); |
41 | 41 | preg_match_all(self::REGEX_VARIABLE_NAME, $subject, $matches, PREG_PATTERN_ORDER); |
42 | 42 | |
43 | - if(!isset($matches[0]) || empty($matches[0])) |
|
43 | + if (!isset($matches[0]) || empty($matches[0])) |
|
44 | 44 | { |
45 | 45 | return $this->collection; |
46 | 46 | } |
47 | 47 | |
48 | - foreach($matches[0] as $idx => $matchedText) |
|
48 | + foreach ($matches[0] as $idx => $matchedText) |
|
49 | 49 | { |
50 | - if(!empty($matches[3][$idx])) |
|
50 | + if (!empty($matches[3][$idx])) |
|
51 | 51 | { |
52 | 52 | $this->addSingle($matches[3][$idx], $matchedText); |
53 | 53 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | protected function addSingle(string $name, string $matchedText) : void |
64 | 64 | { |
65 | 65 | // ignore US style numbers like $451 |
66 | - if(is_numeric($name)) |
|
66 | + if (is_numeric($name)) |
|
67 | 67 | { |
68 | 68 | return; |
69 | 69 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | protected function addPathed(string $path, string $name, string $matchedText) : void |
75 | 75 | { |
76 | 76 | // ignore US style numbers like $45.12 |
77 | - if(is_numeric($path.'.'.$name)) |
|
77 | + if (is_numeric($path.'.'.$name)) |
|
78 | 78 | { |
79 | 79 | return; |
80 | 80 | } |
@@ -50,8 +50,7 @@ |
||
50 | 50 | if(!empty($matches[3][$idx])) |
51 | 51 | { |
52 | 52 | $this->addSingle($matches[3][$idx], $matchedText); |
53 | - } |
|
54 | - else |
|
53 | + } else |
|
55 | 54 | { |
56 | 55 | $this->addPathed($matches[1][$idx], $matches[2][$idx], $matchedText); |
57 | 56 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | $params = $command->getParams(); |
26 | 26 | |
27 | - if($params) |
|
27 | + if ($params) |
|
28 | 28 | { |
29 | 29 | return sprintf( |
30 | 30 | '#elseif(%s)', |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | $params = $command->getParams(); |
46 | 46 | |
47 | - if($params) |
|
47 | + if ($params) |
|
48 | 48 | { |
49 | 49 | return sprintf( |
50 | 50 | '#if(%s)', |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | { |
65 | 65 | $params = $command->getParams(); |
66 | 66 | |
67 | - if($params) |
|
67 | + if ($params) |
|
68 | 68 | { |
69 | 69 | return sprintf( |
70 | 70 | '#for(%s)', |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | { |
80 | 80 | $params = $command->getParams(); |
81 | 81 | |
82 | - if($params) |
|
82 | + if ($params) |
|
83 | 83 | { |
84 | 84 | return sprintf( |
85 | 85 | '#set(%s)', |