@@ -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 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | public function setContext($rules) |
| 72 | 72 | { |
| 73 | - if(is_callable($rules)) { |
|
| 73 | + if (is_callable($rules)) { |
|
| 74 | 74 | $this->_validator = $rules; |
| 75 | 75 | } else { |
| 76 | 76 | $this->_context = []; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | public function validate($context, array $additional = []) |
| 126 | 126 | { |
| 127 | - if(is_callable($this->_validator)) { |
|
| 127 | + if (is_callable($this->_validator)) { |
|
| 128 | 128 | $validator = $this->_validator; |
| 129 | 129 | return $validator($context, $additional); |
| 130 | 130 | } else { |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | reset($rules); |
| 143 | 143 | while (list($rule, $type) = each($rules)) { |
| 144 | 144 | $matched = !($type & self::CONTEXT_EXACTLY) ? |
| 145 | - count(array_filter($context, function ($a) use ($rule) { |
|
| 145 | + count(array_filter($context, function($a) use ($rule) { |
|
| 146 | 146 | return $a === $rule || fnmatch($rule . '.*', $a); |
| 147 | 147 | })) > 0 : |
| 148 | 148 | in_array($rule, $context, true); |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | private function _unsetUnnecessaryRules($rule, &$required) |
| 174 | 174 | { |
| 175 | 175 | if (strpos($rule, '.') !== false) { |
| 176 | - foreach (array_filter(array_keys($this->_context), function ($key) use ($rule) { |
|
| 176 | + foreach (array_filter(array_keys($this->_context), function($key) use ($rule) { |
|
| 177 | 177 | return fnmatch($key . '.*', $rule); |
| 178 | 178 | }) as $remove) { |
| 179 | 179 | unset($required[$remove]); |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | public static function everywhere() { |
| 195 | 195 | static $callable; |
| 196 | - if(!$callable) { |
|
| 196 | + if (!$callable) { |
|
| 197 | 197 | $callable = function() { |
| 198 | 198 | return true; |
| 199 | 199 | }; |
@@ -34,9 +34,9 @@ |
||
| 34 | 34 | |
| 35 | 35 | if ($this->isStart()) { |
| 36 | 36 | $lang = $this->_rule->language; |
| 37 | - if($lang === null && $this->getInjected() !== $language) { |
|
| 37 | + if ($lang === null && $this->getInjected() !== $language) { |
|
| 38 | 38 | $valid = true; |
| 39 | - } elseif($language === $lang && $this->_rule->validate($context)) { |
|
| 39 | + } elseif ($language === $lang && $this->_rule->validate($context)) { |
|
| 40 | 40 | $valid = true; |
| 41 | 41 | } |
| 42 | 42 | } else { |