Completed
Push — master ( 5dbfda...a73b65 )
by Kacper
03:37
created
Exception/Protocol/StreamErrorException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,6 +40,6 @@
 block discarded – undo
40 40
 
41 41
     private function generateMessage(Error $error) : string
42 42
     {
43
-        return 'Stream error: '.str_replace('-', ' ', $error->kind).($error->text ? " ({$error->text})" : null);
43
+        return 'Stream error: ' . str_replace('-', ' ', $error->kind) . ($error->text ? " ({$error->text})" : null);
44 44
     }
45 45
 }
Please login to merge, or discard this patch.
Utils/Dumper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
     {
73 73
         $console = Console::get();
74 74
 
75
-        $result = $console->styled(['color' => 'yellow'], 'array').' with '.$console->styled(['color' => 'magenta'], count($array)).' elements:'.PHP_EOL;
75
+        $result = $console->styled(['color' => 'yellow'], 'array') . ' with ' . $console->styled(['color' => 'magenta'], count($array)) . ' elements:' . PHP_EOL;
76 76
         foreach ($array as $key => $value) {
77
-            $result .= "\t".str_replace("\n", "\n\t", '['.$this->dump($key).']: '.$this->dump($value)).PHP_EOL;
77
+            $result .= "\t" . str_replace("\n", "\n\t", '[' . $this->dump($key) . ']: ' . $this->dump($value)) . PHP_EOL;
78 78
         }
79 79
 
80 80
         return $result;
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
     public function init()
84 84
     {
85
-        $this->register('array',  [$this, '_dumpArray']);
85
+        $this->register('array', [$this, '_dumpArray']);
86 86
         $this->register('object', [$this, '_dumpObject']);
87 87
     }
88 88
 }
Please login to merge, or discard this patch.
Utils/StreamDecorator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@
 block discarded – undo
