Passed
Push — master ( 4c697a...778310 )
by Kacper
02:53
created
Parser/OpenRule.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Highlighter
4
- *1
5
- * Copyright (C) 2015, Some right reserved.
6
- *
7
- * @author Kacper "Kadet" Donat <[email protected]>
8
- *
9
- * Contact with author:
10
- * Xmpp: [email protected]
11
- * E-mail: [email protected]
12
- *
13
- * From Kadet with love.
14
- */
3
+     * Highlighter
4
+     *1
5
+     * Copyright (C) 2015, Some right reserved.
6
+     *
7
+     * @author Kacper "Kadet" Donat <[email protected]>
8
+     *
9
+     * Contact with author:
10
+     * Xmpp: [email protected]
11
+     * E-mail: [email protected]
12
+     *
13
+     * From Kadet with love.
14
+     */
15 15
 
16 16
 namespace Kadet\Highlighter\Utils;
17 17
 
Please login to merge, or discard this 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.
Parser/TokenFactoryInterface.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Highlighter
4
- *
5
- * Copyright (C) 2015, Some right reserved.
6
- *
7
- * @author Kacper "Kadet" Donat <[email protected]>
8
- *
9
- * Contact with author:
10
- * Xmpp: [email protected]
11
- * E-mail: [email protected]
12
- *
13
- * From Kadet with love.
14
- */
3
+     * Highlighter
4
+     *
5
+     * Copyright (C) 2015, Some right reserved.
6
+     *
7
+     * @author Kacper "Kadet" Donat <[email protected]>
8
+     *
9
+     * Contact with author:
10
+     * Xmpp: [email protected]
11
+     * E-mail: [email protected]
12
+     *
13
+     * From Kadet with love.
14
+     */
15 15
 
16 16
 namespace Kadet\Highlighter\Utils;
17 17
 
Please login to merge, or discard this patch.
Parser/TokenFactory.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Highlighter
4
- *
5
- * Copyright (C) 2015, Some right reserved.
6
- *
7
- * @author Kacper "Kadet" Donat <[email protected]>
8
- *
9
- * Contact with author:
10
- * Xmpp: [email protected]
11
- * E-mail: [email protected]
12
- *
13
- * From Kadet with love.
14
- */
3
+     * Highlighter
4
+     *
5
+     * Copyright (C) 2015, Some right reserved.
6
+     *
7
+     * @author Kacper "Kadet" Donat <[email protected]>
8
+     *
9
+     * Contact with author:
10
+     * Xmpp: [email protected]
11
+     * E-mail: [email protected]
12
+     *
13
+     * From Kadet with love.
14
+     */
15 15
 
16 16
 namespace Kadet\Highlighter\Utils;
17 17
 
Please login to merge, or discard this 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.
Formatter/FormatterInterface.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Highlighter
4
- *
5
- * Copyright (C) 2015, Some right reserved.
6
- *
7
- * @author Kacper "Kadet" Donat <[email protected]>
8
- *
9
- * Contact with author:
10
- * Xmpp: [email protected]
11
- * E-mail: [email protected]
12
- *
13
- * From Kadet with love.
14
- */
3
+     * Highlighter
4
+     *
5
+     * Copyright (C) 2015, Some right reserved.
6
+     *
7
+     * @author Kacper "Kadet" Donat <[email protected]>
8
+     *
9
+     * Contact with author:
10
+     * Xmpp: [email protected]
11
+     * E-mail: [email protected]
12
+     *
13
+     * From Kadet with love.
14
+     */
15 15
 
16 16
 namespace Kadet\Highlighter\Utils;
17 17
 
Please login to merge, or discard this patch.
Formatter/HtmlFormatter.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Highlighter
4
- *
5
- * Copyright (C) 2015, Some right reserved.
6
- *
7
- * @author Kacper "Kadet" Donat <[email protected]>
8
- *
9
- * Contact with author:
10
- * Xmpp: [email protected]
11
- * E-mail: [email protected]
12
- *
13
- * From Kadet with love.
14
- */
3
+     * Highlighter
4
+     *
5
+     * Copyright (C) 2015, Some right reserved.
6
+     *
7
+     * @author Kacper "Kadet" Donat <[email protected]>
8
+     *
9
+     * Contact with author:
10
+     * Xmpp: [email protected]
11
+     * E-mail: [email protected]
12
+     *
13
+     * From Kadet with love.
14
+     */
15 15
 
16 16
 namespace Kadet\Highlighter\Utils;
17 17
 
