@@ -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 @@ discard block |
||
61 | 61 | |
62 | 62 | 'comment' => new Rule(new CommentMatcher(['//'], [['/*', '*/']]), ['priority' => 3]), |
63 | 63 | |
64 | - 'call' => new Rule(new RegexMatcher('/(' . self::IDENTIFIER . ')\s*\(/iu'), ['priority' => -1]), |
|
64 | + 'call' => new Rule(new RegexMatcher('/('.self::IDENTIFIER.')\s*\(/iu'), ['priority' => -1]), |
|
65 | 65 | |
66 | 66 | 'keyword' => new Rule(new WordMatcher([ |
67 | 67 | 'do', 'if', 'in', 'for', 'let', 'new', 'try', 'var', 'case', 'else', 'enum', 'eval', |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | ]) |
91 | 91 | ], |
92 | 92 | |
93 | - 'variable' => new Rule(new RegexMatcher('/\b(?<!\.)(' . self::IDENTIFIER . ':?)/iu'), [ |
|
93 | + 'variable' => new Rule(new RegexMatcher('/\b(?<!\.)('.self::IDENTIFIER.':?)/iu'), [ |
|
94 | 94 | 'priority' => -1, |
95 | 95 | 'enabled' => $this->variables |
96 | 96 | ]) |
@@ -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); |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
174 | - if(!isset($this[$type][$index])) { |
|
174 | + if (!isset($this[$type][$index])) { |
|
175 | 175 | throw new NoSuchElementException("There is no rule '$type' type indexed by '$index'."); |
176 | 176 | } |
177 | 177 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | public function all() |
187 | 187 | { |
188 | 188 | $items = $this->getArrayCopy(); |
189 | - if(empty($items)) return []; |
|
189 | + if (empty($items)) return []; |
|
190 | 190 | |
191 | 191 | return call_user_func_array('array_merge', $items); |
192 | 192 | } |