@@ -45,7 +45,7 @@ |
||
45 | 45 | |
46 | 46 | protected function processEnd(Context $context, Language $language, Result $result, TokenIterator $tokens) |
47 | 47 | { |
48 | - foreach(array_filter($context->stack, function ($name) { |
|
48 | + foreach (array_filter($context->stack, function($name) { |
|
49 | 49 | return in_array($name, $this->closes); |
50 | 50 | }) as $hash => $name) { |
51 | 51 | $end = new Token($name, ['pos' => $this->pos]); |
@@ -19,14 +19,14 @@ |
||
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) |
@@ -61,7 +61,7 @@ |
||
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 |
@@ -31,7 +31,7 @@ discard block |
||
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 |
||
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 | } |
@@ -51,7 +51,7 @@ |
||
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+))/')), |
@@ -26,7 +26,7 @@ |
||
26 | 26 | htmlspecialchars(substr($source, $last, $token->pos - $last)) |
27 | 27 | ); |
28 | 28 | |
29 | - if($token->isStart()) { |
|
29 | + if ($token->isStart()) { |
|
30 | 30 | $result .= $stack[] = $this->getOpenTag($token); |
31 | 31 | } else { |
32 | 32 | array_pop($stack); |
@@ -41,7 +41,7 @@ |
||
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 | ) |
@@ -35,7 +35,7 @@ discard block |
||
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 |
||
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); |
@@ -99,6 +99,9 @@ |
||
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'); |
@@ -59,7 +59,7 @@ discard block |
||
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 |
||
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 |
||
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 | } |