Passed
Push — master ( d2ad69...686350 )
by Kacper
02:44
created
KeyLighter.php 1 patch
Spacing   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public static function getLanguage($name) {
38 38
         $embedded = [];
39
-        if(($pos = strpos($name, '>')) !== false) {
39
+        if (($pos = strpos($name, '>')) !== false) {
40 40
             $embedded[] = self::getLanguage(trim(substr($name, $pos + 1)));
41 41
             $name       = trim(substr($name, 0, $pos));
42 42
         }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     public static function highlight($source, $language, FormatterInterface $formatter = null) {
71 71
         $formatter = $formatter ?: self::getDefaultFormatter();
72 72
 
73
-        if(!$language instanceof Language) {
73
+        if (!$language instanceof Language) {
74 74
             $language = self::getLanguage($language);
75 75
         }
76 76
 
@@ -82,8 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
 KeyLighter::setDefaultFormatter(
84 84
     php_sapi_name() === 'cli' ?
85
-        new CliFormatter() :
86
-        new HtmlFormatter()
85
+        new CliFormatter() : new HtmlFormatter()
87 86
 );
88 87
 
89 88
 KeyLighter::registerLanguage('Kadet\\Highlighter\\Language\\PhpLanguage', ['php']);
Please login to merge, or discard this patch.
Language/PhpLanguage.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@
 block discarded – undo
81 81
                 '__CLASS__', '__DIR__', '__FILE__', '__FUNCTION__',
82 82
                 '__LINE__', '__METHOD__', '__NAMESPACE__', '__TRAIT__',
83 83
             ], array_keys(get_defined_constants(true)["Core"]))), ['priority' => -2]),
84
-            'constant.static' => new Rule(new RegexMatcher('/(?:[\w\\\]+::|const\s+)(\w+)/i'), ['priority' => -2]   ),
84
+            'constant.static' => new Rule(new RegexMatcher('/(?:[\w\\\]+::|const\s+)(\w+)/i'), ['priority' => -2]),
85 85
 
86 86
             'keyword' => new Rule(new WordMatcher([
87 87
                 '__halt_compiler', 'abstract', 'and', 'array',
Please login to merge, or discard this patch.
Language/Language.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     {
73 73
         if (is_string($tokens)) {
74 74
             $tokens = $this->tokenize($tokens, $additional);
75
-        } elseif(!$tokens instanceof TokenIterator) {
75
+        } elseif (!$tokens instanceof TokenIterator) {
76 76
             throw new \InvalidArgumentException('$tokens must be string or TokenIterator');
77 77
         }
78 78
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
         $all = [];
86 86
 
87 87
         /** @var Token $token */
88
-        for($tokens->next(); $tokens->valid(); $tokens->next()) {
88
+        for ($tokens->next(); $tokens->valid(); $tokens->next()) {
89 89
             $token = $tokens->current();
90 90
 
91 91
             if (!$token->isValid($this, $context)) {
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
                 if ($token instanceof LanguageToken && $token->getRule()->language === $this) {
110 110
                     $result[0]->setEnd($token);
111 111
 
112
-                    if($result[0]->getRule()->postProcess) {
112
+                    if ($result[0]->getRule()->postProcess) {
113 113
                         $source = substr($tokens->getSource(), $result[0]->pos, $result[0]->getLength());
114 114
 
115 115
                         $tokens = $this->tokenize($source, $result, $result[0]->pos);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
                     }
118 118
 
119 119
                     # closing unclosed tokens
120
-                    foreach(array_reverse($context) as $hash => $name) {
120
+                    foreach (array_reverse($context) as $hash => $name) {
121 121
                         $result[$hash]->setEnd(new Token([$name, 'pos' => $token->pos]));
122 122
                     }
123 123
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
                         unset($context[spl_object_hash($start)]);
129 129
                     } else {
130 130
                         /** @noinspection PhpUnusedParameterInspection */
131
-                        $start = ArrayHelper::find(array_reverse($context), function ($k, $v) use ($token) {
131
+                        $start = ArrayHelper::find(array_reverse($context), function($k, $v) use ($token) {
132 132
                             return $v === $token->name;
133 133
                         });
134 134
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 
166 166
             /** @var Rule $rule */
167 167
             foreach ($rules as $rule) {
168
-                if($rule->language === false) {
168
+                if ($rule->language === false) {
169 169
                     $rule->language;
170 170
                 }
171 171
 
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
             }
175 175
         }
176 176
 
177
-        foreach($this->getEmbedded() as $language) {
177
+        foreach ($this->getEmbedded() as $language) {
178 178
             $result = array_merge($result, $language->_tokens($source));
179 179
         }
180 180
 
181 181
         // Array map would be cool, but is a lot slower
182
-        if($offset) {
182
+        if ($offset) {
183 183
             foreach ($result as $item) {
184 184
                 $item->pos += $offset;
185 185
             }
Please login to merge, or discard this patch.
Parser/MarkerToken.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 
42 42
     protected function validate(Language $language, $context)
43 43
     {
44
-        if($language !== $this->getRule()->language) {
44
+        if ($language !== $this->getRule()->language) {
45 45
             return false;
46 46
         }
47 47
 
Please login to merge, or discard this patch.
Parser/TokenFactory.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function create($params) {
40 40
         $params[0] = !empty($params[0]) ? $this->getName($params[0]) : $this->_base;
41
-        if(empty($params['rule'])) {
41
+        if (empty($params['rule'])) {
42 42
             $params['rule'] = $this->_rule;
43 43
         }
44 44
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      */
102 102
     public function setClass($class)
103 103
     {
104
-        if(!is_a($class, 'Kadet\Highlighter\Parser\Token', true)) {
104
+        if (!is_a($class, 'Kadet\Highlighter\Parser\Token', true)) {
105 105
             throw new \InvalidArgumentException('$class must extend Kadet\Highlighter\Parser\Token');
106 106
         }
107 107
 
Please login to merge, or discard this patch.
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.