@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | public function getInfo() : Mailcode_Parser_Statement_Info |
77 | 77 | { |
78 | - if($this->info instanceof Mailcode_Parser_Statement_Info) |
|
78 | + if ($this->info instanceof Mailcode_Parser_Statement_Info) |
|
79 | 79 | { |
80 | 80 | return $this->info; |
81 | 81 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | protected function validate() : void |
89 | 89 | { |
90 | - if(!$this->tokenizer->hasTokens()) |
|
90 | + if (!$this->tokenizer->hasTokens()) |
|
91 | 91 | { |
92 | 92 | $this->result->makeError( |
93 | 93 | t('Empty statement'), |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | $unknown = $this->tokenizer->getFirstUnknown(); |
101 | 101 | |
102 | - if($unknown) |
|
102 | + if ($unknown) |
|
103 | 103 | { |
104 | 104 | $this->result->makeError( |
105 | 105 | t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')', |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | static $ids = array(); |
48 | 48 | |
49 | - if(empty($ids)) { |
|
49 | + if (empty($ids)) { |
|
50 | 50 | $ids = \AppUtils\FileHelper::createFileFinder(__DIR__.'/Commands/Command') |
51 | 51 | ->getPHPClassNames(); |
52 | 52 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function getAll() |
65 | 65 | { |
66 | - if(!empty($this->commands)) { |
|
66 | + if (!empty($this->commands)) { |
|
67 | 67 | return $this->commands; |
68 | 68 | } |
69 | 69 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | $result = array(); |
73 | 73 | |
74 | - foreach($ids as $id) |
|
74 | + foreach ($ids as $id) |
|
75 | 75 | { |
76 | 76 | $result[] = $this->getDummyCommand($id); |
77 | 77 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | { |
97 | 97 | static $instances = array(); |
98 | 98 | |
99 | - if(!isset($instances[$id])) |
|
99 | + if (!isset($instances[$id])) |
|
100 | 100 | { |
101 | 101 | $instances[$id] = $this->createCommand($id, '__dummy', '', ''); |
102 | 102 | } |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | { |
118 | 118 | $items = $this->getAll(); |
119 | 119 | |
120 | - foreach($items as $item) |
|
120 | + foreach ($items as $item) |
|
121 | 121 | { |
122 | - if($item->getName() === $name) { |
|
122 | + if ($item->getName() === $name) { |
|
123 | 123 | return $item->getID(); |
124 | 124 | } |
125 | 125 | } |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | { |
152 | 152 | $items = $this->getAll(); |
153 | 153 | |
154 | - foreach($items as $item) |
|
154 | + foreach ($items as $item) |
|
155 | 155 | { |
156 | - if($item->getName() === $name) { |
|
156 | + if ($item->getName() === $name) { |
|
157 | 157 | return true; |
158 | 158 | } |
159 | 159 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | { |
166 | 166 | $class = $this->resolveClassName($id, $type); |
167 | 167 | |
168 | - if(!class_exists($class)) |
|
168 | + if (!class_exists($class)) |
|
169 | 169 | { |
170 | 170 | throw new Mailcode_Exception( |
171 | 171 | 'No such command', |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | |
188 | 188 | $dummy = $this->getDummyCommand($id); |
189 | 189 | |
190 | - if($dummy->supportsType()) |
|
190 | + if ($dummy->supportsType()) |
|
191 | 191 | { |
192 | - if(empty($type)) |
|
192 | + if (empty($type)) |
|
193 | 193 | { |
194 | 194 | $type = $dummy->getDefaultType(); |
195 | 195 | } |
@@ -209,13 +209,13 @@ discard block |
||
209 | 209 | */ |
210 | 210 | private function getDummyCommand(string $id) : Mailcode_Commands_Command |
211 | 211 | { |
212 | - if(!isset(self::$dummyCommands[$id])) |
|
212 | + if (!isset(self::$dummyCommands[$id])) |
|
213 | 213 | { |
214 | 214 | $class = 'Mailcode\Mailcode_Commands_Command_'.$id; |
215 | 215 | self::$dummyCommands[$id] = new $class('__dummy'); |
216 | 216 | } |
217 | 217 | |
218 | - if(self::$dummyCommands[$id] instanceof Mailcode_Commands_Command) |
|
218 | + if (self::$dummyCommands[$id] instanceof Mailcode_Commands_Command) |
|
219 | 219 | { |
220 | 220 | return self::$dummyCommands[$id]; |
221 | 221 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | |
42 | 42 | $this->instantiator->checkCommand($cmd); |
43 | 43 | |
44 | - if($cmd instanceof Mailcode_Commands_Command_End) |
|
44 | + if ($cmd instanceof Mailcode_Commands_Command_End) |
|
45 | 45 | { |
46 | 46 | return $cmd; |
47 | 47 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | |
32 | 32 | $this->instantiator->checkCommand($cmd); |
33 | 33 | |
34 | - if($cmd instanceof Mailcode_Commands_Command_Else) |
|
34 | + if ($cmd instanceof Mailcode_Commands_Command_Else) |
|
35 | 35 | { |
36 | 36 | return $cmd; |
37 | 37 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | $this->instantiator->checkCommand($cmd); |
35 | 35 | |
36 | - if($cmd instanceof Mailcode_Commands_Command_ShowVariable) |
|
36 | + if ($cmd instanceof Mailcode_Commands_Command_ShowVariable) |
|
37 | 37 | { |
38 | 38 | return $cmd; |
39 | 39 | } |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | throw $this->instantiator->exceptionUnexpectedType('ShowVariable', $cmd); |
42 | 42 | } |
43 | 43 | |
44 | - public function showDate(string $variableName, string $formatString="") : Mailcode_Commands_Command_ShowDate |
|
44 | + public function showDate(string $variableName, string $formatString = "") : Mailcode_Commands_Command_ShowDate |
|
45 | 45 | { |
46 | 46 | $variableName = $this->instantiator->filterVariableName($variableName); |
47 | 47 | |
48 | 48 | $format = ''; |
49 | - if(!empty($formatString)) |
|
49 | + if (!empty($formatString)) |
|
50 | 50 | { |
51 | 51 | $format = sprintf( |
52 | 52 | ' "%s"', |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | $this->instantiator->checkCommand($cmd); |
69 | 69 | |
70 | - if($cmd instanceof Mailcode_Commands_Command_ShowDate) |
|
70 | + if ($cmd instanceof Mailcode_Commands_Command_ShowDate) |
|
71 | 71 | { |
72 | 72 | return $cmd; |
73 | 73 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | $this->instantiator->checkCommand($cmd); |
90 | 90 | |
91 | - if($cmd instanceof Mailcode_Commands_Command_ShowSnippet) |
|
91 | + if ($cmd instanceof Mailcode_Commands_Command_ShowSnippet) |
|
92 | 92 | { |
93 | 93 | return $cmd; |
94 | 94 | } |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class Mailcode_Factory_CommandSets_Set_Set extends Mailcode_Factory_CommandSets_Set |
22 | 22 | { |
23 | - public function setVar(string $variableName, string $value, bool $quoteValue=true) : Mailcode_Commands_Command_SetVariable |
|
23 | + public function setVar(string $variableName, string $value, bool $quoteValue = true) : Mailcode_Commands_Command_SetVariable |
|
24 | 24 | { |
25 | 25 | $variableName = $this->instantiator->filterVariableName($variableName); |
26 | 26 | |
27 | - if($quoteValue) |
|
27 | + if ($quoteValue) |
|
28 | 28 | { |
29 | 29 | $value = $this->instantiator->quoteString($value); |
30 | 30 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | $this->instantiator->checkCommand($cmd); |
42 | 42 | |
43 | - if($cmd instanceof Mailcode_Commands_Command_SetVariable) |
|
43 | + if ($cmd instanceof Mailcode_Commands_Command_SetVariable) |
|
44 | 44 | { |
45 | 45 | return $cmd; |
46 | 46 | } |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | */ |
46 | 46 | private $elseIf; |
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 | } |
@@ -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 | } |
@@ -67,14 +67,14 @@ discard block |
||
67 | 67 | |
68 | 68 | private function addParams(Mailcode_Commands_Command $command) : void |
69 | 69 | { |
70 | - if(!$command->requiresParameters()) |
|
70 | + if (!$command->requiresParameters()) |
|
71 | 71 | { |
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
75 | 75 | $params = $command->getParams(); |
76 | 76 | |
77 | - if($params === null) |
|
77 | + if ($params === null) |
|
78 | 78 | { |
79 | 79 | return; |
80 | 80 | } |
@@ -85,14 +85,14 @@ discard block |
||
85 | 85 | |
86 | 86 | private function addLogicKeywords() : void |
87 | 87 | { |
88 | - if(!$this->command->supportsLogicKeywords()) |
|
88 | + if (!$this->command->supportsLogicKeywords()) |
|
89 | 89 | { |
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
93 | 93 | $keywords = $this->command->getLogicKeywords()->getKeywords(); |
94 | 94 | |
95 | - foreach($keywords as $keyword) |
|
95 | + foreach ($keywords as $keyword) |
|
96 | 96 | { |
97 | 97 | $this->parts[] = ' '; |
98 | 98 | $this->parts[] = $keyword->getKeywordString(); // e.g. "if variable" |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | |
72 | 72 | private function parse() : void |
73 | 73 | { |
74 | - foreach($this->names as $name) |
|
74 | + foreach ($this->names as $name) |
|
75 | 75 | { |
76 | - if(!stristr($this->paramsString, $name)) |
|
76 | + if (!stristr($this->paramsString, $name)) |
|
77 | 77 | { |
78 | 78 | continue; |
79 | 79 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $names = $this->getDetectedNames(); |
91 | 91 | $amount = count($names); |
92 | 92 | |
93 | - if($amount > 1) |
|
93 | + if ($amount > 1) |
|
94 | 94 | { |
95 | 95 | $this->makeError( |
96 | 96 | t( |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | private function splitParams() : void |
111 | 111 | { |
112 | - if(empty($this->keywords)) |
|
112 | + if (empty($this->keywords)) |
|
113 | 113 | { |
114 | 114 | $this->mainParams = $this->paramsString; |
115 | 115 | |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | |
119 | 119 | $params = $this->detectParameters(); |
120 | 120 | |
121 | - foreach($this->keywords as $keyword) |
|
121 | + foreach ($this->keywords as $keyword) |
|
122 | 122 | { |
123 | 123 | $kParams = array_shift($params); |
124 | 124 | |
125 | 125 | $keyword->setParamsString($kParams); |
126 | 126 | |
127 | - if(!$keyword->isValid()) |
|
127 | + if (!$keyword->isValid()) |
|
128 | 128 | { |
129 | 129 | $this->makeError( |
130 | 130 | t('Error #%1$s:', $keyword->getCode()).' '.$keyword->getErrorMessage(), |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $params = $this->paramsString; |
145 | 145 | $stack = array(); |
146 | 146 | |
147 | - foreach($this->keywords as $keyword) |
|
147 | + foreach ($this->keywords as $keyword) |
|
148 | 148 | { |
149 | 149 | $params = $this->detectParamsKeyword($params, $keyword, $stack); |
150 | 150 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $search = $keyword->getMatchedString(); |
169 | 169 | $pos = strpos($params, $search, 0); |
170 | 170 | |
171 | - if($pos === false) |
|
171 | + if ($pos === false) |
|
172 | 172 | { |
173 | 173 | throw new Mailcode_Exception( |
174 | 174 | 'Keyword matched string not found', |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $length = strlen($search); |
181 | 181 | |
182 | 182 | $store = substr($params, 0, $pos); |
183 | - $params = trim(substr($params, $pos+$length)); |
|
183 | + $params = trim(substr($params, $pos + $length)); |
|
184 | 184 | |
185 | 185 | $stack[] = $store; |
186 | 186 | |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | { |
208 | 208 | $names = array(); |
209 | 209 | |
210 | - foreach($this->keywords as $keyword) |
|
210 | + foreach ($this->keywords as $keyword) |
|
211 | 211 | { |
212 | 212 | $name = $keyword->getName(); |
213 | 213 | |
214 | - if(!in_array($name, $names)) |
|
214 | + if (!in_array($name, $names)) |
|
215 | 215 | { |
216 | 216 | $names[] = $name; |
217 | 217 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $matches = array(); |
245 | 245 | preg_match_all($regex, $this->paramsString, $matches, PREG_PATTERN_ORDER); |
246 | 246 | |
247 | - if(!isset($matches[0][0]) || empty($matches[0][0])) |
|
247 | + if (!isset($matches[0][0]) || empty($matches[0][0])) |
|
248 | 248 | { |
249 | 249 | return array(); |
250 | 250 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $amount = count($matches[0]); |
253 | 253 | $result = array(); |
254 | 254 | |
255 | - for($i=0; $i < $amount; $i++) |
|
255 | + for ($i = 0; $i < $amount; $i++) |
|
256 | 256 | { |
257 | 257 | $result[] = $this->createKeyword( |
258 | 258 | $name, |
@@ -269,22 +269,22 @@ discard block |
||
269 | 269 | return !empty($this->keywords); |
270 | 270 | } |
271 | 271 | |
272 | - public function appendAND(string $paramsString, string $type='') : Mailcode_Commands_LogicKeywords_Keyword |
|
272 | + public function appendAND(string $paramsString, string $type = '') : Mailcode_Commands_LogicKeywords_Keyword |
|
273 | 273 | { |
274 | 274 | return $this->appendKeyword('and', $paramsString, $type); |
275 | 275 | } |
276 | 276 | |
277 | - public function appendOR(string $paramsString, string $type='') : Mailcode_Commands_LogicKeywords_Keyword |
|
277 | + public function appendOR(string $paramsString, string $type = '') : Mailcode_Commands_LogicKeywords_Keyword |
|
278 | 278 | { |
279 | 279 | return $this->appendKeyword('or', $paramsString, $type); |
280 | 280 | } |
281 | 281 | |
282 | - public function appendKeyword(string $name, string $paramsString, string $type='') : Mailcode_Commands_LogicKeywords_Keyword |
|
282 | + public function appendKeyword(string $name, string $paramsString, string $type = '') : Mailcode_Commands_LogicKeywords_Keyword |
|
283 | 283 | { |
284 | 284 | $keyword = $this->createKeyword($name, $type); |
285 | 285 | $keyword->setParamsString($paramsString); |
286 | 286 | |
287 | - if(!$keyword->isValid()) |
|
287 | + if (!$keyword->isValid()) |
|
288 | 288 | { |
289 | 289 | throw new Mailcode_Exception( |
290 | 290 | 'Cannot append invalid logic keyword', |
@@ -305,13 +305,13 @@ discard block |
||
305 | 305 | return $keyword; |
306 | 306 | } |
307 | 307 | |
308 | - private function createKeyword(string $name, string $type='', string $matchedString='') : Mailcode_Commands_LogicKeywords_Keyword |
|
308 | + private function createKeyword(string $name, string $type = '', string $matchedString = '') : Mailcode_Commands_LogicKeywords_Keyword |
|
309 | 309 | { |
310 | - if(empty($matchedString)) |
|
310 | + if (empty($matchedString)) |
|
311 | 311 | { |
312 | 312 | $matchedString = $name; |
313 | 313 | |
314 | - if(!empty($type)) |
|
314 | + if (!empty($type)) |
|
315 | 315 | { |
316 | 316 | $matchedString .= ' '.$type; |
317 | 317 | } |