@@ -151,7 +151,7 @@ |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | - * @return Token|null|false |
|
154 | + * @return Token |
|
155 | 155 | */ |
156 | 156 | public function getEnd() |
157 | 157 | { |
@@ -178,13 +178,12 @@ discard block |
||
178 | 178 | * @return bool Return true to continue processing, false to return already processed tokens. |
179 | 179 | */ |
180 | 180 | public function process(Context $context, Language $language, Result $result, TokenIterator $tokens) { |
181 | - if(!$this->isValid($context)) { |
|
181 | + if (!$this->isValid($context)) { |
|
182 | 182 | return true; |
183 | 183 | } |
184 | 184 | |
185 | 185 | return $this->isStart() ? |
186 | - $this->processStart($context, $language, $result, $tokens) : |
|
187 | - $this->processEnd($context, $language, $result, $tokens); |
|
186 | + $this->processStart($context, $language, $result, $tokens) : $this->processEnd($context, $language, $result, $tokens); |
|
188 | 187 | } |
189 | 188 | |
190 | 189 | protected function processStart(Context $context, Language $language, Result $result, TokenIterator $tokens) { |
@@ -195,7 +194,7 @@ discard block |
||
195 | 194 | } |
196 | 195 | |
197 | 196 | protected function processEnd(Context $context, Language $language, Result $result, TokenIterator $tokens) { |
198 | - if($this->_start) { |
|
197 | + if ($this->_start) { |
|
199 | 198 | $context->pop($this->_start); |
200 | 199 | } else { |
201 | 200 | if (($start = $context->find($this->name)) !== false) { |
@@ -225,9 +224,9 @@ discard block |
||
225 | 224 | return $multiplier; |
226 | 225 | } |
227 | 226 | } elseif (($rule = Helper::cmp($b->rule->priority, $a->rule->priority)) !== 0) { |
228 | - return $multiplier*$rule; |
|
229 | - } else { |
|
230 | - return $multiplier*($a->id < $b->id ? -1 : 1); |
|
227 | + return $multiplier * $rule; |
|
228 | + } else { |
|
229 | + return $multiplier * ($a->id < $b->id ? -1 : 1); |
|
231 | 230 | } |
232 | 231 | } |
233 | 232 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | public function styled($style, $text) |
34 | 34 | { |
35 | - return $this->open($style).$text.$this->close(); |
|
35 | + return $this->open($style) . $text . $this->close(); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function open($style) |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | $this->_current = empty($this->_stack) ? $this->_default : array_pop($this->_stack); |
53 | 53 | |
54 | - return "\033[0m".$this->_set(array_diff_assoc($this->_current, $this->_default)); |
|
54 | + return "\033[0m" . $this->_set(array_diff_assoc($this->_current, $this->_default)); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | private function _color($name, $bg = false) |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | |
104 | 104 | private function _set($style) |
105 | 105 | { |
106 | - $escape = "\e[".implode(';', array_map(function ($style, $name) { |
|
106 | + $escape = "\e[" . implode(';', array_map(function($style, $name) { |
|
107 | 107 | return $this->_style($style, $name); |
108 | - }, array_keys($style), $style)).'m'; |
|
108 | + }, array_keys($style), $style)) . 'm'; |
|
109 | 109 | |
110 | 110 | return $escape === "\e[m" ? null : $escape; |
111 | 111 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | $this->_end->_valid = false; |
44 | 44 | } |
45 | 45 | } else { |
46 | - if (!$this->rule->validator->validate($context, [ $this->name => Validator::CONTEXT_IN ])) { |
|
46 | + if (!$this->rule->validator->validate($context, [$this->name => Validator::CONTEXT_IN])) { |
|
47 | 47 | $this->setValid(false); |
48 | 48 | } else { |
49 | 49 | $this->_valid = false; |
@@ -45,7 +45,7 @@ |
||
45 | 45 | |
46 | 46 | protected function processEnd(Context $context, Language $language, Result $result, TokenIterator $tokens) |
47 | 47 | { |
48 | - foreach(array_filter($context->stack, function ($name) { |
|
48 | + foreach (array_filter($context->stack, function($name) { |
|
49 | 49 | return in_array($name, $this->closes); |
50 | 50 | }) as $hash => $name) { |
51 | 51 | $end = new Token([$name, 'pos' => $this->pos]); |
@@ -30,7 +30,7 @@ |
||
30 | 30 | |
31 | 31 | public function find($needle) { |
32 | 32 | foreach (array_reverse($this->stack, true) as $id => $name) { |
33 | - if($name === $needle) { |
|
33 | + if ($name === $needle) { |
|
34 | 34 | return $id; |
35 | 35 | } |
36 | 36 | } |
@@ -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() |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $css = new Css(); |
34 | 34 | $js = new JavaScript(); |
35 | 35 | $this->rules->addMany([ |
36 | - 'language.'.$js->getIdentifier() => [ |
|
36 | + 'language.' . $js->getIdentifier() => [ |
|
37 | 37 | new OpenRule(new RegexMatcher('/<script.*?>()/'), [ |
38 | 38 | 'factory' => new TokenFactory(LanguageToken::class), |
39 | 39 | 'inject' => $js, |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | 'language' => $js |
46 | 46 | ]) |
47 | 47 | ], |
48 | - 'language.'.$css->getIdentifier() => [ |
|
48 | + 'language.' . $css->getIdentifier() => [ |
|
49 | 49 | new OpenRule(new RegexMatcher('/<style.*?>()/'), [ |
50 | 50 | 'factory' => new TokenFactory(LanguageToken::class), |
51 | 51 | 'inject' => $css, |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | public function __construct(array $singleLine = null, array $multiLine = null) |
32 | 32 | { |
33 | 33 | $this->singleLine = $singleLine ?: []; |
34 | - $this->multiLine = $multiLine ?: []; |
|
34 | + $this->multiLine = $multiLine ?: []; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $all = []; |
50 | 50 | |
51 | 51 | foreach ($this->multiLine as $name => $comment) { |
52 | - $comment = array_map(function ($e) { return preg_quote($e, '/'); }, $comment); |
|
52 | + $comment = array_map(function($e) { return preg_quote($e, '/'); }, $comment); |
|
53 | 53 | |
54 | 54 | $all[] = [$name, "/{$comment[0]}(.*?){$comment[1]}/ms"]; |
55 | 55 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | /** |
26 | 26 | * RegexMatcher constructor. |
27 | 27 | * |
28 | - * @param $regex |
|
28 | + * @param string $regex |
|
29 | 29 | * @param callable $callable |
30 | 30 | */ |
31 | 31 | public function __construct($regex, callable $callable) |
@@ -49,7 +49,7 @@ |
||
49 | 49 | |
50 | 50 | $callable = $this->callable; |
51 | 51 | foreach ($matches as $match) { |
52 | - foreach($callable($match, $factory) as $token) { |
|
52 | + foreach ($callable($match, $factory) as $token) { |
|
53 | 53 | yield $token; |
54 | 54 | } |
55 | 55 | } |