Please login to merge, or discard this patch.
Language/LatexLanguage.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Highlighter
4
- *
5
- * Copyright (C) 2016, Some right reserved.
6
- *
7
- * @author Kacper "Kadet" Donat <[email protected]>
8
- *
9
- * Contact with author:
10
- * Xmpp: [email protected]
11
- * E-mail: [email protected]
12
- *
13
- * From Kadet with love.
14
- */
3
+     * Highlighter
4
+     *
5
+     * Copyright (C) 2016, Some right reserved.
6
+     *
7
+     * @author Kacper "Kadet" Donat <[email protected]>
8
+     *
9
+     * Contact with author:
10
+     * Xmpp: [email protected]
11
+     * E-mail: [email protected]
12
+     *
13
+     * From Kadet with love.
14
+     */
15 15
 
16 16
 namespace Kadet\Highlighter\Language;
17 17
 
Please login to merge, or discard this patch.
Matcher/SubStringMatcher.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Highlighter
4
- *1
5
- * Copyright (C) 2015, Some right reserved.
6
- *
7
- * @author Kacper "Kadet" Donat <[email protected]>
8
- *
9
- * Contact with author:
10
- * Xmpp: [email protected]
11
- * E-mail: [email protected]
12
- *
13
- * From Kadet with love.
14
- */
3
+     * Highlighter
4
+     *1
5
+     * Copyright (C) 2015, Some right reserved.
6
+     *
7
+     * @author Kacper "Kadet" Donat <[email protected]>
8
+     *
9
+     * Contact with author:
10
+     * Xmpp: [email protected]
11
+     * E-mail: [email protected]
12
+     *
13
+     * From Kadet with love.
14
+     */
15 15
 
16 16
 namespace Kadet\Highlighter\Utils;
17 17
 
Please login to merge, or discard this patch.
Utils/Console.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 static function styled($style, $text) {
34
-        return self::open($style).$text.self::close();
34
+        return self::open($style) . $text . self::close();
35 35
     }
36 36
 
37 37
     public static function open($style)
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     public static function close()
49 49
     {
50 50
         self::$_current = empty(self::$_stack) ? self::$_default : array_pop(self::$_stack);
51
-        return "\033[0m".self::_set(array_diff(self::$_current, self::$_default));
51
+        return "\033[0m" . self::_set(array_diff(self::$_current, self::$_default));
52 52
     }
53 53
 
54 54
     private static function _color($name, $bg = false)
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     }
78 78
 
