Passed
Branch fuck-54 (18c095)
by Kacper
03:37
created
KeyLighter.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
 
63 63
     /**
64 64
      * @param Language|callable|string $language
65
-     * @param array[string]            $aliases
65
+     * @param string[]            $aliases
66 66
      */
67 67
     public function registerLanguage($language, $aliases) {
68 68
         $this->_languages = array_merge($this->_languages, array_fill_keys($aliases, $language));
Please login to merge, or discard this patch.
Parser/Token.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
     }
145 145
 
146 146
     /**
147
-     * @return mixed
147
+     * @return Token
148 148
      */
149 149
     public function getStart()
150 150
     {
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
     }
166 166
 
167 167
     /**
168
-     * @return Token|null
168
+     * @return Token
169 169
      */
170 170
     public function getEnd()
171 171
     {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -89,19 +89,19 @@
 block discarded – undo
89 89
         $multiplier = $a->isEnd() ? -1 : 1;
90 90
 
91 91
         if (($a->isStart() && $b->isEnd()) || ($a->isEnd() && $b->isStart())) {
92
-            if($a->getEnd() == $b) {
92
+            if ($a->getEnd() == $b) {
93 93
                 return -1;
94
-            } elseif($a->getStart() == $b) {
94
+            } elseif ($a->getStart() == $b) {
95 95
                 return 1;
96 96
             } else {
97 97
                 return $multiplier;
98 98
             }
99 99
         } elseif (($rule = Helper::cmp($b->_rule->priority, $a->_rule->priority)) !== 0) {
100
-            return $multiplier*$rule;
100
+            return $multiplier * $rule;
101 101
         } elseif (($rule = Helper::cmp($b->index, $a->index)) !== 0) {
102
-            return $multiplier*$rule;
102
+            return $multiplier * $rule;
103 103
         } else {
104
-            return $multiplier*($a->id < $b->id ? -1 : 1);
104
+            return $multiplier * ($a->id < $b->id ? -1 : 1);
105 105
         }
106 106
     }
107 107
 
Please login to merge, or discard this patch.
Parser/TokenList.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,10 +56,10 @@
 block discarded – undo
56 56
     public function sort() {
57 57
         ksort($this->_tokens);
58 58
 
59
-        foreach(array_keys($this->_pending) as $position) {
59
+        foreach (array_keys($this->_pending) as $position) {
60 60
             uasort(
61 61
                 $this->_tokens[$position],
62
-                Token::class.'::compare'
62
+                Token::class . '::compare'
63 63
             );
64 64
         }
65 65
         $this->_pending = [];
Please login to merge, or discard this patch.
Parser/TokenFactory.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function create($params) {
44 44
         $params[0] = !empty($params[0]) ? $this->getName($params[0]) : $this->_base;
45
-        if(empty($params['rule'])) {
45
+        if (empty($params['rule'])) {
46 46
             $params['rule'] = $this->_rule;
47 47
         }
48 48
 
49
-        if(isset($params['pos'])) {
49
+        if (isset($params['pos'])) {
50 50
             $params['pos'] += $this->_offset;
51 51
         }
52 52
 
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 
62 62
         $token = new $this->_class($params);
63 63
 
64
-        if($this->type == 0x3) {
64
+        if ($this->type == 0x3) {
65 65
             return $token;
66 66
         }
67 67
 
68
-        if($this->type === self::START) {
68
+        if ($this->type === self::START) {
69 69
             $token->setEnd(false);
70 70
             return $token;
71 71
         } else {
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      */
149 149
     public function setClass($class)
150 150
     {
151
-        if(!is_a($class, 'Kadet\Highlighter\Parser\Token', true)) {
151
+        if (!is_a($class, 'Kadet\Highlighter\Parser\Token', true)) {
152 152
             throw new \InvalidArgumentException('$class must extend Kadet\Highlighter\Parser\Token');
153 153
         }
154 154
 
Please login to merge, or discard this patch.
Language/Language.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
      * @param array $options
50 50
      */
51 51
     public function __construct(array $options = []) {
52
-        $this->_options  = array_merge([
52
+        $this->_options = array_merge([
53 53
             'embedded' => [],
54 54
         ], $this->_options, $options);
55 55
 
56
-        $this->_rules    = $this->getRules();
56
+        $this->_rules = $this->getRules();
57 57
     }
58 58
 
59 59
     /**
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     {
78 78
         if (is_string($tokens)) {
79 79
             $tokens = $this->tokenize($tokens, $additional, $embedded);
80
-        } elseif(!$tokens instanceof TokenIterator) {
80
+        } elseif (!$tokens instanceof TokenIterator) {
81 81
             // Todo: Own Exceptions
82 82
             throw new \InvalidArgumentException('$tokens must be string or TokenIterator');
83 83
         }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         /** @var Token[] $all */    $all    = [];
92 92
 
93 93
         /** @var Token $token */
94
-        for($tokens->next(); $tokens->valid(); $tokens->next()) {
94
+        for ($tokens->next(); $tokens->valid(); $tokens->next()) {
95 95
             $token = $tokens->current();
96 96
 
97 97
             if (!$token->isValid($this, $context)) {
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                 if ($token instanceof LanguageToken && $token->getLanguage() === $this) {
117 117
                     $result[0]->setEnd($token);
118 118
 
119
-                    if($result[0]->getRule()->postProcess) {
119
+                    if ($result[0]->getRule()->postProcess) {
120 120
                         $source = substr($tokens->getSource(), $result[0]->pos, $result[0]->getLength());
121 121
 
122 122
                         $tokens = $this->tokenize($source, $result, $result[0]->pos, true);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
                     }
125 125
 
126 126
                     # closing unclosed tokens
127
-                    foreach(array_reverse($context) as $hash => $name) {
127
+                    foreach (array_reverse($context) as $hash => $name) {
128 128
                         $end = new Token([$name, 'pos' => $token->pos]);
129 129
                         $all[$hash]->setEnd($end);
130 130
                         $result[] = $end;
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
                         unset($context[spl_object_hash($start)]);
138 138
                     } else {
139 139
                         /** @noinspection PhpUnusedParameterInspection */
140
-                        $start = ArrayHelper::find(array_reverse($context), function ($k, $v) use ($token) {
140
+                        $start = ArrayHelper::find(array_reverse($context), function($k, $v) use ($token) {
141 141
                             return $v === $token->name;
142 142
                         });
143 143
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
         $result = new TokenList();
173 173
 
174 174
         /** @var Language $language */
175
-        foreach($this->_rules($embedded) as $rule) {
175
+        foreach ($this->_rules($embedded) as $rule) {
176 176
             $rule->factory->setOffset($offset);
177 177
             foreach ($rule->match($source) as $token) {
178 178
                 $result->add($token);
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      */
196 196
     private function _rules($embedded = false) {
197 197
         $all = $this->_rules;
198
-        if(!$embedded) {
198
+        if (!$embedded) {
199 199
             $all['language.' . $this->getIdentifier()] = $this->getOpenClose();
200 200
         }
201 201
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 
208 208
             /** @var Rule $rule */
209 209
             foreach ($rules as $rule) {
210
-                if($rule->language === false) {
210
+                if ($rule->language === false) {
211 211
                     $rule->language = $this;
212 212
                 }
213 213
 
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
             }
218 218
         }
219 219
 
220
-        foreach($this->getEmbedded() as $language) {
221
-            foreach($language->_rules() as $rule) {
220
+        foreach ($this->getEmbedded() as $language) {
221
+            foreach ($language->_rules() as $rule) {
222 222
                 yield $rule;
223 223
             }
224 224
         }
Please login to merge, or discard this patch.