@@ -20,9 +20,9 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | abstract class Mailcode_Variables_Collection |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var Mailcode_Variables_Variable[] |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * @var Mailcode_Variables_Variable[] |
|
| 25 | + */ |
|
| 26 | 26 | protected array $variables = array(); |
| 27 | 27 | |
| 28 | 28 | public function __construct() |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | return count($this->variables); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Checks whether the collection contains a variable with the specified name. |
|
| 57 | - * |
|
| 58 | - * @param string $fullName The variable name, with or without $ sign. |
|
| 59 | - * @return bool |
|
| 60 | - */ |
|
| 55 | + /** |
|
| 56 | + * Checks whether the collection contains a variable with the specified name. |
|
| 57 | + * |
|
| 58 | + * @param string $fullName The variable name, with or without $ sign. |
|
| 59 | + * @return bool |
|
| 60 | + */ |
|
| 61 | 61 | public function hasVariableName(string $fullName) : bool |
| 62 | 62 | { |
| 63 | 63 | $fullName = $this->fixName($fullName); |
@@ -73,14 +73,14 @@ discard block |
||
| 73 | 73 | return false; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Retrieves a collection of all variable instances for |
|
| 78 | - * the specified name (there can be several with differing |
|
| 79 | - * matched texts because of spacing). |
|
| 80 | - * |
|
| 81 | - * @param string $fullName |
|
| 82 | - * @return Mailcode_Variables_Collection |
|
| 83 | - */ |
|
| 76 | + /** |
|
| 77 | + * Retrieves a collection of all variable instances for |
|
| 78 | + * the specified name (there can be several with differing |
|
| 79 | + * matched texts because of spacing). |
|
| 80 | + * |
|
| 81 | + * @param string $fullName |
|
| 82 | + * @return Mailcode_Variables_Collection |
|
| 83 | + */ |
|
| 84 | 84 | public function getByFullName(string $fullName) : Mailcode_Variables_Collection |
| 85 | 85 | { |
| 86 | 86 | $fullName = $this->fixName($fullName); |
@@ -98,23 +98,23 @@ discard block |
||
| 98 | 98 | return $collection; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Prepends the $ sign to a variable name if it does not have it. |
|
| 103 | - * |
|
| 104 | - * @param string $fullName |
|
| 105 | - * @return string |
|
| 106 | - */ |
|
| 101 | + /** |
|
| 102 | + * Prepends the $ sign to a variable name if it does not have it. |
|
| 103 | + * |
|
| 104 | + * @param string $fullName |
|
| 105 | + * @return string |
|
| 106 | + */ |
|
| 107 | 107 | protected function fixName(string $fullName) : string |
| 108 | 108 | { |
| 109 | 109 | return dollarize($fullName); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * Retrieves all variables, grouped by their hash - meaning |
|
| 114 | - * unique matched strings. |
|
| 115 | - * |
|
| 116 | - * @return Mailcode_Variables_Variable[] |
|
| 117 | - */ |
|
| 112 | + /** |
|
| 113 | + * Retrieves all variables, grouped by their hash - meaning |
|
| 114 | + * unique matched strings. |
|
| 115 | + * |
|
| 116 | + * @return Mailcode_Variables_Variable[] |
|
| 117 | + */ |
|
| 118 | 118 | public function getGroupedByHash() : array |
| 119 | 119 | { |
| 120 | 120 | $entries = array(); |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | return $this->sortVariables($entries); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Retrieves all variables, grouped by their name. |
|
| 132 | - * |
|
| 133 | - * @return Mailcode_Variables_Variable[] |
|
| 134 | - */ |
|
| 130 | + /** |
|
| 131 | + * Retrieves all variables, grouped by their name. |
|
| 132 | + * |
|
| 133 | + * @return Mailcode_Variables_Variable[] |
|
| 134 | + */ |
|
| 135 | 135 | public function getGroupedByName() : array |
| 136 | 136 | { |
| 137 | 137 | $entries = array(); |
@@ -163,19 +163,19 @@ discard block |
||
| 163 | 163 | return $this->sortVariables($entries); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - /** |
|
| 167 | - * Retrieves all variables, in the order they were addded. |
|
| 168 | - * @return Mailcode_Variables_Variable[] |
|
| 169 | - */ |
|
| 166 | + /** |
|
| 167 | + * Retrieves all variables, in the order they were addded. |
|
| 168 | + * @return Mailcode_Variables_Variable[] |
|
| 169 | + */ |
|
| 170 | 170 | public function getAll() |
| 171 | 171 | { |
| 172 | 172 | return $this->variables; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * Retrieves the full names of the variables that are present in the collection. |
|
| 177 | - * @return string[] |
|
| 178 | - */ |
|
| 175 | + /** |
|
| 176 | + * Retrieves the full names of the variables that are present in the collection. |
|
| 177 | + * @return string[] |
|
| 178 | + */ |
|
| 179 | 179 | public function getNames() : array |
| 180 | 180 | { |
| 181 | 181 | $result = array(); |
@@ -193,13 +193,13 @@ discard block |
||
| 193 | 193 | return $result; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - /** |
|
| 197 | - * Takes a list of variables and sorts them, throwing away |
|
| 198 | - * the source array's keys. |
|
| 199 | - * |
|
| 200 | - * @param Mailcode_Variables_Variable[] $entries |
|
| 201 | - * @return Mailcode_Variables_Variable[] |
|
| 202 | - */ |
|
| 196 | + /** |
|
| 197 | + * Takes a list of variables and sorts them, throwing away |
|
| 198 | + * the source array's keys. |
|
| 199 | + * |
|
| 200 | + * @param Mailcode_Variables_Variable[] $entries |
|
| 201 | + * @return Mailcode_Variables_Variable[] |
|
| 202 | + */ |
|
| 203 | 203 | protected function sortVariables(array $entries) |
| 204 | 204 | { |
| 205 | 205 | $result = array_values($entries); |
@@ -212,13 +212,13 @@ discard block |
||
| 212 | 212 | return $result; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - /** |
|
| 216 | - * Merges the variables collection with the target collection |
|
| 217 | - * by inheriting all that collection's variables. |
|
| 218 | - * |
|
| 219 | - * @param Mailcode_Variables_Collection $collection |
|
| 220 | - * @return Mailcode_Variables_Collection |
|
| 221 | - */ |
|
| 215 | + /** |
|
| 216 | + * Merges the variables collection with the target collection |
|
| 217 | + * by inheriting all that collection's variables. |
|
| 218 | + * |
|
| 219 | + * @param Mailcode_Variables_Collection $collection |
|
| 220 | + * @return Mailcode_Variables_Collection |
|
| 221 | + */ |
|
| 222 | 222 | public function mergeWith(Mailcode_Variables_Collection $collection) : Mailcode_Variables_Collection |
| 223 | 223 | { |
| 224 | 224 | $variables = $collection->getGroupedByHash(); |
@@ -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 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | $entries = array(); |
| 121 | 121 | |
| 122 | - foreach($this->variables as $variable) |
|
| 122 | + foreach ($this->variables as $variable) |
|
| 123 | 123 | { |
| 124 | 124 | $entries[$variable->getHash()] = $variable; |
| 125 | 125 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | { |
| 137 | 137 | $entries = array(); |
| 138 | 138 | |
| 139 | - foreach($this->variables as $variable) |
|
| 139 | + foreach ($this->variables as $variable) |
|
| 140 | 140 | { |
| 141 | 141 | $entries[$variable->getFullName()] = $variable; |
| 142 | 142 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | { |
| 156 | 156 | $entries = array(); |
| 157 | 157 | |
| 158 | - foreach($this->variables as $variable) |
|
| 158 | + foreach ($this->variables as $variable) |
|
| 159 | 159 | { |
| 160 | 160 | $entries[$variable->getUniqueName()] = $variable; |
| 161 | 161 | } |
@@ -180,11 +180,11 @@ discard block |
||
| 180 | 180 | { |
| 181 | 181 | $result = array(); |
| 182 | 182 | |
| 183 | - foreach($this->variables as $variable) |
|
| 183 | + foreach ($this->variables as $variable) |
|
| 184 | 184 | { |
| 185 | 185 | $name = $variable->getFullName(); |
| 186 | 186 | |
| 187 | - if(!in_array($name, $result)) |
|
| 187 | + if (!in_array($name, $result)) |
|
| 188 | 188 | { |
| 189 | 189 | $result[] = $name; |
| 190 | 190 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | { |
| 224 | 224 | $variables = $collection->getGroupedByHash(); |
| 225 | 225 | |
| 226 | - foreach($variables as $variable) |
|
| 226 | + foreach ($variables as $variable) |
|
| 227 | 227 | { |
| 228 | 228 | $this->add($variable); |
| 229 | 229 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | { |
| 236 | 236 | $variables = $this->getAll(); |
| 237 | 237 | |
| 238 | - if(!empty($variables)) |
|
| 238 | + if (!empty($variables)) |
|
| 239 | 239 | { |
| 240 | 240 | return array_shift($variables); |
| 241 | 241 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | private ?Mailcode_Commands_Command $command; |
| 74 | 74 | |
| 75 | - public function __construct(string $path, string $name, string $matchedText, ?Mailcode_Commands_Command $sourceCommand=null) |
|
| 75 | + public function __construct(string $path, string $name, string $matchedText, ?Mailcode_Commands_Command $sourceCommand = null) |
|
| 76 | 76 | { |
| 77 | 77 | $this->path = $path; |
| 78 | 78 | $this->name = $name; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | public function getFullName() : string |
| 97 | 97 | { |
| 98 | - if(empty($this->path)) |
|
| 98 | + if (empty($this->path)) |
|
| 99 | 99 | { |
| 100 | 100 | return dollarize($this->name); |
| 101 | 101 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function getUniqueName() : string |
| 115 | 115 | { |
| 116 | - if(isset($this->command)) |
|
| 116 | + if (isset($this->command)) |
|
| 117 | 117 | { |
| 118 | 118 | return $this->getFullName().'/'.$this->command->getHash(); |
| 119 | 119 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | public function getHash() : string |
| 140 | 140 | { |
| 141 | - if(empty($this->hash)) |
|
| 141 | + if (empty($this->hash)) |
|
| 142 | 142 | { |
| 143 | 143 | $this->hash = md5($this->matchedText); |
| 144 | 144 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public function getValidationResult() : OperationResult |
| 159 | 159 | { |
| 160 | - if(isset($this->validationResult)) |
|
| 160 | + if (isset($this->validationResult)) |
|
| 161 | 161 | { |
| 162 | 162 | return $this->validationResult; |
| 163 | 163 | } |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | protected function validate(OperationResult $result) : void |
| 173 | 173 | { |
| 174 | - foreach($this->validations as $validation) |
|
| 174 | + foreach ($this->validations as $validation) |
|
| 175 | 175 | { |
| 176 | 176 | $method = 'validate_'.$validation; |
| 177 | 177 | |
| 178 | - if(!method_exists($this, $method)) |
|
| 178 | + if (!method_exists($this, $method)) |
|
| 179 | 179 | { |
| 180 | 180 | throw new Mailcode_Exception( |
| 181 | 181 | 'Unknown validation method', |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | protected function validateNumber(string $value, int $errorCode) : void |
| 222 | 222 | { |
| 223 | - if(!is_numeric(substr($value, 0, 1))) |
|
| 223 | + if (!is_numeric(substr($value, 0, 1))) |
|
| 224 | 224 | { |
| 225 | 225 | return; |
| 226 | 226 | } |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | protected function validateUnderscore(string $value, int $errorCode) : void |
| 239 | 239 | { |
| 240 | 240 | // allow empty paths |
| 241 | - if(empty($value)) |
|
| 241 | + if (empty($value)) |
|
| 242 | 242 | { |
| 243 | 243 | return; |
| 244 | 244 | } |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | $length = strlen($value); |
| 247 | 247 | |
| 248 | 248 | // trimming underscores does not change the length: no underscores at start or end of string. |
| 249 | - if(strlen(trim($value, '_')) === $length) |
|
| 249 | + if (strlen(trim($value, '_')) === $length) |
|
| 250 | 250 | { |
| 251 | 251 | return; |
| 252 | 252 | } |
@@ -225,27 +225,27 @@ |
||
| 225 | 225 | * @return array<string,string> |
| 226 | 226 | * @throws Mailcode_Exception |
| 227 | 227 | */ |
| 228 | - private function parseVarName() : array |
|
| 229 | - { |
|
| 230 | - $tokens = explode('.', undollarize($this->variable->getFullName())); |
|
| 231 | - |
|
| 232 | - if(count($tokens) === 2) |
|
| 233 | - { |
|
| 234 | - return array( |
|
| 235 | - 'path' => $tokens[0], |
|
| 236 | - 'name' => $tokens[1] |
|
| 237 | - ); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - throw new Mailcode_Exception( |
|
| 241 | - 'Invalid variable name for a list property.', |
|
| 242 | - sprintf( |
|
| 243 | - 'Exactly 2 parts are required, variable [%s] has [%s].', |
|
| 244 | - $this->variable->getFullName(), |
|
| 245 | - count($tokens) |
|
| 246 | - ), |
|
| 247 | - self::ERROR_INVALID_LIST_VARIABLE_NAME |
|
| 248 | - ); |
|
| 249 | - } |
|
| 228 | + private function parseVarName() : array |
|
| 229 | + { |
|
| 230 | + $tokens = explode('.', undollarize($this->variable->getFullName())); |
|
| 231 | + |
|
| 232 | + if(count($tokens) === 2) |
|
| 233 | + { |
|
| 234 | + return array( |
|
| 235 | + 'path' => $tokens[0], |
|
| 236 | + 'name' => $tokens[1] |
|
| 237 | + ); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + throw new Mailcode_Exception( |
|
| 241 | + 'Invalid variable name for a list property.', |
|
| 242 | + sprintf( |
|
| 243 | + 'Exactly 2 parts are required, variable [%s] has [%s].', |
|
| 244 | + $this->variable->getFullName(), |
|
| 245 | + count($tokens) |
|
| 246 | + ), |
|
| 247 | + self::ERROR_INVALID_LIST_VARIABLE_NAME |
|
| 248 | + ); |
|
| 249 | + } |
|
| 250 | 250 | } |
| 251 | 251 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function getSign() : string |
| 86 | 86 | { |
| 87 | - if($this->isNotContains()) |
|
| 87 | + if ($this->isNotContains()) |
|
| 88 | 88 | { |
| 89 | 89 | return '!'; |
| 90 | 90 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function getConnector() |
| 103 | 103 | { |
| 104 | - if($this->isNotContains()) |
|
| 104 | + if ($this->isNotContains()) |
|
| 105 | 105 | { |
| 106 | 106 | return '&&'; |
| 107 | 107 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | { |
| 118 | 118 | $parts = array(); |
| 119 | 119 | |
| 120 | - foreach($this->searchTerms as $token) |
|
| 120 | + foreach ($this->searchTerms as $token) |
|
| 121 | 121 | { |
| 122 | 122 | $parts[] = $this->renderCommand($token); |
| 123 | 123 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | private function renderCommand(Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral $searchTerm) : string |
| 134 | 134 | { |
| 135 | - if($this->isList()) |
|
| 135 | + if ($this->isList()) |
|
| 136 | 136 | { |
| 137 | 137 | $command = $this->renderListCommand($searchTerm); |
| 138 | 138 | } |
@@ -173,14 +173,14 @@ discard block |
||
| 173 | 173 | private function renderRegex(Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral $searchTerm) : string |
| 174 | 174 | { |
| 175 | 175 | $opts = 's'; |
| 176 | - if($this->caseSensitive) |
|
| 176 | + if ($this->caseSensitive) |
|
| 177 | 177 | { |
| 178 | 178 | $opts = 'is'; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | $filtered = trim($searchTerm->getNormalized(), '"'); |
| 182 | 182 | |
| 183 | - if(!$this->regexEnabled) |
|
| 183 | + if (!$this->regexEnabled) |
|
| 184 | 184 | { |
| 185 | 185 | $filtered = $this->translator->filterRegexString($filtered); |
| 186 | 186 | $filtered = $this->addWildcards($filtered); |
@@ -203,17 +203,17 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | private function addWildcards(string $searchTerm) : string |
| 205 | 205 | { |
| 206 | - if($this->containsType === 'list-begins-with') |
|
| 206 | + if ($this->containsType === 'list-begins-with') |
|
| 207 | 207 | { |
| 208 | 208 | return $searchTerm.'.*'; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - if($this->containsType === 'list-ends-with') |
|
| 211 | + if ($this->containsType === 'list-ends-with') |
|
| 212 | 212 | { |
| 213 | 213 | return '.*'.$searchTerm; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if($this->containsType === 'list-equals') |
|
| 216 | + if ($this->containsType === 'list-equals') |
|
| 217 | 217 | { |
| 218 | 218 | return '\\\A'.$searchTerm.'\\\Z'; |
| 219 | 219 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | { |
| 230 | 230 | $tokens = explode('.', undollarize($this->variable->getFullName())); |
| 231 | 231 | |
| 232 | - if(count($tokens) === 2) |
|
| 232 | + if (count($tokens) === 2) |
|
| 233 | 233 | { |
| 234 | 234 | return array( |
| 235 | 235 | 'path' => $tokens[0], |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | { |
| 30 | 30 | $varName = undollarize($command->getVariableName()); |
| 31 | 31 | |
| 32 | - if($command->isHTMLEnabled()) |
|
| 32 | + if ($command->isHTMLEnabled()) |
|
| 33 | 33 | { |
| 34 | 34 | $statement = sprintf( |
| 35 | 35 | '%s.replaceAll($esc.newline, "<br/>")', |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | // All other special characters have to be escaped |
| 73 | 73 | // with two backslashes. |
| 74 | - foreach($this->regexSpecialChars as $char) |
|
| 74 | + foreach ($this->regexSpecialChars as $char) |
|
| 75 | 75 | { |
| 76 | 76 | $string = str_replace($char, '\\'.$char, $string); |
| 77 | 77 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | $varName = dollarize($varName); |
| 101 | 101 | |
| 102 | - if($absolute) |
|
| 102 | + if ($absolute) |
|
| 103 | 103 | { |
| 104 | 104 | $varName = sprintf('${numeric.abs(%s)}', $varName); |
| 105 | 105 | } |
@@ -34,21 +34,21 @@ discard block |
||
| 34 | 34 | * @param Mailcode_Commands_Command|null $sourceCommand |
| 35 | 35 | * @return Mailcode_Variables_Collection_Regular |
| 36 | 36 | */ |
| 37 | - public function parseString(string $subject, ?Mailcode_Commands_Command $sourceCommand=null) : Mailcode_Variables_Collection_Regular |
|
| 37 | + public function parseString(string $subject, ?Mailcode_Commands_Command $sourceCommand = null) : Mailcode_Variables_Collection_Regular |
|
| 38 | 38 | { |
| 39 | 39 | $this->collection = new Mailcode_Variables_Collection_Regular(); |
| 40 | 40 | |
| 41 | 41 | $matches = array(); |
| 42 | 42 | preg_match_all(self::REGEX_VARIABLE_NAME, $subject, $matches, PREG_PATTERN_ORDER); |
| 43 | 43 | |
| 44 | - if(empty($matches[0])) |
|
| 44 | + if (empty($matches[0])) |
|
| 45 | 45 | { |
| 46 | 46 | return $this->collection; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - foreach($matches[0] as $idx => $matchedText) |
|
| 49 | + foreach ($matches[0] as $idx => $matchedText) |
|
| 50 | 50 | { |
| 51 | - if(!empty($matches[3][$idx])) |
|
| 51 | + if (!empty($matches[3][$idx])) |
|
| 52 | 52 | { |
| 53 | 53 | $this->addSingle($matches[3][$idx], $matchedText, $sourceCommand); |
| 54 | 54 | } |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | return $this->collection; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - protected function addSingle(string $name, string $matchedText, ?Mailcode_Commands_Command $sourceCommand=null) : void |
|
| 64 | + protected function addSingle(string $name, string $matchedText, ?Mailcode_Commands_Command $sourceCommand = null) : void |
|
| 65 | 65 | { |
| 66 | 66 | // ignore US style numbers like $451 |
| 67 | - if(is_numeric($name)) |
|
| 67 | + if (is_numeric($name)) |
|
| 68 | 68 | { |
| 69 | 69 | return; |
| 70 | 70 | } |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | $this->collection->add(new Mailcode_Variables_Variable('', $name, $matchedText, $sourceCommand)); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - protected function addPathed(string $path, string $name, string $matchedText, ?Mailcode_Commands_Command $sourceCommand=null) : void |
|
| 75 | + protected function addPathed(string $path, string $name, string $matchedText, ?Mailcode_Commands_Command $sourceCommand = null) : void |
|
| 76 | 76 | { |
| 77 | 77 | // ignore US style numbers like $45.12 |
| 78 | - if(is_numeric($path.'.'.$name)) |
|
| 78 | + if (is_numeric($path.'.'.$name)) |
|
| 79 | 79 | { |
| 80 | 80 | return; |
| 81 | 81 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | // Split the variable name by the dot |
| 45 | 45 | $parts = explode('.', undollarize($var->getFullName())); |
| 46 | 46 | |
| 47 | - if(count($parts) !== 2) |
|
| 47 | + if (count($parts) !== 2) |
|
| 48 | 48 | { |
| 49 | 49 | $this->validationResult->makeError( |
| 50 | 50 | t('The variable %1$s is not a list property:', '<code>'.$var->getFullName().'</code>').' '. |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function getListVariable() : Mailcode_Variables_Variable |
| 78 | 78 | { |
| 79 | - if(isset($this->listVariable)) |
|
| 79 | + if (isset($this->listVariable)) |
|
| 80 | 80 | { |
| 81 | 81 | return $this->listVariable; |
| 82 | 82 | } |
@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $val = $this->validator->createKeyword(Mailcode_Commands_Keywords::TYPE_BREAK_AT); |
| 45 | 45 | |
| 46 | - $this->breakAtEnabled = $val->isValid() && $this->breakAtToken != null;; |
|
| 46 | + $this->breakAtEnabled = $val->isValid() && $this->breakAtToken != null; ; |
|
| 47 | 47 | |
| 48 | 48 | if ($this->breakAtEnabled) { |
| 49 | 49 | if (!$this->breakAtToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number && |
| 50 | 50 | !$this->breakAtToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) { |
| 51 | 51 | $this->validationResult->makeError( |
| 52 | - t('Invalid break-at type.' . ' ' . 'Expected Number or Variable.'), |
|
| 52 | + t('Invalid break-at type.'.' '.'Expected Number or Variable.'), |
|
| 53 | 53 | BreakAtInterface::VALIDATION_BREAK_AT_CODE_WRONG_TYPE |
| 54 | 54 | ); |
| 55 | 55 | return; |
@@ -73,19 +73,19 @@ discard block |
||
| 73 | 73 | public function getBreakAt() |
| 74 | 74 | { |
| 75 | 75 | $token = $this->getBreakAtToken(); |
| 76 | - if($token === null) { |
|
| 76 | + if ($token === null) { |
|
| 77 | 77 | return null; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) { |
|
| 80 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Variable) { |
|
| 81 | 81 | return $token->getVariable(); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number) { |
|
| 84 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_Number) { |
|
| 85 | 85 | return (int)$token->getValue(); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) { |
|
| 88 | + if ($token instanceof Mailcode_Parser_Statement_Tokenizer_Token_StringLiteral) { |
|
| 89 | 89 | return (int)$token->getText(); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -59,12 +59,12 @@ |
||
| 59 | 59 | * @throws Mailcode_Exception |
| 60 | 60 | * @throws Mailcode_Factory_Exception |
| 61 | 61 | */ |
| 62 | - public function for(string $sourceVariable, string $loopVariable, $breakAtValue = ''): Mailcode_Commands_Command_For |
|
| 62 | + public function for (string $sourceVariable, string $loopVariable, $breakAtValue = ''): Mailcode_Commands_Command_For |
|
| 63 | 63 | { |
| 64 | 64 | $sourceVariable = dollarize($sourceVariable); |
| 65 | 65 | $loopVariable = dollarize($loopVariable); |
| 66 | 66 | |
| 67 | - if($breakAtValue instanceof Mailcode_Variables_Variable) { |
|
| 67 | + if ($breakAtValue instanceof Mailcode_Variables_Variable) { |
|
| 68 | 68 | $breakAtValue = $breakAtValue->getFullName(); |
| 69 | 69 | } |
| 70 | 70 | |