@@ -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 | |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | * @param array $options |
| 50 | 50 | */ |
| 51 | 51 | public function __construct(array $options = []) { |
| 52 | - $this->_options = array_merge([ |
|
| 52 | + $this->_options = array_merge([ |
|
| 53 | 53 | 'embedded' => [], |
| 54 | 54 | ], $this->_options, $options); |
| 55 | 55 | |
| 56 | - $this->_rules = $this->getRules(); |
|
| 56 | + $this->_rules = $this->getRules(); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | if (is_string($tokens)) { |
| 79 | 79 | $tokens = $this->tokenize($tokens, $additional, $embedded); |
| 80 | - } elseif(!$tokens instanceof TokenIterator) { |
|
| 80 | + } elseif (!$tokens instanceof TokenIterator) { |
|
| 81 | 81 | // Todo: Own Exceptions |
| 82 | 82 | throw new \InvalidArgumentException('$tokens must be string or TokenIterator'); |
| 83 | 83 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | /** @var Token[] $all */ $all = []; |
| 92 | 92 | |
| 93 | 93 | /** @var Token $token */ |
| 94 | - for($tokens->next(); $tokens->valid(); $tokens->next()) { |
|
| 94 | + for ($tokens->next(); $tokens->valid(); $tokens->next()) { |
|
| 95 | 95 | $token = $tokens->current(); |
| 96 | 96 | |
| 97 | 97 | if (!$token->isValid($this, $context)) { |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | if ($token instanceof LanguageToken && $token->getLanguage() === $this) { |
| 117 | 117 | $result[0]->setEnd($token); |
| 118 | 118 | |
| 119 | - if($result[0]->getRule()->postProcess) { |
|
| 119 | + if ($result[0]->getRule()->postProcess) { |
|
| 120 | 120 | $source = substr($tokens->getSource(), $result[0]->pos, $result[0]->getLength()); |
| 121 | 121 | |
| 122 | 122 | $tokens = $this->tokenize($source, $result, $result[0]->pos, true); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | # closing unclosed tokens |
| 127 | - foreach(array_reverse($context) as $hash => $name) { |
|
| 127 | + foreach (array_reverse($context) as $hash => $name) { |
|
| 128 | 128 | $end = new Token([$name, 'pos' => $token->pos]); |
| 129 | 129 | $all[$hash]->setEnd($end); |
| 130 | 130 | $result[] = $end; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | unset($context[spl_object_hash($start)]); |
| 138 | 138 | } else { |
| 139 | 139 | /** @noinspection PhpUnusedParameterInspection */ |
| 140 | - $start = ArrayHelper::find(array_reverse($context), function ($k, $v) use ($token) { |
|
| 140 | + $start = ArrayHelper::find(array_reverse($context), function($k, $v) use ($token) { |
|
| 141 | 141 | return $v === $token->name; |
| 142 | 142 | }); |
| 143 | 143 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $result = new TokenList(); |
| 173 | 173 | |
| 174 | 174 | /** @var Language $language */ |
| 175 | - foreach($this->_rules($embedded) as $rule) { |
|
| 175 | + foreach ($this->_rules($embedded) as $rule) { |
|
| 176 | 176 | $rule->factory->setOffset($offset); |
| 177 | 177 | foreach ($rule->match($source) as $token) { |
| 178 | 178 | $result->add($token); |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | private function _rules($embedded = false) { |
| 197 | 197 | $all = $this->_rules; |
| 198 | - if(!$embedded) { |
|
| 198 | + if (!$embedded) { |
|
| 199 | 199 | $all['language.' . $this->getIdentifier()] = $this->getOpenClose(); |
| 200 | 200 | } |
| 201 | 201 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | /** @var Rule $rule */ |
| 209 | 209 | foreach ($rules as $rule) { |
| 210 | - if($rule->language === false) { |
|
| 210 | + if ($rule->language === false) { |
|
| 211 | 211 | $rule->language = $this; |
| 212 | 212 | } |
| 213 | 213 | |
@@ -217,8 +217,8 @@ discard block |
||
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - foreach($this->getEmbedded() as $language) { |
|
| 221 | - foreach($language->_rules() as $rule) { |
|
| 220 | + foreach ($this->getEmbedded() as $language) { |
|
| 221 | + foreach ($language->_rules() as $rule) { |
|
| 222 | 222 | yield $rule; |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -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]); |
@@ -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 | |
@@ -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 | |
@@ -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 | |
@@ -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 | - *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 | |
@@ -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 | |