Passed
Push — master ( b31131...79f37b )
by Kacper
04:02
created
Utils/Console.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
      * @return ConsoleHelper
28 28
      */
29 29
     public static function get() {
30
-        if(!isset(self::$_instance)) {
30
+        if (!isset(self::$_instance)) {
31 31
             self::$_instance = new ConsoleHelper();
32 32
         }
33 33
 
Please login to merge, or discard this patch.
Utils/ConsoleHelper.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     ];
32 32
 
33 33
     public function styled($style, $text) {
34
-        return $this->open($style).$text.$this->close();
34
+        return $this->open($style) . $text . $this->close();
35 35
     }
36 36
 
37 37
     public function open($style)
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     public function close()
49 49
     {
50 50
         $this->_current = empty($this->_stack) ? $this->_default : array_pop($this->_stack);
51
-        return "\033[0m".$this->_set(array_diff($this->_current, $this->_default));
51
+        return "\033[0m" . $this->_set(array_diff($this->_current, $this->_default));
52 52
     }
53 53
 
54 54
     private function _color($name, $bg = false)
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     }
78 78
 
79 79
     private function _style($name, $value) {
80
-        switch($name) {
80
+        switch ($name) {
81 81
             case 'color':
82 82
                 return $this->_color($value);
83 83
             case 'background':
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
     }
99 99
 
100 100
     private function _set($style) {
101
-        $escape = "\e[".implode(';', array_map(function($style, $name) {
101
+        $escape = "\e[" . implode(';', array_map(function($style, $name) {
102 102
             return $this->_style($style, $name);
103
-        }, array_keys($style), $style)).'m';
103
+        }, array_keys($style), $style)) . 'm';
104 104
 
105 105
         return $escape === "\e[m" ? null : $escape;
106 106
     }
Please login to merge, or discard this patch.
Parser/TokenFactory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 
40 40
     public function create($params) {
41 41
         $params[0] = !empty($params[0]) ? $this->getName($params[0]) : $this->_base;
42
-        if(empty($params['rule'])) {
42
+        if (empty($params['rule'])) {
43 43
             $params['rule'] = $this->_rule;
44 44
         }
45 45
 
46
-        if(isset($params['pos'])) {
46
+        if (isset($params['pos'])) {
47 47
             $params['pos'] += $this->getOffset();
48 48
         }
49 49
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public function setClass($class)
126 126
     {
127
-        if(!is_a($class, 'Kadet\Highlighter\Parser\Token', true)) {
127
+        if (!is_a($class, 'Kadet\Highlighter\Parser\Token', true)) {
128 128
             throw new \InvalidArgumentException('$class must extend Kadet\Highlighter\Parser\Token');
129 129
         }
130 130
 
Please login to merge, or discard this patch.
Parser/LanguageToken.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,9 +34,9 @@
 block discarded – undo
34 34
 
35 35
         if ($this->isStart()) {
36 36
             $lang = $this->_rule->language;
37
-            if($lang === null && $this->getInjected() !== $language) {
37
+            if ($lang === null && $this->getInjected() !== $language) {
38 38
                 $valid = true;
39
-            } elseif($language === $lang && $this->_rule->validateContext($context)) {
39
+            } elseif ($language === $lang && $this->_rule->validateContext($context)) {
40 40
                 $valid = true;
41 41
             }
42 42
         } else {
Please login to merge, or discard this patch.
Parser/Token.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -93,19 +93,19 @@
 block discarded – undo
93 93
             $multiplier = $a->isEnd() ? -1 : 1;
94 94
 
95 95
             if (($a->isStart() && $b->isEnd()) || ($a->isEnd() && $b->isStart())) {
96
-                if($a->getEnd() == $b) {
96
+                if ($a->getEnd() == $b) {
97 97
                     return -1;
98
-                } elseif($a->getStart() == $b) {
98
+                } elseif ($a->getStart() == $b) {
99 99
                     return 1;
100 100
                 } else {
101 101
                     return $multiplier;
102 102
                 }
103 103
             } elseif (($rule = Helper::cmp($b->_rule->priority, $a->_rule->priority)) !== 0) {
104
-                return $multiplier*$rule;
104
+                return $multiplier * $rule;
105 105
             } elseif (($rule = Helper::cmp($b->index, $a->index)) !== 0) {
106
-                return $multiplier*$rule;
106
+                return $multiplier * $rule;
107 107
             } else {
108
-                return $multiplier*($a->id < $b->id ? -1 : 1);
108
+                return $multiplier * ($a->id < $b->id ? -1 : 1);
109 109
             }
110 110
         }
111 111
 
Please login to merge, or discard this patch.
Utils/Singleton.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
      * @return ConsoleHelper
28 28
      */
29 29
     public static function get() {
30
-        if(!isset(self::$_instance)) {
30
+        if (!isset(self::$_instance)) {
31 31
             self::$_instance = new ConsoleHelper();
32 32
         }
33 33
 
Please login to merge, or discard this patch.
KeyLighter.php 1 patch
Spacing   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function getLanguage($name) {
41 41
         $embedded = [];
42
-        if(($pos = strpos($name, '>')) !== false) {
42
+        if (($pos = strpos($name, '>')) !== false) {
43 43
             $embedded[] = self::getLanguage(trim(substr($name, $pos + 1)));
44 44
             $name       = trim(substr($name, 0, $pos));
45 45
         }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     public function highlight($source, $language, FormatterInterface $formatter = null) {
74 74
         $formatter = $formatter ?: $this->getDefaultFormatter();
75 75
 
76
-        if(!$language instanceof Language) {
76
+        if (!$language instanceof Language) {
77 77
             $language = $this->getLanguage($language);
78 78
         }
79 79
 
@@ -83,8 +83,7 @@  discard block
 block discarded – undo
83 83
     public function __construct() {
84 84
         $this->setDefaultFormatter(
85 85
             php_sapi_name() === 'cli' ?
86
-                new CliFormatter() :
87
-                new HtmlFormatter()
86
+                new CliFormatter() : new HtmlFormatter()
88 87
         );
89 88
 
90 89
         $this->registerLanguage('Kadet\\Highlighter\\Language\\PhpLanguage', ['php']);
Please login to merge, or discard this patch.
Language/JavaScriptLanguage.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
             ]),
54 54
         ];
55 55
 
56
-        if($this->variables) {
56
+        if ($this->variables) {
57 57
             $rules = array_merge($rules, [
58 58
                 'variable' => new Rule(new RegexMatcher('/(' . self::IDENTIFIER . ')/iu'), ['priority' => -10000]),
59 59
                 'variable.property' => new Rule(new RegexMatcher('/(?=(?:\w|\)|\])\s*\.([a-z_]\w*))/i'), [
Please login to merge, or discard this patch.
Language/Language.php 1 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.