@@ -164,6 +164,9 @@ discard block |
||
164 | 164 | return $result; |
165 | 165 | } |
166 | 166 | |
167 | + /** |
|
168 | + * @param string $source |
|
169 | + */ |
|
167 | 170 | public function tokenize($source) |
168 | 171 | { |
169 | 172 | $iterator = new \ArrayIterator($this->_tokens($source)); |
@@ -182,7 +185,7 @@ discard block |
||
182 | 185 | /** |
183 | 186 | * Language range Rule(s) |
184 | 187 | * |
185 | - * @return Rule|Rule[] |
|
188 | + * @return Rule |
|
186 | 189 | */ |
187 | 190 | public function getOpenClose() |
188 | 191 | { |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2015, Some right reserved. |
|
6 | - * |
|
7 | - * @author Kacper "Kadet" Donat <[email protected]> |
|
8 | - * |
|
9 | - * Contact with author: |
|
10 | - * Xmpp: [email protected] |
|
11 | - * E-mail: [email protected] |
|
12 | - * |
|
13 | - * From Kadet with love. |
|
14 | - */ |
|
3 | + * Highlighter |
|
4 | + * |
|
5 | + * Copyright (C) 2015, Some right reserved. |
|
6 | + * |
|
7 | + * @author Kacper "Kadet" Donat <[email protected]> |
|
8 | + * |
|
9 | + * Contact with author: |
|
10 | + * Xmpp: [email protected] |
|
11 | + * E-mail: [email protected] |
|
12 | + * |
|
13 | + * From Kadet with love. |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | namespace Kadet\Highlighter\Utils; |
17 | 17 |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | { |
73 | 73 | if (is_string($tokens)) { |
74 | 74 | $tokens = $this->tokenize($tokens, $additional, $embedded); |
75 | - } elseif(!$tokens instanceof TokenIterator) { |
|
75 | + } elseif (!$tokens instanceof TokenIterator) { |
|
76 | 76 | // Todo: Own Exceptions |
77 | 77 | throw new \InvalidArgumentException('$tokens must be string or TokenIterator'); |
78 | 78 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | /** @var Token[] $all */ $all = []; |
87 | 87 | |
88 | 88 | /** @var Token $token */ |
89 | - for($tokens->next(); $tokens->valid(); $tokens->next()) { |
|
89 | + for ($tokens->next(); $tokens->valid(); $tokens->next()) { |
|
90 | 90 | $token = $tokens->current(); |
91 | 91 | |
92 | 92 | if (!$token->isValid($this, $context)) { |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | if ($token instanceof LanguageToken && $token->getLanguage() === $this) { |
112 | 112 | $result[0]->setEnd($token); |
113 | 113 | |
114 | - if($result[0]->getRule()->postProcess) { |
|
114 | + if ($result[0]->getRule()->postProcess) { |
|
115 | 115 | $source = substr($tokens->getSource(), $result[0]->pos, $result[0]->getLength()); |
116 | 116 | |
117 | 117 | $tokens = $this->tokenize($source, $result, $result[0]->pos, true); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | # closing unclosed tokens |
122 | - foreach(array_reverse($context) as $hash => $name) { |
|
122 | + foreach (array_reverse($context) as $hash => $name) { |
|
123 | 123 | $end = new Token([$name, 'pos' => $token->pos]); |
124 | 124 | $all[$hash]->setEnd($end); |
125 | 125 | $result[] = $end; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | unset($context[spl_object_hash($start)]); |
133 | 133 | } else { |
134 | 134 | /** @noinspection PhpUnusedParameterInspection */ |
135 | - $start = ArrayHelper::find(array_reverse($context), function ($k, $v) use ($token) { |
|
135 | + $start = ArrayHelper::find(array_reverse($context), function($k, $v) use ($token) { |
|
136 | 136 | return $v === $token->name; |
137 | 137 | }); |
138 | 138 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | private function _tokens($source, $offset = 0, $additional = [], $embedded = false) |
166 | 166 | { |
167 | 167 | $all = $this->_rules; |
168 | - if(!$embedded) { |
|
168 | + if (!$embedded) { |
|
169 | 169 | $all['language.' . $this->getIdentifier()] = $this->getOpenClose(); |
170 | 170 | } |
171 | 171 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | /** @var Rule $rule */ |
179 | 179 | foreach ($rules as $rule) { |
180 | - if($rule->language === false) { |
|
180 | + if ($rule->language === false) { |
|
181 | 181 | $rule->language = $this; |
182 | 182 | } |
183 | 183 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | - foreach($this->getEmbedded() as $language) { |
|
191 | + foreach ($this->getEmbedded() as $language) { |
|
192 | 192 | $result = array_merge($result, $language->_tokens($source, $offset)); |
193 | 193 | } |
194 | 194 |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - *1 |
|
5 | - * Copyright (C) 2015, Some right reserved. |
|
6 | - * @author Kacper "Kadet" Donat <[email protected]> |
|
7 | - * |
|
8 | - * Contact with author: |
|
9 | - * Xmpp: [email protected] |
|
10 | - * E-mail: [email protected] |
|
11 | - * |
|
12 | - * From Kadet with love. |
|
13 | - */ |
|
3 | + * Highlighter |
|
4 | + *1 |
|
5 | + * Copyright (C) 2015, Some right reserved. |
|
6 | + * @author Kacper "Kadet" Donat <[email protected]> |
|
7 | + * |
|
8 | + * Contact with author: |
|
9 | + * Xmpp: [email protected] |
|
10 | + * E-mail: [email protected] |
|
11 | + * |
|
12 | + * From Kadet with love. |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | namespace Kadet\Highlighter\Language; |
16 | 16 |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2015, Some right reserved. |
|
6 | - * @author Kacper "Kadet" Donat <[email protected]> |
|
7 | - * |
|
8 | - * Contact with author: |
|
9 | - * Xmpp: [email protected] |
|
10 | - * E-mail: [email protected] |
|
11 | - * |
|
12 | - * From Kadet with love. |
|
13 | - */ |
|
3 | + * Highlighter |
|
4 | + * |
|
5 | + * Copyright (C) 2015, Some right reserved. |
|
6 | + * @author Kacper "Kadet" Donat <[email protected]> |
|
7 | + * |
|
8 | + * Contact with author: |
|
9 | + * Xmpp: [email protected] |
|
10 | + * E-mail: [email protected] |
|
11 | + * |
|
12 | + * From Kadet with love. |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | namespace Kadet\Highlighter\Language; |
16 | 16 |
@@ -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', |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param $styles |
34 | 34 | */ |
35 | 35 | public function __construct($styles = false) { |
36 | - $this->_styles = $styles ?: include __DIR__.'/../Styles/Cli/Default.php'; |
|
36 | + $this->_styles = $styles ?: include __DIR__ . '/../Styles/Cli/Default.php'; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | public function format($source, \Traversable $tokens) |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | $last = $token->pos; |
53 | 53 | } |
54 | - $result .= substr($source, $last).Console::reset(); |
|
54 | + $result .= substr($source, $last) . Console::reset(); |
|
55 | 55 | |
56 | 56 | return $result; |
57 | 57 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public function getColor($token) |
60 | 60 | { |
61 | 61 | do { |
62 | - if(isset($this->_styles[$token])) { |
|
62 | + if (isset($this->_styles[$token])) { |
|
63 | 63 | return $this->_styles[$token]; |
64 | 64 | } |
65 | 65 |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2015, Some right reserved. |
|
6 | - * |
|
7 | - * @author Kacper "Kadet" Donat <[email protected]> |
|
8 | - * |
|
9 | - * Contact with author: |
|
10 | - * Xmpp: [email protected] |
|
11 | - * E-mail: [email protected] |
|
12 | - * |
|
13 | - * From Kadet with love. |
|
14 | - */ |
|
3 | + * Highlighter |
|
4 | + * |
|
5 | + * Copyright (C) 2015, Some right reserved. |
|
6 | + * |
|
7 | + * @author Kacper "Kadet" Donat <[email protected]> |
|
8 | + * |
|
9 | + * Contact with author: |
|
10 | + * Xmpp: [email protected] |
|
11 | + * E-mail: [email protected] |
|
12 | + * |
|
13 | + * From Kadet with love. |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | namespace Kadet\Highlighter\Utils; |
17 | 17 |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | reset($required); |
129 | 129 | while (list($rule, $type) = each($required)) { |
130 | 130 | $matched = !($type & self::CONTEXT_EXACTLY) ? |
131 | - count(array_filter($context, function ($a) use ($rule) { |
|
131 | + count(array_filter($context, function($a) use ($rule) { |
|
132 | 132 | return $a === $rule || fnmatch($rule . '.*', $a); |
133 | 133 | })) > 0 : |
134 | 134 | in_array($rule, $context, true); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | private function _unsetUnnecessaryRules($rule, &$required) |
160 | 160 | { |
161 | 161 | if (strpos($rule, '.') !== false) { |
162 | - foreach (array_filter(array_keys($this->_context), function ($key) use ($rule) { |
|
162 | + foreach (array_filter(array_keys($this->_context), function($key) use ($rule) { |
|
163 | 163 | return fnmatch($key . '.*', $rule); |
164 | 164 | }) as $remove) { |
165 | 165 | unset($required[$remove]); |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2015, Some right reserved. |
|
6 | - * |
|
7 | - * @author Kacper "Kadet" Donat <[email protected]> |
|
8 | - * |
|
9 | - * Contact with author: |
|
10 | - * Xmpp: [email protected] |
|
11 | - * E-mail: [email protected] |
|
12 | - * |
|
13 | - * From Kadet with love. |
|
14 | - */ |
|
3 | + * Highlighter |
|
4 | + * |
|
5 | + * Copyright (C) 2015, Some right reserved. |
|
6 | + * |
|
7 | + * @author Kacper "Kadet" Donat <[email protected]> |
|
8 | + * |
|
9 | + * Contact with author: |
|
10 | + * Xmpp: [email protected] |
|
11 | + * E-mail: [email protected] |
|
12 | + * |
|
13 | + * From Kadet with love. |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | namespace Kadet\Highlighter\Utils; |
17 | 17 |
@@ -20,7 +20,7 @@ |
||
20 | 20 | { |
21 | 21 | public function match($source) |
22 | 22 | { |
23 | - return array_filter(parent::match($source), function (Token $token) { |
|
23 | + return array_filter(parent::match($source), function(Token $token) { |
|
24 | 24 | if ($token->isEnd()) { |
25 | 25 | $token->setStart(null); |
26 | 26 |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - *1 |
|
5 | - * Copyright (C) 2015, Some right reserved. |
|
6 | - * |
|
7 | - * @author Kacper "Kadet" Donat <[email protected]> |
|
8 | - * |
|
9 | - * Contact with author: |
|
10 | - * Xmpp: [email protected] |
|
11 | - * E-mail: [email protected] |
|
12 | - * |
|
13 | - * From Kadet with love. |
|
14 | - */ |
|
3 | + * Highlighter |
|
4 | + *1 |
|
5 | + * Copyright (C) 2015, Some right reserved. |
|
6 | + * |
|
7 | + * @author Kacper "Kadet" Donat <[email protected]> |
|
8 | + * |
|
9 | + * Contact with author: |
|
10 | + * Xmpp: [email protected] |
|
11 | + * E-mail: [email protected] |
|
12 | + * |
|
13 | + * From Kadet with love. |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | namespace Kadet\Highlighter\Utils; |
17 | 17 |
@@ -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 | } |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2015, Some right reserved. |
|
6 | - * |
|
7 | - * @author Kacper "Kadet" Donat <[email protected]> |
|
8 | - * |
|
9 | - * Contact with author: |
|
10 | - * Xmpp: [email protected] |
|
11 | - * E-mail: [email protected] |
|
12 | - * |
|
13 | - * From Kadet with love. |
|
14 | - */ |
|
3 | + * Highlighter |
|
4 | + * |
|
5 | + * Copyright (C) 2015, Some right reserved. |
|
6 | + * |
|
7 | + * @author Kacper "Kadet" Donat <[email protected]> |
|
8 | + * |
|
9 | + * Contact with author: |
|
10 | + * Xmpp: [email protected] |
|
11 | + * E-mail: [email protected] |
|
12 | + * |
|
13 | + * From Kadet with love. |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | namespace Kadet\Highlighter\Utils; |
17 | 17 |
@@ -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 | } |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2015, Some right reserved. |
|
6 | - * |
|
7 | - * @author Kacper "Kadet" Donat <[email protected]> |
|
8 | - * |
|
9 | - * Contact with author: |
|
10 | - * Xmpp: [email protected] |
|
11 | - * E-mail: [email protected] |
|
12 | - * |
|
13 | - * From Kadet with love. |
|
14 | - */ |
|
3 | + * Highlighter |
|
4 | + * |
|
5 | + * Copyright (C) 2015, Some right reserved. |
|
6 | + * |
|
7 | + * @author Kacper "Kadet" Donat <[email protected]> |
|
8 | + * |
|
9 | + * Contact with author: |
|
10 | + * Xmpp: [email protected] |
|
11 | + * E-mail: [email protected] |
|
12 | + * |
|
13 | + * From Kadet with love. |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | namespace Kadet\Highlighter\Utils; |
17 | 17 |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2015, Some right reserved. |
|
6 | - * |
|
7 | - * @author Kacper "Kadet" Donat <[email protected]> |
|
8 | - * |
|
9 | - * Contact with author: |
|
10 | - * Xmpp: [email protected] |
|
11 | - * E-mail: [email protected] |
|
12 | - * |
|
13 | - * From Kadet with love. |
|
14 | - */ |
|
3 | + * Highlighter |
|
4 | + * |
|
5 | + * Copyright (C) 2015, Some right reserved. |
|
6 | + * |
|
7 | + * @author Kacper "Kadet" Donat <[email protected]> |
|
8 | + * |
|
9 | + * Contact with author: |
|
10 | + * Xmpp: [email protected] |
|
11 | + * E-mail: [email protected] |
|
12 | + * |
|
13 | + * From Kadet with love. |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | namespace Kadet\Highlighter\Utils; |
17 | 17 |
@@ -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 |