@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | public const URL_ENCODING_DECODE = 'decode'; |
29 | 29 | |
30 | 30 | /** |
31 | - * @var Mailcode_Factory_CommandSets|NULL |
|
32 | - */ |
|
31 | + * @var Mailcode_Factory_CommandSets|NULL |
|
32 | + */ |
|
33 | 33 | private static ?Mailcode_Factory_CommandSets $commandSets = null; |
34 | 34 | |
35 | 35 | /** |
@@ -83,33 +83,33 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | - * Creates a renderer instance, which can be used to easily |
|
87 | - * create and convert commands to strings. |
|
88 | - * |
|
89 | - * @return Mailcode_Renderer |
|
90 | - */ |
|
86 | + * Creates a renderer instance, which can be used to easily |
|
87 | + * create and convert commands to strings. |
|
88 | + * |
|
89 | + * @return Mailcode_Renderer |
|
90 | + */ |
|
91 | 91 | public static function createRenderer() : Mailcode_Renderer |
92 | 92 | { |
93 | 93 | return new Mailcode_Renderer(); |
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Creates a printer instance, which works like the renderer, |
|
98 | - * but outputs the generated strings to standard output. |
|
99 | - * |
|
100 | - * @return Mailcode_Printer |
|
101 | - */ |
|
96 | + /** |
|
97 | + * Creates a printer instance, which works like the renderer, |
|
98 | + * but outputs the generated strings to standard output. |
|
99 | + * |
|
100 | + * @return Mailcode_Printer |
|
101 | + */ |
|
102 | 102 | public static function createPrinter() : Mailcode_Printer |
103 | 103 | { |
104 | 104 | return new Mailcode_Printer(); |
105 | 105 | } |
106 | 106 | |
107 | - /** |
|
108 | - * Gets/creates the global instance of the date format info |
|
109 | - * class, used to handle date formatting aspects. |
|
110 | - * |
|
111 | - * @return Mailcode_Date_FormatInfo |
|
112 | - */ |
|
107 | + /** |
|
108 | + * Gets/creates the global instance of the date format info |
|
109 | + * class, used to handle date formatting aspects. |
|
110 | + * |
|
111 | + * @return Mailcode_Date_FormatInfo |
|
112 | + */ |
|
113 | 113 | public static function createDateInfo() : Mailcode_Date_FormatInfo |
114 | 114 | { |
115 | 115 | return Mailcode_Date_FormatInfo::getInstance(); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return Mailcode_Factory_CommandSets_Set_If |
59 | 59 | */ |
60 | - public static function if() : Mailcode_Factory_CommandSets_Set_If |
|
60 | + public static function if () : Mailcode_Factory_CommandSets_Set_If |
|
61 | 61 | { |
62 | 62 | return self::getSets()->if(); |
63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return Mailcode_Factory_CommandSets_Set_ElseIf |
69 | 69 | */ |
70 | - public static function elseIf() : Mailcode_Factory_CommandSets_Set_ElseIf |
|
70 | + public static function elseIf () : Mailcode_Factory_CommandSets_Set_ElseIf |
|
71 | 71 | { |
72 | 72 | return self::getSets()->elseIf(); |
73 | 73 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | protected static function getSets() : Mailcode_Factory_CommandSets |
119 | 119 | { |
120 | - if(!isset(self::$commandSets)) |
|
120 | + if (!isset(self::$commandSets)) |
|
121 | 121 | { |
122 | 122 | self::$commandSets = new Mailcode_Factory_CommandSets(); |
123 | 123 | } |
@@ -28,21 +28,21 @@ discard block |
||
28 | 28 | public const ERROR_INVALID_DUMMY_COMMAND_TYPE = 45903; |
29 | 29 | public const ERROR_INVALID_COMMAND_CLASS = 45904; |
30 | 30 | |
31 | - /** |
|
32 | - * @var Mailcode_Commands_Command[] |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var Mailcode_Commands_Command[] |
|
33 | + */ |
|
34 | 34 | private $commands = array(); |
35 | 35 | |
36 | - /** |
|
37 | - * @var array<string,Mailcode_Commands_Command> |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @var array<string,Mailcode_Commands_Command> |
|
38 | + */ |
|
39 | 39 | private static $dummyCommands = array(); |
40 | 40 | |
41 | - /** |
|
42 | - * Retrieves a list of all available command IDs. |
|
43 | - * |
|
44 | - * @return string[] |
|
45 | - */ |
|
41 | + /** |
|
42 | + * Retrieves a list of all available command IDs. |
|
43 | + * |
|
44 | + * @return string[] |
|
45 | + */ |
|
46 | 46 | public function getIDs() : array |
47 | 47 | { |
48 | 48 | static $ids = array(); |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | return $result; |
89 | 89 | } |
90 | 90 | |
91 | - /** |
|
92 | - * Gets an available command by its ID. |
|
93 | - * |
|
94 | - * @param string $id |
|
95 | - * @return Mailcode_Commands_Command |
|
96 | - */ |
|
91 | + /** |
|
92 | + * Gets an available command by its ID. |
|
93 | + * |
|
94 | + * @param string $id |
|
95 | + * @return Mailcode_Commands_Command |
|
96 | + */ |
|
97 | 97 | public function getByID(string $id) : Mailcode_Commands_Command |
98 | 98 | { |
99 | 99 | static $instances = array(); |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | return $instances[$id]; |
107 | 107 | } |
108 | 108 | |
109 | - /** |
|
110 | - * Retrieves the ID of a command by its name. |
|
111 | - * |
|
112 | - * @param string $name |
|
113 | - * @throws Mailcode_Exception |
|
114 | - * @return string |
|
115 | - * |
|
116 | - * @see Mailcode_Commands::ERROR_COMMAND_NAME_DOES_NOT_EXIST |
|
117 | - */ |
|
109 | + /** |
|
110 | + * Retrieves the ID of a command by its name. |
|
111 | + * |
|
112 | + * @param string $name |
|
113 | + * @throws Mailcode_Exception |
|
114 | + * @return string |
|
115 | + * |
|
116 | + * @see Mailcode_Commands::ERROR_COMMAND_NAME_DOES_NOT_EXIST |
|
117 | + */ |
|
118 | 118 | public function getIDByName(string $name) : string |
119 | 119 | { |
120 | 120 | $items = $this->getAll(); |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | return in_array($id, $ids); |
144 | 144 | } |
145 | 145 | |
146 | - /** |
|
147 | - * Checks wether the specified name exists. |
|
148 | - * |
|
149 | - * @param string $name For example: "showvar". |
|
150 | - * @return bool |
|
151 | - */ |
|
146 | + /** |
|
147 | + * Checks wether the specified name exists. |
|
148 | + * |
|
149 | + * @param string $name For example: "showvar". |
|
150 | + * @return bool |
|
151 | + */ |
|
152 | 152 | public function nameExists(string $name) : bool |
153 | 153 | { |
154 | 154 | $items = $this->getAll(); |
@@ -216,14 +216,14 @@ discard block |
||
216 | 216 | return $class; |
217 | 217 | } |
218 | 218 | |
219 | - /** |
|
220 | - * Translates the command type to the expected class naming scheme. |
|
221 | - * |
|
222 | - * Example: not-empty => NotEmpty |
|
223 | - * |
|
224 | - * @param string $type |
|
225 | - * @return string |
|
226 | - */ |
|
219 | + /** |
|
220 | + * Translates the command type to the expected class naming scheme. |
|
221 | + * |
|
222 | + * Example: not-empty => NotEmpty |
|
223 | + * |
|
224 | + * @param string $type |
|
225 | + * @return string |
|
226 | + */ |
|
227 | 227 | private function adjustTypeName(string $type) : string |
228 | 228 | { |
229 | 229 | $type = str_replace('-', ' ', $type); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | { |
48 | 48 | static $ids = array(); |
49 | 49 | |
50 | - if(empty($ids)) { |
|
50 | + if (empty($ids)) { |
|
51 | 51 | $ids = FileHelper::createFileFinder(__DIR__.'/Commands/Command') |
52 | 52 | ->getPHPClassNames(); |
53 | 53 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function getAll() |
67 | 67 | { |
68 | - if(!empty($this->commands)) { |
|
68 | + if (!empty($this->commands)) { |
|
69 | 69 | return $this->commands; |
70 | 70 | } |
71 | 71 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | $result = array(); |
75 | 75 | |
76 | - foreach($ids as $id) |
|
76 | + foreach ($ids as $id) |
|
77 | 77 | { |
78 | 78 | $result[] = $this->getDummyCommand($id); |
79 | 79 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | { |
99 | 99 | static $instances = array(); |
100 | 100 | |
101 | - if(!isset($instances[$id])) |
|
101 | + if (!isset($instances[$id])) |
|
102 | 102 | { |
103 | 103 | $instances[$id] = $this->createCommand($id, '__dummy', '', ''); |
104 | 104 | } |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | { |
120 | 120 | $items = $this->getAll(); |
121 | 121 | |
122 | - foreach($items as $item) |
|
122 | + foreach ($items as $item) |
|
123 | 123 | { |
124 | - if($item->getName() === $name) { |
|
124 | + if ($item->getName() === $name) { |
|
125 | 125 | return $item->getID(); |
126 | 126 | } |
127 | 127 | } |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | { |
154 | 154 | $items = $this->getAll(); |
155 | 155 | |
156 | - foreach($items as $item) |
|
156 | + foreach ($items as $item) |
|
157 | 157 | { |
158 | - if($item->getName() === $name) { |
|
158 | + if ($item->getName() === $name) { |
|
159 | 159 | return true; |
160 | 160 | } |
161 | 161 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | { |
168 | 168 | $class = $this->resolveClassName($id, $type); |
169 | 169 | |
170 | - if(!class_exists($class)) |
|
170 | + if (!class_exists($class)) |
|
171 | 171 | { |
172 | 172 | throw new Mailcode_Exception( |
173 | 173 | 'No such command', |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | $command = new $class($type, $params, $matchedString); |
184 | 184 | |
185 | - if($command instanceof Mailcode_Commands_Command) |
|
185 | + if ($command instanceof Mailcode_Commands_Command) |
|
186 | 186 | { |
187 | 187 | return $command; |
188 | 188 | } |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | |
204 | 204 | $dummy = $this->getDummyCommand($id); |
205 | 205 | |
206 | - if($dummy->supportsType()) |
|
206 | + if ($dummy->supportsType()) |
|
207 | 207 | { |
208 | - if(empty($type)) |
|
208 | + if (empty($type)) |
|
209 | 209 | { |
210 | 210 | $type = $dummy->getDefaultType(); |
211 | 211 | } |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | */ |
244 | 244 | private function getDummyCommand(string $id) : Mailcode_Commands_Command |
245 | 245 | { |
246 | - if(isset(self::$dummyCommands[$id])) { |
|
246 | + if (isset(self::$dummyCommands[$id])) { |
|
247 | 247 | return self::$dummyCommands[$id]; |
248 | 248 | } |
249 | 249 | |
250 | 250 | $class = 'Mailcode\Mailcode_Commands_Command_'.$id; |
251 | 251 | $cmd = new $class('__dummy'); |
252 | 252 | |
253 | - if($cmd instanceof Mailcode_Commands_Command) |
|
253 | + if ($cmd instanceof Mailcode_Commands_Command) |
|
254 | 254 | { |
255 | 255 | self::$dummyCommands[$id] = $cmd; |
256 | 256 | return $cmd; |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | $result = array(); |
276 | 276 | $commands = $this->getAll(); |
277 | 277 | |
278 | - foreach($commands as $command) |
|
278 | + foreach ($commands as $command) |
|
279 | 279 | { |
280 | - if($command instanceof Mailcode_Interfaces_Commands_ProtectedContent) |
|
280 | + if ($command instanceof Mailcode_Interfaces_Commands_ProtectedContent) |
|
281 | 281 | { |
282 | 282 | $result[] = $command; |
283 | 283 | } |
@@ -31,24 +31,24 @@ discard block |
||
31 | 31 | public const CHARTYPE_TIME = 'time'; |
32 | 32 | public const CHARTYPE_PUNCTUATION = 'punctuation'; |
33 | 33 | |
34 | - /** |
|
35 | - * @var string |
|
36 | - */ |
|
34 | + /** |
|
35 | + * @var string |
|
36 | + */ |
|
37 | 37 | private $defaultFormat = "Y/m/d"; |
38 | 38 | |
39 | - /** |
|
40 | - * @var Mailcode_Date_FormatInfo_Character[] |
|
41 | - */ |
|
39 | + /** |
|
40 | + * @var Mailcode_Date_FormatInfo_Character[] |
|
41 | + */ |
|
42 | 42 | private $formatChars = array(); |
43 | 43 | |
44 | - /** |
|
45 | - * @var string[] |
|
46 | - */ |
|
44 | + /** |
|
45 | + * @var string[] |
|
46 | + */ |
|
47 | 47 | private $allowedChars = array(); |
48 | 48 | |
49 | - /** |
|
50 | - * @var Mailcode_Date_FormatInfo|NULL |
|
51 | - */ |
|
49 | + /** |
|
50 | + * @var Mailcode_Date_FormatInfo|NULL |
|
51 | + */ |
|
52 | 52 | private static $instance; |
53 | 53 | |
54 | 54 | private function __construct() |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | return self::$instance; |
67 | 67 | } |
68 | 68 | |
69 | - /** |
|
70 | - * Initialized the list of allowed date formatting |
|
71 | - * characters. This is done only once per request |
|
72 | - * by storing them statically for performance reasons. |
|
73 | - */ |
|
69 | + /** |
|
70 | + * Initialized the list of allowed date formatting |
|
71 | + * characters. This is done only once per request |
|
72 | + * by storing them statically for performance reasons. |
|
73 | + */ |
|
74 | 74 | private function initCharacters() : void |
75 | 75 | { |
76 | 76 | $chars = array( |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | $this->defaultFormat = $formatString; |
116 | 116 | } |
117 | 117 | |
118 | - /** |
|
119 | - * Validates the date format string, by ensuring that |
|
120 | - * all the characters it is composed of are known. |
|
121 | - * |
|
122 | - * @param string $formatString |
|
123 | - * @return OperationResult |
|
124 | - * |
|
125 | - * @see Mailcode_Commands_Command_ShowDate::VALIDATION_EMPTY_FORMAT_STRING |
|
126 | - * @see Mailcode_Commands_Command_ShowDate::VALIDATION_INVALID_FORMAT_CHARACTER |
|
127 | - */ |
|
118 | + /** |
|
119 | + * Validates the date format string, by ensuring that |
|
120 | + * all the characters it is composed of are known. |
|
121 | + * |
|
122 | + * @param string $formatString |
|
123 | + * @return OperationResult |
|
124 | + * |
|
125 | + * @see Mailcode_Commands_Command_ShowDate::VALIDATION_EMPTY_FORMAT_STRING |
|
126 | + * @see Mailcode_Commands_Command_ShowDate::VALIDATION_INVALID_FORMAT_CHARACTER |
|
127 | + */ |
|
128 | 128 | public function validateFormat(string $formatString) : OperationResult |
129 | 129 | { |
130 | 130 | $result = new OperationResult($this); |
@@ -163,23 +163,23 @@ discard block |
||
163 | 163 | return $result; |
164 | 164 | } |
165 | 165 | |
166 | - /** |
|
167 | - * Retrieves all characters that are allowed to |
|
168 | - * be used in a date format string, with information |
|
169 | - * on each. |
|
170 | - * |
|
171 | - * @return Mailcode_Date_FormatInfo_Character[] |
|
172 | - */ |
|
166 | + /** |
|
167 | + * Retrieves all characters that are allowed to |
|
168 | + * be used in a date format string, with information |
|
169 | + * on each. |
|
170 | + * |
|
171 | + * @return Mailcode_Date_FormatInfo_Character[] |
|
172 | + */ |
|
173 | 173 | public function getCharactersList() : array |
174 | 174 | { |
175 | 175 | return $this->formatChars; |
176 | 176 | } |
177 | 177 | |
178 | - /** |
|
179 | - * Retrieves the characters list, grouped by type label. |
|
180 | - * |
|
181 | - * @return array<string,array<int,Mailcode_Date_FormatInfo_Character>> |
|
182 | - */ |
|
178 | + /** |
|
179 | + * Retrieves the characters list, grouped by type label. |
|
180 | + * |
|
181 | + * @return array<string,array<int,Mailcode_Date_FormatInfo_Character>> |
|
182 | + */ |
|
183 | 183 | public function getCharactersGrouped() : array |
184 | 184 | { |
185 | 185 | $grouped = array(); |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | { |
33 | 33 | $result = array(); |
34 | 34 | |
35 | - foreach($commands as $command) |
|
35 | + foreach ($commands as $command) |
|
36 | 36 | { |
37 | - if($command instanceof Mailcode_Commands_ShowBase) |
|
37 | + if ($command instanceof Mailcode_Commands_ShowBase) |
|
38 | 38 | { |
39 | 39 | $result[] = $command; |
40 | 40 | } |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | { |
57 | 57 | $result = array(); |
58 | 58 | |
59 | - foreach($commands as $command) |
|
59 | + foreach ($commands as $command) |
|
60 | 60 | { |
61 | - if($command instanceof Mailcode_Interfaces_Commands_ListVariables) |
|
61 | + if ($command instanceof Mailcode_Interfaces_Commands_ListVariables) |
|
62 | 62 | { |
63 | 63 | $result[] = $command; |
64 | 64 | } |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | { |
78 | 78 | $result = array(); |
79 | 79 | |
80 | - foreach($commands as $command) |
|
80 | + foreach ($commands as $command) |
|
81 | 81 | { |
82 | - if($command instanceof Mailcode_Commands_Command_ShowVariable) |
|
82 | + if ($command instanceof Mailcode_Commands_Command_ShowVariable) |
|
83 | 83 | { |
84 | 84 | $result[] = $command; |
85 | 85 | } |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | { |
99 | 99 | $result = array(); |
100 | 100 | |
101 | - foreach($commands as $command) |
|
101 | + foreach ($commands as $command) |
|
102 | 102 | { |
103 | - if($command instanceof Mailcode_Commands_Command_For) |
|
103 | + if ($command instanceof Mailcode_Commands_Command_For) |
|
104 | 104 | { |
105 | 105 | $result[] = $command; |
106 | 106 | } |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | { |
120 | 120 | $result = array(); |
121 | 121 | |
122 | - foreach($commands as $command) |
|
122 | + foreach ($commands as $command) |
|
123 | 123 | { |
124 | - if($command instanceof Mailcode_Commands_Command_ShowDate) |
|
124 | + if ($command instanceof Mailcode_Commands_Command_ShowDate) |
|
125 | 125 | { |
126 | 126 | $result[] = $command; |
127 | 127 | } |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | { |
141 | 141 | $result = array(); |
142 | 142 | |
143 | - foreach($commands as $command) |
|
143 | + foreach ($commands as $command) |
|
144 | 144 | { |
145 | - if($command instanceof Mailcode_Commands_Command_If) |
|
145 | + if ($command instanceof Mailcode_Commands_Command_If) |
|
146 | 146 | { |
147 | 147 | $result[] = $command; |
148 | 148 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function normalize() : string |
39 | 39 | { |
40 | - if(!$this->command->isValid()) |
|
40 | + if (!$this->command->isValid()) |
|
41 | 41 | { |
42 | 42 | return ''; |
43 | 43 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | private function addType() : void |
59 | 59 | { |
60 | - if(!$this->command->supportsType() || !$this->command->hasType()) |
|
60 | + if (!$this->command->supportsType() || !$this->command->hasType()) |
|
61 | 61 | { |
62 | 62 | return; |
63 | 63 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | $params = $this->getParamsString($command); |
71 | 71 | |
72 | - if(empty($params)) |
|
72 | + if (empty($params)) |
|
73 | 73 | { |
74 | 74 | return; |
75 | 75 | } |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | { |
88 | 88 | $params = $this->getParamsStatement($command); |
89 | 89 | |
90 | - if($params === null) |
|
90 | + if ($params === null) |
|
91 | 91 | { |
92 | 92 | return ''; |
93 | 93 | } |
94 | 94 | |
95 | - if($command->hasFreeformParameters()) |
|
95 | + if ($command->hasFreeformParameters()) |
|
96 | 96 | { |
97 | 97 | return $params->getStatementString(); |
98 | 98 | } |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | |
103 | 103 | private function addLogicKeywords() : void |
104 | 104 | { |
105 | - if(!$this->command->supportsLogicKeywords()) |
|
105 | + if (!$this->command->supportsLogicKeywords()) |
|
106 | 106 | { |
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
110 | 110 | $keywords = $this->command->getLogicKeywords()->getKeywords(); |
111 | 111 | |
112 | - foreach($keywords as $keyword) |
|
112 | + foreach ($keywords as $keyword) |
|
113 | 113 | { |
114 | 114 | $this->parts[] = ' '; |
115 | 115 | $this->parts[] = $keyword->getKeywordString(); // e.g. "if variable" |
@@ -45,44 +45,44 @@ discard block |
||
45 | 45 | |
46 | 46 | public const META_URL_ENCODING = 'url_encoding'; |
47 | 47 | |
48 | - /** |
|
49 | - * @var string |
|
50 | - */ |
|
48 | + /** |
|
49 | + * @var string |
|
50 | + */ |
|
51 | 51 | protected string $type = ''; |
52 | 52 | |
53 | - /** |
|
54 | - * @var string |
|
55 | - */ |
|
53 | + /** |
|
54 | + * @var string |
|
55 | + */ |
|
56 | 56 | protected string $paramsString = ''; |
57 | 57 | |
58 | - /** |
|
59 | - * @var string |
|
60 | - */ |
|
58 | + /** |
|
59 | + * @var string |
|
60 | + */ |
|
61 | 61 | protected string $matchedText = ''; |
62 | 62 | |
63 | - /** |
|
64 | - * @var string |
|
65 | - */ |
|
63 | + /** |
|
64 | + * @var string |
|
65 | + */ |
|
66 | 66 | protected string $hash = ''; |
67 | 67 | |
68 | - /** |
|
69 | - * @var OperationResult |
|
70 | - */ |
|
68 | + /** |
|
69 | + * @var OperationResult |
|
70 | + */ |
|
71 | 71 | protected OperationResult $validationResult; |
72 | 72 | |
73 | - /** |
|
74 | - * @var Mailcode |
|
75 | - */ |
|
73 | + /** |
|
74 | + * @var Mailcode |
|
75 | + */ |
|
76 | 76 | protected Mailcode $mailcode; |
77 | 77 | |
78 | - /** |
|
79 | - * @var Mailcode_Parser_Statement|NULL |
|
80 | - */ |
|
78 | + /** |
|
79 | + * @var Mailcode_Parser_Statement|NULL |
|
80 | + */ |
|
81 | 81 | protected ?Mailcode_Parser_Statement $params = null; |
82 | 82 | |
83 | - /** |
|
84 | - * @var string[] |
|
85 | - */ |
|
83 | + /** |
|
84 | + * @var string[] |
|
85 | + */ |
|
86 | 86 | protected array $validations = array( |
87 | 87 | Mailcode_Interfaces_Commands_Validation_EmptyParams::VALIDATION_NAME_EMPTY_PARAMS, |
88 | 88 | Mailcode_Interfaces_Commands_Validation_ParamKeywords::VALIDATION_NAME_KEYWORDS, |
@@ -91,24 +91,24 @@ discard block |
||
91 | 91 | Mailcode_Interfaces_Commands_Validation_TypeUnsupported::VALIDATION_NAME_TYPE_UNSUPPORTED |
92 | 92 | ); |
93 | 93 | |
94 | - /** |
|
95 | - * @var string |
|
96 | - */ |
|
94 | + /** |
|
95 | + * @var string |
|
96 | + */ |
|
97 | 97 | protected string $comment = ''; |
98 | 98 | |
99 | - /** |
|
100 | - * @var Mailcode_Commands_LogicKeywords|NULL |
|
101 | - */ |
|
99 | + /** |
|
100 | + * @var Mailcode_Commands_LogicKeywords|NULL |
|
101 | + */ |
|
102 | 102 | protected ?Mailcode_Commands_LogicKeywords $logicKeywords = null; |
103 | 103 | |
104 | - /** |
|
105 | - * @var Mailcode_Parser_Statement_Validator|NULL |
|
106 | - */ |
|
104 | + /** |
|
105 | + * @var Mailcode_Parser_Statement_Validator|NULL |
|
106 | + */ |
|
107 | 107 | protected ?Mailcode_Parser_Statement_Validator $validator = null; |
108 | 108 | |
109 | - /** |
|
110 | - * @var boolean |
|
111 | - */ |
|
109 | + /** |
|
110 | + * @var boolean |
|
111 | + */ |
|
112 | 112 | private bool $validated = false; |
113 | 113 | |
114 | 114 | /** |
@@ -143,13 +143,13 @@ discard block |
||
143 | 143 | |
144 | 144 | } |
145 | 145 | |
146 | - /** |
|
147 | - * Sets the command's parent opening command, if any. |
|
148 | - * NOTE: This is set automatically by the parser, and |
|
149 | - * should not be called manually. |
|
150 | - * |
|
151 | - * @param Mailcode_Commands_Command $command |
|
152 | - */ |
|
146 | + /** |
|
147 | + * Sets the command's parent opening command, if any. |
|
148 | + * NOTE: This is set automatically by the parser, and |
|
149 | + * should not be called manually. |
|
150 | + * |
|
151 | + * @param Mailcode_Commands_Command $command |
|
152 | + */ |
|
153 | 153 | public function setParent(Mailcode_Commands_Command $command) : void |
154 | 154 | { |
155 | 155 | $this->parent = $command; |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | return $this->validationResult->isValid(); |
296 | 296 | } |
297 | 297 | |
298 | - /** |
|
299 | - * @return string[] |
|
300 | - */ |
|
298 | + /** |
|
299 | + * @return string[] |
|
300 | + */ |
|
301 | 301 | abstract protected function getValidations() : array; |
302 | 302 | |
303 | 303 | protected function _validateNesting() : void |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | private bool $nestingValidated = false; |
129 | 129 | |
130 | - public function __construct(string $type='', string $paramsString='', string $matchedText='') |
|
130 | + public function __construct(string $type = '', string $paramsString = '', string $matchedText = '') |
|
131 | 131 | { |
132 | 132 | $this->type = $type; |
133 | 133 | $this->paramsString = html_entity_decode($paramsString); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | { |
208 | 208 | $this->requireNonDummy(); |
209 | 209 | |
210 | - if($this->hash === '') { |
|
210 | + if ($this->hash === '') { |
|
211 | 211 | $this->hash = md5($this->matchedText); |
212 | 212 | } |
213 | 213 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | protected function requireNonDummy() : void |
218 | 218 | { |
219 | - if(!$this->isDummy()) |
|
219 | + if (!$this->isDummy()) |
|
220 | 220 | { |
221 | 221 | return; |
222 | 222 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | protected function validate() : OperationResult |
237 | 237 | { |
238 | - if(!$this->validated) |
|
238 | + if (!$this->validated) |
|
239 | 239 | { |
240 | 240 | $this->requireNonDummy(); |
241 | 241 | $this->validateSyntax(); |
@@ -255,10 +255,10 @@ discard block |
||
255 | 255 | { |
256 | 256 | $validations = $this->resolveValidations(); |
257 | 257 | |
258 | - foreach($validations as $validation) |
|
258 | + foreach ($validations as $validation) |
|
259 | 259 | { |
260 | 260 | // break off at the first validation issue |
261 | - if(!$this->validateSyntaxMethod($validation)) |
|
261 | + if (!$this->validateSyntaxMethod($validation)) |
|
262 | 262 | { |
263 | 263 | return; |
264 | 264 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | { |
278 | 278 | $method = 'validateSyntax_'.$validation; |
279 | 279 | |
280 | - if(!method_exists($this, $method)) |
|
280 | + if (!method_exists($this, $method)) |
|
281 | 281 | { |
282 | 282 | throw new Mailcode_Exception( |
283 | 283 | 'Missing validation method ['.$validation.']', |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | |
308 | 308 | public function validateNesting() : OperationResult |
309 | 309 | { |
310 | - if($this->nestingValidated) |
|
310 | + if ($this->nestingValidated) |
|
311 | 311 | { |
312 | 312 | return $this->validationResult; |
313 | 313 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | |
332 | 332 | public function getType() : string |
333 | 333 | { |
334 | - if($this->supportsType()) |
|
334 | + if ($this->supportsType()) |
|
335 | 335 | { |
336 | 336 | return $this->type; |
337 | 337 | } |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | |
352 | 352 | public function getHighlighted() : string |
353 | 353 | { |
354 | - if(!$this->isValid()) |
|
354 | + if (!$this->isValid()) |
|
355 | 355 | { |
356 | 356 | return ''; |
357 | 357 | } |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | |
363 | 363 | public function getParamsString() : string |
364 | 364 | { |
365 | - if($this->requiresParameters()) |
|
365 | + if ($this->requiresParameters()) |
|
366 | 366 | { |
367 | 367 | return $this->paramsString; |
368 | 368 | } |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | |
378 | 378 | public function requireParams() : Mailcode_Parser_Statement |
379 | 379 | { |
380 | - if(isset($this->params)) |
|
380 | + if (isset($this->params)) |
|
381 | 381 | { |
382 | 382 | return $this->params; |
383 | 383 | } |
@@ -407,22 +407,22 @@ discard block |
||
407 | 407 | |
408 | 408 | public final function getCommandType() : string |
409 | 409 | { |
410 | - if($this instanceof Mailcode_Commands_Command_Type_Closing) |
|
410 | + if ($this instanceof Mailcode_Commands_Command_Type_Closing) |
|
411 | 411 | { |
412 | 412 | return 'Closing'; |
413 | 413 | } |
414 | 414 | |
415 | - if($this instanceof Mailcode_Commands_Command_Type_Opening) |
|
415 | + if ($this instanceof Mailcode_Commands_Command_Type_Opening) |
|
416 | 416 | { |
417 | 417 | return 'Opening'; |
418 | 418 | } |
419 | 419 | |
420 | - if($this instanceof Mailcode_Commands_Command_Type_Sibling) |
|
420 | + if ($this instanceof Mailcode_Commands_Command_Type_Sibling) |
|
421 | 421 | { |
422 | 422 | return 'Sibling'; |
423 | 423 | } |
424 | 424 | |
425 | - if($this instanceof Mailcode_Commands_Command_Type_Standalone) |
|
425 | + if ($this instanceof Mailcode_Commands_Command_Type_Standalone) |
|
426 | 426 | { |
427 | 427 | return 'Standalone'; |
428 | 428 | } |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | |
460 | 460 | public function getLogicKeywords() : Mailcode_Commands_LogicKeywords |
461 | 461 | { |
462 | - if(isset($this->logicKeywords) && $this->supportsLogicKeywords()) |
|
462 | + if (isset($this->logicKeywords) && $this->supportsLogicKeywords()) |
|
463 | 463 | { |
464 | 464 | return $this->logicKeywords; |
465 | 465 | } |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | |
480 | 480 | public function getTranslationParam(string $name) |
481 | 481 | { |
482 | - if(isset($this->translationParams[$name])) |
|
482 | + if (isset($this->translationParams[$name])) |
|
483 | 483 | { |
484 | 484 | return $this->translationParams[$name]; |
485 | 485 | } |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | return null; |
488 | 488 | } |
489 | 489 | |
490 | - public function setURLEncoding(bool $encoding=true) |
|
490 | + public function setURLEncoding(bool $encoding = true) |
|
491 | 491 | { |
492 | 492 | $this->requireURLEncoding(); |
493 | 493 | |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | return $this; |
499 | 499 | } |
500 | 500 | |
501 | - public function setURLDecoding(bool $decode=true) |
|
501 | + public function setURLDecoding(bool $decode = true) |
|
502 | 502 | { |
503 | 503 | $this->requireURLEncoding(); |
504 | 504 | |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | |
512 | 512 | protected function requireURLEncoding() : void |
513 | 513 | { |
514 | - if($this->supportsURLEncoding()) { |
|
514 | + if ($this->supportsURLEncoding()) { |
|
515 | 515 | return; |
516 | 516 | } |
517 | 517 | |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | |
538 | 538 | protected function getValidator() : Mailcode_Parser_Statement_Validator |
539 | 539 | { |
540 | - if(isset($this->validator)) |
|
540 | + if (isset($this->validator)) |
|
541 | 541 | { |
542 | 542 | return $this->validator; |
543 | 543 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | public function __construct(Mailcode_Commands_Command $command) |
41 | 41 | { |
42 | - if(!$command instanceof Mailcode_Interfaces_Commands_ProtectedContent) |
|
42 | + if (!$command instanceof Mailcode_Interfaces_Commands_ProtectedContent) |
|
43 | 43 | { |
44 | 44 | throw new Mailcode_Exception( |
45 | 45 | 'Invalid command', |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | { |
67 | 67 | $params = $command->getParams(); |
68 | 68 | |
69 | - if($params === null) |
|
69 | + if ($params === null) |
|
70 | 70 | { |
71 | 71 | return null; |
72 | 72 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | $contentID = $info->getTokenByIndex(0); |
92 | 92 | |
93 | - if($contentID instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number) |
|
93 | + if ($contentID instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number) |
|
94 | 94 | { |
95 | 95 | $info->removeToken($contentID); |
96 | 96 | return $copy; |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class Mailcode_Commands_Command_SetVariable extends Mailcode_Commands_Command implements Mailcode_Commands_Command_Type_Standalone |
22 | 22 | { |
23 | - /** |
|
24 | - * @var Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL |
|
25 | + */ |
|
26 | 26 | private $variableToken; |
27 | 27 | |
28 | 28 | public function getName() : string |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | ); |
154 | 154 | } |
155 | 155 | |
156 | - /** |
|
157 | - * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
158 | - */ |
|
156 | + /** |
|
157 | + * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
158 | + */ |
|
159 | 159 | public function getAssignmentTokens() : array |
160 | 160 | { |
161 | 161 | $params = $this->requireParams()->getInfo()->getTokens(); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | { |
79 | 79 | $val = $this->getValidator()->createVariable()->setIndex(0); |
80 | 80 | |
81 | - if($val->isValid()) |
|
81 | + if ($val->isValid()) |
|
82 | 82 | { |
83 | 83 | $this->variableToken = $val->getToken(); |
84 | 84 | } |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | ->limitToOperands() |
100 | 100 | ->getTokens(); |
101 | 101 | |
102 | - foreach($tokens as $token) |
|
102 | + foreach ($tokens as $token) |
|
103 | 103 | { |
104 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand) |
|
104 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand) |
|
105 | 105 | { |
106 | 106 | $this->validateOperand($token); |
107 | 107 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | // ensure that the operand we have in the command is one of the |
119 | 119 | // allowed ones. |
120 | - if(!in_array($sign, $allowed)) |
|
120 | + if (!in_array($sign, $allowed)) |
|
121 | 121 | { |
122 | 122 | $this->validationResult->makeError( |
123 | 123 | t('The %1$s sign is not allowed in this command.', '<code>'.$sign.'</code>'), |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | { |
131 | 131 | $tokens = $this->getAssignmentTokens(); |
132 | 132 | |
133 | - if(empty($tokens)) |
|
133 | + if (empty($tokens)) |
|
134 | 134 | { |
135 | 135 | $this->validationResult->makeError( |
136 | 136 | t('No value assigned to the variable.'), |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | public function getVariable() : Mailcode_Variables_Variable |
143 | 143 | { |
144 | - if($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) |
|
144 | + if ($this->variableToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) |
|
145 | 145 | { |
146 | 146 | return $this->variableToken->getVariable(); |
147 | 147 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $eq = array_shift($params); // equals sign |
166 | 166 | |
167 | 167 | // in case the equals sign was omitted. |
168 | - if($eq !== null && !$eq instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand) |
|
168 | + if ($eq !== null && !$eq instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand) |
|
169 | 169 | { |
170 | 170 | array_unshift($params, $eq); |
171 | 171 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | |
180 | 180 | $items = array(); |
181 | 181 | |
182 | - foreach($tokens as $token) |
|
182 | + foreach ($tokens as $token) |
|
183 | 183 | { |
184 | 184 | $items[] = $token->getNormalized(); |
185 | 185 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function getSyntaxName() : string |
113 | 113 | { |
114 | - if(isset($this->langToken)) |
|
114 | + if (isset($this->langToken)) |
|
115 | 115 | { |
116 | 116 | return $this->langToken->getText(); |
117 | 117 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | ->getInfo() |
135 | 135 | ->getStringLiteralByIndex(1); |
136 | 136 | |
137 | - if($lang) |
|
137 | + if ($lang) |
|
138 | 138 | { |
139 | 139 | $this->langToken = $lang; |
140 | 140 | return; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | { |
159 | 159 | // To keep PHPStan happy. If no token has been found, this |
160 | 160 | // method will not be called. |
161 | - if(!isset($this->langToken)) |
|
161 | + if (!isset($this->langToken)) |
|
162 | 162 | { |
163 | 163 | return; |
164 | 164 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $name = $this->langToken->getText(); |
167 | 167 | $supported = self::getSupportedSyntaxes(); |
168 | 168 | |
169 | - if(in_array($name, $supported)) |
|
169 | + if (in_array($name, $supported)) |
|
170 | 170 | { |
171 | 171 | return; |
172 | 172 | } |