107 107
     {
108 108
         foreach ($events as $event) {
109 109
             if (!isset($this->_redirectors[$event])) {
110
-                $this->_redirectors[$event] = function (...$arguments) use ($event) {
110
+                $this->_redirectors[$event] = function(...$arguments) use ($event) {
111 111
                     $this->emit($event, $arguments);
112 112
                 };
113 113
             }
Please login to merge, or discard this patch.
Utils/PriorityCollection.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
     public function remove($value)
63 63
     {
64
-        $this->_collection = array_filter($this->_collection, function ($e) use ($value) {
64
+        $this->_collection = array_filter($this->_collection, function($e) use ($value) {
65 65
             return $e[1] !== $value;
66 66
         });
67 67
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
     private function rebuildCache()
72 72
     {
73
-        usort($this->_collection, function ($a, $b) {
73
+        usort($this->_collection, function($a, $b) {
74 74
             return $b[0] <=> $a[0];
75 75
         });
76 76
 
Please login to merge, or discard this patch.
Utils/BetterEmitter.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -32,6 +32,10 @@
 block discarded – undo
32 32
         return $this->addListener($event, $this->getConditionalCallable($listener, $condition), $priority);
33 33
     }
34 34
 
35
+    /**
36
+     * @param string $event
37
+     * @param \Closure $condition
38
+     */
35 39
     public function once($event, callable $listener, $condition = null, int $priority = 0)
36 40
     {
37 41
         return $this->on($event, $this->getOnceCallable($this->getConditionalCallable($listener, $condition), $event), null, $priority);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
                     return false;
57 57
                 }
58 58
             } catch (\Throwable $exception) {
59
-                if($this->emit('exception', [ $exception, $event ])) {
59
+                if ($this->emit('exception', [$exception, $event])) {
60 60
                     throw $exception;
61 61
                 }
62 62
                 return false;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
         $condition = with\predicate($condition);
92 92
 
93
-        return function (...$arguments) use ($listener, $condition) {
93
+        return function(...$arguments) use ($listener, $condition) {
94 94
             if ($condition(...$arguments)) {
95 95
                 return $listener(...$arguments);
96 96
             }
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 
102 102
     private function getOnceCallable(callable $listener, $event) : callable
103 103
     {
104
-        return $onceListener = function (...$arguments) use (&$onceListener, $event, $listener) {
105
-            if(($result = $listener(...$arguments)) !== INF) {
104
+        return $onceListener = function(...$arguments) use (&$onceListener, $event, $listener) {
105
+            if (($result = $listener(...$arguments)) !== INF) {
106 106
                 $this->removeListener($event, $onceListener);
107 107
                 return $result;
108 108
             }
Please login to merge, or discard this patch.
Stanza/Error.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function setType(string $type)
68 68
     {
69
-        if(!in_array($type, ['auth', 'cancel', 'continue', 'modify', 'wait'])) {
69
+        if (!in_array($type, ['auth', 'cancel', 'continue', 'modify', 'wait'])) {
70 70
             throw new InvalidArgumentException(
71 71
                 format("Error type must be 'auth', 'cancel', 'continue', 'modify' or 'wait', '{type}' given.", [
72 72
                     'type' => $type
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
      */
113 113
     public function setText(string $text)
114 114
     {
115
-        if(!$this->text) {
115
+        if (!$this->text) {
116 116
             $this->append(new XmlElement('text', self::XMLNS));
117 117
         }
118 118
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
             !$condition instanceof XmlElement ? $this->_definedCondition($condition) : $condition
135 135
         ];
136 136
 
137
-        if($description !== null) {
137
+        if ($description !== null) {
138 138
             $content[] = new XmlElement('text', self::XMLNS, ['content' => $description]);
139 139
         }
140 140
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
     private function _definedCondition(string $condition) : XmlElement
147 147
     {
148
-        if(!in_array($condition, [
148
+        if (!in_array($condition, [
149 149
             'bad-request', 'conflict', 'feature-not-implemented', 'forbidden',
150 150
             'gone', 'internal-server-error', 'item-not-found', 'jid-malformed',
151 151
             'not-acceptable', 'not-allowed', 'not-authorized', 'policy-violation',
Please login to merge, or discard this patch.
Exception/Protocol/BindingException.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,13 +42,13 @@
 block discarded – undo
42 42
 
43 43
     private static function _conditionDescription(Error $error)
44 44
     {
45
-        if(!empty($error->text)) {
45
+        if (!empty($error->text)) {
46 46
             return $error->text;
47 47
         }
48 48
 
49 49
         return [
50 50
             'bad-request' => 'Bad Request: "{resource}" is not valid XMPP resource identifier.',
51 51
             'conflict'    => 'Conflict: {bare}/{resource} is already in use.'
52
-        ][$error->condition] ?? 'Unknown reason: '.$error->condition;
52
+        ][$error->condition] ?? 'Unknown reason: ' . $error->condition;
53 53
     }
54 54
 }
Please login to merge, or discard this patch.
Xml/XmlStream.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -91,35 +91,35 @@  discard block
 block discarded – undo
91 91
         parent::__construct($transport);
92 92
         $this->setParser($parser);
93 93
 
94
-        $this->on('close', function () { $this->_isOpened = false; });
95
-        $this->on('element', function (Error $element) {
94
+        $this->on('close', function() { $this->_isOpened = false; });
95
+        $this->on('element', function(Error $element) {
96 96
             $this->handleError($element);
97 97
         }, with\instance(Error::class));
98 98
     }
99 99
 
100 100
     public function setParser(XmlParser $parser)
101 101
     {
102
-        if($this->_parser) {
103
-            $this->removeListener('data', [ $this->_parser, 'parse' ]);
102
+        if ($this->_parser) {
103
+            $this->removeListener('data', [$this->_parser, 'parse']);
104 104
         }
105 105
 
106 106
         $this->_parser = $parser;
107 107
 
108
-        $this->_parser->on('parse.begin', function (XmlElement $stream) {
108
+        $this->_parser->on('parse.begin', function(XmlElement $stream) {
109 109
             $this->_inbound = $stream;
110
-            $this->emit('stream.open', [ $stream ]);
110
+            $this->emit('stream.open', [$stream]);
111 111
         }, with\argument(1, with\equals(0)));
112 112
 
113
-        $this->_parser->on('parse.end', function (XmlElement $stream) {
114
-            $this->emit('stream.close', [ $stream ]);
113
+        $this->_parser->on('parse.end', function(XmlElement $stream) {
114
+            $this->emit('stream.close', [$stream]);
115 115
             $this->_inbound = null;
116 116
         }, with\argument(1, with\equals(0)));
117 117
 
118
-        $this->_parser->on('element', function (...$arguments) {
118
+        $this->_parser->on('element', function(...$arguments) {
119 119
             $this->emit('element', $arguments);
120 120
         });
121 121
 
122
-        $this->on('data', [ $this->_parser, 'parse' ]);
122
+        $this->on('data', [$this->_parser, 'parse']);
123 123
     }
124 124
 
125 125
     /**
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function write($data)
132 132
     {
133
-        if($data instanceof XmlElement) {
133
+        if ($data instanceof XmlElement) {
134 134
             $this->_outbound->append($data);
135 135
         }
136 136
 
137
-        $this->emit('send.'.($data instanceof XmlElement ? 'element' : 'text'), [ $data ]);
137
+        $this->emit('send.' . ($data instanceof XmlElement ? 'element' : 'text'), [$data]);
138 138
 
139 139
         return parent::write($data);
140 140
     }
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 
196 196
     private function handleError(Error $element)
197 197
     {
198
-        if ($this->emit('stream.error', [ $element ])) {
198
+        if ($this->emit('stream.error', [$element])) {
199 199
             throw new StreamErrorException($element);
200 200
         }
201 201
 
Please login to merge, or discard this patch.
Xml/XmlElementFactory.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         }
34 34
 
35 35
         foreach ($lookup['<predicate>'] as list($class, $predicate)) {
36
-            if($predicate($tag, $namespace)) {
36
+            if ($predicate($tag, $namespace)) {
37 37
                 return $class;
38 38
             }
39 39
         }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     {
65 65
         $result = ['<predicate>' => []];
66 66
         foreach ($dictionary as $element) {
67
-            if($element['name'] instanceof \Closure || $element['uri'] instanceof \Closure) {
67
+            if ($element['name'] instanceof \Closure || $element['uri'] instanceof \Closure) {
68 68
                 $result['<predicate>'][] = [$element[0], \Kadet\Xmpp\Utils\filter\consecutive(
69 69
                     \Kadet\Xmpp\Utils\filter\predicate($element['name']),
70 70
                     \Kadet\Xmpp\Utils\filter\predicate($element['uri'])
Please login to merge, or discard this patch.