@@ -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 | } |
@@ -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 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return false|Token|null |
50 | 50 | */ |
51 | - public function create($name, $params = [ ]) |
|
51 | + public function create($name, $params = []) |
|
52 | 52 | { |
53 | 53 | $name = $name !== null ? $this->getName($name) : $this->_base; |
54 | 54 | |
@@ -61,24 +61,24 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | $class = isset($params['class']) ? $params['class'] : $this->_class; |
64 | - $end = isset($params['end']) ? $params['end'] : null; |
|
64 | + $end = isset($params['end']) ? $params['end'] : null; |
|
65 | 65 | $start = isset($params['start']) ? $params['start'] : null; |
66 | 66 | |
67 | 67 | // we don't want to pass that into token |
68 | 68 | unset($params['class'], $params['end'], $params['start']); |
69 | 69 | |
70 | - if($this->_type & Token::START) { |
|
71 | - if($start === null) { |
|
70 | + if ($this->_type & Token::START) { |
|
71 | + if ($start === null) { |
|
72 | 72 | $start = new $class($name, $params); |
73 | 73 | } |
74 | 74 | |
75 | - if($this->_type === Token::START) { |
|
75 | + if ($this->_type === Token::START) { |
|
76 | 76 | $start->setEnd(false); |
77 | 77 | return $start; |
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | - if($this->_type & Token::END) { |
|
81 | + if ($this->_type & Token::END) { |
|
82 | 82 | if (isset($params['length'])) { |
83 | 83 | $length = $params['length']; |
84 | 84 | unset($params['length']); |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | |
89 | 89 | /** @var Token $end */ |
90 | 90 | $end = new $class($name, $end); |
91 | - } elseif($end === null) { |
|
91 | + } elseif ($end === null) { |
|
92 | 92 | $end = new $class($name, $params); |
93 | 93 | } |
94 | 94 | |
95 | - if($this->_type === Token::END || $start === null) { |
|
95 | + if ($this->_type === Token::END || $start === null) { |
|
96 | 96 | $end->setStart(false); |
97 | 97 | return $end; |
98 | 98 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | { |
33 | 33 | public function __construct($name, $options = []) { |
34 | 34 | parent::__construct($name, $options); |
35 | - if(isset($options['inject'])) { |
|
35 | + if (isset($options['inject'])) { |
|
36 | 36 | $this->inject = $options['inject']; |
37 | 37 | } |
38 | 38 | } |
@@ -85,7 +85,7 @@ |
||
85 | 85 | return $this->_end === null; |
86 | 86 | } |
87 | 87 | |
88 | - public function isValid(Context $context) |
|
88 | + public function isValid(Context $context) |
|
89 | 89 | { |
90 | 90 | if ($this->_valid === null) { |
91 | 91 | $this->validate($context); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function __construct($name = null, array $options = []) |
62 | 62 | { |
63 | - $this->name = $name; |
|
63 | + $this->name = $name; |
|
64 | 64 | |
65 | 65 | if (isset($options['pos'])) { |
66 | 66 | $this->pos = $options['pos']; |
@@ -182,13 +182,12 @@ discard block |
||
182 | 182 | * @return bool Return true to continue processing, false to return already processed tokens. |
183 | 183 | */ |
184 | 184 | public function process(Context $context, Language $language, Result $result, TokenIterator $tokens) { |
185 | - if(!$this->isValid($context)) { |
|
185 | + if (!$this->isValid($context)) { |
|
186 | 186 | return true; |
187 | 187 | } |
188 | 188 | |
189 | 189 | return $this->isStart() ? |
190 | - $this->processStart($context, $language, $result, $tokens) : |
|
191 | - $this->processEnd($context, $language, $result, $tokens); |
|
190 | + $this->processStart($context, $language, $result, $tokens) : $this->processEnd($context, $language, $result, $tokens); |
|
192 | 191 | } |
193 | 192 | |
194 | 193 | protected function processStart(Context $context, Language $language, Result $result, TokenIterator $tokens) { |
@@ -199,7 +198,7 @@ discard block |
||
199 | 198 | } |
200 | 199 | |
201 | 200 | protected function processEnd(Context $context, Language $language, Result $result, TokenIterator $tokens) { |
202 | - if($this->_start) { |
|
201 | + if ($this->_start) { |
|
203 | 202 | $context->pop($this->_start); |
204 | 203 | } else { |
205 | 204 | if (($start = $context->find($this->name)) !== false) { |
@@ -229,11 +228,11 @@ discard block |
||
229 | 228 | return $multiplier; |
230 | 229 | } |
231 | 230 | } elseif (($rule = Helper::cmp($b->rule->priority, $a->rule->priority)) !== 0) { |
232 | - return $multiplier*$rule; |
|
231 | + return $multiplier * $rule; |
|
233 | 232 | } elseif (($rule = Helper::cmp($b->index, $a->index)) !== 0) { |
234 | - return $multiplier*$rule; |
|
233 | + return $multiplier * $rule; |
|
235 | 234 | } else { |
236 | - return $multiplier*($a->id < $b->id ? -1 : 1); |
|
235 | + return $multiplier * ($a->id < $b->id ? -1 : 1); |
|
237 | 236 | } |
238 | 237 | } |
239 | 238 | } |
@@ -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'); |