@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | { |
| 63 | 63 | $fullName = $this->fixName($fullName); |
| 64 | 64 | |
| 65 | - foreach($this->variables as $variable) |
|
| 65 | + foreach ($this->variables as $variable) |
|
| 66 | 66 | { |
| 67 | - if($variable->getFullName() === $fullName) |
|
| 67 | + if ($variable->getFullName() === $fullName) |
|
| 68 | 68 | { |
| 69 | 69 | return true; |
| 70 | 70 | } |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | $collection = new Mailcode_Variables_Collection_Regular(); |
| 89 | 89 | |
| 90 | - foreach($this->variables as $variable) |
|
| 90 | + foreach ($this->variables as $variable) |
|
| 91 | 91 | { |
| 92 | - if($variable->getFullName() === $fullName) |
|
| 92 | + if ($variable->getFullName() === $fullName) |
|
| 93 | 93 | { |
| 94 | 94 | $collection->add($variable); |
| 95 | 95 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | protected function fixName(string $fullName) : string |
| 108 | 108 | { |
| 109 | - if(substr($fullName, 0, 1) === '$') |
|
| 109 | + if (substr($fullName, 0, 1) === '$') |
|
| 110 | 110 | { |
| 111 | 111 | return $fullName; |
| 112 | 112 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | { |
| 125 | 125 | $entries = array(); |
| 126 | 126 | |
| 127 | - foreach($this->variables as $variable) |
|
| 127 | + foreach ($this->variables as $variable) |
|
| 128 | 128 | { |
| 129 | 129 | $entries[$variable->getHash()] = $variable; |
| 130 | 130 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | { |
| 142 | 142 | $entries = array(); |
| 143 | 143 | |
| 144 | - foreach($this->variables as $variable) |
|
| 144 | + foreach ($this->variables as $variable) |
|
| 145 | 145 | { |
| 146 | 146 | $entries[$variable->getFullName()] = $variable; |
| 147 | 147 | } |
@@ -166,11 +166,11 @@ discard block |
||
| 166 | 166 | { |
| 167 | 167 | $result = array(); |
| 168 | 168 | |
| 169 | - foreach($this->variables as $variable) |
|
| 169 | + foreach ($this->variables as $variable) |
|
| 170 | 170 | { |
| 171 | 171 | $name = $variable->getFullName(); |
| 172 | 172 | |
| 173 | - if(!in_array($name, $result)) |
|
| 173 | + if (!in_array($name, $result)) |
|
| 174 | 174 | { |
| 175 | 175 | $result[] = $name; |
| 176 | 176 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | { |
| 210 | 210 | $variables = $collection->getGroupedByHash(); |
| 211 | 211 | |
| 212 | - foreach($variables as $variable) |
|
| 212 | + foreach ($variables as $variable) |
|
| 213 | 213 | { |
| 214 | 214 | $this->add($variable); |
| 215 | 215 | } |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | { |
| 222 | 222 | $variables = $this->getAll(); |
| 223 | 223 | |
| 224 | - if(!empty($variables)) |
|
| 224 | + if (!empty($variables)) |
|
| 225 | 225 | { |
| 226 | 226 | return array_shift($variables); |
| 227 | 227 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | public function getFullName() : string |
| 78 | 78 | { |
| 79 | - if(empty($this->path)) |
|
| 79 | + if (empty($this->path)) |
|
| 80 | 80 | { |
| 81 | 81 | return '$'.$this->name; |
| 82 | 82 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | public function getHash() : string |
| 103 | 103 | { |
| 104 | - if(empty($this->hash)) |
|
| 104 | + if (empty($this->hash)) |
|
| 105 | 105 | { |
| 106 | 106 | $this->hash = md5($this->matchedText); |
| 107 | 107 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | public function getValidationResult() : OperationResult |
| 118 | 118 | { |
| 119 | - if(isset($this->validationResult)) |
|
| 119 | + if (isset($this->validationResult)) |
|
| 120 | 120 | { |
| 121 | 121 | return $this->validationResult; |
| 122 | 122 | } |
@@ -130,11 +130,11 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | protected function validate() : void |
| 132 | 132 | { |
| 133 | - foreach($this->validations as $validation) |
|
| 133 | + foreach ($this->validations as $validation) |
|
| 134 | 134 | { |
| 135 | 135 | $method = 'validate_'.$validation; |
| 136 | 136 | |
| 137 | - if(!method_exists($this, $method)) |
|
| 137 | + if (!method_exists($this, $method)) |
|
| 138 | 138 | { |
| 139 | 139 | throw new Mailcode_Exception( |
| 140 | 140 | 'Unknown validation method', |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | $this->$method(); |
| 151 | 151 | |
| 152 | - if(!$this->validationResult->isValid()) |
|
| 152 | + if (!$this->validationResult->isValid()) |
|
| 153 | 153 | { |
| 154 | 154 | return; |
| 155 | 155 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | protected function validateNumber(string $value, int $errorCode) : void |
| 180 | 180 | { |
| 181 | - if(!is_numeric(substr($value, 0, 1))) |
|
| 181 | + if (!is_numeric(substr($value, 0, 1))) |
|
| 182 | 182 | { |
| 183 | 183 | return; |
| 184 | 184 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | protected function validateUnderscore(string $value, int $errorCode) : void |
| 197 | 197 | { |
| 198 | 198 | // allow empty paths |
| 199 | - if(empty($value)) |
|
| 199 | + if (empty($value)) |
|
| 200 | 200 | { |
| 201 | 201 | return; |
| 202 | 202 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | $length = strlen($value); |
| 205 | 205 | |
| 206 | 206 | // trimming underscores does not change the length: no underscores at start or end of string. |
| 207 | - if(strlen(trim($value, '_')) == $length) |
|
| 207 | + if (strlen(trim($value, '_')) == $length) |
|
| 208 | 208 | { |
| 209 | 209 | return; |
| 210 | 210 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | $errors = $this->errors; |
| 99 | 99 | |
| 100 | - if(!$result->isValid()) |
|
| 100 | + if (!$result->isValid()) |
|
| 101 | 101 | { |
| 102 | 102 | $errors[] = new Mailcode_Collection_Error_Message( |
| 103 | 103 | '', |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | { |
| 140 | 140 | $hashes = array(); |
| 141 | 141 | |
| 142 | - foreach($this->commands as $command) |
|
| 142 | + foreach ($this->commands as $command) |
|
| 143 | 143 | { |
| 144 | 144 | $hash = $command->getHash(); |
| 145 | 145 | |
| 146 | - if(!isset($hashes[$hash])) |
|
| 146 | + if (!isset($hashes[$hash])) |
|
| 147 | 147 | { |
| 148 | 148 | $hashes[$hash] = $command; |
| 149 | 149 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | public function addCommands(array $commands) : Mailcode_Collection |
| 162 | 162 | { |
| 163 | - foreach($commands as $command) |
|
| 163 | + foreach ($commands as $command) |
|
| 164 | 164 | { |
| 165 | 165 | $this->addCommand($command); |
| 166 | 166 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | { |
| 180 | 180 | $collection = new Mailcode_Variables_Collection_Regular(); |
| 181 | 181 | |
| 182 | - foreach($this->commands as $command) |
|
| 182 | + foreach ($this->commands as $command) |
|
| 183 | 183 | { |
| 184 | 184 | $collection->mergeWith($command->getVariables()); |
| 185 | 185 | } |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | public function getValidationResult() : OperationResult |
| 191 | 191 | { |
| 192 | - if(isset($this->validationResult)) |
|
| 192 | + if (isset($this->validationResult)) |
|
| 193 | 193 | { |
| 194 | 194 | return $this->validationResult; |
| 195 | 195 | } |
@@ -205,9 +205,9 @@ discard block |
||
| 205 | 205 | { |
| 206 | 206 | $errors = $this->getErrors(); |
| 207 | 207 | |
| 208 | - foreach($errors as $error) |
|
| 208 | + foreach ($errors as $error) |
|
| 209 | 209 | { |
| 210 | - if($error->getCode() === $code) |
|
| 210 | + if ($error->getCode() === $code) |
|
| 211 | 211 | { |
| 212 | 212 | return true; |
| 213 | 213 | } |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | { |
| 226 | 226 | $result = array(); |
| 227 | 227 | |
| 228 | - foreach($this->commands as $command) |
|
| 228 | + foreach ($this->commands as $command) |
|
| 229 | 229 | { |
| 230 | - if($command instanceof Mailcode_Commands_Command_ShowVariable) |
|
| 230 | + if ($command instanceof Mailcode_Commands_Command_ShowVariable) |
|
| 231 | 231 | { |
| 232 | 232 | $result[] = $command; |
| 233 | 233 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | { |
| 241 | 241 | $commands = $this->getCommands(); |
| 242 | 242 | |
| 243 | - if(!empty($commands)) |
|
| 243 | + if (!empty($commands)) |
|
| 244 | 244 | { |
| 245 | 245 | return array_shift($commands); |
| 246 | 246 | } |
@@ -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 | } |
@@ -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)', |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $method = '_translate'.$id; |
| 49 | 49 | |
| 50 | - if(!method_exists($this, $method)) |
|
| 50 | + if (!method_exists($this, $method)) |
|
| 51 | 51 | { |
| 52 | 52 | throw new Mailcode_Translator_Exception( |
| 53 | 53 | 'Unknown command type in translator', |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | $subject = $safeguard->makeSafe(); |
| 76 | 76 | |
| 77 | - if(!$safeguard->hasPlaceholders()) |
|
| 77 | + if (!$safeguard->hasPlaceholders()) |
|
| 78 | 78 | { |
| 79 | 79 | return $subject; |
| 80 | 80 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | $replaces = array(); |
| 85 | 85 | |
| 86 | - foreach($placeholders as $placeholder) |
|
| 86 | + foreach ($placeholders as $placeholder) |
|
| 87 | 87 | { |
| 88 | 88 | $replaces[$placeholder->getReplacementText()] = $this->translateCommand($placeholder->getCommand()); |
| 89 | 89 | } |
@@ -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 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | $total = count($matches[0]); |
| 75 | 75 | |
| 76 | - for($i=0; $i < $total; $i++) |
|
| 76 | + for ($i = 0; $i < $total; $i++) |
|
| 77 | 77 | { |
| 78 | 78 | $match = $this->parseMatch($matches, $i); |
| 79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | protected function prepareString(string $subject) : string |
| 87 | 87 | { |
| 88 | - if(!ConvertHelper::isStringHTML($subject)) |
|
| 88 | + if (!ConvertHelper::isStringHTML($subject)) |
|
| 89 | 89 | { |
| 90 | 90 | return $subject; |
| 91 | 91 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | $name = $match->getName(); |
| 108 | 108 | |
| 109 | - if(!$this->commands->nameExists($name)) |
|
| 109 | + if (!$this->commands->nameExists($name)) |
|
| 110 | 110 | { |
| 111 | 111 | $collection->addErrorMessage( |
| 112 | 112 | $match->getMatchedString(), |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $match->getMatchedString() |
| 124 | 124 | ); |
| 125 | 125 | |
| 126 | - if($cmd->isValid()) |
|
| 126 | + if ($cmd->isValid()) |
|
| 127 | 127 | { |
| 128 | 128 | $collection->addCommand($cmd); |
| 129 | 129 | return; |
@@ -153,16 +153,16 @@ discard block |
||
| 153 | 153 | // 5 = parameter type command, type |
| 154 | 154 | // 6 = parameter type command, params |
| 155 | 155 | |
| 156 | - if(!empty($matches[1][$index])) |
|
| 156 | + if (!empty($matches[1][$index])) |
|
| 157 | 157 | { |
| 158 | 158 | $name = $matches[1][$index]; |
| 159 | 159 | } |
| 160 | - else if(!empty($matches[2][$index])) |
|
| 160 | + else if (!empty($matches[2][$index])) |
|
| 161 | 161 | { |
| 162 | 162 | $name = $matches[2][$index]; |
| 163 | 163 | $params = $matches[3][$index]; |
| 164 | 164 | } |
| 165 | - else if(!empty($matches[4][$index])) |
|
| 165 | + else if (!empty($matches[4][$index])) |
|
| 166 | 166 | { |
| 167 | 167 | $name = $matches[4][$index]; |
| 168 | 168 | $type = $matches[5][$index]; |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | public function getInfo() : Mailcode_Parser_Statement_Info |
| 77 | 77 | { |
| 78 | - if(isset($this->info)) |
|
| 78 | + if (isset($this->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()).')', |