Completed
Push — master ( 4aee11...dd7177 )
by Kacper
04:24
created
Xml/XmlElement.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -258,7 +258,7 @@
 block discarded – undo
258 258
      *
259 259
      * @param string      $attribute Attribute name, optionally with prefix
260 260
      * @param string|null $uri       XML Namespace URI of attribute, prefix will be automatically looked up
261
-     * @return bool|mixed
261
+     * @return string
262 262
      */
263 263
     public function getAttribute(string $attribute, string $uri = null)
264 264
     {
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function getInnerXml()
138 138
     {
139
-        return implode('', array_map(function ($element) {
139
+        return implode('', array_map(function($element) {
140 140
             if (is_string($element)) {
141 141
                 return htmlspecialchars($element);
142 142
             } elseif ($element instanceof XmlElement) {
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         $attributes = $this->attributes();
182 182
 
183 183
         $result = "<{$this->fullName}";
184
-        $result .= ' ' . implode(' ', array_map(function ($key, $value) {
184
+        $result .= ' ' . implode(' ', array_map(function($key, $value) {
185 185
             return $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"';
186 186
         }, array_keys($attributes), array_values($attributes)));
187 187
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
      */
203 203
     public function lookupPrefix(string $uri = null)
204 204
     {
205
-        return $this->getNamespaces()[ $uri ] ?? false;
205
+        return $this->getNamespaces()[$uri] ?? false;
206 206
     }
207 207
 
208 208
     /**
@@ -246,12 +246,12 @@  discard block
 block discarded – undo
246 246
     {
247 247
         $attribute = $this->_prefix($attribute, $uri);
248 248
         if ($value === null) {
249
-            unset($this->_attributes[ $attribute ]);
249
+            unset($this->_attributes[$attribute]);
250 250
 
251 251
             return;
252 252
         }
253 253
 
254
-        $this->_attributes[ $attribute ] = $value;
254
+        $this->_attributes[$attribute] = $value;
255 255
     }
256 256
 
257 257
     /**
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
      */
264 264
     public function getAttribute(string $attribute, string $uri = null)
265 265
     {
266
-        return $this->_attributes[ $this->_prefix($attribute, $uri) ] ?? false;
266
+        return $this->_attributes[$this->_prefix($attribute, $uri)] ?? false;
267 267
     }
268 268
 
269 269
     /**
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
      */
277 277
     public function hasAttribute(string $attribute, string $uri = null)
278 278
     {
279
-        return isset($this->_attributes[ $this->_prefix($attribute, $uri) ]);
279
+        return isset($this->_attributes[$this->_prefix($attribute, $uri)]);
280 280
     }
281 281
 
282 282
     /**
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
      */
286 286
     public function getParents()
287 287
     {
288
-        return $this->_parent ? array_merge([ $this->_parent ], $this->_parent->getParents()) : [];
288
+        return $this->_parent ? array_merge([$this->_parent], $this->_parent->getParents()) : [];
289 289
     }
290 290
 
291 291
     /**
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
     protected function setParent(XmlElement $parent)
305 305
     {
306 306
         if (!$this->_prefix && ($prefix = $parent->lookupPrefix($this->namespace)) !== false) {
307
-            $this->_namespaces[ $this->namespace ] = $prefix;
307
+            $this->_namespaces[$this->namespace] = $prefix;
308 308
             $this->_prefix                         = $prefix;
309 309
         }
310 310
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
             return false;
328 328
         }
329 329
 
330
-        if(is_array($element)) {
330
+        if (is_array($element)) {
331 331
             array_walk($element, [$this, 'appendChild']);
332 332
             return $element;
333 333
         }
@@ -337,14 +337,14 @@  discard block
 block discarded – undo
337 337
 
338 338
     public function remove($element)
339 339
     {
340
-        if(!$element instanceof \Closure) {
340
+        if (!$element instanceof \Closure) {
341 341
             $element = is_array($element) ? filter\in($element) : filter\same($element);
342 342
         }
343 343
         $old = $this->_children;
344 344
         $this->_children = array_filter($this->_children, not($element));
345 345
 
346 346
         foreach (array_diff($old, $this->_children) as $removed) {
347
-            if($removed instanceof XmlElement) {
347
+            if ($removed instanceof XmlElement) {
348 348
                 $removed->_parent = null;
349 349
             }
350 350
         }
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
             $prefix = $this->_prefix;
396 396
         }
397 397
 
398
-        $this->_namespaces[ $uri ] = $prefix;
398
+        $this->_namespaces[$uri] = $prefix;
399 399
     }
400 400
 
401 401
     public function getFullName()
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
      */
444 444
     public function element(string $name, string $uri = null, int $index = 0)
445 445
     {
446
-        return array_values($this->elements($name, $uri))[ $index ] ?? false;
446
+        return array_values($this->elements($name, $uri))[$index] ?? false;
447 447
     }
448 448
 
449 449
     /**
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
     private function attributes(): array
525 525
     {
526 526
         $namespaces = $this->getNamespaces(false);
527
-        $namespaces = array_map(function ($prefix, $uri) {
527
+        $namespaces = array_map(function($prefix, $uri) {
528 528
             return [$prefix ? "xmlns:{$prefix}" : 'xmlns', $uri];
529 529
         }, array_values($namespaces), array_keys($namespaces));
530 530
 
Please login to merge, or discard this patch.
Component/Roster.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -184,7 +184,6 @@
 block discarded – undo
184 184
     }
185 185
 
186 186
     /**
187
-     * @param callable(Item $item) $mapper
188 187
      * @return array
189 188
      */
190 189
     public function map(callable $mapper)
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     private function handleSet(Iq\Query\Roster $query)
63 63
     {
64 64
         foreach ($query->items as $item) {
65
-            if($item->subscription == 'remove') {
65
+            if ($item->subscription == 'remove') {
66 66
                 $this->removeItem($item->jid);
67 67
             } else {
68 68
                 $this->setItem($item);
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
         $iq = new Iq('remove', ['query' => new Iq\Query\Roster()]);
153 153
         /** @var Iq\Query\Roster\Item $item */
154
-        foreach($remove as $item) {
154
+        foreach ($remove as $item) {
155 155
             $iq->query->append(new Iq\Query\Roster\Item($item->jid, ['subscription' => 'remove']));
156 156
         }
157 157
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
     private function setItem(Iq\Query\Roster\Item $item)
230 230
     {
231
-        $this->emit('item', [ $item ]);
231
+        $this->emit('item', [$item]);
232 232
         $this->_items[(string)$item->jid] = $item;
233 233
     }
234 234
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
             return;
242 242
         }
243 243
 
244
-        $this->emit('remove', [ $this->_items[(string)$jid] ]);
244
+        $this->emit('remove', [$this->_items[(string)$jid]]);
245 245
         unset($this->_items[(string)$jid]);
246 246
     }
247 247
 }
Please login to merge, or discard this patch.
Stanza/Iq.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,6 @@
 block discarded – undo
19 19
 use Kadet\Xmpp\Jid;
20 20
 use Kadet\Xmpp\Stanza\Iq\Query;
21 21
 use function Kadet\Xmpp\Utils\filter\pass;
22
-use Kadet\Xmpp\Xml\XmlElement;
23 22
 
24 23
 /**
25 24
  * Represents IQ Stanza
Please login to merge, or discard this patch.
Stanza/Iq/Query/Roster.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
     protected function appendChild($element)
88 88
     {
89
-        if(!$element instanceof Item) {
89
+        if (!$element instanceof Item) {
90 90
             throw new InvalidArgumentException(format('Only instances of roster item ({expected}) can be added into roster, tried to add {actual}', [
91 91
                 'expected' => Item::class,
92 92
                 'actual'   => get_class($element)
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     public static function getXmlCollocations() : array
100 100
     {
101 101
         return [
102
-            [ Item::class, 'name' => 'item', 'uri' => 'jabber:iq:roster' ]
102
+            [Item::class, 'name' => 'item', 'uri' => 'jabber:iq:roster']
103 103
         ];
104 104
     }
105 105
 }
Please login to merge, or discard this patch.
XmppClient.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -148,17 +148,17 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,7 +297,7 @@  discard block
 block discarded – undo
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
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Sasl/DigestMD5.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
      */
29 29
     public function createResponse($challenge = null)
30 30
     {
31
-        if(strpos($challenge, 'rspauth=') !== false) {
31
+        if (strpos($challenge, 'rspauth=') !== false) {
32 32
             return '';
33 33
         }
34 34
 
Please login to merge, or discard this patch.
Utils/filter.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function equals($value) : \Closure
36 36
 {
37
-    return function ($argument) use ($value) {
37
+    return function($argument) use ($value) {
38 38
         return $argument == $value;
39 39
     };
40 40
 }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function same($value) : \Closure
57 57
 {
58
-    return function ($argument) use ($value) {
58
+    return function($argument) use ($value) {
59 59
         return $argument === $value;
60 60
     };
61 61
 }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
  */
78 78
 function instance($expected) : \Closure
79 79
 {
80
-    return function ($object) use ($expected) {
80
+    return function($object) use ($expected) {
81 81
         return $expected instanceof \Closure ? $expected(get_class($object)) : $object instanceof $expected;
82 82
     };
83 83
 }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
  */
104 104
 function matches($regex, ...$options) : \Closure
105 105
 {
106
-    return function ($value) use ($regex, $options) {
106
+    return function($value) use ($regex, $options) {
107 107
         return preg_match($regex, $value, $null, ...$options) > 0;
108 108
     };
109 109
 }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
  * @return \Closure
123 123
  */
124 124
 function in(...$options) {
125
-    return function ($value) use ($options) {
125
+    return function($value) use ($options) {
126 126
         return in_array($value, $options);
127 127
     };
128 128
 }
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
  */
143 143
 function contains($value)
144 144
 {
145
-    if($value instanceof \Closure) {
146
-        return function (array $array) use ($value) {
145
+    if ($value instanceof \Closure) {
146
+        return function(array $array) use ($value) {
147 147
             foreach ($array as $item) {
148
-                if($value($item)) {
148
+                if ($value($item)) {
149 149
                     return true;
150 150
                 }
151 151
             }
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         };
155 155
     }
156 156
 
157
-    return function (array $array) use ($value) {
157
+    return function(array $array) use ($value) {
158 158
         return array_search($value, $array) !== false;
159 159
     };
160 160
 }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
  */
175 175
 function has($key)
176 176
 {
177
-    return function (array $array) use ($key) {
177
+    return function(array $array) use ($key) {
178 178
         return (contains($key))(array_keys($array));
179 179
     };
180 180
 }
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
  */
249 249
 function all(callable ...$functions) : \Closure
250 250
 {
251
-    return function (...$args) use ($functions) {
251
+    return function(...$args) use ($functions) {
252 252
         foreach ($functions as $function) {
253 253
             if (!$function(...$args)) {
254 254
                 return false;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
  */
278 278
 function any(callable ...$functions) : \Closure
279 279
 {
280
-    return function (...$args) use ($functions) {
280
+    return function(...$args) use ($functions) {
281 281
         foreach ($functions as $function) {
282 282
             if ($function(...$args)) {
283 283
                 return true;
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
  */
322 322
 function not(callable $predicate) : \Closure
323 323
 {
324
-    return function (...$arguments) use ($predicate) {
324
+    return function(...$arguments) use ($predicate) {
325 325
         return !$predicate(...$arguments);
326 326
     };
327 327
 }
@@ -349,13 +349,13 @@  discard block
 block discarded – undo
349 349
  */
350 350
 function argument(int $offset, callable $predicate, $length = true) : \Closure
351 351
 {
352
-    if($length === true) {
352
+    if ($length === true) {
353 353
         $length = 1;
354
-    } elseif($length === false) {
354
+    } elseif ($length === false) {
355 355
         $length = null;
356 356
     }
357 357
 
358
-    return function (...$arguments) use ($predicate, $offset, $length) {
358
+    return function(...$arguments) use ($predicate, $offset, $length) {
359 359
         return $predicate(...array_slice($arguments, $offset, $length, false));
360 360
     };
361 361
 }
@@ -378,9 +378,9 @@  discard block
 block discarded – undo
378 378
  */
379 379
 function consecutive(callable ...$predicates)
380 380
 {
381
-    return function (...$arguments) use ($predicates) {
381
+    return function(...$arguments) use ($predicates) {
382 382
         foreach ($arguments as $index => $value) {
383
-            if(!$predicates[$index]($value)) {
383
+            if (!$predicates[$index]($value)) {
384 384
                 return false;
385 385
             }
386 386
         }
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 function property($name, $value) {
393 393
     $predicate = $value instanceof \Closure ? $value : \Kadet\Xmpp\Utils\filter\equals($value);
394 394
 
395
-    return function ($element) use ($name, $predicate) {
395
+    return function($element) use ($name, $predicate) {
396 396
         return $predicate($element->$name);
397 397
     };
398 398
 }
Please login to merge, or discard this patch.
Utils/helper.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 function typeof($value) : string
27 27
 {
28 28
     if (is_object($value)) {
29
-        return "object of type ".get_class($value);
29
+        return "object of type " . get_class($value);
30 30
     } elseif (is_resource($value)) {
31
-        return get_resource_type($value).' resource';
31
+        return get_resource_type($value) . ' resource';
32 32
     }
33 33
 
34 34
     return gettype($value);
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 
37 37
 function partial(callable $callable, $argument, int $position = 0) : callable
38 38
 {
39
-    return function (...$arguments) use ($callable, $argument, $position) {
39
+    return function(...$arguments) use ($callable, $argument, $position) {
40 40
         $arguments = array_merge(
41 41
             array_slice($arguments, 0, $position),
42
-            [ $argument ],
42
+            [$argument],
43 43
             array_slice($arguments, $position)
44 44
         );
45 45
 
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
 
50 50
 function dd($value)
51 51
 {
52
-    echo Dumper::get()->dump($value).PHP_EOL.PHP_EOL;
52
+    echo Dumper::get()->dump($value) . PHP_EOL . PHP_EOL;
53 53
 }
54 54
 
55 55
 function format($string, array $arguments = [])
56 56
 {
57
-    return str_replace(array_map(function ($e) { return "{{$e}}"; }, array_keys($arguments)), $arguments, $string);
57
+    return str_replace(array_map(function($e) { return "{{$e}}"; }, array_keys($arguments)), $arguments, $string);
58 58
 }
59 59
 
60 60
 function rearrange(array $array, array $keys) : array
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 function copy(array $array)
70 70
 {
71 71
     return array_map(function($element) {
72
-        if(is_array($element)) {
72
+        if (is_array($element)) {
73 73
             return copy($element);
74
-        } elseif(is_object($element)) {
74
+        } elseif (is_object($element)) {
75 75
             return clone $element;
76 76
         }
77 77
 
Please login to merge, or discard this patch.