@@ -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 | } |
@@ -45,14 +45,14 @@ |
||
| 45 | 45 | |
| 46 | 46 | public static function rearrange(array $array, array $keys) |
| 47 | 47 | { |
| 48 | - return array_combine($keys, array_map(function ($key) use ($array) { |
|
| 48 | + return array_combine($keys, array_map(function($key) use ($array) { |
|
| 49 | 49 | return $array[$key]; |
| 50 | 50 | }, $keys)); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | public static function column(array $array, $index) |
| 54 | 54 | { |
| 55 | - return array_map(function ($e) use ($index) { return $e[$index]; }, $array); |
|
| 55 | + return array_map(function($e) use ($index) { return $e[$index]; }, $array); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | public static function find(array $array, callable $tester) |
@@ -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)); |
@@ -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 | */ |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return false|Token|null |
| 50 | 50 | */ |
| 51 | - public function create($name, $params = [ ]) |
|
| 51 | + public function create($name, $params = []) |
|
| 52 | 52 | { |
| 53 | 53 | $name = $name !== null ? $this->getName($name) : $this->_base; |
| 54 | 54 | |
@@ -61,24 +61,24 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | $class = isset($params['class']) ? $params['class'] : $this->_class; |
| 64 | - $end = isset($params['end']) ? $params['end'] : null; |
|
| 64 | + $end = isset($params['end']) ? $params['end'] : null; |
|
| 65 | 65 | $start = isset($params['start']) ? $params['start'] : null; |
| 66 | 66 | |
| 67 | 67 | // we don't want to pass that into token |
| 68 | 68 | unset($params['class'], $params['end'], $params['start']); |
| 69 | 69 | |
| 70 | - if($this->_type & Token::START) { |
|
| 71 | - if($start === null) { |
|
| 70 | + if ($this->_type & Token::START) { |
|
| 71 | + if ($start === null) { |
|
| 72 | 72 | $start = new $class($name, $params); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if($this->_type === Token::START) { |
|
| 75 | + if ($this->_type === Token::START) { |
|
| 76 | 76 | $start->setEnd(false); |
| 77 | 77 | return $start; |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if($this->_type & Token::END) { |
|
| 81 | + if ($this->_type & Token::END) { |
|
| 82 | 82 | if (isset($params['length'])) { |
| 83 | 83 | $length = $params['length']; |
| 84 | 84 | unset($params['length']); |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | /** @var Token $end */ |
| 90 | 90 | $end = new $class($name, $end); |
| 91 | - } elseif($end === null) { |
|
| 91 | + } elseif ($end === null) { |
|
| 92 | 92 | $end = new $class($name, $params); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if($this->_type === Token::END || $start === null) { |
|
| 95 | + if ($this->_type === Token::END || $start === null) { |
|
| 96 | 96 | $end->setStart(false); |
| 97 | 97 | return $end; |
| 98 | 98 | } |
@@ -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 | } |
@@ -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', |
@@ -59,7 +59,7 @@ |
||
| 59 | 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 = []; |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | new CloseRule(new SubStringMatcher(')')), |
| 70 | 70 | ], |
| 71 | 71 | |
| 72 | - 'keyword.at-rule' => new Rule(new RegexMatcher('/(@(?:-[a-z]+-)?(?:'.implode('|', $at).'))/'), [ |
|
| 72 | + 'keyword.at-rule' => new Rule(new RegexMatcher('/(@(?:-[a-z]+-)?(?:' . implode('|', $at) . '))/'), [ |
|
| 73 | 73 | 'priority' => 2 |
| 74 | 74 | ]), |
| 75 | 75 | |
@@ -108,6 +108,9 @@ discard block |
||
| 108 | 108 | return $this->_parser->process($tokens); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | + /** |
|
| 112 | + * @param string $source |
|
| 113 | + */ |
|
| 111 | 114 | public function tokenize($source, $additional = [], $offset = 0, $embedded = false) |
| 112 | 115 | { |
| 113 | 116 | return new TokenIterator( |
@@ -145,7 +148,7 @@ discard block |
||
| 145 | 148 | /** |
| 146 | 149 | * @param bool $embedded |
| 147 | 150 | * |
| 148 | - * @return Rule[] |
|
| 151 | + * @return \Generator |
|
| 149 | 152 | */ |
| 150 | 153 | private function _rules($embedded = false) |
| 151 | 154 | { |
@@ -177,7 +180,7 @@ discard block |
||
| 177 | 180 | * |
| 178 | 181 | * @param $embedded |
| 179 | 182 | * |
| 180 | - * @return Rule|\Kadet\Highlighter\Parser\Rule[] |
|
| 183 | + * @return Rule |
|
| 181 | 184 | */ |
| 182 | 185 | public function getEnds($embedded = false) |
| 183 | 186 | { |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | ]); |
| 100 | 100 | |
| 101 | 101 | for ($tokens->next(); $tokens->valid(); $tokens->next()) { |
| 102 | - if(!$tokens->current()->process($context, $this, $result, $tokens)) { |
|
| 102 | + if (!$tokens->current()->process($context, $this, $result, $tokens)) { |
|
| 103 | 103 | break; |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | private function _rules($embedded = false) |
| 150 | 150 | { |
| 151 | 151 | $rules = clone $this->rules; |
| 152 | - if(is_bool($embedded)) { |
|
| 153 | - $rules->addMany(['language.'.$this->getIdentifier() => $this->getEnds($embedded)]); |
|
| 152 | + if (is_bool($embedded)) { |
|
| 153 | + $rules->addMany(['language.' . $this->getIdentifier() => $this->getEnds($embedded)]); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | foreach ($rules->all() as $rule) { |