@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | */ |
26 | 26 | trait Mailcode_Traits_Commands_Validation_Operand |
27 | 27 | { |
28 | - /** |
|
29 | - * @var Mailcode_Parser_Statement_Tokenizer_Token_Operand|NULL |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var Mailcode_Parser_Statement_Tokenizer_Token_Operand|NULL |
|
30 | + */ |
|
31 | 31 | protected $operandToken; |
32 | 32 | |
33 | - /** |
|
34 | - * @return string[] |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @return string[] |
|
35 | + */ |
|
36 | 36 | abstract protected function getAllowedOperands() : array; |
37 | 37 | |
38 | 38 | protected function validateSyntax_operand() : void |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | ); |
79 | 79 | } |
80 | 80 | |
81 | - /** |
|
82 | - * Retrieves the operand sign. |
|
83 | - * |
|
84 | - * @return string |
|
85 | - */ |
|
81 | + /** |
|
82 | + * Retrieves the operand sign. |
|
83 | + * |
|
84 | + * @return string |
|
85 | + */ |
|
86 | 86 | public function getSign() : string |
87 | 87 | { |
88 | 88 | return $this->getOperand()->getSign(); |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | { |
40 | 40 | $var = $this->validator->createOperand(); |
41 | 41 | |
42 | - if($var->isValid()) |
|
42 | + if ($var->isValid()) |
|
43 | 43 | { |
44 | - if(in_array($var->getSign(), $this->getAllowedOperands())) |
|
44 | + if (in_array($var->getSign(), $this->getAllowedOperands())) |
|
45 | 45 | { |
46 | 46 | $this->operandToken = $var->getToken(); |
47 | 47 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | public function getOperand() : Mailcode_Parser_Statement_Tokenizer_Token_Operand |
68 | 68 | { |
69 | - if($this->operandToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand) |
|
69 | + if ($this->operandToken instanceof Mailcode_Parser_Statement_Tokenizer_Token_Operand) |
|
70 | 70 | { |
71 | 71 | return $this->operandToken; |
72 | 72 | } |
@@ -44,8 +44,7 @@ discard block |
||
44 | 44 | if(in_array($var->getSign(), $this->getAllowedOperands())) |
45 | 45 | { |
46 | 46 | $this->operandToken = $var->getToken(); |
47 | - } |
|
48 | - else |
|
47 | + } else |
|
49 | 48 | { |
50 | 49 | $this->validationResult->makeError( |
51 | 50 | t('Invalid operand %1$s.', $var->getSign()).' '. |
@@ -54,8 +53,7 @@ discard block |
||
54 | 53 | Mailcode_Commands_CommonConstants::VALIDATION_INVALID_OPERAND |
55 | 54 | ); |
56 | 55 | } |
57 | - } |
|
58 | - else |
|
56 | + } else |
|
59 | 57 | { |
60 | 58 | $this->validationResult->makeError( |
61 | 59 | t('No operand has been specified.'), |
@@ -36,8 +36,7 @@ |
||
36 | 36 | if($var->isValid()) |
37 | 37 | { |
38 | 38 | $this->variableToken = $var->getToken(); |
39 | - } |
|
40 | - else |
|
39 | + } else |
|
41 | 40 | { |
42 | 41 | $this->validationResult->makeError( |
43 | 42 | t('No variable has been specified.'), |
@@ -24,9 +24,9 @@ |
||
24 | 24 | */ |
25 | 25 | trait Mailcode_Traits_Commands_Validation_Variable |
26 | 26 | { |
27 | - /** |
|
28 | - * @var Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var Mailcode_Parser_Statement_Tokenizer_Token_Variable|NULL |
|
29 | + */ |
|
30 | 30 | protected $variableToken; |
31 | 31 | |
32 | 32 | protected function validateSyntax_variable() : void |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | { |
34 | 34 | $var = $this->validator->createVariable(); |
35 | 35 | |
36 | - if($var->isValid()) |
|
36 | + if ($var->isValid()) |
|
37 | 37 | { |
38 | 38 | $this->variableToken = $var->getToken(); |
39 | 39 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | public function getVariableToken() : Mailcode_Parser_Statement_Tokenizer_Token_Variable |
50 | 50 | { |
51 | - if(isset($this->variableToken)) |
|
51 | + if (isset($this->variableToken)) |
|
52 | 52 | { |
53 | 53 | return $this->variableToken; |
54 | 54 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function getVariable() : Mailcode_Variables_Variable |
70 | 70 | { |
71 | - if(isset($this->variableToken)) |
|
71 | + if (isset($this->variableToken)) |
|
72 | 72 | { |
73 | 73 | return $this->variableToken->getVariable(); |
74 | 74 | } |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | { |
117 | 117 | $parent = $subject->getParent(); |
118 | 118 | |
119 | - if($parent === null) |
|
119 | + if ($parent === null) |
|
120 | 120 | { |
121 | 121 | return null; |
122 | 122 | } |
123 | 123 | |
124 | - if($parent instanceof Mailcode_Commands_Command_For) |
|
124 | + if ($parent instanceof Mailcode_Commands_Command_For) |
|
125 | 125 | { |
126 | 126 | return $parent; |
127 | 127 | } |
@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class Mailcode_Parser_Statement_Info_Pruner |
24 | 24 | { |
25 | - /** |
|
26 | - * @var Mailcode_Parser_Statement_Info |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var Mailcode_Parser_Statement_Info |
|
27 | + */ |
|
28 | 28 | private $info; |
29 | 29 | |
30 | - /** |
|
31 | - * @var string[] |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var string[] |
|
32 | + */ |
|
33 | 33 | private $exclude = array(); |
34 | 34 | |
35 | - /** |
|
36 | - * @var string[] |
|
37 | - */ |
|
35 | + /** |
|
36 | + * @var string[] |
|
37 | + */ |
|
38 | 38 | private $classNames = array(); |
39 | 39 | |
40 | 40 | public function __construct(Mailcode_Parser_Statement_Info $info) |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | return $this; |
75 | 75 | } |
76 | 76 | |
77 | - /** |
|
78 | - * Retrieves all tokens in the statement matching the |
|
79 | - * current criteria. |
|
80 | - * |
|
81 | - * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
82 | - */ |
|
77 | + /** |
|
78 | + * Retrieves all tokens in the statement matching the |
|
79 | + * current criteria. |
|
80 | + * |
|
81 | + * @return Mailcode_Parser_Statement_Tokenizer_Token[] |
|
82 | + */ |
|
83 | 83 | public function getTokens() : array |
84 | 84 | { |
85 | 85 | $tokens = $this->info->getTokens(); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | $id = $token->getID(); |
48 | 48 | |
49 | - if(!in_array($id, $this->exclude)) |
|
49 | + if (!in_array($id, $this->exclude)) |
|
50 | 50 | { |
51 | 51 | $this->exclude[] = $id; |
52 | 52 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | public function limitByClassName(string $className) : Mailcode_Parser_Statement_Info_Pruner |
68 | 68 | { |
69 | - if(!in_array($className, $this->classNames)) |
|
69 | + if (!in_array($className, $this->classNames)) |
|
70 | 70 | { |
71 | 71 | $this->classNames[] = $className; |
72 | 72 | } |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | $tokens = $this->info->getTokens(); |
86 | 86 | $keep = array(); |
87 | 87 | |
88 | - foreach($tokens as $token) |
|
88 | + foreach ($tokens as $token) |
|
89 | 89 | { |
90 | - if(in_array($token->getID(), $this->exclude)) |
|
90 | + if (in_array($token->getID(), $this->exclude)) |
|
91 | 91 | { |
92 | 92 | continue; |
93 | 93 | } |
@@ -20,9 +20,9 @@ |
||
20 | 20 | */ |
21 | 21 | class Mailcode_Commands_Command_Comment extends Mailcode_Commands_Command implements Mailcode_Commands_Command_Type_Standalone |
22 | 22 | { |
23 | - /** |
|
24 | - * @var string |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var string |
|
25 | + */ |
|
26 | 26 | private $commentString = ''; |
27 | 27 | |
28 | 28 | protected function init() : void |
@@ -80,7 +80,7 @@ |
||
80 | 80 | |
81 | 81 | protected function validateSyntax_comment() : void |
82 | 82 | { |
83 | - if(empty($this->commentString)) |
|
83 | + if (empty($this->commentString)) |
|
84 | 84 | { |
85 | 85 | $this->validationResult->makeError( |
86 | 86 | t('The comment text ist empty.'), |
@@ -35,13 +35,13 @@ |
||
35 | 35 | } |
36 | 36 | } |
37 | 37 | |
38 | - /** |
|
39 | - * Resolves the string with which this location needs to be |
|
40 | - * replaced. |
|
41 | - * |
|
42 | - * @param Mailcode_Parser_Safeguard_Formatter_Location $location |
|
43 | - * @return string |
|
44 | - */ |
|
38 | + /** |
|
39 | + * Resolves the string with which this location needs to be |
|
40 | + * replaced. |
|
41 | + * |
|
42 | + * @param Mailcode_Parser_Safeguard_Formatter_Location $location |
|
43 | + * @return string |
|
44 | + */ |
|
45 | 45 | private function resolveReplacement(Mailcode_Parser_Safeguard_Formatter_Location $location) : string |
46 | 46 | { |
47 | 47 | if($location->requiresAdjustment()) |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | $locations = $this->resolveLocations(); |
31 | 31 | |
32 | - foreach($locations as $location) |
|
32 | + foreach ($locations as $location) |
|
33 | 33 | { |
34 | 34 | $location->replaceWith($this->resolveReplacement($location)); |
35 | 35 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | private function resolveReplacement(Mailcode_Parser_Safeguard_Formatter_Location $location) : string |
48 | 48 | { |
49 | - if($location->requiresAdjustment()) |
|
49 | + if ($location->requiresAdjustment()) |
|
50 | 50 | { |
51 | 51 | return $this->getReplaceString($location); |
52 | 52 | } |
@@ -23,14 +23,14 @@ |
||
23 | 23 | */ |
24 | 24 | class Mailcode_Parser_Safeguard_Formatter_Type_SingleLines extends Mailcode_Parser_Safeguard_Formatter_FormatType |
25 | 25 | { |
26 | - /** |
|
27 | - * @var string |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var string |
|
28 | + */ |
|
29 | 29 | private $eol; |
30 | 30 | |
31 | - /** |
|
32 | - * @var int |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var int |
|
33 | + */ |
|
34 | 34 | private $eolLength; |
35 | 35 | |
36 | 36 | protected function initFormatting() : void |
@@ -25,14 +25,14 @@ |
||
25 | 25 | */ |
26 | 26 | class Mailcode_Parser_Safeguard_Formatter_Type_SingleLines_Location extends Mailcode_Parser_Safeguard_Formatter_Location |
27 | 27 | { |
28 | - /** |
|
29 | - * @var int |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var int |
|
30 | + */ |
|
31 | 31 | protected $eolLength; |
32 | 32 | |
33 | - /** |
|
34 | - * @var string |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var string |
|
35 | + */ |
|
36 | 36 | protected $eol; |
37 | 37 | |
38 | 38 | protected function init() : void |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $position = $this->getStartPosition(); |
56 | 56 | |
57 | 57 | // we're at the beginning of the string |
58 | - if($position === false || $position === 0) |
|
58 | + if ($position === false || $position === 0) |
|
59 | 59 | { |
60 | 60 | $this->log(sprintf( |
61 | 61 | 'Prepend: NO | Position: [%s] | Not found, or at beginning of string.', |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | $prevPos = $position - $this->eolLength; |
69 | 69 | |
70 | - if($prevPos < 0) |
|
70 | + if ($prevPos < 0) |
|
71 | 71 | { |
72 | 72 | $prevPos = 0; |
73 | 73 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | protected function checkPreviousPosition(int $prevPos) : void |
79 | 79 | { |
80 | - if($this->isWithinCommand($prevPos)) |
|
80 | + if ($this->isWithinCommand($prevPos)) |
|
81 | 81 | { |
82 | 82 | $this->log(sprintf( |
83 | 83 | 'Prepend: NO | Position: [%s] | Is within a mailcode command.', |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | $match = $this->subject->getSubstr($prevPos, $this->eolLength); |
91 | 91 | |
92 | - if($match !== $this->formatter->getEOLChar()) |
|
92 | + if ($match !== $this->formatter->getEOLChar()) |
|
93 | 93 | { |
94 | 94 | $this->log(sprintf( |
95 | 95 | 'Prepend: YES | Position: [%s] | Characters: [%s] | Do not match the EOL character.', |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $position = $this->getEndPosition(); |
109 | 109 | |
110 | 110 | // we're at the end of the string |
111 | - if($position === false || $position >= $subjectLength) |
|
111 | + if ($position === false || $position >= $subjectLength) |
|
112 | 112 | { |
113 | 113 | $this->log(sprintf( |
114 | 114 | 'Append: NO | Position: [%s] | End of string, or too long | Subject length: [%s]', |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | $nextPos = $position + $this->eolLength; |
123 | 123 | |
124 | - if($nextPos > $subjectLength) |
|
124 | + if ($nextPos > $subjectLength) |
|
125 | 125 | { |
126 | 126 | $nextPos = $subjectLength - $this->eolLength; |
127 | 127 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | protected function checkNextPosition(int $nextPos) : void |
133 | 133 | { |
134 | - if($this->isWithinCommand($nextPos)) |
|
134 | + if ($this->isWithinCommand($nextPos)) |
|
135 | 135 | { |
136 | 136 | $this->log(sprintf( |
137 | 137 | 'Append: YES | Position: [%s] | Is within a mailcode command.', |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | $next = $this->subject->getSubstr($nextPos, $this->eolLength); |
147 | 147 | |
148 | - if($next !== $this->formatter->getEOLChar()) |
|
148 | + if ($next !== $this->formatter->getEOLChar()) |
|
149 | 149 | { |
150 | 150 | $this->log(sprintf( |
151 | 151 | 'Append: YES | Position: [%s] | Next characters: [%s] | Do not match the EOL character.', |
@@ -32,7 +32,7 @@ |
||
32 | 32 | |
33 | 33 | public function requiresAdjustment(): bool |
34 | 34 | { |
35 | - if(!parent::requiresAdjustment()) |
|
35 | + if (!parent::requiresAdjustment()) |
|
36 | 36 | { |
37 | 37 | return false; |
38 | 38 | } |
@@ -119,8 +119,7 @@ |
||
119 | 119 | if($closing) |
120 | 120 | { |
121 | 121 | array_pop($stack); |
122 | - } |
|
123 | - else |
|
122 | + } else |
|
124 | 123 | { |
125 | 124 | $stack[] = $tagName; |
126 | 125 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $pos = $this->getStartPosition(); |
55 | 55 | |
56 | - if(is_bool($pos)) |
|
56 | + if (is_bool($pos)) |
|
57 | 57 | { |
58 | 58 | return ''; |
59 | 59 | } |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | { |
76 | 76 | $tagNames = $this->getParentTags(); |
77 | 77 | |
78 | - foreach($tagNames as $tagName) |
|
78 | + foreach ($tagNames as $tagName) |
|
79 | 79 | { |
80 | - if($this->formatter->isTagExcluded($tagName)) |
|
80 | + if ($this->formatter->isTagExcluded($tagName)) |
|
81 | 81 | { |
82 | 82 | return true; |
83 | 83 | } |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | // Create a stack of all direct parent tags of the command. |
100 | 100 | // Handles closing tags as well. |
101 | 101 | $stack = array(); |
102 | - foreach($tags[2] as $idx => $tagName) |
|
102 | + foreach ($tags[2] as $idx => $tagName) |
|
103 | 103 | { |
104 | 104 | $closing = $tags[1][$idx] === '/'; |
105 | 105 | |
106 | - if($closing) |
|
106 | + if ($closing) |
|
107 | 107 | { |
108 | 108 | array_pop($stack); |
109 | 109 | } |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | |
129 | 129 | // This check is easy: if the command is in the attribute |
130 | 130 | // of any of the tags, we will find the command marker in there. |
131 | - foreach($tags[3] as $attributes) |
|
131 | + foreach ($tags[3] as $attributes) |
|
132 | 132 | { |
133 | - if(strstr($attributes, self::COMMAND_MARKER)) |
|
133 | + if (strstr($attributes, self::COMMAND_MARKER)) |
|
134 | 134 | { |
135 | 135 | return true; |
136 | 136 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | private function getTagAncestry() : array |
149 | 149 | { |
150 | - if($this->ancestryChecked) |
|
150 | + if ($this->ancestryChecked) |
|
151 | 151 | { |
152 | 152 | return $this->tagAncestry; |
153 | 153 | } |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | { |
25 | 25 | public const COMMAND_MARKER = '__MAILCODE_COMMAND__'; |
26 | 26 | |
27 | - /** |
|
28 | - * @var boolean |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var boolean |
|
29 | + */ |
|
30 | 30 | private $ancestryChecked = false; |
31 | 31 | |
32 | - /** |
|
33 | - * @var array<int,array<int,string>> |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @var array<int,array<int,string>> |
|
34 | + */ |
|
35 | 35 | private $tagAncestry = array(); |
36 | 36 | |
37 | 37 | protected function init() : void |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | return !$this->isInTagAttributes() && !$this->isInExcludedTag(); |
44 | 44 | } |
45 | 45 | |
46 | - /** |
|
47 | - * Retrieves the part of the subject string that comes |
|
48 | - * before the command. |
|
49 | - * |
|
50 | - * @return string |
|
51 | - */ |
|
46 | + /** |
|
47 | + * Retrieves the part of the subject string that comes |
|
48 | + * before the command. |
|
49 | + * |
|
50 | + * @return string |
|
51 | + */ |
|
52 | 52 | private function getHaystackBefore() : string |
53 | 53 | { |
54 | 54 | $pos = $this->getStartPosition(); |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | return $this->subject->getSubstr(0, $pos).self::COMMAND_MARKER.'>'; |
66 | 66 | } |
67 | 67 | |
68 | - /** |
|
69 | - * Whether the command is nested in one of the tags |
|
70 | - * that have been added to the list of excluded tags. |
|
71 | - * |
|
72 | - * @return bool |
|
73 | - */ |
|
68 | + /** |
|
69 | + * Whether the command is nested in one of the tags |
|
70 | + * that have been added to the list of excluded tags. |
|
71 | + * |
|
72 | + * @return bool |
|
73 | + */ |
|
74 | 74 | protected function isInExcludedTag() : bool |
75 | 75 | { |
76 | 76 | $tagNames = $this->getParentTags(); |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | |
89 | - /** |
|
90 | - * Retrieves a list of the command's parent HTML tags, from |
|
91 | - * highest to lowest. |
|
92 | - * |
|
93 | - * @return string[] |
|
94 | - */ |
|
89 | + /** |
|
90 | + * Retrieves a list of the command's parent HTML tags, from |
|
91 | + * highest to lowest. |
|
92 | + * |
|
93 | + * @return string[] |
|
94 | + */ |
|
95 | 95 | private function getParentTags() : array |
96 | 96 | { |
97 | 97 | $tags = $this->getTagAncestry(); |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | return $stack; |
117 | 117 | } |
118 | 118 | |
119 | - /** |
|
120 | - * Checks whether the command is located within the attributes |
|
121 | - * of an HTML tag. |
|
122 | - * |
|
123 | - * @return bool |
|
124 | - */ |
|
119 | + /** |
|
120 | + * Checks whether the command is located within the attributes |
|
121 | + * of an HTML tag. |
|
122 | + * |
|
123 | + * @return bool |
|
124 | + */ |
|
125 | 125 | protected function isInTagAttributes() : bool |
126 | 126 | { |
127 | 127 | $tags = $this->getTagAncestry(); |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | return false; |
140 | 140 | } |
141 | 141 | |
142 | - /** |
|
143 | - * Retrieves a list of tag names that come as parents |
|
144 | - * above the command. |
|
145 | - * |
|
146 | - * @return array<int,array<int,string>> |
|
147 | - */ |
|
142 | + /** |
|
143 | + * Retrieves a list of tag names that come as parents |
|
144 | + * above the command. |
|
145 | + * |
|
146 | + * @return array<int,array<int,string>> |
|
147 | + */ |
|
148 | 148 | private function getTagAncestry() : array |
149 | 149 | { |
150 | 150 | if($this->ancestryChecked) |