@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | private $sourceCommand; |
| 58 | 58 | |
| 59 | - public function __construct(string $statement, bool $freeform=false, ?Mailcode_Commands_Command $sourceCommand=null) |
|
| 59 | + public function __construct(string $statement, bool $freeform = false, ?Mailcode_Commands_Command $sourceCommand = null) |
|
| 60 | 60 | { |
| 61 | 61 | $this->sourceCommand = $sourceCommand; |
| 62 | 62 | $this->statement = $this->prepareStatement($statement); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | public function getInfo() : Mailcode_Parser_Statement_Info |
| 108 | 108 | { |
| 109 | - if($this->info instanceof Mailcode_Parser_Statement_Info) |
|
| 109 | + if ($this->info instanceof Mailcode_Parser_Statement_Info) |
|
| 110 | 110 | { |
| 111 | 111 | return $this->info; |
| 112 | 112 | } |
@@ -118,12 +118,12 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | protected function validate() : void |
| 120 | 120 | { |
| 121 | - if($this->freeform) |
|
| 121 | + if ($this->freeform) |
|
| 122 | 122 | { |
| 123 | 123 | return; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if(!$this->tokenizer->hasTokens()) |
|
| 126 | + if (!$this->tokenizer->hasTokens()) |
|
| 127 | 127 | { |
| 128 | 128 | $this->result->makeError( |
| 129 | 129 | t('Empty statement'), |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | $unknown = $this->tokenizer->getFirstUnknown(); |
| 137 | 137 | |
| 138 | - if($unknown) |
|
| 138 | + if ($unknown) |
|
| 139 | 139 | { |
| 140 | 140 | $this->result->makeError( |
| 141 | 141 | t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')', |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | $total = count($matches[0]); |
| 82 | 82 | |
| 83 | - for($i=0; $i < $total; $i++) |
|
| 83 | + for ($i = 0; $i < $total; $i++) |
|
| 84 | 84 | { |
| 85 | 85 | $match = $this->parseMatch($matches, $i); |
| 86 | 86 | |
@@ -101,18 +101,18 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | $matches = array_unique($result[0]); |
| 103 | 103 | |
| 104 | - if(!empty($matches)) |
|
| 104 | + if (!empty($matches)) |
|
| 105 | 105 | { |
| 106 | - foreach($matches as $match) |
|
| 106 | + foreach ($matches as $match) |
|
| 107 | 107 | { |
| 108 | - if(strpos($match, '{') !== false || strpos($match, '}') !== false) |
|
| 108 | + if (strpos($match, '{') !== false || strpos($match, '}') !== false) |
|
| 109 | 109 | { |
| 110 | 110 | $subject = $this->replaceBrackets($subject, $match); |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if(!ConvertHelper::isStringHTML($subject)) |
|
| 115 | + if (!ConvertHelper::isStringHTML($subject)) |
|
| 116 | 116 | { |
| 117 | 117 | return $subject; |
| 118 | 118 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | private function replaceBrackets(string $subject, string $needle) : string |
| 125 | 125 | { |
| 126 | - $replacement = str_replace( |
|
| 126 | + $replacement = str_replace( |
|
| 127 | 127 | array('{', '}'), |
| 128 | 128 | array( |
| 129 | 129 | self::LITERAL_BRACKET_LEFT_REPLACEMENT, |
@@ -177,17 +177,17 @@ discard block |
||
| 177 | 177 | private function handleNesting(Mailcode_Commands_Command $cmd) : void |
| 178 | 178 | { |
| 179 | 179 | // Set the command's parent from the stack, if any is present. |
| 180 | - if(!empty($this->stack)) |
|
| 180 | + if (!empty($this->stack)) |
|
| 181 | 181 | { |
| 182 | 182 | $cmd->setParent($this->getStackLast()); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // Handle opening and closing commands, adding and removing from the stack. |
| 186 | - if($cmd instanceof Mailcode_Commands_Command_Type_Opening) |
|
| 186 | + if ($cmd instanceof Mailcode_Commands_Command_Type_Opening) |
|
| 187 | 187 | { |
| 188 | 188 | $this->stack[] = $cmd; |
| 189 | 189 | } |
| 190 | - else if($cmd instanceof Mailcode_Commands_Command_Type_Closing) |
|
| 190 | + else if ($cmd instanceof Mailcode_Commands_Command_Type_Closing) |
|
| 191 | 191 | { |
| 192 | 192 | array_pop($this->stack); |
| 193 | 193 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | { |
| 198 | 198 | $cmd = $this->stack[array_key_last($this->stack)]; |
| 199 | 199 | |
| 200 | - if($cmd instanceof Mailcode_Commands_Command) |
|
| 200 | + if ($cmd instanceof Mailcode_Commands_Command) |
|
| 201 | 201 | { |
| 202 | 202 | return $cmd; |
| 203 | 203 | } |
@@ -226,16 +226,16 @@ discard block |
||
| 226 | 226 | // 5 = parameter type command, type |
| 227 | 227 | // 6 = parameter type command, params |
| 228 | 228 | |
| 229 | - if(!empty($matches[1][$index])) |
|
| 229 | + if (!empty($matches[1][$index])) |
|
| 230 | 230 | { |
| 231 | 231 | $name = $matches[1][$index]; |
| 232 | 232 | } |
| 233 | - else if(!empty($matches[2][$index])) |
|
| 233 | + else if (!empty($matches[2][$index])) |
|
| 234 | 234 | { |
| 235 | 235 | $name = $matches[2][$index]; |
| 236 | 236 | $params = $matches[3][$index]; |
| 237 | 237 | } |
| 238 | - else if(!empty($matches[4][$index])) |
|
| 238 | + else if (!empty($matches[4][$index])) |
|
| 239 | 239 | { |
| 240 | 240 | $name = $matches[4][$index]; |
| 241 | 241 | $type = $matches[5][$index]; |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * @param Mailcode_Commands_Command|null $sourceCommand |
| 273 | 273 | * @return Mailcode_Parser_Statement |
| 274 | 274 | */ |
| 275 | - public function createStatement(string $statement, bool $freeform=false, ?Mailcode_Commands_Command $sourceCommand=null) : Mailcode_Parser_Statement |
|
| 275 | + public function createStatement(string $statement, bool $freeform = false, ?Mailcode_Commands_Command $sourceCommand = null) : Mailcode_Parser_Statement |
|
| 276 | 276 | { |
| 277 | 277 | return new Mailcode_Parser_Statement($statement, $freeform, $sourceCommand); |
| 278 | 278 | } |