@@ -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 |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $token = $tokens->current(); |
119 | 119 | |
120 | 120 | if ($token->isValid($this, $this->_context)) { |
121 | - if(($token->isStart() ? $this->handleStart($token) : $this->handleEnd($token)) === false) { |
|
121 | + if (($token->isStart() ? $this->handleStart($token) : $this->handleEnd($token)) === false) { |
|
122 | 122 | break; |
123 | 123 | }; |
124 | 124 | } |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | if ($start) { |
288 | 288 | unset($this->_context[spl_object_hash($start)]); |
289 | 289 | } else { |
290 | - $start = ArrayHelper::find(array_reverse($this->_context), function ($k, $v) use ($token) { |
|
290 | + $start = ArrayHelper::find(array_reverse($this->_context), function($k, $v) use ($token) { |
|
291 | 291 | return $v === $token->name; |
292 | 292 | }); |
293 | 293 |
@@ -98,11 +98,11 @@ |
||
98 | 98 | return $multiplier; |
99 | 99 | } |
100 | 100 | } elseif (($rule = Helper::cmp($b->_rule->priority, $a->_rule->priority)) !== 0) { |
101 | - return $multiplier*$rule; |
|
101 | + return $multiplier * $rule; |
|
102 | 102 | } elseif (($rule = Helper::cmp($b->index, $a->index)) !== 0) { |
103 | - return $multiplier*$rule; |
|
103 | + return $multiplier * $rule; |
|
104 | 104 | } else { |
105 | - return $multiplier*($a->id < $b->id ? -1 : 1); |
|
105 | + return $multiplier * ($a->id < $b->id ? -1 : 1); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 |
@@ -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 @@ 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 |
@@ -67,11 +67,11 @@ |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | public function setContext($context) { |
70 | - if(is_array($context)) { |
|
70 | + if (is_array($context)) { |
|
71 | 71 | $this->_validator = new Validator($context); |
72 | - } elseif(is_callable($context)) { |
|
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'); |
@@ -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 |
@@ -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 |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | |
43 | 43 | public function setRules($rules) |
44 | 44 | { |
45 | - if(empty($rules)) { |
|
46 | - $this->_rules = [ 'none' => Validator::CONTEXT_IN_ONE_OF ]; |
|
45 | + if (empty($rules)) { |
|
46 | + $this->_rules = ['none' => Validator::CONTEXT_IN_ONE_OF]; |
|
47 | 47 | } else { |
48 | 48 | foreach ($rules as $key => $rule) { |
49 | - list($plain, $type) = $this->_parse($rule); |
|
49 | + list($plain, $type) = $this->_parse($rule); |
|
50 | 50 | $this->_rules[$plain] = $type; |
51 | 51 | } |
52 | 52 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | private function _clean($rule, $type, &$required) |
56 | 56 | { |
57 | 57 | if (strpos($rule, '.') !== false) { |
58 | - foreach (array_filter(array_keys($required), function ($key) use ($rule) { |
|
58 | + foreach (array_filter(array_keys($required), function($key) use ($rule) { |
|
59 | 59 | return fnmatch($key . '.*', $rule); |
60 | 60 | }) as $remove) { |
61 | 61 | unset($required[$remove]); |
@@ -64,16 +64,16 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | protected function _validate($context, $rules) { |
67 | - if(empty($rules)) { |
|
67 | + if (empty($rules)) { |
|
68 | 68 | return true; |
69 | 69 | } |
70 | 70 | |
71 | - if(empty($context)) { |
|
71 | + if (empty($context)) { |
|
72 | 72 | $context = ['none']; |
73 | 73 | } |
74 | 74 | |
75 | 75 | $result = false; // At least one rule must match |
76 | - while(list($rule, $type) = each($rules)) { |
|
76 | + while (list($rule, $type) = each($rules)) { |
|
77 | 77 | $matched = $this->_matches($context, $rule, $type); |
78 | 78 | |
79 | 79 | if ($type & Validator::CONTEXT_NOT_IN) { |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | $rule = substr($rule, $pos); |
128 | 128 | |
129 | - if($type & self::CONTEXT_REGEX) { |
|
129 | + if ($type & self::CONTEXT_REGEX) { |
|
130 | 130 | $rule = "/^$rule(\\.\\w+)?/i"; |
131 | 131 | } |
132 | 132 | |
@@ -134,22 +134,22 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | private function _matches($context, $rule, $type) { |
137 | - if($type & self::CONTEXT_EXACTLY) { |
|
137 | + if ($type & self::CONTEXT_EXACTLY) { |
|
138 | 138 | return in_array($rule, $context, true); |
139 | - } elseif($type & self::CONTEXT_REGEX) { |
|
140 | - foreach($context as $item) { |
|
141 | - if(preg_match($rule, $item)) { |
|
139 | + } elseif ($type & self::CONTEXT_REGEX) { |
|
140 | + foreach ($context as $item) { |
|
141 | + if (preg_match($rule, $item)) { |
|
142 | 142 | return true; |
143 | 143 | } |
144 | 144 | } |
145 | 145 | return false; |
146 | 146 | } else { |
147 | - if(in_array($rule, $context, true)) { |
|
147 | + if (in_array($rule, $context, true)) { |
|
148 | 148 | return true; |
149 | 149 | } |
150 | 150 | |
151 | - foreach($context as $item) { |
|
152 | - if(fnmatch("$rule.*", $item)) { |
|
151 | + foreach ($context as $item) { |
|
152 | + if (fnmatch("$rule.*", $item)) { |
|
153 | 153 | return true; |
154 | 154 | } |
155 | 155 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | { |
162 | 162 | static $validator; |
163 | 163 | if (!$validator) { |
164 | - $validator = new DelegateValidator(function () { |
|
164 | + $validator = new DelegateValidator(function() { |
|
165 | 165 | return true; |
166 | 166 | }); |
167 | 167 | } |
@@ -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 |