Completed
Push — master ( edcce7...6aac40 )
by Kacper
04:23
created
Utils/ArrayHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,14 +19,14 @@
 block discarded – undo
19 19
 {
20 20
     public static function rearrange(array $array, array $keys)
21 21
     {
22
-        return array_combine($keys, array_map(function ($key) use ($array) {
22
+        return array_combine($keys, array_map(function($key) use ($array) {
23 23
             return $array[$key];
24 24
         }, $keys));
25 25
     }
26 26
 
27 27
     public static function column(array $array, $index)
28 28
     {
29
-        return array_map(function ($e) use ($index) { return $e[$index]; }, $array);
29
+        return array_map(function($e) use ($index) { return $e[$index]; }, $array);
30 30
     }
31 31
 
32 32
     public static function find(array $array, callable $tester)
Please login to merge, or discard this patch.
Language/Perl.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
             'string.nowdoc'  => new Rule(
62 62
                 new RegexMatcher('/<<\s*\'(\w+)\';(?P<string>.*?)\R\1/sm', [
63 63
                     'string' => Token::NAME,
64
-                          0  => 'keyword.nowdoc'
64
+                            0  => 'keyword.nowdoc'
65 65
                 ]), ['context' => ['!comment']]
66 66
             ),
67 67
 
Please login to merge, or discard this patch.
Matcher/CommentMatcher.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     public function __construct(array $singleLine = null, array $multiLine = null)
32 32
     {
33 33
         $this->singleLine = $singleLine ?: [];
34
-        $this->multiLine  = $multiLine  ?: [];
34
+        $this->multiLine  = $multiLine ?: [];
35 35
     }
36 36
 
37 37
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         $all = [];
50 50
 
51 51
         foreach ($this->multiLine as $name => $comment) {
52
-            $comment = array_map(function ($e) { return preg_quote($e, '/'); }, $comment);
52
+            $comment = array_map(function($e) { return preg_quote($e, '/'); }, $comment);
53 53
 
54 54
             $all[] = [$name, "/({$comment[0]}(.*?){$comment[1]})/ms"];
55 55
         }
Please login to merge, or discard this patch.
Language/Shell.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
                 new Rule(new RegexMatcher('/(\$\w+)/i'), ['context' => ['*none', '*string.double']]),
52 52
                 'special'  => new Rule(new RegexMatcher('/(\$[#@_])/i'), ['context' => ['*none', '*string.double']]),
53 53
                 'argument' => new Rule(new RegexMatcher('/(\$\d+)/i'), ['context' => ['*none', '*string.double']]),
54
-                new Rule(new RegexMatcher('/\$\{(\w+)(.*?)\}/i', [ 1 => Token::NAME, 2 => 'string' ]), ['context' => ['*none', '*string.double']])
54
+                new Rule(new RegexMatcher('/\$\{(\w+)(.*?)\}/i', [1 => Token::NAME, 2 => 'string']), ['context' => ['*none', '*string.double']])
55 55
             ],
56 56
 
57 57
             'number'    => new Rule(new RegexMatcher('/(-?(?:0[0-7]+|0[xX][0-9a-fA-F]+|0b[01]+|\d+))/')),
Please login to merge, or discard this patch.
Language/Latex.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
                 new Rule(new RegexMatcher('/(\\\\\[.*?\\\\\])/s')),
42 42
                 new Rule(
43 43
                     new RegexMatcher(
44
-                        '/\\\begin{((?:' . implode('|', self::$mathEnvironments) . ')\*?)}(.*?)\\\end{\1}/s',
44
+                        '/\\\begin{((?:'.implode('|', self::$mathEnvironments).')\*?)}(.*?)\\\end{\1}/s',
45 45
                         [2 => Token::NAME]
46 46
                     )
47 47
                 )
Please login to merge, or discard this patch.
bin/Commands/HighlightCommand.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     {
36 36
         $this->setName('highlight')
37 37
             ->addArgument('path', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'File(s) to highlight')
38
-            ->addOption('normalize',  null, InputOption::VALUE_OPTIONAL, 'Normalize input to LF')
38
+            ->addOption('normalize', null, InputOption::VALUE_OPTIONAL, 'Normalize input to LF')
39 39
             ->addOption('language', 'l', InputOption::VALUE_OPTIONAL, 'Source Language to highlight, see <comment>list-languages</comment> command')
40 40
             ->addOption('format', 'f', InputOption::VALUE_OPTIONAL, 'Output format, see <comment>list-languages</comment> command', 'cli')
41 41
             ->addOption(
@@ -48,26 +48,26 @@  discard block
 block discarded – undo
48 48
 
49 49
     protected function execute(InputInterface $input, OutputInterface $output)
50 50
     {
51
-        if(!empty($input->getOption('debug')) && $output->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE) {
51
+        if (!empty($input->getOption('debug')) && $output->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE) {
52 52
             $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
53 53
         }
54 54
 
55 55
         $output->writeln($this->getApplication()->getLongVersion()."\n", Output::VERBOSITY_VERBOSE);
56 56
         $formatter = KeyLighter::get()->getFormatter($input->getOption('format')) ?: KeyLighter::get()->getDefaultFormatter();
57 57
 
58
-        foreach($input->getArgument('path') as $filename) {
58
+        foreach ($input->getArgument('path') as $filename) {
59 59
             $this->process($input, $output, $filename, $formatter);
60 60
         }
61 61
     }
62 62
 
63 63
     protected function content($path, $normalize = false)
64 64
     {
65
-        if(!($file = @fopen($path, 'r'))) {
65
+        if (!($file = @fopen($path, 'r'))) {
66 66
             return false;
67 67
         }
68 68
 
69 69
         $content = '';
70
-        while(!feof($file)) {
70
+        while (!feof($file)) {
71 71
             $content .= fgets($file);
72 72
         }
73 73
         fclose($file);
Please login to merge, or discard this patch.
bin/Commands/Test/RegenerateCommand.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -99,6 +99,9 @@
 block discarded – undo
99 99
             || $input->hasParameterOption('-r');
100 100
     }
101 101
 
102
+    /**
103
+     * @param string $filename
104
+     */
102 105
     private function regenerate(InputInterface $input, $filename) {
103 106
         $filename = str_replace(DIRECTORY_SEPARATOR, '/', $filename);
104 107
         $patterns = $input->getArgument('files');
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         /** @var \SplFileInfo $file */
60 60
         foreach ($iterator as $file) {
61 61
             $pathname = substr($file->getPathname(), strlen($this->_input) + 1);
62
-            if(!$this->regenerate($input, $pathname)) {
62
+            if (!$this->regenerate($input, $pathname)) {
63 63
                 continue;
64 64
             }
65 65
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
             if ($this->review($input, $output, $tokens, $reviewer)) {
72 72
                 $result = StringHelper::normalize($this->_formatter->format($tokens));
73 73
 
74
-                if(!file_exists($this->_output.'/'.dirname($pathname))) {
74
+                if (!file_exists($this->_output.'/'.dirname($pathname))) {
75 75
                     mkdir($this->_output.'/'.dirname($pathname), 755, true);
76 76
                 }
77 77
 
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
         $filename = str_replace(DIRECTORY_SEPARATOR, '/', $filename);
104 104
         $patterns = $input->getArgument('files');
105 105
 
106
-        foreach($patterns as $pattern) {
107
-            if($input->getOption('new') && file_exists("{$this->_output}/$filename.tkn")) {
106
+        foreach ($patterns as $pattern) {
107
+            if ($input->getOption('new') && file_exists("{$this->_output}/$filename.tkn")) {
108 108
                 continue;
109 109
             }
110 110
 
111
-            if(fnmatch($pattern, $filename)) {
111
+            if (fnmatch($pattern, $filename)) {
112 112
                 return true;
113 113
             }
114 114
         }
Please login to merge, or discard this patch.
bin/Commands/Benchmark/AnalyzeCommand.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -16,9 +16,7 @@
 block discarded – undo
16 16
 namespace Kadet\Highlighter\bin\Commands\Benchmark;
17 17
 
18 18
 
19
-use Kadet\Highlighter\Formatter\FormatterInterface;
20 19
 use Kadet\Highlighter\KeyLighter;
21
-use Kadet\Highlighter\Language\Language;
22 20
 use Symfony\Component\Console\Command\Command;
23 21
 use Symfony\Component\Console\Helper\Table;
24 22
 use Symfony\Component\Console\Helper\TableCell;
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
             $this->separator($file, $table);
50 50
 
51 51
             foreach ($data['times'] as $set => $times) {
52
-                $result = array_map(function ($time) use ($data, $input) {
52
+                $result = array_map(function($time) use ($data, $input) {
53 53
                     return $input->getOption('relative') ? $data['size'] / $time : $time * 1000;
54 54
                 }, $times);
55 55
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
             }
64 64
 
65 65
             foreach ($data['memory'] as $set => $memory) {
66
-                $result = array_map(function ($memory) use ($data, $input) {
67
-                    $bytes = $input->getOption('relative') ? $memory/$data['size'] : $memory;
66
+                $result = array_map(function($memory) use ($data, $input) {
67
+                    $bytes = $input->getOption('relative') ? $memory / $data['size'] : $memory;
68 68
                     return $this->formatBytes($bytes, (bool)$input->getOption('relative'));
69 69
                 }, $memory);
70 70
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             }
73 73
         }
74 74
 
75
-        if(!$input->hasParameterOption('--summary')) {
75
+        if (!$input->hasParameterOption('--summary')) {
76 76
             $table->render();
77 77
         }
78 78
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         }, ARRAY_FILTER_USE_KEY);
82 82
 
83 83
         $max = max(array_map('strlen', array_keys($summary)));
84
-        foreach($summary as $name => $set) {
84
+        foreach ($summary as $name => $set) {
85 85
             $output->writeln(sprintf(
86 86
                 "<comment>%s</comment> %s %s",
87 87
                 str_pad($name, $max, ' ', STR_PAD_LEFT),
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     {
131 131
         $mean = array_sum($result) / count($result);
132 132
 
133
-        return sqrt(array_sum(array_map(function ($result) use ($mean) {
133
+        return sqrt(array_sum(array_map(function($result) use ($mean) {
134 134
             return pow($result - $mean, 2);
135 135
         }, $result)) / count($result));
136 136
     }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
         $bytes /= (1 << (10 * $pow));
146 146
 
147
-        return $this->format($bytes);//.$units[$pow].($relative ? '/byte' : '');
147
+        return $this->format($bytes); //.$units[$pow].($relative ? '/byte' : '');
148 148
     }
149 149
 
150 150
     protected function configure()
Please login to merge, or discard this patch.
bin/Commands/Benchmark/RunCommand.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -110,6 +110,9 @@  discard block
 block discarded – undo
110 110
         ;
111 111
     }
112 112
 
113
+    /**
114
+     * @param string $source
115
+     */
113 116
     protected function benchmark($source, Language $language, FormatterInterface $formatter, $geshi = null)
114 117
     {
115 118
         gc_collect_cycles(); // force garbage collector
@@ -161,6 +164,9 @@  discard block
 block discarded – undo
161 164
         ];
162 165
     }
163 166
 
167
+    /**
168
+     * @param string $source
169
+     */
164 170
     protected function geshi($source, $language)
165 171
     {
166 172
         $geshi = microtime(true);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
             $times  = [];
71 71
             $memory = [];
72 72
 
73
-            for($i = $input->getOption('times'), $progress = new ProgressBar($output, $i); $i > 0; $i--) {
73
+            for ($i = $input->getOption('times'), $progress = new ProgressBar($output, $i); $i > 0; $i--) {
74 74
                 $progress->display();
75 75
                 $result = $this->benchmark($source, $language, $formatter);
76
-                $times  = array_merge_recursive($times,  $result['times']);
76
+                $times  = array_merge_recursive($times, $result['times']);
77 77
                 $memory = array_merge_recursive($memory, $result['memory']);
78 78
 
79
-                if($input->getOption('geshi') && class_exists('GeSHi')) {
79
+                if ($input->getOption('geshi') && class_exists('GeSHi')) {
80 80
                     $times['geshi'][] = $this->geshi($source, $file->getExtension());
81 81
                 }
82 82
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
     {
179 179
         $result = json_encode($results, $input->getOption('pretty') ? JSON_PRETTY_PRINT : 0);
180 180
 
181
-        if($input->hasArgument('output')) {
181
+        if ($input->hasArgument('output')) {
182 182
             file_put_contents($input->getArgument('output'), $result);
183 183
         } else {
184 184
             $output->write($result);
Please login to merge, or discard this patch.