Skip to content

Commit 6a88c86

Browse files
chore(EventSource): add typing
Signed-off-by: Josh <josh.t.richards@gmail.com>
1 parent 9da1e46 commit 6a88c86

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

lib/private/EventSource.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,10 @@ protected function init(): void {
4343
}
4444

4545
/**
46-
* send a message to the client
47-
*
48-
* @param string $type
49-
* @param mixed $data
50-
*
5146
* @throws \BadMethodCallException
52-
* if only one parameter is given, a typeless message will be send with that parameter as data
5347
* @suppress PhanDeprecatedFunction
5448
*/
55-
public function send($type, $data = null) {
49+
public function send(string $type, mixed $data = null): void {
5650
if ($data && !preg_match('/^[A-Za-z0-9_]+$/', $type)) {
5751
throw new \BadMethodCallException('Type needs to be alphanumeric (' . $type . ')');
5852
}
@@ -69,10 +63,7 @@ public function send($type, $data = null) {
6963
flush();
7064
}
7165

72-
/**
73-
* close the connection of the event source
74-
*/
75-
public function close() {
66+
public function close(): void {
7667
$this->send('__internal__', 'close'); //server side closing can be an issue, let the client do it
7768
}
7869
}

0 commit comments

Comments
 (0)