@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2016, 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) 2016, 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\Language; |
17 | 17 |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2016, 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) 2016, 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\Language; |
17 | 17 |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2016, 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) 2016, 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\Language; |
17 | 17 |
@@ -28,7 +28,7 @@ |
||
28 | 28 | $this->_source = $source; |
29 | 29 | $this->_start = $start; |
30 | 30 | |
31 | - parent::__construct($start !== null ? [ $start->id => $start ] : [], 0, \ArrayIterator::class); |
|
31 | + parent::__construct($start !== null ? [$start->id => $start] : [], 0, \ArrayIterator::class); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | public function getSource() |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2016, 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) 2016, 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\Language; |
17 | 17 |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2016, 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) 2016, 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\Language; |
17 | 17 |
@@ -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 = []; |
@@ -1,17 +1,17 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2016, 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) 2016, 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\Language; |
17 | 17 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | 'string.nowdoc' => new Rule( |
68 | 68 | new RegexMatcher('/<<\s*\'(\w+)\';(?P<string>.*?)\n\1/sm', [ |
69 | 69 | 'string' => Token::NAME, |
70 | - 0 => 'keyword.nowdoc' |
|
70 | + 0 => 'keyword.nowdoc' |
|
71 | 71 | ]), ['context' => ['!comment']] |
72 | 72 | ), |
73 | 73 |
@@ -71,7 +71,7 @@ |
||
71 | 71 | $this->_validator = new Validator($context); |
72 | 72 | } elseif(is_callable($context)) { |
73 | 73 | $this->_validator = new DelegateValidator($context); |
74 | - }elseif($context instanceof Validator) { |
|
74 | + } elseif($context instanceof Validator) { |
|
75 | 75 | $this->_validator = $context; |
76 | 76 | } else { |
77 | 77 | throw new \InvalidArgumentException('$context must be valid Validator'); |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2016, 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) 2016, 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\Language; |
17 | 17 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'enabled' => true |
61 | 61 | ], $options); |
62 | 62 | |
63 | - if(isset($options['context'])) { |
|
63 | + if (isset($options['context'])) { |
|
64 | 64 | $this->setContext($options['context']); |
65 | 65 | } |
66 | 66 | |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | public function setContext($context) { |
74 | - if(is_array($context)) { |
|
74 | + if (is_array($context)) { |
|
75 | 75 | $this->validator = new Validator($context); |
76 | - } elseif(is_callable($context)) { |
|
76 | + } elseif (is_callable($context)) { |
|
77 | 77 | $this->validator = new DelegateValidator($context); |
78 | - }elseif($context instanceof Validator) { |
|
78 | + }elseif ($context instanceof Validator) { |
|
79 | 79 | $this->validator = $context; |
80 | 80 | } else { |
81 | 81 | throw new \InvalidArgumentException('$context must be valid Validator'); |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2016, 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) 2016, 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\Language; |
17 | 17 |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Highlighter |
|
4 | - * |
|
5 | - * Copyright (C) 2016, 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) 2016, 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\Language; |
17 | 17 |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | |
45 | 45 | public function setRules($rules) |
46 | 46 | { |
47 | - if(empty($rules)) { |
|
48 | - $this->_rules = [ 'none' => Validator::CONTEXT_IN_ONE_OF ]; |
|
47 | + if (empty($rules)) { |
|
48 | + $this->_rules = ['none' => Validator::CONTEXT_IN_ONE_OF]; |
|
49 | 49 | } else { |
50 | 50 | foreach ($rules as $key => $rule) { |
51 | - list($plain, $type) = $this->_parse($rule); |
|
51 | + list($plain, $type) = $this->_parse($rule); |
|
52 | 52 | $this->_rules[$plain] = $type; |
53 | 53 | } |
54 | 54 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | private function _clean($rule, &$required) |
58 | 58 | { |
59 | 59 | if (strpos($rule, '.') !== false) { |
60 | - foreach (array_filter(array_keys($required), function ($key) use ($rule) { |
|
60 | + foreach (array_filter(array_keys($required), function($key) use ($rule) { |
|
61 | 61 | return fnmatch($key . '.*', $rule); |
62 | 62 | }) as $remove) { |
63 | 63 | unset($required[$remove]); |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | protected function _validate($context, $rules, $result = false) { |
69 | - if(empty($context)) { |
|
69 | + if (empty($context)) { |
|
70 | 70 | $context = ['none']; |
71 | 71 | } |
72 | 72 | |
73 | - while(list($rule, $type) = each($rules)) { |
|
73 | + while (list($rule, $type) = each($rules)) { |
|
74 | 74 | $matched = $this->_matches($context, $rule, $type); |
75 | 75 | |
76 | 76 | if ($type & Validator::CONTEXT_NOT_IN) { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | $rule = substr($rule, $pos); |
125 | 125 | |
126 | - if($type & self::CONTEXT_REGEX) { |
|
126 | + if ($type & self::CONTEXT_REGEX) { |
|
127 | 127 | $rule = "/^$rule(\\.\\w+)?/i"; |
128 | 128 | } |
129 | 129 | |
@@ -131,22 +131,22 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | private function _matches($context, $rule, $type) { |
134 | - if($type & self::CONTEXT_EXACTLY) { |
|
134 | + if ($type & self::CONTEXT_EXACTLY) { |
|
135 | 135 | return in_array($rule, $context, true); |
136 | - } elseif($type & self::CONTEXT_REGEX) { |
|
137 | - foreach($context as $item) { |
|
138 | - if(preg_match($rule, $item)) { |
|
136 | + } elseif ($type & self::CONTEXT_REGEX) { |
|
137 | + foreach ($context as $item) { |
|
138 | + if (preg_match($rule, $item)) { |
|
139 | 139 | return true; |
140 | 140 | } |
141 | 141 | } |
142 | 142 | return false; |
143 | 143 | } else { |
144 | - if(in_array($rule, $context, true)) { |
|
144 | + if (in_array($rule, $context, true)) { |
|
145 | 145 | return true; |
146 | 146 | } |
147 | 147 | |
148 | - foreach($context as $item) { |
|
149 | - if(fnmatch("$rule.*", $item)) { |
|
148 | + foreach ($context as $item) { |
|
149 | + if (fnmatch("$rule.*", $item)) { |
|
150 | 150 | return true; |
151 | 151 | } |
152 | 152 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | { |
159 | 159 | static $validator; |
160 | 160 | if (!$validator) { |
161 | - $validator = new DelegateValidator(function () { |
|
161 | + $validator = new DelegateValidator(function() { |
|
162 | 162 | return true; |
163 | 163 | }); |
164 | 164 | } |