@@ -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 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function getParser() : Mailcode_Parser |
| 75 | 75 | { |
| 76 | - if(!isset($this->parser)) |
|
| 76 | + if (!isset($this->parser)) |
|
| 77 | 77 | { |
| 78 | 78 | $this->parser = new Mailcode_Parser($this); |
| 79 | 79 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function getCommands() : Mailcode_Commands |
| 91 | 91 | { |
| 92 | - if(!isset($this->commands)) |
|
| 92 | + if (!isset($this->commands)) |
|
| 93 | 93 | { |
| 94 | 94 | $this->commands = new Mailcode_Commands(); |
| 95 | 95 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | public function createVariables() : Mailcode_Variables |
| 117 | 117 | { |
| 118 | - if(!isset($this->variables)) |
|
| 118 | + if (!isset($this->variables)) |
|
| 119 | 119 | { |
| 120 | 120 | $this->variables = new Mailcode_Variables(); |
| 121 | 121 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | public function createTranslator() : Mailcode_Translator |
| 133 | 133 | { |
| 134 | - if(!isset($this->translator)) |
|
| 134 | + if (!isset($this->translator)) |
|
| 135 | 135 | { |
| 136 | 136 | $this->translator = new Mailcode_Translator(); |
| 137 | 137 | } |
@@ -87,7 +87,7 @@ |
||
| 87 | 87 | */ |
| 88 | 88 | public function getTypeLabel() : string |
| 89 | 89 | { |
| 90 | - switch($this->type) |
|
| 90 | + switch ($this->type) |
|
| 91 | 91 | { |
| 92 | 92 | case Mailcode_Date_FormatInfo::CHARTYPE_DATE: |
| 93 | 93 | return t('Date'); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | public static function getInstance() : Mailcode_Date_FormatInfo |
| 60 | 60 | { |
| 61 | - if(!isset(self::$instance)) |
|
| 61 | + if (!isset(self::$instance)) |
|
| 62 | 62 | { |
| 63 | 63 | self::$instance = new Mailcode_Date_FormatInfo(); |
| 64 | 64 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | array(self::CHARTYPE_PUNCTUATION, ' ', t('Space')) |
| 91 | 91 | ); |
| 92 | 92 | |
| 93 | - foreach($chars as $def) |
|
| 93 | + foreach ($chars as $def) |
|
| 94 | 94 | { |
| 95 | 95 | $char = new Mailcode_Date_FormatInfo_Character( |
| 96 | 96 | $def[0], |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | $trimmed = trim($formatString); |
| 131 | 131 | |
| 132 | - if(empty($trimmed)) |
|
| 132 | + if (empty($trimmed)) |
|
| 133 | 133 | { |
| 134 | 134 | $result->makeError( |
| 135 | 135 | t('Empty date format.'), |
@@ -142,15 +142,15 @@ discard block |
||
| 142 | 142 | $chars = ConvertHelper::string2array($formatString); |
| 143 | 143 | $total = count($chars); |
| 144 | 144 | |
| 145 | - for($i=0; $i < $total; $i++) |
|
| 145 | + for ($i = 0; $i < $total; $i++) |
|
| 146 | 146 | { |
| 147 | 147 | $char = $chars[$i]; |
| 148 | 148 | |
| 149 | - if(!in_array($char, $this->allowedChars)) |
|
| 149 | + if (!in_array($char, $this->allowedChars)) |
|
| 150 | 150 | { |
| 151 | 151 | $result->makeError( |
| 152 | 152 | t('Invalid character in date format:').' '. |
| 153 | - t('%1$s at position %2$s.', '<code>'.$char.'</code>', $i+1), |
|
| 153 | + t('%1$s at position %2$s.', '<code>'.$char.'</code>', $i + 1), |
|
| 154 | 154 | self::VALIDATION_INVALID_FORMAT_CHARACTER |
| 155 | 155 | ); |
| 156 | 156 | |
@@ -182,11 +182,11 @@ discard block |
||
| 182 | 182 | { |
| 183 | 183 | $grouped = array(); |
| 184 | 184 | |
| 185 | - foreach($this->formatChars as $char) |
|
| 185 | + foreach ($this->formatChars as $char) |
|
| 186 | 186 | { |
| 187 | 187 | $type = $char->getTypeLabel(); |
| 188 | 188 | |
| 189 | - if(!isset($grouped[$type])) |
|
| 189 | + if (!isset($grouped[$type])) |
|
| 190 | 190 | { |
| 191 | 191 | $grouped[$type] = array(); |
| 192 | 192 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | $groups = array_keys($grouped); |
| 198 | 198 | |
| 199 | - foreach($groups as $group) |
|
| 199 | + foreach ($groups as $group) |
|
| 200 | 200 | { |
| 201 | 201 | usort($grouped[$group], function(Mailcode_Date_FormatInfo_Character $a, Mailcode_Date_FormatInfo_Character $b) |
| 202 | 202 | { |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |