Passed
Push — master ( 05f929...203740 )
by Kacper
03:48 queued 01:02
created
Language/Language.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -164,6 +164,9 @@  discard block
 block discarded – undo
164 164
         return $result;
165 165
     }
166 166
 
167
+    /**
168
+     * @param string $source
169
+     */
167 170
     public function tokenize($source)
168 171
     {
169 172
         $iterator = new \ArrayIterator($this->_tokens($source));
@@ -182,7 +185,7 @@  discard block
 block discarded – undo
182 185
     /**
183 186
      * Language range Rule(s)
184 187
      *
185
-     * @return Rule|Rule[]
188
+     * @return Rule
186 189
      */
187 190
     public function getOpenClose()
188 191
     {
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
      * @param array $options
49 49
      */
50 50
     public function __construct(array $options = []) {
51
-        $this->_options  = array_merge([
51
+        $this->_options = array_merge([
52 52
             'embedded' => [],
53 53
         ], $this->_options, $options);
54 54
 
55
-        $this->_rules    = $this->getRules();
55
+        $this->_rules = $this->getRules();
56 56
     }
57 57
 
58 58
     /**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     {
77 77
         if (is_string($tokens)) {
78 78
             $tokens = $this->tokenize($tokens, $additional, $embedded);
79
-        } elseif(!$tokens instanceof TokenIterator) {
79
+        } elseif (!$tokens instanceof TokenIterator) {
80 80
             // Todo: Own Exceptions
81 81
             throw new \InvalidArgumentException('$tokens must be string or TokenIterator');
82 82
         }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         /** @var Token[] $all */    $all    = [];
91 91
 
92 92
         /** @var Token $token */
93
-        for($tokens->next(); $tokens->valid(); $tokens->next()) {
93
+        for ($tokens->next(); $tokens->valid(); $tokens->next()) {
94 94
             $token = $tokens->current();
95 95
 
96 96
             if (!$token->isValid($this, $context)) {
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
                 if ($token instanceof LanguageToken && $token->getLanguage() === $this) {
116 116
                     $result[0]->setEnd($token);
117 117
 
118
-                    if($result[0]->getRule()->postProcess) {
118
+                    if ($result[0]->getRule()->postProcess) {
119 119
                         $source = substr($tokens->getSource(), $result[0]->pos, $result[0]->getLength());
120 120
 
121 121
                         $tokens = $this->tokenize($source, $result, $result[0]->pos, true);
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
                     }
124 124
 
125 125
                     # closing unclosed tokens
126
-                    foreach(array_reverse($context) as $hash => $name) {
126
+                    foreach (array_reverse($context) as $hash => $name) {
127 127
                         $end = new Token([$name, 'pos' => $token->pos]);
128 128
                         $all[$hash]->setEnd($end);
129 129
                         $result[] = $end;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
                         unset($context[spl_object_hash($start)]);
137 137
                     } else {
138 138
                         /** @noinspection PhpUnusedParameterInspection */
139
-                        $start = ArrayHelper::find(array_reverse($context), function ($k, $v) use ($token) {
139
+                        $start = ArrayHelper::find(array_reverse($context), function($k, $v) use ($token) {
140 140
                             return $v === $token->name;
141 141
                         });
142 142
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
     private function _tokens($source, $offset = 0, $additional = [], $embedded = false)
170 170
     {
171 171
         $all = $this->_rules;
172
-        if(!$embedded) {
172
+        if (!$embedded) {
173 173
             $all['language.' . $this->getIdentifier()] = $this->getOpenClose();
174 174
         }
175 175
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 
182 182
             /** @var Rule $rule */
183 183
             foreach ($rules as $rule) {
184
-                if($rule->language === false) {
184
+                if ($rule->language === false) {
185 185
                     $rule->language = $this;
186 186
                 }
187 187
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
             }
193 193
         }
194 194
 
195
-        foreach($this->getEmbedded() as $language) {
195
+        foreach ($this->getEmbedded() as $language) {
196 196
             $result = array_merge($result, $language->_tokens($source, $offset));
197 197
         }
198 198
 
Please login to merge, or discard this patch.
Formatter/CliFormatter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
      * @param $styles
34 34
      */
35 35
     public function __construct($styles = false) {
36
-        $this->_styles = $styles ?: include __DIR__.'/../Styles/Cli/Default.php';
36
+        $this->_styles = $styles ?: include __DIR__ . '/../Styles/Cli/Default.php';
37 37
     }
38 38
 
39 39
     public function format($source, \Traversable $tokens)
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
             $last = $token->pos;
53 53
         }
54
-        $result .= substr($source, $last).Console::reset();
54
+        $result .= substr($source, $last) . Console::reset();
55 55
 
56 56
         return $result;
57 57
     }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     public function getColor($token)
60 60
     {
61 61
         do {
62
-            if(isset($this->_styles[$token])) {
62
+            if (isset($this->_styles[$token])) {
63 63
                 return $this->_styles[$token];
64 64
             }
65 65
 
Please login to merge, or discard this patch.
Parser/Rule.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         reset($required);
129 129
         while (list($rule, $type) = each($required)) {
130 130
             $matched = !($type & self::CONTEXT_EXACTLY) ?
131
-                count(array_filter($context, function ($a) use ($rule) {
131
+                count(array_filter($context, function($a) use ($rule) {
132 132
                     return $a === $rule || fnmatch($rule . '.*', $a);
133 133
                 })) > 0 :
134 134
                 in_array($rule, $context, true);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     private function _unsetUnnecessaryRules($rule, &$required)
160 160
     {
161 161
         if (strpos($rule, '.') !== false) {
162
-            foreach (array_filter(array_keys($this->_context), function ($key) use ($rule) {
162
+            foreach (array_filter(array_keys($this->_context), function($key) use ($rule) {
163 163
                 return fnmatch($key . '.*', $rule);
164 164
             }) as $remove) {
165 165
                 unset($required[$remove]);
Please login to merge, or discard this patch.
Parser/CloseRule.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 {
21 21
     public function match($source)
22 22
     {
23
-        return array_filter(parent::match($source), function (Token $token) {
23
+        return array_filter(parent::match($source), function(Token $token) {
24 24
             if ($token->isEnd()) {
25 25
                 $token->setStart(null);
26 26
 
Please login to merge, or discard this patch.
Matcher/WordMatcher.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
         ], $options);
35 35
 
36 36
         if ($options['escape']) {
37
-            $words = array_map(function ($word) {
37
+            $words = array_map(function($word) {
38 38
                 return preg_quote($word, '/');
39 39
             }, $words);
40 40
         }
Please login to merge, or discard this patch.
Matcher/CommentMatcher.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
         $all = [];
53 53
 
54 54
         foreach ($this->multiLine as $name => $comment) {
55
-            $comment = array_map(function ($e) { return preg_quote($e, '/'); }, $comment);
55
+            $comment = array_map(function($e) { return preg_quote($e, '/'); }, $comment);
56 56
 
57 57
             $all[] = [$name, "/{$comment[0]}(.*?){$comment[1]}/ms"];
58 58
         }
Please login to merge, or discard this patch.
Utils/ArrayHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,14 +45,14 @@
 block discarded – undo
45 45
 
46 46
     public static function rearrange(array $array, array $keys)
47 47
     {
48
-        return array_combine($keys, array_map(function ($key) use ($array) {
48
+        return array_combine($keys, array_map(function($key) use ($array) {
49 49
             return $array[$key];
50 50
         }, $keys));
51 51
     }
52 52
 
53 53
     public static function column(array $array, $index)
54 54
     {
55
-        return array_map(function ($e) use ($index) { return $e[$index]; }, $array);
55
+        return array_map(function($e) use ($index) { return $e[$index]; }, $array);
56 56
     }
57 57
 
58 58
     public static function find(array $array, callable $tester)
Please login to merge, or discard this patch.
Parser/OpenRule.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 {
21 21
     public function match($source)
22 22
     {
23
-        return array_filter(parent::match($source), function (Token $token) {
23
+        return array_filter(parent::match($source), function(Token $token) {
24 24
             if ($token->isEnd()) {
25 25
                 $token->setStart(null);
26 26
 
Please login to merge, or discard this patch.
Language/HtmlLanguage.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
         $js = new JavaScriptLanguage();
29 29
 
30 30
         return array_merge(parent::getRules(), [
31
-            'language.'.$js->getIdentifier() => [
31
+            'language.' . $js->getIdentifier() => [
32 32
                 new OpenRule(new RegexMatcher('/<script.*?>()/'), [
33 33
                     'factory'     => new TokenFactory('Kadet\\Highlighter\\Parser\\LanguageToken'),
34 34
                     'inject'      => $js,
Please login to merge, or discard this patch.