Passed
Pull Request — master (#20)
by
unknown
09:30
created
src/Mailcode/Collection/NestingValidator.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,19 +30,19 @@
 block discarded – undo
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)
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/Formatter/Type/PreProcessing.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@
 block discarded – undo
25 25
     {
26 26
         $command = $location->getPlaceholder()->getCommand();
27 27
 
28
-        if($command instanceof Mailcode_Interfaces_Commands_PreProcessing)
28
+        if ($command instanceof Mailcode_Interfaces_Commands_PreProcessing)
29 29
         {
30 30
             return $command->preProcessOpening();
31 31
         }
32 32
 
33
-        if($command instanceof Mailcode_Commands_Command_Type_Closing)
33
+        if ($command instanceof Mailcode_Commands_Command_Type_Closing)
34 34
         {
35 35
             $opening = $command->getOpeningCommand();
36 36
 
37
-            if($opening instanceof Mailcode_Interfaces_Commands_PreProcessing) {
37
+            if ($opening instanceof Mailcode_Interfaces_Commands_PreProcessing) {
38 38
                 return $opening->preProcessClosing();
39 39
             }
40 40
         }
Please login to merge, or discard this patch.
tools/prepend.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 declare(strict_types=1);
4 4
 
5
-if(!file_exists('../vendor/autoload.php')) {
5
+if (!file_exists('../vendor/autoload.php')) {
6 6
     die('Autoloader not present.');
7 7
 }
8 8
 
Please login to merge, or discard this patch.
tools/translator.php 2 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,8 +40,7 @@  discard block
 block discarded – undo
40 40
     try
41 41
     {
42 42
         $translated = translateMailcode($commandsText, $activeSyntax);
43
-    }
44
-    catch (Mailcode_Exception $e)
43
+    } catch (Mailcode_Exception $e)
45 44
     {
46 45
         $translated = '';
47 46
         $error = $e->getMessage();
@@ -146,8 +145,7 @@  discard block
 block discarded – undo
146 145
                         <?php pt('No commands specified.') ?>
147 146
                     </div>
148 147
                 <?php
149
-            }
150
-            else if($error)
148
+            } else if($error)
151 149
             {
152 150
                 ?>
153 151
                     <div class="alert alert-danger">
@@ -155,8 +153,7 @@  discard block
 block discarded – undo
155 153
                         <?php echo $error ?>
156 154
                     </div>
157 155
                 <?php
158
-            }
159
-            else
156
+            } else
160 157
             {
161 158
                 ?>
162 159
                     <textarea class="form-control" rows="10"><?php echo htmlspecialchars($translated) ?></textarea>
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 $error = null;
32 32
 $activeSyntax = $syntaxes[0]->getTypeID();
33 33
 
34
-if($request->getBool('translate'))
34
+if ($request->getBool('translate'))
35 35
 {
36 36
     $commandsText = $request->registerParam('mailcode')->getString();
37 37
     $activeSyntax = $request->registerParam('syntax')
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
         $error = $e->getMessage();
49 49
 
50 50
         $collection = $e->getCollection();
51
-        if($collection)
51
+        if ($collection)
52 52
         {
53 53
             $first = $collection->getFirstError();
54 54
             $error = $first->getMessage();
55 55
             $matched = $first->getMatchedText();
56
-            if(!empty($matched)) {
56
+            if (!empty($matched)) {
57 57
                 $error .= '<br>'.t('In command:').' <code>'.$matched.'</code>';
58 58
             }
59 59
         }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
                             $selected = '';
118 118
                             $typeID = $syntax->getTypeID();
119 119
 
120
-                            if($typeID === $activeSyntax) {
120
+                            if ($typeID === $activeSyntax) {
121 121
                                 $selected = ' selected';
122 122
                             }
123 123
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         <p></p><br>
138 138
         <h2><?php pt('Translated commands') ?></h2>
139 139
         <?php
140
-            if(empty($commandsText))
140
+            if (empty($commandsText))
141 141
             {
142 142
                 ?>
143 143
                     <div class="alert alert-info">
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                     </div>
146 146
                 <?php
147 147
             }
148
-            else if($error)
148
+            else if ($error)
149 149
             {
150 150
                 ?>
151 151
                     <div class="alert alert-danger">
Please login to merge, or discard this patch.
src/Mailcode/Variables/Collection/Invalid.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
     public function add(Mailcode_Variables_Variable $variable) : Mailcode_Variables_Collection
28 28
     {
29
-        if($variable->isValid())
29
+        if ($variable->isValid())
30 30
         {
31 31
             return $this;
32 32
         }
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     {
39 39
         $first = $this->getFirst();
40 40
 
41
-        if($first)
41
+        if ($first)
42 42
         {
43 43
             return $first->getValidationResult();
44 44
         }
Please login to merge, or discard this patch.
src/Mailcode/Parser/Statement.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -26,24 +26,24 @@  discard block
 block discarded – undo
26 26
     public const VALIDATION_EMPTY = 48801;
27 27
     public const VALIDATION_UNQUOTED_STRING_LITERALS = 48802;
28 28
     
29
-   /**
30
-    * @var string
31
-    */
29
+    /**
30
+     * @var string
31
+     */
32 32
     protected string $statement;
33 33
     
34
-   /**
35
-    * @var OperationResult
36
-    */
34
+    /**
35
+     * @var OperationResult
36
+     */
37 37
     protected OperationResult $result;
38 38
     
39
-   /**
40
-    * @var Mailcode_Parser_Statement_Tokenizer
41
-    */
39
+    /**
40
+     * @var Mailcode_Parser_Statement_Tokenizer
41
+     */
42 42
     protected Mailcode_Parser_Statement_Tokenizer $tokenizer;
43 43
     
44
-   /**
45
-    * @var Mailcode_Parser_Statement_Info|NULL
46
-    */
44
+    /**
45
+     * @var Mailcode_Parser_Statement_Info|NULL
46
+     */
47 47
     protected ?Mailcode_Parser_Statement_Info $info = null;
48 48
 
49 49
     /**
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         if($unknown)
139 139
         {
140 140
             $this->result->makeError(
141
-               t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')',
141
+                t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')',
142 142
                 self::VALIDATION_UNQUOTED_STRING_LITERALS
143 143
             );
144 144
         }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     private ?Mailcode_Commands_Command $sourceCommand = null;
58 58
 
59
-    public function __construct(string $statement, bool $freeform=false, ?Mailcode_Commands_Command $sourceCommand=null)
59
+    public function __construct(string $statement, bool $freeform = false, ?Mailcode_Commands_Command $sourceCommand = null)
60 60
     {
61 61
         $this->sourceCommand = $sourceCommand;
62 62
         $this->statement = $this->prepareStatement($statement);
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     
107 107
     public function getInfo() : Mailcode_Parser_Statement_Info
108 108
     {
109
-        if($this->info instanceof Mailcode_Parser_Statement_Info)
109
+        if ($this->info instanceof Mailcode_Parser_Statement_Info)
110 110
         {
111 111
             return $this->info; 
112 112
         }
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
     
119 119
     protected function validate() : void
120 120
     {
121
-        if($this->freeform)
121
+        if ($this->freeform)
122 122
         {
123 123
             return;
124 124
         }
125 125
 
126
-        if(!$this->tokenizer->hasTokens())
126
+        if (!$this->tokenizer->hasTokens())
127 127
         {
128 128
             $this->result->makeError(
129 129
                 t('Empty statement'),
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         
136 136
         $unknown = $this->tokenizer->getFirstUnknown();
137 137
         
138
-        if($unknown)
138
+        if ($unknown)
139 139
         {
140 140
             $this->result->makeError(
141 141
                t('Unquoted string literal found:').' ('.htmlspecialchars($unknown->getMatchedText()).')',
Please login to merge, or discard this patch.
src/Mailcode/Parser/PreParser/CommandDef.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -139,11 +139,11 @@
 block discarded – undo
139 139
         $commands = $parser->getCommands();
140 140
         $content = $this->getContent();
141 141
 
142
-        foreach($commands as $command)
142
+        foreach ($commands as $command)
143 143
         {
144 144
             $string = $command->getOpeningText();
145 145
 
146
-            if(strpos($content, $string) !== false)
146
+            if (strpos($content, $string) !== false)
147 147
             {
148 148
                 $this->addEscapeError($command, $collection);
149 149
                 return false;
Please login to merge, or discard this patch.
src/Mailcode/Parser/Safeguard/PlaceholderCollection.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function getByIndex(int $index) : Mailcode_Parser_Safeguard_Placeholder
41 41
     {
42
-        if(isset($this->placeholders[$index]))
42
+        if (isset($this->placeholders[$index]))
43 43
         {
44 44
             return $this->placeholders[$index];
45 45
         }
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 
54 54
     public function getByCommand(Mailcode_Commands_Command $command) : Mailcode_Parser_Safeguard_Placeholder
55 55
     {
56
-        foreach($this->placeholders as $placeholder)
56
+        foreach ($this->placeholders as $placeholder)
57 57
         {
58
-            if($placeholder->getCommand() === $command)
58
+            if ($placeholder->getCommand() === $command)
59 59
             {
60 60
                 return $placeholder;
61 61
             }
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public function getByID(int $id) : Mailcode_Parser_Safeguard_Placeholder
79 79
     {
80
-        foreach($this->placeholders as $placeholder)
80
+        foreach ($this->placeholders as $placeholder)
81 81
         {
82
-            if($placeholder->getID() === $id)
82
+            if ($placeholder->getID() === $id)
83 83
             {
84 84
                 return $placeholder;
85 85
             }
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function getByString(string $string) : Mailcode_Parser_Safeguard_Placeholder
106 106
     {
107
-        foreach($this->placeholders as $placeholder)
107
+        foreach ($this->placeholders as $placeholder)
108 108
         {
109
-            if($placeholder->getReplacementText() === $string)
109
+            if ($placeholder->getReplacementText() === $string)
110 110
             {
111 111
                 return $placeholder;
112 112
             }
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function getStrings() : array
131 131
     {
132
-        if(is_array($this->placeholderStrings))
132
+        if (is_array($this->placeholderStrings))
133 133
         {
134 134
             return $this->placeholderStrings;
135 135
         }
136 136
 
137 137
         $this->placeholderStrings = array();
138 138
 
139
-        foreach($this->placeholders as $placeholder)
139
+        foreach ($this->placeholders as $placeholder)
140 140
         {
141 141
             $this->placeholderStrings[] = $placeholder->getReplacementText();
142 142
         }
Please login to merge, or discard this patch.
src/Mailcode/Traits/Commands/Validation/NoHTML.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 
39 39
         $keywords = $this->params->getInfo()->getKeywords();
40 40
 
41
-        foreach($keywords as $keyword)
41
+        foreach ($keywords as $keyword)
42 42
         {
43
-            if($keyword->isNoHTML())
43
+            if ($keyword->isNoHTML())
44 44
             {
45 45
                 $this->noHTMLToken = $keyword;
46 46
                 break;
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      * @return $this
56 56
      * @throws Mailcode_Exception
57 57
      */
58
-    public function setHTMLEnabled(bool $enabled=true) : self
58
+    public function setHTMLEnabled(bool $enabled = true) : self
59 59
     {
60 60
         $this->params->getInfo()->setKeywordEnabled(Mailcode_Commands_Keywords::TYPE_NOHTML, !$enabled);
61 61
 
Please login to merge, or discard this patch.