| @@ -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()).')', | 
| @@ -30,14 +30,14 @@ discard block | ||
| 30 | 30 |          '{\s*([a-z]+)\s+([a-z-]+)\s*:([^}]*)}' | 
| 31 | 31 | ); | 
| 32 | 32 | |
| 33 | - /** | |
| 34 | - * @var Mailcode | |
| 35 | - */ | |
| 33 | + /** | |
| 34 | + * @var Mailcode | |
| 35 | + */ | |
| 36 | 36 | protected $mailcode; | 
| 37 | 37 | |
| 38 | - /** | |
| 39 | - * @var Mailcode_Commands | |
| 40 | - */ | |
| 38 | + /** | |
| 39 | + * @var Mailcode_Commands | |
| 40 | + */ | |
| 41 | 41 | protected $commands; | 
| 42 | 42 | |
| 43 | 43 | /** | 
| @@ -51,24 +51,24 @@ discard block | ||
| 51 | 51 | $this->commands = $this->mailcode->getCommands(); | 
| 52 | 52 | } | 
| 53 | 53 | |
| 54 | - /** | |
| 55 | - * Gets the regex format string used to detect commands. | |
| 56 | - * | |
| 57 | - * @return string | |
| 58 | - */ | |
| 54 | + /** | |
| 55 | + * Gets the regex format string used to detect commands. | |
| 56 | + * | |
| 57 | + * @return string | |
| 58 | + */ | |
| 59 | 59 | protected static function getRegex() : string | 
| 60 | 60 |      { | 
| 61 | 61 |          return '/'.implode('|', self::COMMAND_REGEX_PARTS).'/sixU'; | 
| 62 | 62 | } | 
| 63 | 63 | |
| 64 | - /** | |
| 65 | - * Parses a string to detect all commands within. Returns a | |
| 66 | - * collection instance that contains information on all the | |
| 67 | - * commands. | |
| 68 | - * | |
| 69 | - * @param string $string | |
| 70 | - * @return Mailcode_Collection A collection with all unique commands found. | |
| 71 | - */ | |
| 64 | + /** | |
| 65 | + * Parses a string to detect all commands within. Returns a | |
| 66 | + * collection instance that contains information on all the | |
| 67 | + * commands. | |
| 68 | + * | |
| 69 | + * @param string $string | |
| 70 | + * @return Mailcode_Collection A collection with all unique commands found. | |
| 71 | + */ | |
| 72 | 72 | public function parseString(string $string) : Mailcode_Collection | 
| 73 | 73 |      { | 
| 74 | 74 | $collection = new Mailcode_Collection(); | 
| @@ -135,14 +135,14 @@ discard block | ||
| 135 | 135 | return str_replace($needle, $replacement, $subject); | 
| 136 | 136 | } | 
| 137 | 137 | |
| 138 | - /** | |
| 139 | - * Processes a single match found in the string: creates the command, | |
| 140 | - * and adds it to the collection if it's a valid command, or to the list | |
| 141 | - * of invalid commands otherwise. | |
| 142 | - * | |
| 143 | - * @param Mailcode_Parser_Match $match | |
| 144 | - * @param Mailcode_Collection $collection | |
| 145 | - */ | |
| 138 | + /** | |
| 139 | + * Processes a single match found in the string: creates the command, | |
| 140 | + * and adds it to the collection if it's a valid command, or to the list | |
| 141 | + * of invalid commands otherwise. | |
| 142 | + * | |
| 143 | + * @param Mailcode_Parser_Match $match | |
| 144 | + * @param Mailcode_Collection $collection | |
| 145 | + */ | |
| 146 | 146 | protected function processMatch(Mailcode_Parser_Match $match, Mailcode_Collection $collection) : void | 
| 147 | 147 |      { | 
| 148 | 148 | $name = $match->getName(); | 
| @@ -205,14 +205,14 @@ discard block | ||
| 205 | 205 |          throw new Mailcode_Exception('Not a command', '', self::ERROR_NOT_A_COMMAND); | 
| 206 | 206 | } | 
| 207 | 207 | |
| 208 | - /** | |
| 209 | - * Parses a single regex match: determines which named group | |
| 210 | - * matches, and retrieves the according information. | |
| 211 | - * | |
| 212 | - * @param array[] $matches The regex results array. | |
| 213 | - * @param int $index The matched index. | |
| 214 | - * @return Mailcode_Parser_Match | |
| 215 | - */ | |
| 208 | + /** | |
| 209 | + * Parses a single regex match: determines which named group | |
| 210 | + * matches, and retrieves the according information. | |
| 211 | + * | |
| 212 | + * @param array[] $matches The regex results array. | |
| 213 | + * @param int $index The matched index. | |
| 214 | + * @return Mailcode_Parser_Match | |
| 215 | + */ | |
| 216 | 216 | protected function parseMatch(array $matches, int $index) : Mailcode_Parser_Match | 
| 217 | 217 |      { | 
| 218 | 218 | $name = ''; // the command name, e.g. "showvar" | 
| @@ -250,14 +250,14 @@ discard block | ||
| 250 | 250 | ); | 
| 251 | 251 | } | 
| 252 | 252 | |
| 253 | - /** | |
| 254 | - * Creates an instance of the safeguard tool, which | |
| 255 | - * is used to safeguard commands in a string with placeholders. | |
| 256 | - * | |
| 257 | - * @param string $subject The string to use to safeguard commands in. | |
| 258 | - * @return Mailcode_Parser_Safeguard | |
| 259 | - * @see Mailcode_Parser_Safeguard | |
| 260 | - */ | |
| 253 | + /** | |
| 254 | + * Creates an instance of the safeguard tool, which | |
| 255 | + * is used to safeguard commands in a string with placeholders. | |
| 256 | + * | |
| 257 | + * @param string $subject The string to use to safeguard commands in. | |
| 258 | + * @return Mailcode_Parser_Safeguard | |
| 259 | + * @see Mailcode_Parser_Safeguard | |
| 260 | + */ | |
| 261 | 261 | public function createSafeguard(string $subject) : Mailcode_Parser_Safeguard | 
| 262 | 262 |      { | 
| 263 | 263 | return new Mailcode_Parser_Safeguard($this, $subject); | 
| @@ -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 | } |