@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function __construct(Jid $jid, $password, AbstractConnector $connector = null) |
206 | 206 | { |
207 | - if(!$connector) |
|
207 | + if (!$connector) |
|
208 | 208 | $connector = new TcpConnector($jid->server); |
209 | 209 | |
210 | 210 | $this->connector = $connector; |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | 'wrap' => 0 |
260 | 260 | ]; |
261 | 261 | |
262 | - $this->connector->onSend->add(function ($socket, $packet) use ($settings) { |
|
262 | + $this->connector->onSend->add(function($socket, $packet) use ($settings) { |
|
263 | 263 | $len = strlen($packet); |
264 | 264 | |
265 | 265 | if (function_exists('tidy_repair_string')) |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | ]); |
273 | 273 | }); |
274 | 274 | |
275 | - $this->connector->onReceive->add(function ($socket, $packet) use ($settings) { |
|
275 | + $this->connector->onReceive->add(function($socket, $packet) use ($settings) { |
|
276 | 276 | $len = strlen($packet); |
277 | 277 | |
278 | 278 | if (function_exists('tidy_repair_string')) |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | $start = time(); |
338 | 338 | $packet = null; |
339 | 339 | |
340 | - $this->wait($type, $id, function ($pckt) use (&$packet) { |
|
340 | + $this->wait($type, $id, function($pckt) use (&$packet) { |
|
341 | 341 | $packet = $pckt; |
342 | 342 | }); |
343 | 343 | |
344 | - while(!$packet && time() - $start < $timeout) { |
|
344 | + while (!$packet && time() - $start < $timeout) { |
|
345 | 345 | $this->process(); |
346 | 346 | usleep(5000); |
347 | 347 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | { |
392 | 392 | if ($this->logger) |
393 | 393 | $this->logger->notice('SASL Auth, available mechanisms: {mechanisms}', [ |
394 | - 'mechanisms' => implode(', ', array_map(function (XmlBranch $item) { |
|
394 | + 'mechanisms' => implode(', ', array_map(function(XmlBranch $item) { |
|
395 | 395 | return $item->content; |
396 | 396 | }, (array)$this->connector->features->mechanisms[0]->mechanism)) |
397 | 397 | ]); |
@@ -741,8 +741,7 @@ discard block |
||
741 | 741 | if (!$user->fromChannel()) return null; |
742 | 742 | |
743 | 743 | return isset($this->rooms[$user->bare()]->users[$user->resource]) ? |
744 | - $this->rooms[$user->bare()]->users[$user->resource] : |
|
745 | - null; |
|
744 | + $this->rooms[$user->bare()]->users[$user->resource] : null; |
|
746 | 745 | } |
747 | 746 | |
748 | 747 | /** |
@@ -823,7 +822,7 @@ discard block |
||
823 | 822 | |
824 | 823 | $xml = new xmlBranch("presence"); |
825 | 824 | $xml->addAttribute("from", $this->jid->__toString()) |
826 | - ->addAttribute("to", $room->bare() . '/' . $nick) |
|
825 | + ->addAttribute("to", $room->bare().'/'.$nick) |
|
827 | 826 | ->addAttribute("id", uniqid('mucjoin_')); |
828 | 827 | $xml->addChild(new xmlBranch("x"))->addAttribute("xmlns", "http://jabber.org/protocol/muc"); |
829 | 828 | $this->write($xml->asXml()); |
@@ -1009,7 +1008,7 @@ discard block |
||
1009 | 1008 | } |
1010 | 1009 | |
1011 | 1010 | public function __destruct() { |
1012 | - if($this->connector->connected) |
|
1011 | + if ($this->connector->connected) |
|
1013 | 1012 | $this->disconnect(); |
1014 | 1013 | } |
1015 | 1014 | } |
1016 | 1015 | \ No newline at end of file |
@@ -148,17 +148,17 @@ discard block |
||
148 | 148 | |
149 | 149 | $this->applyOptions($options); |
150 | 150 | |
151 | - $this->on('element', function (Features $element) { |
|
151 | + $this->on('element', function(Features $element) { |
|
152 | 152 | $this->_features = $element; |
153 | 153 | $this->emit('features', [$element]); |
154 | 154 | }, Features::class); |
155 | 155 | |
156 | - $this->on('element', function (Stanza $stanza) { |
|
157 | - $this->emit('stanza', [ $stanza ]); |
|
158 | - $this->emit($stanza->localName, [ $stanza ]); |
|
156 | + $this->on('element', function(Stanza $stanza) { |
|
157 | + $this->emit('stanza', [$stanza]); |
|
158 | + $this->emit($stanza->localName, [$stanza]); |
|
159 | 159 | }, Stanza::class); |
160 | 160 | |
161 | - $this->on('close', function () { |
|
161 | + $this->on('close', function() { |
|
162 | 162 | $this->state = 'disconnected'; |
163 | 163 | }); |
164 | 164 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $this->state = 'bound'; |
212 | 212 | |
213 | 213 | $queue = new \SplQueue(); |
214 | - $this->emit('init', [ $queue ]); |
|
214 | + $this->emit('init', [$queue]); |
|
215 | 215 | |
216 | 216 | \React\Promise\all(iterator_to_array($queue))->then(function() { |
217 | 217 | $this->state = 'ready'; |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | |
236 | 236 | if ($alias === true) { |
237 | 237 | $this->_addToContainer($module, array_merge(class_implements($module), array_slice(class_parents($module), 1))); |
238 | - } elseif(is_array($alias)) { |
|
238 | + } elseif (is_array($alias)) { |
|
239 | 239 | $this->_addToContainer($module, $alias); |
240 | 240 | } else { |
241 | - $this->_addToContainer($module, [ $alias === false ? get_class($module) : $alias ]); |
|
241 | + $this->_addToContainer($module, [$alias === false ? get_class($module) : $alias]); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $deferred = new Deferred(); |
262 | 262 | |
263 | 263 | $this->once('element', function(Stanza $stanza) use ($deferred) { |
264 | - if($stanza->type === "error") { |
|
264 | + if ($stanza->type === "error") { |
|
265 | 265 | $deferred->reject($stanza); |
266 | 266 | } else { |
267 | 267 | $deferred->resolve($stanza); |
@@ -297,12 +297,12 @@ discard block |
||
297 | 297 | //region Parser |
298 | 298 | public function setParser(XmlParser $parser) |
299 | 299 | { |
300 | - if($this->state !== "disconnected") { |
|
300 | + if ($this->state !== "disconnected") { |
|
301 | 301 | throw new \BadMethodCallException('Parser can be changed only when client is disconnected.'); |
302 | 302 | } |
303 | 303 | |
304 | 304 | parent::setParser($parser); |
305 | - $this->_parser->factory->load(require __DIR__ . '/XmlElementLookup.php'); |
|
305 | + $this->_parser->factory->load(require __DIR__.'/XmlElementLookup.php'); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | public function getParser() |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | )); |
326 | 326 | } |
327 | 327 | |
328 | - $this->_connector->on('connect', function ($stream) { |
|
328 | + $this->_connector->on('connect', function($stream) { |
|
329 | 329 | return $this->handleConnect($stream); |
330 | 330 | }); |
331 | 331 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | ->disableOriginalConstructor() |
51 | 51 | ->getMock(); |
52 | 52 | |
53 | - $factory = $this |
|
53 | + $factory = $this |
|
54 | 54 | ->getMockBuilder('Kadet\Highlighter\Parser\TokenFactory') |
55 | 55 | ->disableOriginalConstructor() |
56 | 56 | ->getMock(); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function testAcceptsCallableAsContext() |
79 | 79 | { |
80 | 80 | $rule = new Rule(null, [ |
81 | - 'context' => function () { |
|
81 | + 'context' => function() { |
|
82 | 82 | return true; |
83 | 83 | } |
84 | 84 | ]); |
@@ -114,7 +114,7 @@ |
||
114 | 114 | |
115 | 115 | public function testCallableValidator() |
116 | 116 | { |
117 | - $validator = new DelegateValidator(function ($context) { |
|
117 | + $validator = new DelegateValidator(function($context) { |
|
118 | 118 | return in_array('bar', $context->stack) && !in_array('foo', $context->stack); |
119 | 119 | }); |
120 | 120 |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | |
20 | 20 | public function testFileProvider() |
21 | 21 | { |
22 | - $dir = realpath(__DIR__ . '/Samples'); |
|
23 | - $out = realpath(__DIR__ . '/Expected/Test'); |
|
22 | + $dir = realpath(__DIR__.'/Samples'); |
|
23 | + $out = realpath(__DIR__.'/Expected/Test'); |
|
24 | 24 | |
25 | 25 | $iterator = new \RecursiveIteratorIterator( |
26 | 26 | new \RecursiveDirectoryIterator( |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $pathname = substr($file->getPathname(), strlen($dir) + 1); |
36 | 36 | $language = Language::byFilename($pathname); |
37 | 37 | |
38 | - yield $pathname => [ $language, $file->getPathname(), "$out/$pathname.tkn" ]; |
|
38 | + yield $pathname => [$language, $file->getPathname(), "$out/$pathname.tkn"]; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | public function testRendering() |
41 | 41 | { |
42 | 42 | $source = 'abc + test'; |
43 | - $expected = Console::open(['color' => 'red']) . 'abc' . Console::close() . ' ' . |
|
44 | - Console::open(['color' => 'blue']) . '+' . Console::close() . ' ' . |
|
45 | - Console::open(['color' => 'red']) . 'test' . Console::close() . Console::reset(); |
|
43 | + $expected = Console::open(['color' => 'red']).'abc'.Console::close().' '. |
|
44 | + Console::open(['color' => 'blue']).'+'.Console::close().' '. |
|
45 | + Console::open(['color' => 'red']).'test'.Console::close().Console::reset(); |
|
46 | 46 | |
47 | 47 | $first = $this->_factory->create('token', ['pos' => 0, 'length' => 3]); |
48 | 48 | $operator = $this->_factory->create('operator', ['pos' => 4, 'length' => 1]); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $this->markTestSkipped('This test requires callback mocks, that are not yet implemented.'); |
68 | 68 | |
69 | 69 | $source = 'abc'; |
70 | - $expected = Console::open(['color' => 'red']) . 'abc' . Console::close() . Console::reset(); |
|
70 | + $expected = Console::open(['color' => 'red']).'abc'.Console::close().Console::reset(); |
|
71 | 71 | |
72 | 72 | $token = $this->_factory->create('token', ['pos' => 0, 'length' => 3]); |
73 | 73 |
@@ -54,11 +54,11 @@ |
||
54 | 54 | 'c' => 4 |
55 | 55 | ]; |
56 | 56 | |
57 | - $this->assertEquals('b', ArrayHelper::find($array, function ($k, $v) { |
|
57 | + $this->assertEquals('b', ArrayHelper::find($array, function($k, $v) { |
|
58 | 58 | return $k == 'b'; |
59 | 59 | })); |
60 | 60 | |
61 | - $this->assertFalse(ArrayHelper::find($array, function ($k, $v) { |
|
61 | + $this->assertFalse(ArrayHelper::find($array, function($k, $v) { |
|
62 | 62 | return $k == 'b' && $v == 3; |
63 | 63 | })); |
64 | 64 | } |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | $console = new ConsoleHelper(); |
41 | 41 | $this->assertEquals( |
42 | 42 | "\e[31mtest\e[32mtest2\e[0m\e[31mtest3\e[0m", |
43 | - $console->open(["color" => "red"]) . |
|
44 | - "test" . |
|
45 | - $console->open(["color" => "green"]) . "test2" . $console->close() . |
|
46 | - "test3" . |
|
43 | + $console->open(["color" => "red"]). |
|
44 | + "test". |
|
45 | + $console->open(["color" => "green"])."test2".$console->close(). |
|
46 | + "test3". |
|
47 | 47 | $console->close() |
48 | 48 | ); |
49 | 49 | } |
@@ -61,18 +61,18 @@ discard block |
||
61 | 61 | { |
62 | 62 | return [ |
63 | 63 | 'background red' => ["\033[41m", ["background" => "red"]], |
64 | - 'bold' => ["\033[1m", ["bold" => true]], |
|
65 | - 'dim' => ["\033[2m", ["dim" => true]], |
|
66 | - 'italic' => ["\033[3m", ["italic" => true]], |
|
67 | - 'underline' => ["\033[4m", ["underline" => true]], |
|
68 | - 'blink' => ["\033[5m", ["blink" => true]], |
|
69 | - 'invert' => ["\033[7m", ["invert" => true]], |
|
64 | + 'bold' => ["\033[1m", ["bold" => true]], |
|
65 | + 'dim' => ["\033[2m", ["dim" => true]], |
|
66 | + 'italic' => ["\033[3m", ["italic" => true]], |
|
67 | + 'underline' => ["\033[4m", ["underline" => true]], |
|
68 | + 'blink' => ["\033[5m", ["blink" => true]], |
|
69 | + 'invert' => ["\033[7m", ["invert" => true]], |
|
70 | 70 | |
71 | - 'wrong' => [null, ["wrong" => true]], |
|
71 | + 'wrong' => [null, ["wrong" => true]], |
|
72 | 72 | |
73 | - 'bg and bold' => ["\033[41;1m", ["background" => "red", 'bold' => true]], |
|
73 | + 'bg and bold' => ["\033[41;1m", ["background" => "red", 'bold' => true]], |
|
74 | 74 | |
75 | - 'color, bg and bold' => ["\033[31;41;1m", ["color" => "red", "background" => "red", 'bold' => true]], |
|
75 | + 'color, bg and bold' => ["\033[31;41;1m", ["color" => "red", "background" => "red", 'bold' => true]], |
|
76 | 76 | ]; |
77 | 77 | } |
78 | 78 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function __construct($styles = false) |
41 | 41 | { |
42 | - $this->_styles = $styles ?: include __DIR__ . '/../Styles/Cli/Default.php'; |
|
42 | + $this->_styles = $styles ?: include __DIR__.'/../Styles/Cli/Default.php'; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public function format(Tokens $tokens, $leveled = true) |
@@ -61,22 +61,22 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | $result .= |
64 | - Console::styled(['color' => 'yellow'], 'Open ') . |
|
65 | - '[' . $pos['line'] . ':' . $pos['pos'] . '] ' . |
|
66 | - Console::styled(['bold' => true], $token->name) . ' ' . |
|
67 | - Console::styled(['color' => 'blue'], get_class($token)) . ' ' . |
|
68 | - Console::styled(['color' => 'light green'], '(' . (isset($token->rule->language) ? $token->rule->language->getIdentifier() : 'none') . ')') . |
|
64 | + Console::styled(['color' => 'yellow'], 'Open '). |
|
65 | + '['.$pos['line'].':'.$pos['pos'].'] '. |
|
66 | + Console::styled(['bold' => true], $token->name).' '. |
|
67 | + Console::styled(['color' => 'blue'], get_class($token)).' '. |
|
68 | + Console::styled(['color' => 'light green'], '('.(isset($token->rule->language) ? $token->rule->language->getIdentifier() : 'none').')'). |
|
69 | 69 | PHP_EOL; |
70 | 70 | |
71 | 71 | $level++; |
72 | 72 | |
73 | 73 | $result .= Console::styled( |
74 | 74 | self::getColor($token->name), |
75 | - ($leveled ? str_repeat(' ', $level) : null) . |
|
75 | + ($leveled ? str_repeat(' ', $level) : null). |
|
76 | 76 | implode( |
77 | - PHP_EOL . ($leveled ? str_repeat(' ', $level) : null), |
|
77 | + PHP_EOL.($leveled ? str_repeat(' ', $level) : null), |
|
78 | 78 | explode(PHP_EOL, $this->escape(substr($source, $token->pos, $token->getLength()))) |
79 | - ) . |
|
79 | + ). |
|
80 | 80 | PHP_EOL |
81 | 81 | ); |
82 | 82 | } else { |
@@ -87,23 +87,23 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | $result .= |
90 | - Console::styled(['color' => 'red'], 'Close ') . |
|
91 | - '[' . $pos['line'] . ':' . $pos['pos'] . '] ' . |
|
92 | - Console::styled(['bold' => true], $token->name) . ' ' . |
|
93 | - Console::styled(['color' => 'blue'], get_class($token)) . |
|
90 | + Console::styled(['color' => 'red'], 'Close '). |
|
91 | + '['.$pos['line'].':'.$pos['pos'].'] '. |
|
92 | + Console::styled(['bold' => true], $token->name).' '. |
|
93 | + Console::styled(['color' => 'blue'], get_class($token)). |
|
94 | 94 | PHP_EOL; |
95 | 95 | } |
96 | 96 | |
97 | 97 | $last = $token->pos; |
98 | 98 | } |
99 | - $result .= $this->escape(substr($source, $last)) . Console::reset(); |
|
99 | + $result .= $this->escape(substr($source, $last)).Console::reset(); |
|
100 | 100 | |
101 | 101 | return $result; |
102 | 102 | } |
103 | 103 | |
104 | 104 | private function escape($string) |
105 | 105 | { |
106 | - return str_replace(["\r", "\n"], ['\r', '\n' . PHP_EOL], $string); |
|
106 | + return str_replace(["\r", "\n"], ['\r', '\n'.PHP_EOL], $string); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | public function getColor($token) |