79 79
     private static function _style($name, $value) {
80
-        switch($name) {
80
+        switch ($name) {
81 81
             case 'color':
82 82
                 return self::_color($value);
83 83
             case 'background':
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
     }
99 99
 
100 100
     private static function _set($style) {
101
-        $escape = "\033[".implode(';', array_map(function($style, $name) {
101
+        $escape = "\033[" . implode(';', array_map(function($style, $name) {
102 102
                 return self::_style($style, $name);
103
-            }, array_keys($style), $style)).'m';
103
+            }, array_keys($style), $style)) . 'm';
104 104
 
105 105
         return $escape;
106 106
     }
Please login to merge, or discard this patch.
bin/keylighter.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Highlighter
4
- *
5
- * Copyright (C) 2016, Some right reserved.
6
- *
7
- * @author Kacper "Kadet" Donat <[email protected]>
8
- *
9
- * Contact with author:
10
- * Xmpp: [email protected]
11
- * E-mail: [email protected]
12
- *
13
- * From Kadet with love.
14
- *
15
- * Just Simple CLI App implementation, subject to change.
16
- */
3
+     * Highlighter
4
+     *
5
+     * Copyright (C) 2016, Some right reserved.
6
+     *
7
+     * @author Kacper "Kadet" Donat <[email protected]>
8
+     *
9
+     * Contact with author:
10
+     * Xmpp: [email protected]
11
+     * E-mail: [email protected]
12
+     *
13
+     * From Kadet with love.
14
+     *
15
+     * Just Simple CLI App implementation, subject to change.
16
+     */
17 17
 
18 18
 use Kadet\Highlighter\Utils\Console;
19 19
 
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
 
18 18
 use Kadet\Highlighter\Utils\Console;
19 19
 
20
-require __DIR__.'/../vendor/autoload.php';
20
+require __DIR__ . '/../vendor/autoload.php';
21 21
 
22
-$title = Console::styled(['color' => 'yellow'], 'KeyLighter ').'v'.\Kadet\Highlighter\KeyLighter::VERSION.' by Kadet';
22
+$title = Console::styled(['color' => 'yellow'], 'KeyLighter ') . 'v' . \Kadet\Highlighter\KeyLighter::VERSION . ' by Kadet';
23 23
 $formatters = [
24 24
     'html' => new \Kadet\Highlighter\Formatter\HtmlFormatter(),
25 25
     'cli'  => new \Kadet\Highlighter\Formatter\CliFormatter(),
@@ -27,17 +27,17 @@  discard block
 block discarded – undo
27 27
 
28 28
 function printTable($table, $spacing = 4) {
29 29
     $max = [];
30
-    foreach(array_keys(reset($table)) as $key) {
30
+    foreach (array_keys(reset($table)) as $key) {
31 31
         $max[$key] = max(array_map(function($option) use ($key) { return strlen($option[$key]); }, $table)) + $spacing;
32 32
     }
33 33
 
34
-    if(isset($key)) {
34
+    if (isset($key)) {
35 35
         $max[$key] = 0; // Reset last
36 36
     }
37 37
 
38 38
     foreach ($table as $option) {
39 39
         echo "\t";
40
-        foreach($option as $key => $cell) {
40
+        foreach ($option as $key => $cell) {
41 41
             echo str_pad($cell, $max[$key], ' ', STR_PAD_RIGHT);
42 42
         }
43 43
         echo PHP_EOL;
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 function getOption($options, $value = true, $default = null) {
54 54
     global $argv;
55 55
 
56
-    foreach($options as $option) {
57
-        if($pos = array_search($option, $argv)) {
56
+    foreach ($options as $option) {
57
+        if ($pos = array_search($option, $argv)) {
58 58
             $return = !$value || !isset($argv[$pos + 1]) ? $default : $argv[$pos + 1];
59 59
 
60
-            if($value && isset($argv[$pos + 1])) {
61
-                unset($argv[$pos+1]);
60
+            if ($value && isset($argv[$pos + 1])) {
61
+                unset($argv[$pos + 1]);
62 62
             }
63 63
             unset($argv[$pos]);
64 64
 
@@ -70,29 +70,29 @@  discard block
 block discarded – undo
70 70
 }
71 71
 
72 72
 function benchmark($description, callable $callable) {
73
-    echo Console::styled(['color' => 'yellow'], $description.'... ');
73
+    echo Console::styled(['color' => 'yellow'], $description . '... ');
74 74
     $start = microtime(true);
75 75
         $return = $callable();
76 76
     $done = microtime(true) - $start;
77
-    echo Console::styled(['color' => 'green'], 'Done! ').number_format($done, 3).'s'.PHP_EOL;
77
+    echo Console::styled(['color' => 'green'], 'Done! ') . number_format($done, 3) . 's' . PHP_EOL;
78 78
 
79 79
     return $return;
80 80
 }
81 81
 
82
-if($argc == 1) {
82
+if ($argc == 1) {
83 83
     echo $title, PHP_EOL, PHP_EOL;
84 84
 
85
-    echo Console::styled(['color' => 'green'], 'Usage: '), 'php '.$argv[0].' [options] file', PHP_EOL;
85
+    echo Console::styled(['color' => 'green'], 'Usage: '), 'php ' . $argv[0] . ' [options] file', PHP_EOL;
86 86
 
87 87
     echo Console::styled(['color' => 'green'], 'Options: '), PHP_EOL;
88 88
     printTable([
89
-        ['-l, --language',    'language', 'Source Language to highlight, default: html > php'],
90
-        ['-f, --format',      'format',   'Formatter used to highlight source, for example: html, default: cli'],
91
-        ['-h, --help',         null,      'This screen'],
92
-        ['-v, --verbose',     'level',    'Verbose mode'],
93
-        ['-lf, --formatters',  null,      'List available formatters'],
94
-        ['-ll, --languages',   null,      'List available languages'],
95
-        ['-s, --silent',       null,      'No output, '],
89
+        ['-l, --language', 'language', 'Source Language to highlight, default: html > php'],
90
+        ['-f, --format', 'format', 'Formatter used to highlight source, for example: html, default: cli'],
91
+        ['-h, --help', null, 'This screen'],
92
+        ['-v, --verbose', 'level', 'Verbose mode'],
93
+        ['-lf, --formatters', null, 'List available formatters'],
94
+        ['-ll, --languages', null, 'List available languages'],
95
+        ['-s, --silent', null, 'No output, '],
96 96
 
97 97
     ]);
98 98
     exit(0);
@@ -100,19 +100,19 @@  discard block
 block discarded – undo
100 100
 
101 101
 unset($argv[0]);
102 102
 
103
-if(getOption(['-ll', '--languages'], false, true)) {
103
+if (getOption(['-ll', '--languages'], false, true)) {
104 104
     $languages = \Kadet\Highlighter\KeyLighter::registeredLanguages();
105 105
 
106 106
     $result = [];
107
-    foreach($languages as $alias => $class) {
108
-        if(!isset($result[$class])) {
107
+    foreach ($languages as $alias => $class) {
108
+        if (!isset($result[$class])) {
109 109
             $result[$class] = ['aliases' => [], 'class' => $class];
110 110
         }
111 111
 
112 112
         $result[$class]['aliases'][] = $alias;
113 113
     }
114 114
 
115
-    echo Console::styled(['color' => 'green'], 'Available languages: ').PHP_EOL;
115
+    echo Console::styled(['color' => 'green'], 'Available languages: ') . PHP_EOL;
116 116
 
117 117
     printTable(array_map(function($language) {
118 118
         return [
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
     exit(0);
126 126
 }
127 127
 
128
-if(getOption(['-lf', '--formatters'], false, true)) {
129
-    echo Console::styled(['color' => 'green'], 'Available formatters: ').PHP_EOL;
128
+if (getOption(['-lf', '--formatters'], false, true)) {
129
+    echo Console::styled(['color' => 'green'], 'Available formatters: ') . PHP_EOL;
130 130
     printTable(array_map(function($name, $formatter) {
131 131
         return [
132 132
             Console::styled(['color' => 'yellow'], $name),
@@ -138,43 +138,43 @@  discard block
 block discarded – undo
138 138
 }
139 139
 
140 140
 $language  = \Kadet\Highlighter\KeyLighter::getLanguage(getOption(['-l', '--language']) ?: 'html > php');
141
-$verbose   = getOption(['-v', '--verbose'], true, 1)  ?: 0;
141
+$verbose   = getOption(['-v', '--verbose'], true, 1) ?: 0;
142 142
 $formatter = getFormatter(getOption(['-f', '--format'])) ?: \Kadet\Highlighter\KeyLighter::getDefaultFormatter();
143 143
 $silent    = getOption(['-s', '--silent'], false, true);
144 144
 
145 145
 $file = reset($argv);
146 146
 
147
-if($verbose > 0) {
148
-    echo $title.PHP_EOL;
147
+if ($verbose > 0) {
148
+    echo $title . PHP_EOL;
149 149
     echo PHP_EOL;
150
-    echo Console::styled(['color' => 'green'], 'Language:  ').get_class($language).PHP_EOL;
150
+    echo Console::styled(['color' => 'green'], 'Language:  ') . get_class($language) . PHP_EOL;
151 151
 
152 152
     $embedded = $language->getEmbedded();
153
-    if(!empty($embedded)) {
154
-        echo Console::styled(['color' => 'green'], '    With:  ').implode(', ', array_map('get_class', $embedded)).PHP_EOL;
153
+    if (!empty($embedded)) {
154
+        echo Console::styled(['color' => 'green'], '    With:  ') . implode(', ', array_map('get_class', $embedded)) . PHP_EOL;
155 155
 
156 156
     }
157 157
 
158
-    echo Console::styled(['color' => 'green'], 'Formatter: ').get_class($formatter).PHP_EOL;
159
-    echo Console::styled(['color' => 'green'], 'File:      ').$file.PHP_EOL;
158
+    echo Console::styled(['color' => 'green'], 'Formatter: ') . get_class($formatter) . PHP_EOL;
159
+    echo Console::styled(['color' => 'green'], 'File:      ') . $file . PHP_EOL;
160 160
     echo PHP_EOL;
161 161
 }
162 162
 
163
-if(!file_exists($file)) {
164
-    echo Console::styled(['color' => 'red'], 'File not exists.').PHP_EOL;
163
+if (!file_exists($file)) {
164
+    echo Console::styled(['color' => 'red'], 'File not exists.') . PHP_EOL;
165 165
     die(1);
166 166
 }
167 167
 
168 168
 $source = file_get_contents($file);
169
-if($verbose > 1) {
169
+if ($verbose > 1) {
170 170
     $tokens    = benchmark('Tokenization', function() use($language, $source) { return $language->tokenize($source); });
171 171
     $tokens    = benchmark('Parsing', function() use($language, $tokens) { return $language->parse($tokens); });
172 172
     $formatted = benchmark('Formatting', function() use($formatter, $tokens, $source) {
173 173
         return $formatter->format($tokens);
174 174
     });
175 175
 
176
-    if(function_exists('xdebug_peak_memory_usage')) {
177
-        echo Console::styled(['color' => 'green'], 'Max memory usage: ').number_format(xdebug_peak_memory_usage()/1024/1024, 4).'MBytes'.PHP_EOL;
176
+    if (function_exists('xdebug_peak_memory_usage')) {
177
+        echo Console::styled(['color' => 'green'], 'Max memory usage: ') . number_format(xdebug_peak_memory_usage() / 1024 / 1024, 4) . 'MBytes' . PHP_EOL;
178 178
     }
179 179
 
180 180
     echo PHP_EOL;
@@ -182,6 +182,6 @@  discard block
 block discarded – undo
182 182
     $formatted = \Kadet\Highlighter\KeyLighter::highlight($source, $language, $formatter);
183 183
 }
184 184
 
185
-if(!$silent) {
186
-    echo $formatted.PHP_EOL;
185
+if (!$silent) {
186
+    echo $formatted . PHP_EOL;
187 187
 }
188 188
\ No newline at end of file
Please login to merge, or discard this patch.