@@ -11,7 +11,7 @@ |
||
11 | 11 | $matches = array(); |
12 | 12 | preg_match_all('/-*[0-9]+\s*[.,]\s*[0-9]+|-*[0-9]+/sx', $this->tokenized, $matches, PREG_PATTERN_ORDER); |
13 | 13 | |
14 | - foreach($matches[0] as $match) |
|
14 | + foreach ($matches[0] as $match) |
|
15 | 15 | { |
16 | 16 | $this->registerToken('Number', $match); |
17 | 17 | } |
@@ -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(); |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | return preg_replace('%<style\b[^>]*>(.*?)</style>%six', '', $subject); |
102 | 102 | } |
103 | 103 | |
104 | - /** |
|
105 | - * Processes a single match found in the string: creates the command, |
|
106 | - * and adds it to the collection if it's a valid command, or to the list |
|
107 | - * of invalid commands otherwise. |
|
108 | - * |
|
109 | - * @param Mailcode_Parser_Match $match |
|
110 | - * @param Mailcode_Collection $collection |
|
111 | - */ |
|
104 | + /** |
|
105 | + * Processes a single match found in the string: creates the command, |
|
106 | + * and adds it to the collection if it's a valid command, or to the list |
|
107 | + * of invalid commands otherwise. |
|
108 | + * |
|
109 | + * @param Mailcode_Parser_Match $match |
|
110 | + * @param Mailcode_Collection $collection |
|
111 | + */ |
|
112 | 112 | protected function processMatch(Mailcode_Parser_Match $match, Mailcode_Collection $collection) : void |
113 | 113 | { |
114 | 114 | $name = $match->getName(); |
@@ -170,14 +170,14 @@ discard block |
||
170 | 170 | throw new Mailcode_Exception('Not a command', '', self::ERROR_NOT_A_COMMAND); |
171 | 171 | } |
172 | 172 | |
173 | - /** |
|
174 | - * Parses a single regex match: determines which named group |
|
175 | - * matches, and retrieves the according information. |
|
176 | - * |
|
177 | - * @param array[] $matches The regex results array. |
|
178 | - * @param int $index The matched index. |
|
179 | - * @return Mailcode_Parser_Match |
|
180 | - */ |
|
173 | + /** |
|
174 | + * Parses a single regex match: determines which named group |
|
175 | + * matches, and retrieves the according information. |
|
176 | + * |
|
177 | + * @param array[] $matches The regex results array. |
|
178 | + * @param int $index The matched index. |
|
179 | + * @return Mailcode_Parser_Match |
|
180 | + */ |
|
181 | 181 | protected function parseMatch(array $matches, int $index) : Mailcode_Parser_Match |
182 | 182 | { |
183 | 183 | $name = ''; // the command name, e.g. "showvar" |
@@ -215,27 +215,27 @@ discard block |
||
215 | 215 | ); |
216 | 216 | } |
217 | 217 | |
218 | - /** |
|
219 | - * Creates an instance of the safeguard tool, which |
|
220 | - * is used to safeguard commands in a string with placeholders. |
|
221 | - * |
|
222 | - * @param string $subject The string to use to safeguard commands in. |
|
223 | - * @return Mailcode_Parser_Safeguard |
|
224 | - * @see Mailcode_Parser_Safeguard |
|
225 | - */ |
|
218 | + /** |
|
219 | + * Creates an instance of the safeguard tool, which |
|
220 | + * is used to safeguard commands in a string with placeholders. |
|
221 | + * |
|
222 | + * @param string $subject The string to use to safeguard commands in. |
|
223 | + * @return Mailcode_Parser_Safeguard |
|
224 | + * @see Mailcode_Parser_Safeguard |
|
225 | + */ |
|
226 | 226 | public function createSafeguard(string $subject) : Mailcode_Parser_Safeguard |
227 | 227 | { |
228 | 228 | return new Mailcode_Parser_Safeguard($this, $subject); |
229 | 229 | } |
230 | 230 | |
231 | - /** |
|
232 | - * Creates a statement parser, which is used to validate arbitrary |
|
233 | - * command statements. |
|
234 | - * |
|
235 | - * @param string $statement |
|
236 | - * @param bool $freeform |
|
237 | - * @return Mailcode_Parser_Statement |
|
238 | - */ |
|
231 | + /** |
|
232 | + * Creates a statement parser, which is used to validate arbitrary |
|
233 | + * command statements. |
|
234 | + * |
|
235 | + * @param string $statement |
|
236 | + * @param bool $freeform |
|
237 | + * @return Mailcode_Parser_Statement |
|
238 | + */ |
|
239 | 239 | public function createStatement(string $statement, bool $freeform=false) : Mailcode_Parser_Statement |
240 | 240 | { |
241 | 241 | return new Mailcode_Parser_Statement($statement, $freeform); |
@@ -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 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | protected function prepareString(string $subject) : string |
94 | 94 | { |
95 | - if(!ConvertHelper::isStringHTML($subject)) |
|
95 | + if (!ConvertHelper::isStringHTML($subject)) |
|
96 | 96 | { |
97 | 97 | return $subject; |
98 | 98 | } |
@@ -142,17 +142,17 @@ discard block |
||
142 | 142 | private function handleNesting(Mailcode_Commands_Command $cmd) : void |
143 | 143 | { |
144 | 144 | // Set the command's parent from the stack, if any is present. |
145 | - if(!empty($this->stack)) |
|
145 | + if (!empty($this->stack)) |
|
146 | 146 | { |
147 | 147 | $cmd->setParent($this->getStackLast()); |
148 | 148 | } |
149 | 149 | |
150 | 150 | // Handle opening and closing commands, adding and removing from the stack. |
151 | - if($cmd instanceof Mailcode_Commands_Command_Type_Opening) |
|
151 | + if ($cmd instanceof Mailcode_Commands_Command_Type_Opening) |
|
152 | 152 | { |
153 | 153 | $this->stack[] = $cmd; |
154 | 154 | } |
155 | - else if($cmd instanceof Mailcode_Commands_Command_Type_Closing) |
|
155 | + else if ($cmd instanceof Mailcode_Commands_Command_Type_Closing) |
|
156 | 156 | { |
157 | 157 | array_pop($this->stack); |
158 | 158 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | { |
163 | 163 | $cmd = $this->stack[array_key_last($this->stack)]; |
164 | 164 | |
165 | - if($cmd instanceof Mailcode_Commands_Command) |
|
165 | + if ($cmd instanceof Mailcode_Commands_Command) |
|
166 | 166 | { |
167 | 167 | return $cmd; |
168 | 168 | } |
@@ -191,16 +191,16 @@ discard block |
||
191 | 191 | // 5 = parameter type command, type |
192 | 192 | // 6 = parameter type command, params |
193 | 193 | |
194 | - if(!empty($matches[1][$index])) |
|
194 | + if (!empty($matches[1][$index])) |
|
195 | 195 | { |
196 | 196 | $name = $matches[1][$index]; |
197 | 197 | } |
198 | - else if(!empty($matches[2][$index])) |
|
198 | + else if (!empty($matches[2][$index])) |
|
199 | 199 | { |
200 | 200 | $name = $matches[2][$index]; |
201 | 201 | $params = $matches[3][$index]; |
202 | 202 | } |
203 | - else if(!empty($matches[4][$index])) |
|
203 | + else if (!empty($matches[4][$index])) |
|
204 | 204 | { |
205 | 205 | $name = $matches[4][$index]; |
206 | 206 | $type = $matches[5][$index]; |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @param bool $freeform |
237 | 237 | * @return Mailcode_Parser_Statement |
238 | 238 | */ |
239 | - public function createStatement(string $statement, bool $freeform=false) : Mailcode_Parser_Statement |
|
239 | + public function createStatement(string $statement, bool $freeform = false) : Mailcode_Parser_Statement |
|
240 | 240 | { |
241 | 241 | return new Mailcode_Parser_Statement($statement, $freeform); |
242 | 242 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | public function protectContent(string $string, Mailcode_Parser_Safeguard_Placeholder $open, Mailcode_Parser_Safeguard_Placeholder $end) : string |
35 | 35 | { |
36 | - if(!$end->getCommand() instanceof Mailcode_Commands_Command_End) |
|
36 | + if (!$end->getCommand() instanceof Mailcode_Commands_Command_End) |
|
37 | 37 | { |
38 | 38 | throw new Mailcode_Exception( |
39 | 39 | 'Invalid commands nesting', |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $start = strpos($string, $open->getReplacementText()) + $open->getReplacementLength(); |
46 | 46 | $end = strpos($string, $end->getReplacementText()); |
47 | 47 | |
48 | - $content = substr($string, $start, ($end-$start)); |
|
48 | + $content = substr($string, $start, ($end - $start)); |
|
49 | 49 | |
50 | 50 | return $this->replaceContent($string, $content); |
51 | 51 | } |