@@ -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 | { |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | |
83 | 83 | /** @var Token $token */ |
84 | - for($tokens->next(); $tokens->valid(); $tokens->next()) { |
|
84 | + for ($tokens->next(); $tokens->valid(); $tokens->next()) { |
|
85 | 85 | $token = $tokens->current(); |
86 | 86 | |
87 | 87 | if (!$token->isValid($this, $context)) { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | unset($context[spl_object_hash($start)]); |
111 | 111 | } else { |
112 | 112 | /** @noinspection PhpUnusedParameterInspection */ |
113 | - $start = ArrayHelper::find(array_reverse($context), function ($k, $v) use ($token) { |
|
113 | + $start = ArrayHelper::find(array_reverse($context), function($k, $v) use ($token) { |
|
114 | 114 | return $v === $token->name; |
115 | 115 | }); |
116 | 116 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | /** @var Rule $rule */ |
149 | 149 | foreach ($rules as $rule) { |
150 | - if($name !== 'language.' . $this->getIdentifier()) { |
|
150 | + if ($name !== 'language.' . $this->getIdentifier()) { |
|
151 | 151 | $rule->setLanguage($this); |
152 | 152 | } |
153 | 153 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | - foreach($this->_embedded as $language) { |
|
160 | + foreach ($this->_embedded as $language) { |
|
161 | 161 | $result = array_merge($result, $language->_tokens($source)); |
162 | 162 | } |
163 | 163 |
@@ -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 |
@@ -31,7 +31,7 @@ |
||
31 | 31 | /** |
32 | 32 | * TokenFactory constructor. |
33 | 33 | * |
34 | - * @param $class |
|
34 | + * @param string $class |
|
35 | 35 | */ |
36 | 36 | public function __construct($class, $type = 0x3) { |
37 | 37 | $this->_class = $class; |
@@ -40,7 +40,7 @@ |
||
40 | 40 | |
41 | 41 | public function create($params) { |
42 | 42 | $params[0] = !empty($params[0]) ? $this->getName($params[0]) : $this->_base; |
43 | - if(empty($params['rule'])) { |
|
43 | + if (empty($params['rule'])) { |
|
44 | 44 | $params['rule'] = $this->_rule; |
45 | 45 | } |
46 | 46 |
@@ -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,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 |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public static function getLanguage($name) { |
39 | 39 | $embedded = []; |
40 | - if(($pos = strpos($name, '>')) !== false) { |
|
40 | + if (($pos = strpos($name, '>')) !== false) { |
|
41 | 41 | $embedded[] = self::getLanguage(trim(substr($name, $pos + 1))); |
42 | 42 | $name = trim(substr($name, 0, $pos)); |
43 | 43 | } |
44 | 44 | |
45 | - if(!isset(self::$_languages[$name])) { |
|
45 | + if (!isset(self::$_languages[$name])) { |
|
46 | 46 | throw new \InvalidArgumentException("Language $name is not defined."); |
47 | 47 | } |
48 | 48 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | public static function highlight($source, $language, FormatterInterface $formatter = null) { |
69 | 69 | $formatter = $formatter ?: self::getDefaultFormatter(); |
70 | 70 | |
71 | - if(!$language instanceof Language) { |
|
71 | + if (!$language instanceof Language) { |
|
72 | 72 | $language = self::getLanguage($language); |
73 | 73 | } |
74 | 74 | |
@@ -80,8 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | Highlighter::setDefaultFormatter( |
82 | 82 | php_sapi_name() === 'cli' ? |
83 | - new CliFormatter() : |
|
84 | - new HtmlFormatter() |
|
83 | + new CliFormatter() : new HtmlFormatter() |
|
85 | 84 | ); |
86 | 85 | |
87 | 86 | Highlighter::registerLanguage('Kadet\\Highlighter\\Language\\PhpLanguage', ['php']); |
@@ -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 |
@@ -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 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | |
42 | 42 | protected function validate(Language $language, $context) |
43 | 43 | { |
44 | - if($language !== $this->getRule()->getLanguage()) { |
|
44 | + if ($language !== $this->getRule()->getLanguage()) { |
|
45 | 45 | return false; |
46 | 46 | } |
47 | 47 |
@@ -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 |