@@ -34,7 +34,7 @@ |
||
| 34 | 34 | ], $options); |
| 35 | 35 | |
| 36 | 36 | if ($options['escape']) { |
| 37 | - $words = array_map(function ($word) { |
|
| 37 | + $words = array_map(function($word) { |
|
| 38 | 38 | return preg_quote($word, '/'); |
| 39 | 39 | }, $words); |
| 40 | 40 | } |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | $all = []; |
| 53 | 53 | |
| 54 | 54 | foreach ($this->multiLine as $name => $comment) { |
| 55 | - $comment = array_map(function ($e) { return preg_quote($e, '/'); }, $comment); |
|
| 55 | + $comment = array_map(function($e) { return preg_quote($e, '/'); }, $comment); |
|
| 56 | 56 | |
| 57 | 57 | $all[] = [$name, "/{$comment[0]}(.*?){$comment[1]}/ms"]; |
| 58 | 58 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | * @return ConsoleHelper |
| 28 | 28 | */ |
| 29 | 29 | public static function get() { |
| 30 | - if(!isset(self::$_instance)) { |
|
| 30 | + if (!isset(self::$_instance)) { |
|
| 31 | 31 | self::$_instance = new ConsoleHelper(); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | ]; |
| 32 | 32 | |
| 33 | 33 | public function styled($style, $text) { |
| 34 | - return $this->open($style).$text.$this->close(); |
|
| 34 | + return $this->open($style) . $text . $this->close(); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | public function open($style) |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | public function close() |
| 49 | 49 | { |
| 50 | 50 | $this->_current = empty($this->_stack) ? $this->_default : array_pop($this->_stack); |
| 51 | - return "\033[0m".$this->_set(array_diff($this->_current, $this->_default)); |
|
| 51 | + return "\033[0m" . $this->_set(array_diff($this->_current, $this->_default)); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | private function _color($name, $bg = false) |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | private function _style($name, $value) { |
| 80 | - switch($name) { |
|
| 80 | + switch ($name) { |
|
| 81 | 81 | case 'color': |
| 82 | 82 | return $this->_color($value); |
| 83 | 83 | case 'background': |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | private function _set($style) { |
| 101 | - $escape = "\e[".implode(';', array_map(function($style, $name) { |
|
| 101 | + $escape = "\e[" . implode(';', array_map(function($style, $name) { |
|
| 102 | 102 | return $this->_style($style, $name); |
| 103 | - }, array_keys($style), $style)).'m'; |
|
| 103 | + }, array_keys($style), $style)) . 'm'; |
|
| 104 | 104 | |
| 105 | 105 | return $escape === "\e[m" ? null : $escape; |
| 106 | 106 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | * @return ConsoleHelper |
| 28 | 28 | */ |
| 29 | 29 | public static function get() { |
| 30 | - if(!isset(self::$_instance)) { |
|
| 30 | + if (!isset(self::$_instance)) { |
|
| 31 | 31 | self::$_instance = new ConsoleHelper(); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * @param Language|callable|string $language |
| 65 | - * @param array[string] $aliases |
|
| 65 | + * @param string[] $aliases |
|
| 66 | 66 | */ |
| 67 | 67 | public function registerLanguage($language, $aliases) { |
| 68 | 68 | $this->_languages = array_merge($this->_languages, array_fill_keys($aliases, $language)); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function getLanguage($name) { |
| 51 | 51 | $embedded = []; |
| 52 | - if(($pos = strpos($name, '>')) !== false) { |
|
| 52 | + if (($pos = strpos($name, '>')) !== false) { |
|
| 53 | 53 | $embedded[] = self::getLanguage(trim(substr($name, $pos + 1))); |
| 54 | 54 | $name = trim(substr($name, 0, $pos)); |
| 55 | 55 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | public function highlight($source, $language, FormatterInterface $formatter = null) { |
| 84 | 84 | $formatter = $formatter ?: $this->getDefaultFormatter(); |
| 85 | 85 | |
| 86 | - if(!$language instanceof Language) { |
|
| 86 | + if (!$language instanceof Language) { |
|
| 87 | 87 | $language = $this->getLanguage($language); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | |
| 42 | 42 | protected function validate(Language $language, $context) |
| 43 | 43 | { |
| 44 | - if($language !== $this->getRule()->language) { |
|
| 44 | + if ($language !== $this->getRule()->language) { |
|
| 45 | 45 | return false; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -56,10 +56,10 @@ |
||
| 56 | 56 | public function sort() { |
| 57 | 57 | ksort($this->_tokens); |
| 58 | 58 | |
| 59 | - foreach(array_keys($this->_pending) as $position) { |
|
| 59 | + foreach (array_keys($this->_pending) as $position) { |
|
| 60 | 60 | uasort( |
| 61 | 61 | $this->_tokens[$position], |
| 62 | - Token::class.'::compare' |
|
| 62 | + Token::class . '::compare' |
|
| 63 | 63 | ); |
| 64 | 64 | } |
| 65 | 65 | $this->_pending = []; |
@@ -113,7 +113,7 @@ |
||
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | - * @param mixed $class |
|
| 116 | + * @param string $class |
|
| 117 | 117 | * |
| 118 | 118 | * @throws \InvalidArgumentException |
| 119 | 119 | */ |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function create($params) { |
| 48 | 48 | $params[0] = !empty($params[0]) ? $this->getName($params[0]) : $this->_base; |
| 49 | - if(empty($params['rule'])) { |
|
| 49 | + if (empty($params['rule'])) { |
|
| 50 | 50 | $params['rule'] = $this->_rule; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - if(isset($params['pos'])) { |
|
| 53 | + if (isset($params['pos'])) { |
|
| 54 | 54 | $params['pos'] += $this->_offset; |
| 55 | 55 | } |
| 56 | 56 | |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | /** @var Token $token */ |
| 67 | 67 | $token = new $this->_class($params); |
| 68 | 68 | |
| 69 | - if($this->_type == 0x3) { |
|
| 69 | + if ($this->_type == 0x3) { |
|
| 70 | 70 | return $token; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if($this->_type === Token::START) { |
|
| 73 | + if ($this->_type === Token::START) { |
|
| 74 | 74 | $token->setEnd(false); |
| 75 | 75 | return $token; |
| 76 | 76 | } else { |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function setClass($class) |
| 121 | 121 | { |
| 122 | - if(!is_a($class, 'Kadet\Highlighter\Parser\Token', true)) { |
|
| 122 | + if (!is_a($class, 'Kadet\Highlighter\Parser\Token', true)) { |
|
| 123 | 123 | throw new \InvalidArgumentException('$class must extend Kadet\Highlighter\Parser\Token'); |
| 124 | 124 | } |
| 125 | 125 | |