@@ -44,6 +44,9 @@ |
||
44 | 44 | return $this->{$name}; |
45 | 45 | } |
46 | 46 | |
47 | + /** |
|
48 | + * @param string $name |
|
49 | + */ |
|
47 | 50 | private function hasCollection($name) |
48 | 51 | { |
49 | 52 | return property_exists($this, $name) && is_a($this->{$name}, CollectionInterface::class); |
@@ -66,6 +66,6 @@ |
||
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | -Router::setConnectionFactory(function (Contract\RouterInterface $router, Contract\RealmInterface $realm) { |
|
69 | +Router::setConnectionFactory(function(Contract\RouterInterface $router, Contract\RealmInterface $realm) { |
|
70 | 70 | return new Connection($router, $realm); |
71 | 71 | }); |
@@ -56,15 +56,15 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) |
58 | 58 | { |
59 | - $this->adaptee->then(function () use ($onFulfilled) { |
|
59 | + $this->adaptee->then(function() use ($onFulfilled) { |
|
60 | 60 | if ($onFulfilled !== null) { |
61 | 61 | return call_user_func_array($onFulfilled, func_get_args()); |
62 | 62 | } |
63 | - }, function () use ($onRejected) { |
|
63 | + }, function() use ($onRejected) { |
|
64 | 64 | if ($onRejected !== null) { |
65 | 65 | return call_user_func_array($onRejected, func_get_args()); |
66 | 66 | } |
67 | - }, function () use ($onProgress) { |
|
67 | + }, function() use ($onProgress) { |
|
68 | 68 | if ($onProgress !== null) { |
69 | 69 | return call_user_func_array($onProgress, func_get_args()); |
70 | 70 | } |
@@ -82,15 +82,15 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function done(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) |
84 | 84 | { |
85 | - $this->adaptee->done(function () use ($onFulfilled) { |
|
85 | + $this->adaptee->done(function() use ($onFulfilled) { |
|
86 | 86 | if ($onFulfilled !== null) { |
87 | 87 | return call_user_func_array($onFulfilled, func_get_args()); |
88 | 88 | } |
89 | - }, function () use ($onRejected) { |
|
89 | + }, function() use ($onRejected) { |
|
90 | 90 | if ($onRejected !== null) { |
91 | 91 | return call_user_func_array($onRejected, func_get_args()); |
92 | 92 | } |
93 | - }, function () use ($onProgress) { |
|
93 | + }, function() use ($onProgress) { |
|
94 | 94 | if ($onProgress !== null) { |
95 | 95 | return call_user_func_array($onProgress, func_get_args()); |
96 | 96 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function otherwise(callable $onRejected) |
108 | 108 | { |
109 | - $this->adaptee->otherwise(function () use ($onRejected) { |
|
109 | + $this->adaptee->otherwise(function() use ($onRejected) { |
|
110 | 110 | return call_user_func_array($onRejected, func_get_args()); |
111 | 111 | }); |
112 | 112 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function always(callable $onAlways) |
122 | 122 | { |
123 | - $this->adaptee->always(function () use ($onAlways) { |
|
123 | + $this->adaptee->always(function() use ($onAlways) { |
|
124 | 124 | return call_user_func_array($onAlways, func_get_args()); |
125 | 125 | }); |
126 | 126 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function progress(callable $onProgress) |
136 | 136 | { |
137 | - $this->adaptee->progress(function () use ($onProgress) { |
|
137 | + $this->adaptee->progress(function() use ($onProgress) { |
|
138 | 138 | return call_user_func_array($onProgress, func_get_args()); |
139 | 139 | }); |
140 | 140 |
@@ -26,8 +26,8 @@ |
||
26 | 26 | private $session; |
27 | 27 | |
28 | 28 | private function __construct(RouterInterface $router, |
29 | - RealmInterface $realm = null, |
|
30 | - SessionInterface $session = null |
|
29 | + RealmInterface $realm = null, |
|
30 | + SessionInterface $session = null |
|
31 | 31 | ) { |
32 | 32 | $this->router = $router; |
33 | 33 | $this->realm = $realm; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | protected function doSubscribe() |
100 | 100 | { |
101 | - \React\Promise\all($this->getSubscriptionPromises())->done(function () { |
|
101 | + \React\Promise\all($this->getSubscriptionPromises())->done(function() { |
|
102 | 102 | $this->isSubscribed = true; |
103 | 103 | $this->isSubscribing = false; |
104 | 104 | $this->subscriptionPromise->resolve($this->subscriptions); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | foreach (array_keys($this->subscriptions) as $topic) { |
116 | 116 | $promises[] = $this->session->subscribe($topic, $this->subscriptionCallbacks[$topic]) |
117 | - ->then(function (SubscribedMessage $msg) use ($topic) { |
|
117 | + ->then(function(SubscribedMessage $msg) use ($topic) { |
|
118 | 118 | $this->subscriptions[$topic] = $msg->getSubscriptionId(); |
119 | 119 | $this->subscriptionPromise->notify($topic); |
120 | 120 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function unsubscribe() |
132 | 132 | { |
133 | - $resolver = function (callable $resolve) { |
|
133 | + $resolver = function(callable $resolve) { |
|
134 | 134 | $resolve(); |
135 | 135 | }; |
136 | 136 | $promise = new Promise($resolver); |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | public function getSessionInfo($sessionId) |
70 | 70 | { |
71 | 71 | return $this->session->call(self::SESSION_INFO_TOPIC, [$sessionId])->then( |
72 | - function ($res) { |
|
72 | + function($res) { |
|
73 | 73 | $this->emit('info', [$res]); |
74 | 74 | |
75 | 75 | return $res; |
76 | 76 | }, |
77 | - function (ErrorMessage $error) use ($sessionId) { |
|
77 | + function(ErrorMessage $error) use ($sessionId) { |
|
78 | 78 | $this->emit('error', [$error, $sessionId]); |
79 | 79 | } |
80 | 80 | ); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | return $this->createPromiseAdapter( |
97 | - function (callable $resolve) { |
|
97 | + function(callable $resolve) { |
|
98 | 98 | $resolve($this->getList()); |
99 | 99 | } |
100 | 100 | ); |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | // @var \Tidal\WampWatch\Subscription\Collection |
172 | 172 | $collection = $this->getMetaSubscriptionCollection(); |
173 | 173 | |
174 | - $collection->addSubscription(self::SESSION_JOIN_TOPIC, function (array $res) { |
|
174 | + $collection->addSubscription(self::SESSION_JOIN_TOPIC, function(array $res) { |
|
175 | 175 | $sessionInfo = $res[0]; |
176 | 176 | if (!$this->validateSessionInfo($sessionInfo) || $this->hasSession($sessionInfo)) { |
177 | 177 | return; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $this->addSession($sessionInfo); |
180 | 180 | }); |
181 | 181 | |
182 | - $collection->addSubscription(self::SESSION_LEAVE_TOPIC, function (array $res) { |
|
182 | + $collection->addSubscription(self::SESSION_LEAVE_TOPIC, function(array $res) { |
|
183 | 183 | // @bug : wamp.session.on_leave is bugged as of crossbar.io 0.11.0 |
184 | 184 | // will provide sessionID when Browser closes/reloads, |
185 | 185 | // but not when calling connection.close(); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | protected function getSessionIdRetrievalCallback() |
211 | 211 | { |
212 | - return function ($res) { |
|
212 | + return function($res) { |
|
213 | 213 | $this->setList($res[0]); |
214 | 214 | $sessionIds = $this->getList(); |
215 | 215 | $this->emit('list', [$sessionIds]); |
@@ -153,6 +153,9 @@ discard block |
||
153 | 153 | : $this->metaSubscriptionCollection = new SubscriptionCollection($this->session); |
154 | 154 | } |
155 | 155 | |
156 | + /** |
|
157 | + * @param string $procedure |
|
158 | + */ |
|
156 | 159 | protected function setInitialCall($procedure, callable $callback) |
157 | 160 | { |
158 | 161 | $this->initialCallProcedure = (string) $procedure; |
@@ -192,6 +195,9 @@ discard block |
||
192 | 195 | }; |
193 | 196 | } |
194 | 197 | |
198 | + /** |
|
199 | + * @param string $procedure |
|
200 | + */ |
|
195 | 201 | private function retrieveCallData($procedure, callable $filter = null, $arguments = []) |
196 | 202 | { |
197 | 203 | $deferred = new DeferredAdapter( |
@@ -204,6 +210,10 @@ discard block |
||
204 | 210 | |
205 | 211 | $this->session->call($procedure, $arguments) |
206 | 212 | ->then( |
213 | + |
|
214 | + /** |
|
215 | + * @param string $res |
|
216 | + */ |
|
207 | 217 | function ($res) use ($deferred, $filter) { |
208 | 218 | $deferred->resolve($filter($res)); |
209 | 219 | }, |
@@ -228,7 +238,7 @@ discard block |
||
228 | 238 | } |
229 | 239 | |
230 | 240 | /** |
231 | - * @param $event |
|
241 | + * @param string $event |
|
232 | 242 | * @return \Closure |
233 | 243 | */ |
234 | 244 | private function getSubscriptionHandler($event) |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $this->callInitialProcedure(), |
83 | 83 | ]; |
84 | 84 | |
85 | - \React\Promise\all($promises)->done(function () { |
|
85 | + \React\Promise\all($promises)->done(function() { |
|
86 | 86 | $this->isRunning = true; |
87 | 87 | $this->emit('start', [$this->getList()]); |
88 | 88 | }); |
@@ -167,12 +167,12 @@ discard block |
||
167 | 167 | if (!isset($this->initialCallProcedure) || !isset($this->initialCallCallback)) { |
168 | 168 | $this->initialCallDone = true; |
169 | 169 | |
170 | - return new Promise(function (callable $resolve) { |
|
170 | + return new Promise(function(callable $resolve) { |
|
171 | 171 | $resolve(); |
172 | 172 | }); |
173 | 173 | } |
174 | 174 | |
175 | - return $this->session->call($this->initialCallProcedure, [])->then(function ($res) { |
|
175 | + return $this->session->call($this->initialCallProcedure, [])->then(function($res) { |
|
176 | 176 | $this->initialCallDone = true; |
177 | 177 | $cb = $this->initialCallCallback; |
178 | 178 | $cb($res); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | private function getErrorCallback() |
187 | 187 | { |
188 | - return function ($error) { |
|
188 | + return function($error) { |
|
189 | 189 | $this->emit('error', [$error]); |
190 | 190 | |
191 | 191 | return $error; |
@@ -198,13 +198,13 @@ discard block |
||
198 | 198 | new Deferred() |
199 | 199 | ); |
200 | 200 | |
201 | - $filter = $filter ?: function ($res) { |
|
201 | + $filter = $filter ?: function($res) { |
|
202 | 202 | return $res; |
203 | 203 | }; |
204 | 204 | |
205 | 205 | $this->session->call($procedure, $arguments) |
206 | 206 | ->then( |
207 | - function ($res) use ($deferred, $filter) { |
|
207 | + function($res) use ($deferred, $filter) { |
|
208 | 208 | $deferred->resolve($filter($res)); |
209 | 209 | }, |
210 | 210 | $this->getErrorCallback() |
@@ -233,14 +233,14 @@ discard block |
||
233 | 233 | */ |
234 | 234 | private function getSubscriptionHandler($event) |
235 | 235 | { |
236 | - return function ($res) use ($event) { |
|
236 | + return function($res) use ($event) { |
|
237 | 237 | $this->emit($event, $res); |
238 | 238 | }; |
239 | 239 | } |
240 | 240 | |
241 | 241 | protected function getSubscriptionIdRetrievalCallback() |
242 | 242 | { |
243 | - return function (\Thruway\CallResult $res) { |
|
243 | + return function(\Thruway\CallResult $res) { |
|
244 | 244 | /** @var \Thruway\Message\ResultMessage $message */ |
245 | 245 | $message = $res->getResultMessage(); |
246 | 246 | $list = $message->getArguments()[0]; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | public function getSubscriptionInfo($topic) |
59 | 59 | { |
60 | 60 | return $this->session->call(self::SUBSCRIPTION_GET_TOPIC, [$topic])->then( |
61 | - function ($res) { |
|
61 | + function($res) { |
|
62 | 62 | $this->emit('info', [$res]); |
63 | 63 | |
64 | 64 | return $res; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | return $this->retrieveSubscriptionIds(); |
74 | 74 | } |
75 | 75 | |
76 | - return $this->createPromiseAdapter(function (callable $resolve) { |
|
76 | + return $this->createPromiseAdapter(function(callable $resolve) { |
|
77 | 77 | $resolve($this->subscriptionIds); |
78 | 78 | }); |
79 | 79 | } |