@@ -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 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param $styles |
| 36 | 36 | */ |
| 37 | 37 | public function __construct($styles = false) { |
| 38 | - $this->_styles = $styles ?: include __DIR__.'/../Styles/Cli/Default.php'; |
|
| 38 | + $this->_styles = $styles ?: include __DIR__ . '/../Styles/Cli/Default.php'; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function format(TokenIterator $tokens) |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | $last = $token->pos; |
| 57 | 57 | } |
| 58 | - $result .= substr($source, $last).Console::reset(); |
|
| 58 | + $result .= substr($source, $last) . Console::reset(); |
|
| 59 | 59 | |
| 60 | 60 | return $result; |
| 61 | 61 | } |
@@ -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 | |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | '__CLASS__', '__DIR__', '__FILE__', '__FUNCTION__', |
| 82 | 82 | '__LINE__', '__METHOD__', '__NAMESPACE__', '__TRAIT__', |
| 83 | 83 | ], array_keys(get_defined_constants(true)["Core"]))), ['priority' => -2]), |
| 84 | - 'constant.static' => new Rule(new RegexMatcher('/(?:[\w\\\]+::|const\s+)(\w+)/i'), ['priority' => -2] ), |
|
| 84 | + 'constant.static' => new Rule(new RegexMatcher('/(?:[\w\\\]+::|const\s+)(\w+)/i'), ['priority' => -2]), |
|
| 85 | 85 | |
| 86 | 86 | 'keyword' => new Rule(new WordMatcher([ |
| 87 | 87 | '__halt_compiler', 'abstract', 'and', 'array', |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | ]), |
| 54 | 54 | ]; |
| 55 | 55 | |
| 56 | - if($this->variables) { |
|
| 56 | + if ($this->variables) { |
|
| 57 | 57 | $rules = array_merge($rules, [ |
| 58 | 58 | 'variable' => new Rule(new RegexMatcher('/(' . self::IDENTIFIER . ')/iu'), ['priority' => -10000]), |
| 59 | 59 | 'variable.property' => new Rule(new RegexMatcher('/(?=(?:\w|\)|\])\s*\.([a-z_]\w*))/i'), [ |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | 'INTERSECT', 'INTERVAL', 'INTO', 'IS', 'ITERATE', 'LANGUAGE', 'LARGE', 'LATERAL', 'LEADING', |
| 41 | 41 | 'LEAVE', 'LEFT', 'LIKE', 'LOCAL', 'LOOP', 'MATCH', 'MEMBER', 'MERGE', 'METHOD', 'MODIFIES', |
| 42 | 42 | 'MODULE', 'MONTH', 'MULTISET', 'NATIONAL', 'NATURAL', 'NCHAR', 'NCLOB', 'NEW', 'NO', 'NONE', 'NOT', |
| 43 | - 'OF', 'OLD', 'ON', 'ONLY', 'OPEN', 'OR', 'ORDER', 'OUT','OUTER', 'OUTPUT', 'OVER', |
|
| 43 | + 'OF', 'OLD', 'ON', 'ONLY', 'OPEN', 'OR', 'ORDER', 'OUT', 'OUTER', 'OUTPUT', 'OVER', |
|
| 44 | 44 | 'OVERLAPS', 'PARAMETER', 'PARTITION', 'PRECISION', 'PREPARE', 'PRIMARY', 'PROCEDURE', 'RANGE', 'READS', |
| 45 | 45 | 'RECURSIVE', 'REF', 'REFERENCES', 'REFERENCING', 'RELEASE', |
| 46 | 46 | 'REPEAT', 'RESIGNAL', 'RESULT', 'RETURN', 'RETURNS', 'REVOKE', 'RIGHT', 'ROLLBACK', 'ROLLUP', 'ROW', |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | $js = new JavaScriptLanguage(); |
| 29 | 29 | |
| 30 | 30 | return array_merge(parent::getRules(), [ |
| 31 | - 'language.'.$js->getIdentifier() => [ |
|
| 31 | + 'language.' . $js->getIdentifier() => [ |
|
| 32 | 32 | new OpenRule(new RegexMatcher('/<script.*?>()/'), [ |
| 33 | 33 | 'factory' => new TokenFactory('Kadet\\Highlighter\\Parser\\LanguageToken'), |
| 34 | 34 | 'inject' => $js, |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | public static function rearrange(array $array, array $keys) |
| 22 | 22 | { |
| 23 | - return array_combine($keys, array_map(function ($key) use ($array) { |
|
| 23 | + return array_combine($keys, array_map(function($key) use ($array) { |
|
| 24 | 24 | return $array[$key]; |
| 25 | 25 | }, $keys)); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | public static function column(array $array, $index) |
| 29 | 29 | { |
| 30 | - return array_map(function ($e) use ($index) { return $e[$index]; }, $array); |
|
| 30 | + return array_map(function($e) use ($index) { return $e[$index]; }, $array); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public static function find(array $array, callable $tester) |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | public static function resolve(array $array, $key, $fallback = null) { |
| 45 | 45 | do { |
| 46 | - if(isset($array[$key])) { |
|
| 46 | + if (isset($array[$key])) { |
|
| 47 | 47 | return $array[$key]; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -140,7 +140,7 @@ |
||
| 140 | 140 | } else { |
| 141 | 141 | /** @noinspection PhpUnusedParameterInspection */ |
| 142 | 142 | $start = ArrayHelper::find( |
| 143 | - array_reverse($context), function ($k, $v) use ($token) { |
|
| 143 | + array_reverse($context), function($k, $v) use ($token) { |
|
| 144 | 144 | return $v === $token->name; |
| 145 | 145 | }); |
| 146 | 146 | |