@@ -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+))/')), |
@@ -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 | } |
@@ -54,8 +54,8 @@ |
||
| 54 | 54 | $split = preg_split('/\R\R/', $source, 2); |
| 55 | 55 | |
| 56 | 56 | $http = $split[0]; |
| 57 | - if(isset($split[1]) && $payload = $split[1]) { |
|
| 58 | - if(preg_match('/Content-Type: ([^;\r\n]*)/', $http, $matches)) { |
|
| 57 | + if (isset($split[1]) && $payload = $split[1]) { |
|
| 58 | + if (preg_match('/Content-Type: ([^;\r\n]*)/', $http, $matches)) { |
|
| 59 | 59 | $mime = $matches[1]; |
| 60 | 60 | } else { |
| 61 | 61 | $mime = 'text/plain'; |
@@ -38,9 +38,9 @@ |
||
| 38 | 38 | new OpenRule(new RegexMatcher('/(<[\w\.-]+)[:\/>:\s]/')), |
| 39 | 39 | new CloseRule(new SubStringMatcher('>'), ['context' => ['!string', '!comment']]), |
| 40 | 40 | ], |
| 41 | - 'tag.close' => new Rule(new RegexMatcher('/(<\/' . self::IDENTIFIER . '>)/')), |
|
| 41 | + 'tag.close' => new Rule(new RegexMatcher('/(<\/'.self::IDENTIFIER.'>)/')), |
|
| 42 | 42 | |
| 43 | - 'symbol.tag' => new Rule(new RegexMatcher('/<\\/?' . self::IDENTIFIER . '/', [ |
|
| 43 | + 'symbol.tag' => new Rule(new RegexMatcher('/<\\/?'.self::IDENTIFIER.'/', [ |
|
| 44 | 44 | 'name' => Token::NAME, |
| 45 | 45 | 'namespace' => '$.namespace', |
| 46 | 46 | ]), ['context' => ['tag', '!string']]), |
@@ -26,10 +26,10 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | protected function execute(InputInterface $input, OutputInterface $output) |
| 28 | 28 | { |
| 29 | - if($input->getOption('dry')) { |
|
| 29 | + if ($input->getOption('dry')) { |
|
| 30 | 30 | $output->writeln($this->generate()); |
| 31 | 31 | } else { |
| 32 | - $path = __DIR__ . '/../../../Docs/A-languages.md'; |
|
| 32 | + $path = __DIR__.'/../../../Docs/A-languages.md'; |
|
| 33 | 33 | |
| 34 | 34 | $output->writeln("<info>Opening file ./Docs/A-languages.md ...</info>", OutputInterface::VERBOSITY_VERBOSE); |
| 35 | 35 | $content = file_get_contents($path); |
@@ -54,19 +54,19 @@ discard block |
||
| 54 | 54 | protected function generate() |
| 55 | 55 | { |
| 56 | 56 | $result = []; |
| 57 | - foreach(['name', 'mime', 'extension'] as $what) { |
|
| 58 | - foreach(KeyLighter::get()->registeredLanguages($what, true) as $name => $class) { |
|
| 57 | + foreach (['name', 'mime', 'extension'] as $what) { |
|
| 58 | + foreach (KeyLighter::get()->registeredLanguages($what, true) as $name => $class) { |
|
| 59 | 59 | $result[$class][$what][] = $name; |
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - $return = 'Class | Name | MIME | Extension'.PHP_EOL; |
|
| 64 | - $return .= '------|------|------|----------'.PHP_EOL; |
|
| 65 | - foreach($result as $class => $aliases) { |
|
| 63 | + $return = 'Class | Name | MIME | Extension'.PHP_EOL; |
|
| 64 | + $return .= '------|------|------|----------'.PHP_EOL; |
|
| 65 | + foreach ($result as $class => $aliases) { |
|
| 66 | 66 | $return .= '`'.$class.'` | '; |
| 67 | 67 | $return .= (isset($aliases['name']) ? '`'.implode('`, `', $aliases['name']).'`' : 'none').' | '; |
| 68 | 68 | $return .= (isset($aliases['mime']) ? '`'.implode('`, `', $aliases['mime']).'`' : 'none').' | '; |
| 69 | - $return .= (isset($aliases['extension']) ? '`'.implode('`, `', $aliases['extension']).'`' : 'none'). PHP_EOL; |
|
| 69 | + $return .= (isset($aliases['extension']) ? '`'.implode('`, `', $aliases['extension']).'`' : 'none').PHP_EOL; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | return $return; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | 'comment' => new Rule(new CommentMatcher(['//'], [['/*', '*/']]), ['priority' => 3]), |
| 64 | 64 | |
| 65 | - 'call' => new Rule(new RegexMatcher('/(' . self::IDENTIFIER . ')\s*\(/iu'), ['priority' => -1]), |
|
| 65 | + 'call' => new Rule(new RegexMatcher('/('.self::IDENTIFIER.')\s*\(/iu'), ['priority' => -1]), |
|
| 66 | 66 | |
| 67 | 67 | 'keyword' => new Rule(new WordMatcher([ |
| 68 | 68 | 'do', 'if', 'in', 'for', 'let', 'new', 'try', 'var', 'case', 'else', 'enum', 'eval', |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | ]) |
| 92 | 92 | ], |
| 93 | 93 | |
| 94 | - 'variable' => new Rule(new RegexMatcher('/\b(?<!\.)(' . self::IDENTIFIER . ':?)/iu'), [ |
|
| 94 | + 'variable' => new Rule(new RegexMatcher('/\b(?<!\.)('.self::IDENTIFIER.':?)/iu'), [ |
|
| 95 | 95 | 'priority' => -1, |
| 96 | 96 | 'enabled' => $this->variables |
| 97 | 97 | ]), |