@@ -23,25 +23,25 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | trait Mailcode_Traits_Formatting_HTMLHighlighting |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * Stored this way so we can use isset() instead |
|
| 28 | - * of using in_array, which is some magnitudes slower. |
|
| 29 | - * The boolean value is not used otherwise. |
|
| 30 | - * |
|
| 31 | - * @var array<string,bool> |
|
| 32 | - */ |
|
| 26 | + /** |
|
| 27 | + * Stored this way so we can use isset() instead |
|
| 28 | + * of using in_array, which is some magnitudes slower. |
|
| 29 | + * The boolean value is not used otherwise. |
|
| 30 | + * |
|
| 31 | + * @var array<string,bool> |
|
| 32 | + */ |
|
| 33 | 33 | private $excludeTags = array( |
| 34 | 34 | 'style' => true, // NOTE: style tags are excluded natively on the parser level. |
| 35 | 35 | 'script' => true |
| 36 | 36 | ); |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Adds an HTML tag name to the list of tags within which |
|
| 40 | - * commands may not be highlighted. |
|
| 41 | - * |
|
| 42 | - * @param string $tagName Case insensitive. |
|
| 43 | - * @return $this |
|
| 44 | - */ |
|
| 38 | + /** |
|
| 39 | + * Adds an HTML tag name to the list of tags within which |
|
| 40 | + * commands may not be highlighted. |
|
| 41 | + * |
|
| 42 | + * @param string $tagName Case insensitive. |
|
| 43 | + * @return $this |
|
| 44 | + */ |
|
| 45 | 45 | public function excludeTag(string $tagName) |
| 46 | 46 | { |
| 47 | 47 | $tagName = strtolower($tagName); |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | return $this; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Adds several exluded tag names at once. |
|
| 56 | - * |
|
| 57 | - * @param string[] $tagNames |
|
| 58 | - * @return $this |
|
| 59 | - */ |
|
| 54 | + /** |
|
| 55 | + * Adds several exluded tag names at once. |
|
| 56 | + * |
|
| 57 | + * @param string[] $tagNames |
|
| 58 | + * @return $this |
|
| 59 | + */ |
|
| 60 | 60 | public function excludeTags(array $tagNames) |
| 61 | 61 | { |
| 62 | 62 | foreach($tagNames as $tagName) |
@@ -67,12 +67,12 @@ discard block |
||
| 67 | 67 | return $this; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Whether the specified tag name is in the exlusion list. |
|
| 72 | - * |
|
| 73 | - * @param string $tagName |
|
| 74 | - * @return bool |
|
| 75 | - */ |
|
| 70 | + /** |
|
| 71 | + * Whether the specified tag name is in the exlusion list. |
|
| 72 | + * |
|
| 73 | + * @param string $tagName |
|
| 74 | + * @return bool |
|
| 75 | + */ |
|
| 76 | 76 | public function isTagExcluded(string $tagName) : bool |
| 77 | 77 | { |
| 78 | 78 | $tagName = strtolower($tagName); |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | */ |
| 60 | 60 | public function excludeTags(array $tagNames) |
| 61 | 61 | { |
| 62 | - foreach($tagNames as $tagName) |
|
| 62 | + foreach ($tagNames as $tagName) |
|
| 63 | 63 | { |
| 64 | 64 | $this->excludeTag((string)$tagName); |
| 65 | 65 | } |
@@ -26,14 +26,14 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | trait Mailcode_Traits_Commands_Validation_CaseSensitive |
| 28 | 28 | { |
| 29 | - /** |
|
| 30 | - * @var boolean |
|
| 31 | - */ |
|
| 29 | + /** |
|
| 30 | + * @var boolean |
|
| 31 | + */ |
|
| 32 | 32 | protected $caseInsensitive = false; |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @var Mailcode_Parser_Statement_Tokenizer_Token_Keyword|NULL |
|
| 36 | - */ |
|
| 34 | + /** |
|
| 35 | + * @var Mailcode_Parser_Statement_Tokenizer_Token_Keyword|NULL |
|
| 36 | + */ |
|
| 37 | 37 | protected $regexToken; |
| 38 | 38 | |
| 39 | 39 | protected function validateSyntax_case_sensitive() : void |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $this->caseInsensitive = $val->isValid(); |
| 44 | 44 | |
| 45 | - if($val->isValid()) |
|
| 45 | + if ($val->isValid()) |
|
| 46 | 46 | { |
| 47 | 47 | $this->regexToken = $val->getToken(); |
| 48 | 48 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | public function getCaseToken() : ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword |
| 57 | 57 | { |
| 58 | - if($this->regexToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 58 | + if ($this->regexToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 59 | 59 | { |
| 60 | 60 | return $this->regexToken; |
| 61 | 61 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $this->regexEnabled = $val->isValid(); |
| 44 | 44 | |
| 45 | - if($val->isValid()) |
|
| 45 | + if ($val->isValid()) |
|
| 46 | 46 | { |
| 47 | 47 | $this->regexToken = $val->getToken(); |
| 48 | 48 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | public function getRegexToken() : ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword |
| 57 | 57 | { |
| 58 | - if($this->regexToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 58 | + if ($this->regexToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 59 | 59 | { |
| 60 | 60 | return $this->regexToken; |
| 61 | 61 | } |
@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | class Mailcode_Parser_Statement_Validator |
| 30 | 30 | { |
| 31 | - /** |
|
| 32 | - * @var Mailcode_Parser_Statement |
|
| 33 | - */ |
|
| 31 | + /** |
|
| 32 | + * @var Mailcode_Parser_Statement |
|
| 33 | + */ |
|
| 34 | 34 | private $statement; |
| 35 | 35 | |
| 36 | 36 | public function __construct(Mailcode_Parser_Statement $statement) |
@@ -38,24 +38,24 @@ discard block |
||
| 38 | 38 | $this->statement = $statement; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Creates a variable validator: checks whether a single |
|
| 43 | - * variable token is present in the parameters. |
|
| 44 | - * |
|
| 45 | - * @return Mailcode_Parser_Statement_Validator_Type_Variable |
|
| 46 | - */ |
|
| 41 | + /** |
|
| 42 | + * Creates a variable validator: checks whether a single |
|
| 43 | + * variable token is present in the parameters. |
|
| 44 | + * |
|
| 45 | + * @return Mailcode_Parser_Statement_Validator_Type_Variable |
|
| 46 | + */ |
|
| 47 | 47 | public function createVariable() : Mailcode_Parser_Statement_Validator_Type_Variable |
| 48 | 48 | { |
| 49 | 49 | return new Mailcode_Parser_Statement_Validator_Type_Variable($this->statement); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Creates a keyword validator: checks whether a single |
|
| 54 | - * keyword token is present in the parameters. |
|
| 55 | - * |
|
| 56 | - * @param string $keywordName |
|
| 57 | - * @return Mailcode_Parser_Statement_Validator_Type_Keyword |
|
| 58 | - */ |
|
| 52 | + /** |
|
| 53 | + * Creates a keyword validator: checks whether a single |
|
| 54 | + * keyword token is present in the parameters. |
|
| 55 | + * |
|
| 56 | + * @param string $keywordName |
|
| 57 | + * @return Mailcode_Parser_Statement_Validator_Type_Keyword |
|
| 58 | + */ |
|
| 59 | 59 | public function createKeyword(string $keywordName) : Mailcode_Parser_Statement_Validator_Type_Keyword |
| 60 | 60 | { |
| 61 | 61 | return new Mailcode_Parser_Statement_Validator_Type_Keyword( |
@@ -74,11 +74,11 @@ |
||
| 74 | 74 | return new Mailcode_Parser_Statement_Validator_Type_Value($this->statement); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - public function createOperand(string $sign='') : Mailcode_Parser_Statement_Validator_Type_Operand |
|
| 77 | + public function createOperand(string $sign = '') : Mailcode_Parser_Statement_Validator_Type_Operand |
|
| 78 | 78 | { |
| 79 | 79 | $validate = new Mailcode_Parser_Statement_Validator_Type_Operand($this->statement); |
| 80 | 80 | |
| 81 | - if(!empty($sign)) |
|
| 81 | + if (!empty($sign)) |
|
| 82 | 82 | { |
| 83 | 83 | $validate->setOperandSign($sign); |
| 84 | 84 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $this->instantiator->checkCommand($cmd); |
| 42 | 42 | |
| 43 | - if($cmd instanceof Mailcode_Commands_Command_Comment) |
|
| 43 | + if ($cmd instanceof Mailcode_Commands_Command_Comment) |
|
| 44 | 44 | { |
| 45 | 45 | return $cmd; |
| 46 | 46 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @throws Mailcode_Exception |
| 58 | 58 | * @throws Mailcode_Factory_Exception |
| 59 | 59 | */ |
| 60 | - public function for(string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For |
|
| 60 | + public function for (string $sourceVariable, string $loopVariable) : Mailcode_Commands_Command_For |
|
| 61 | 61 | { |
| 62 | 62 | $sourceVariable = '$'.ltrim($sourceVariable, '$'); |
| 63 | 63 | $loopVariable = '$'.ltrim($loopVariable, '$'); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | $this->instantiator->checkCommand($cmd); |
| 81 | 81 | |
| 82 | - if($cmd instanceof Mailcode_Commands_Command_For) |
|
| 82 | + if ($cmd instanceof Mailcode_Commands_Command_For) |
|
| 83 | 83 | { |
| 84 | 84 | return $cmd; |
| 85 | 85 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | $this->instantiator->checkCommand($cmd); |
| 109 | 109 | |
| 110 | - if($cmd instanceof Mailcode_Commands_Command_Break) |
|
| 110 | + if ($cmd instanceof Mailcode_Commands_Command_Break) |
|
| 111 | 111 | { |
| 112 | 112 | return $cmd; |
| 113 | 113 | } |
@@ -127,17 +127,17 @@ discard block |
||
| 127 | 127 | * @throws Mailcode_Exception |
| 128 | 128 | * @throws Mailcode_Factory_Exception |
| 129 | 129 | */ |
| 130 | - public function mono(bool $multiline=false, array $classes=array()) : Mailcode_Commands_Command_Mono |
|
| 130 | + public function mono(bool $multiline = false, array $classes = array()) : Mailcode_Commands_Command_Mono |
|
| 131 | 131 | { |
| 132 | 132 | $params = ''; |
| 133 | 133 | $source = '{code'; |
| 134 | 134 | |
| 135 | - if($multiline) { |
|
| 135 | + if ($multiline) { |
|
| 136 | 136 | $params = 'multiline:'; |
| 137 | 137 | $source = '{code: multiline:'; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if(!empty($classes)) { |
|
| 140 | + if (!empty($classes)) { |
|
| 141 | 141 | $classString = sprintf('"%s"', implode(' ', $classes)); |
| 142 | 142 | $params .= $classString; |
| 143 | 143 | $source .= $classString; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | $this->instantiator->checkCommand($cmd); |
| 156 | 156 | |
| 157 | - if($cmd instanceof Mailcode_Commands_Command_Mono) |
|
| 157 | + if ($cmd instanceof Mailcode_Commands_Command_Mono) |
|
| 158 | 158 | { |
| 159 | 159 | return $cmd; |
| 160 | 160 | } |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | $this->instantiator->checkCommand($cmd); |
| 181 | 181 | |
| 182 | - if($cmd instanceof Mailcode_Commands_Command_Code) |
|
| 182 | + if ($cmd instanceof Mailcode_Commands_Command_Code) |
|
| 183 | 183 | { |
| 184 | 184 | return $cmd; |
| 185 | 185 | } |
@@ -26,14 +26,14 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | trait Mailcode_Traits_Commands_Validation_Multiline |
| 28 | 28 | { |
| 29 | - /** |
|
| 30 | - * @var boolean |
|
| 31 | - */ |
|
| 29 | + /** |
|
| 30 | + * @var boolean |
|
| 31 | + */ |
|
| 32 | 32 | protected $multiline = false; |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @var Mailcode_Parser_Statement_Tokenizer_Token_Keyword|NULL |
|
| 36 | - */ |
|
| 34 | + /** |
|
| 35 | + * @var Mailcode_Parser_Statement_Tokenizer_Token_Keyword|NULL |
|
| 36 | + */ |
|
| 37 | 37 | protected $multilineToken; |
| 38 | 38 | |
| 39 | 39 | protected function validateSyntax_multiline() : void |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $this->multiline = $val->isValid(); |
| 44 | 44 | |
| 45 | - if($val->isValid()) |
|
| 45 | + if ($val->isValid()) |
|
| 46 | 46 | { |
| 47 | 47 | $this->multilineToken = $val->getToken(); |
| 48 | 48 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | public function getMultilineToken() : ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword |
| 57 | 57 | { |
| 58 | - if($this->multilineToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 58 | + if ($this->multilineToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Keyword) |
|
| 59 | 59 | { |
| 60 | 60 | return $this->multilineToken; |
| 61 | 61 | } |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | $this |
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | - if(!$this->params->isValid() && $this->requiresParameters()) |
|
| 44 | + if (!$this->params->isValid() && $this->requiresParameters()) |
|
| 45 | 45 | { |
| 46 | 46 | $error = $this->params->getValidationResult(); |
| 47 | 47 | |
@@ -40,15 +40,15 @@ |
||
| 40 | 40 | { |
| 41 | 41 | $opening = $this->getOpeningCommand(); |
| 42 | 42 | |
| 43 | - if($opening === null) { |
|
| 43 | + if ($opening === null) { |
|
| 44 | 44 | return array(); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $siblings = $opening->getSiblingCommands(); |
| 48 | 48 | $result = array(); |
| 49 | - foreach($siblings as $sibling) |
|
| 49 | + foreach ($siblings as $sibling) |
|
| 50 | 50 | { |
| 51 | - if($sibling !== $this) { |
|
| 51 | + if ($sibling !== $this) { |
|
| 52 | 52 | $result[] = $sibling; |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | $commands = $this->collection->getCommands(); |
| 62 | 62 | |
| 63 | - foreach($commands as $command) |
|
| 63 | + foreach ($commands as $command) |
|
| 64 | 64 | { |
| 65 | 65 | $method = 'validate_'.$command->getCommandType(); |
| 66 | 66 | |
| 67 | - if(!method_exists($this, $method)) |
|
| 67 | + if (!method_exists($this, $method)) |
|
| 68 | 68 | { |
| 69 | 69 | throw new Mailcode_Exception( |
| 70 | 70 | 'Unknown command type validation method.', |
@@ -79,13 +79,13 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | $this->$method($command); |
| 81 | 81 | |
| 82 | - if(!$this->validationResult->isValid()) |
|
| 82 | + if (!$this->validationResult->isValid()) |
|
| 83 | 83 | { |
| 84 | 84 | break; |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if($this->validationResult->isValid()) |
|
| 88 | + if ($this->validationResult->isValid()) |
|
| 89 | 89 | { |
| 90 | 90 | $this->validate_Unclosed(); |
| 91 | 91 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | $leftover = $this->getOpenCommand(); |
| 99 | 99 | |
| 100 | - if($leftover === null) |
|
| 100 | + if ($leftover === null) |
|
| 101 | 101 | { |
| 102 | 102 | return; |
| 103 | 103 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | protected function getOpenCommand() : ?Mailcode_Commands_Command_Type_Opening |
| 115 | 115 | { |
| 116 | - if(empty($this->stack)) |
|
| 116 | + if (empty($this->stack)) |
|
| 117 | 117 | { |
| 118 | 118 | return null; |
| 119 | 119 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $cmd = $this->stack[$idx]; |
| 126 | 126 | |
| 127 | - if($cmd instanceof Mailcode_Commands_Command_Type_Opening) |
|
| 127 | + if ($cmd instanceof Mailcode_Commands_Command_Type_Opening) |
|
| 128 | 128 | { |
| 129 | 129 | return $cmd; |
| 130 | 130 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | { |
| 149 | 149 | $parent = $this->getOpenCommand(); |
| 150 | 150 | |
| 151 | - if($parent === null) |
|
| 151 | + if ($parent === null) |
|
| 152 | 152 | { |
| 153 | 153 | $this->validationResult->makeError( |
| 154 | 154 | t( |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | return; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if($parent->getName() !== $command->getParentName()) |
|
| 165 | + if ($parent->getName() !== $command->getParentName()) |
|
| 166 | 166 | { |
| 167 | 167 | $this->validationResult->makeError( |
| 168 | 168 | t( |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | protected function validate_Closing(Mailcode_Commands_Command_Type_Closing $command) : void |
| 186 | 186 | { |
| 187 | - if(empty($this->stack)) |
|
| 187 | + if (empty($this->stack)) |
|
| 188 | 188 | { |
| 189 | 189 | $this->validationResult->makeError( |
| 190 | 190 | t('All open commands have already been ended.'), |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | $openingCommand = array_pop($this->stack); |
| 198 | 198 | |
| 199 | - if($openingCommand instanceof Mailcode_Commands_Command_Type_Opening) |
|
| 199 | + if ($openingCommand instanceof Mailcode_Commands_Command_Type_Opening) |
|
| 200 | 200 | { |
| 201 | 201 | $this->log(sprintf('Closing command %s', $openingCommand->getName())); |
| 202 | 202 | |
@@ -30,19 +30,19 @@ |
||
| 30 | 30 | public const VALIDATION_UNCLOSED_COMMAND = 49104; |
| 31 | 31 | public const VALIDATION_CLOSING_NON_OPENING_COMMAND = 49105; |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var Mailcode_Collection |
|
| 35 | - */ |
|
| 33 | + /** |
|
| 34 | + * @var Mailcode_Collection |
|
| 35 | + */ |
|
| 36 | 36 | protected $collection; |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var OperationResult |
|
| 40 | - */ |
|
| 38 | + /** |
|
| 39 | + * @var OperationResult |
|
| 40 | + */ |
|
| 41 | 41 | protected $validationResult; |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @var Mailcode_Commands_Command_Type[] |
|
| 45 | - */ |
|
| 43 | + /** |
|
| 44 | + * @var Mailcode_Commands_Command_Type[] |
|
| 45 | + */ |
|
| 46 | 46 | protected $stack = array(); |
| 47 | 47 | |
| 48 | 48 | public function __construct(Mailcode_Collection $collection) |