reactphp / socket

Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP.
https://reactphp.org/socket/
MIT License
1.2k stars 156 forks source link

Add new `SocketServer` and deprecate `Server` to avoid class name collisions #263

Closed clue closed 3 years ago

clue commented 3 years ago

This changeset adds a new SocketServer class as a replacement for the Server class to avoid class name collisions and ambiguities.

// deprecated
$socket = new React\Socket\Server(0);
$socket = new React\Socket\Server('127.0.0.1:8000');
$socket = new React\Socket\Server('127.0.0.1:8000', null, $context);
$socket = new React\Socket\Server('127.0.0.1:8000', $loop, $context);

// new
$socket = new React\Socket\SocketServer('127.0.0.1:0');
$socket = new React\Socket\SocketServer('127.0.0.1:8000');
$socket = new React\Socket\SocketServer('127.0.0.1:8000', $context);
$socket = new React\Socket\SocketServer('127.0.0.1:8000', $context, $loop);

The new SocketServer class has been added with an improved constructor signature as a replacement for the previous Server class in order to avoid any ambiguities. The previous name has been deprecated and should not be used anymore. In its most basic form, the deprecated Server can now be considered an alias for new SocketServer. Existing code continues to work as-is.

Builds on top of https://github.com/reactphp/http/pull/417 and #260