Why does each call to this socket server give a unique list of peers?

I’m trying to create a kind of signalling server. What I’m attempting to do is allow socket connections and respond to 'helo' with a list of already connected peers:

<?php

use SwooleWebSocketServer;

$host = '0.0.0.0';
$port = 9090;

$server = new Server($host, $port, SWOOLE_PROCESS, SWOOLE_SOCK_TCP);

$connectedPeers = [];

function get_request_key($request) {
    return $request->server['remote_addr'] . ':' . (string)$request->server['remote_port'];
}

$server->on('open', function (Server $server, $request) use(&$connectedPeers) {
    echo "New connection: #{$request->fd}n";
    $connectedPeers[] = get_request_key($request);
    echo var_dump($connectedPeers);
});

$server->on('message', function (Server $server, $frame) use(&$connectedPeers) {
    echo "Received from #{$frame->fd}: {$frame->data}n";
   // echo var_dump($frame);
    $msg = $frame->data;

    if($msg === 'helo'){
        /* in this instance, reply with a list of peers */
        $server->push($frame->fd, '{"type":"peers", "peers":' . json_encode($connectedPeers) . '}');
    }
    else
    // Broadcast message to all connected clients
    foreach ($server->connections as $fd) {
        if ($fd !== $frame->fd) {
            $server->push($fd, $msg);
        }
    }
});

$server->on('close', function (Server $server, $fd) {
    echo "Connection #{$fd} closedn";
});

echo "WebSocket Secure Server started on wss://$host:$portn";
$server->start();
?>

The problem is that if I run this with php server.php, and then connect with two different clients, the response to each is a unique list of peers.

I.e. Client A gets a list with just itself. Client B gets a list with just itself. Client A and B never see each other.

I’m sure it has to do with reference/copy of $connectedPeers but I’m very new to PHP and don’t really understand how lifetime works in this instance.