@@ -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 | ) |
@@ -49,7 +49,7 @@ discard block |
||
| 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 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if(!$input->hasOption('summary')) { |
|
| 62 | + if (!$input->hasOption('summary')) { |
|
| 63 | 63 | $table->render(); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | }, ARRAY_FILTER_USE_KEY); |
| 69 | 69 | |
| 70 | 70 | $max = max(array_map('strlen', array_keys($summary))); |
| 71 | - foreach($summary as $name => $set) { |
|
| 71 | + foreach ($summary as $name => $set) { |
|
| 72 | 72 | $output->writeln(sprintf( |
| 73 | 73 | "<comment>%s</comment> %s %s", |
| 74 | 74 | str_pad($name, $max, ' ', STR_PAD_LEFT), |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | { |
| 118 | 118 | $mean = array_sum($result) / count($result); |
| 119 | 119 | |
| 120 | - return sqrt(array_sum(array_map(function ($result) use ($mean) { |
|
| 120 | + return sqrt(array_sum(array_map(function($result) use ($mean) { |
|
| 121 | 121 | return pow($result - $mean, 2); |
| 122 | 122 | }, $result)) / count($result)); |
| 123 | 123 | } |
@@ -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); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | /** @var \SplFileInfo $file */ |
| 53 | 53 | foreach ($iterator as $file) { |
| 54 | 54 | $pathname = substr($file->getPathname(), strlen($this->_input) + 1); |
| 55 | - if(!$this->regenerate($input, $pathname)) { |
|
| 55 | + if (!$this->regenerate($input, $pathname)) { |
|
| 56 | 56 | continue; |
| 57 | 57 | } |
| 58 | 58 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $language = Language::byFilename($pathname); |
| 62 | 62 | $result = StringHelper::normalize($this->_keylighter->highlight(file_get_contents($file->getPathname()), $language, $this->_formatter)); |
| 63 | 63 | |
| 64 | - if(!file_exists($this->_output.'/'.dirname($pathname))) { |
|
| 64 | + if (!file_exists($this->_output.'/'.dirname($pathname))) { |
|
| 65 | 65 | mkdir($this->_output.'/'.dirname($pathname), true); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | $filename = str_replace(DIRECTORY_SEPARATOR, '/', $filename); |
| 74 | 74 | $patterns = $input->getArgument('files'); |
| 75 | 75 | |
| 76 | - foreach($patterns as $pattern) { |
|
| 77 | - if($input->getOption('new') && file_exists("{$this->_output}/$filename.tkn")) { |
|
| 76 | + foreach ($patterns as $pattern) { |
|
| 77 | + if ($input->getOption('new') && file_exists("{$this->_output}/$filename.tkn")) { |
|
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if(fnmatch($pattern, $filename)) { |
|
| 81 | + if (fnmatch($pattern, $filename)) { |
|
| 82 | 82 | return true; |
| 83 | 83 | } |
| 84 | 84 | } |