Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 40 additions & 31 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
{
"name": "cboden/ratchet"
, "type": "library"
, "description": "PHP WebSocket library"
, "keywords": ["WebSockets", "Server", "Ratchet", "Sockets", "WebSocket"]
, "homepage": "http://socketo.me"
, "license": "MIT"
, "authors": [
"name": "cboden/ratchet",
"type": "library",
"description": "PHP WebSocket library",
"keywords": [
"WebSockets",
"Server",
"Ratchet",
"Sockets",
"WebSocket"
],
"homepage": "http://socketo.me",
"license": "MIT",
"authors": [
{
"name": "Chris Boden"
, "email": "cboden@gmail.com"
, "role": "Developer"
}
, {
"name": "Matt Bonneau"
, "role": "Developer"
"name": "Chris Boden",
"email": "cboden@gmail.com",
"role": "Developer"
},
{
"name": "Matt Bonneau",
"role": "Developer"
}
]
, "support": {
"issues": "https://github.com/ratchetphp/Ratchet/issues"
, "chat": "https://gitter.im/reactphp/reactphp"
}
, "autoload": {
],
"support": {
"issues": "https://github.com/ratchetphp/Ratchet/issues",
"chat": "https://gitter.im/reactphp/reactphp"
},
"autoload": {
"psr-4": {
"Ratchet\\": "src/Ratchet"
}
}
, "require": {
"php": ">=5.4.2"
, "ratchet/rfc6455": "^0.4.0 | ^0.3.1"
, "react/socket": "^1.0 || ^0.8 || ^0.7 || ^0.6 || ^0.5"
, "react/event-loop": "^1.0 || ^0.5 || ^0.4"
, "guzzlehttp/psr7": "^1.7|^2.0"
, "symfony/http-foundation": "^2.6|^3.0|^4.0|^5.0|^6.0|^7.0"
, "symfony/routing": "^2.6|^3.0|^4.0|^5.0|^6.0|^7.0"
}
, "require-dev": {
},
"require": {
"php": ">=5.4.2",
"ratchet/rfc6455": "^0.4.0 | ^0.3.1",
"react/socket": "^1.0 || ^0.8 || ^0.7 || ^0.6 || ^0.5",
"react/event-loop": "^1.0 || ^0.5 || ^0.4",
"guzzlehttp/psr7": "^1.7|^2.0",
"symfony/http-foundation": "^2.6|^3.0|^4.0|^5.0|^6.0|^7.0",
"symfony/routing": "^2.6|^3.0|^4.0|^5.0|^6.0|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36"
},
"scripts": {
"tests": "vendor/bin/phpunit"
}
}
2 changes: 1 addition & 1 deletion src/Ratchet/Server/FlashPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function addAllowedAccess($domain, $ports = '*', $secure = false) {
throw new \UnexpectedValueException('Invalid Port');
}

$this->_access[] = array($domain, $ports, (boolean)$secure);
$this->_access[] = [$domain, $ports, (bool) $secure];
$this->_cacheValid = false;

return $this;
Expand Down
6 changes: 3 additions & 3 deletions src/Ratchet/Wamp/ServerProtocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function getSubProtocols() {
*/
public function onOpen(ConnectionInterface $conn) {
$decor = new WampConnection($conn);
$this->connections->attach($conn, $decor);
$this->connections->offsetSet($conn, $decor);

$this->_decorating->onOpen($decor);
}
Expand Down Expand Up @@ -125,7 +125,7 @@ public function onMessage(ConnectionInterface $from, $msg) {
case static::MSG_PUBLISH:
$exclude = (array_key_exists(3, $json) ? $json[3] : null);
if (!is_array($exclude)) {
if (true === (boolean)$exclude) {
if (true === (bool)$exclude) {
$exclude = [$from->WAMP->sessionId];
} else {
$exclude = [];
Expand All @@ -147,7 +147,7 @@ public function onMessage(ConnectionInterface $from, $msg) {
*/
public function onClose(ConnectionInterface $conn) {
$decor = $this->connections[$conn];
$this->connections->detach($conn);
$this->connections->offsetUnset($conn);

$this->_decorating->onClose($decor);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Ratchet/Wamp/Topic.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ public function broadcast($msg, array $exclude = array(), array $eligible = arra
* @return boolean
*/
public function has(ConnectionInterface $conn) {
return $this->subscribers->contains($conn);
return $this->subscribers->offsetExists($conn);
}

/**
* @param WampConnection $conn
* @return Topic
*/
public function add(ConnectionInterface $conn) {
$this->subscribers->attach($conn);
$this->subscribers->offsetSet($conn);

return $this;
}
Expand All @@ -76,8 +76,8 @@ public function add(ConnectionInterface $conn) {
* @return Topic
*/
public function remove(ConnectionInterface $conn) {
if ($this->subscribers->contains($conn)) {
$this->subscribers->detach($conn);
if ($this->subscribers->offsetExists($conn)) {
$this->subscribers->offsetUnset($conn);
}

return $this;
Expand Down
10 changes: 5 additions & 5 deletions src/Ratchet/Wamp/TopicManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public function onCall(ConnectionInterface $conn, $id, $topic, array $params) {
public function onSubscribe(ConnectionInterface $conn, $topic) {
$topicObj = $this->getTopic($topic);

if ($conn->WAMP->subscriptions->contains($topicObj)) {
if ($conn->WAMP->subscriptions->offsetExists($topicObj)) {
return;
}

$this->topicLookup[$topic]->add($conn);
$conn->WAMP->subscriptions->attach($topicObj);
$conn->WAMP->subscriptions->offsetSet($topicObj);
$this->app->onSubscribe($conn, $topicObj);
}

Expand All @@ -54,7 +54,7 @@ public function onSubscribe(ConnectionInterface $conn, $topic) {
public function onUnsubscribe(ConnectionInterface $conn, $topic) {
$topicObj = $this->getTopic($topic);

if (!$conn->WAMP->subscriptions->contains($topicObj)) {
if (!$conn->WAMP->subscriptions->offsetExists($topicObj)) {
return;
}

Expand Down Expand Up @@ -112,8 +112,8 @@ protected function getTopic($topic) {
}

protected function cleanTopic(Topic $topic, ConnectionInterface $conn) {
if ($conn->WAMP->subscriptions->contains($topic)) {
$conn->WAMP->subscriptions->detach($topic);
if ($conn->WAMP->subscriptions->offsetExists($topic)) {
$conn->WAMP->subscriptions->offsetUnset($topic);
}

$this->topicLookup[$topic->getId()]->remove($conn);
Expand Down
12 changes: 6 additions & 6 deletions src/Ratchet/WebSocket/WsServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function(FrameInterface $frame) use ($wsConn) {
$this->ueFlowFactory
);

$this->connections->attach($conn, new ConnContext($wsConn, $streamer));
$this->connections->offsetSet($conn, new ConnContext($wsConn, $streamer));

return $this->delegate->onOpen($wsConn);
}
Expand All @@ -170,9 +170,9 @@ public function onMessage(ConnectionInterface $from, $msg) {
* {@inheritdoc}
*/
public function onClose(ConnectionInterface $conn) {
if ($this->connections->contains($conn)) {
if ($this->connections->offsetExists($conn)) {
$context = $this->connections[$conn];
$this->connections->detach($conn);
$this->connections->offsetUnset($conn);

$this->delegate->onClose($context->connection);
}
Expand All @@ -182,7 +182,7 @@ public function onClose(ConnectionInterface $conn) {
* {@inheritdoc}
*/
public function onError(ConnectionInterface $conn, \Exception $e) {
if ($this->connections->contains($conn)) {
if ($this->connections->offsetExists($conn)) {
$this->delegate->onError($this->connections[$conn]->connection, $e);
} else {
$conn->close();
Expand Down Expand Up @@ -215,7 +215,7 @@ public function enableKeepAlive(LoopInterface $loop, $interval = 30) {

$this->pongReceiver = function(FrameInterface $frame, $wsConn) use ($pingedConnections, &$lastPing) {
if ($frame->getPayload() === $lastPing->getPayload()) {
$pingedConnections->detach($wsConn);
$pingedConnections->offsetUnset($wsConn);
}
};

Expand All @@ -231,7 +231,7 @@ public function enableKeepAlive(LoopInterface $loop, $interval = 30) {
$wsConn = $this->connections[$conn]->connection;

$wsConn->send($lastPing);
$pingedConnections->attach($wsConn);
$pingedConnections->offsetSet($wsConn);
}
});
}
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/AbstractConnectionDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,19 @@ public function testUnsetLevel2() {
public function testGetConnection() {
$class = new \ReflectionClass('Ratchet\\AbstractConnectionDecorator');
$method = $class->getMethod('getConnection');
$method->setAccessible(true);
// $method->setAccessible(true);

$conn = $method->invokeArgs($this->l1, array());
$conn = $method->invokeArgs($this->l1, []);

$this->assertSame($this->mock, $conn);
}

public function testGetConnectionLevel2() {
$class = new \ReflectionClass('Ratchet\\AbstractConnectionDecorator');
$method = $class->getMethod('getConnection');
$method->setAccessible(true);
// $method->setAccessible(true);

$conn = $method->invokeArgs($this->l2, array());
$conn = $method->invokeArgs($this->l2, []);

$this->assertSame($this->l1, $conn);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testCtorWithoutArgumentsStartsListeningOnDefaultPorts() {
$app = new App();

$ref = new \ReflectionProperty($app, '_server');
$ref->setAccessible(true);
// $ref->setAccessible(true);
$server = $ref->getValue($app);
assert($server instanceof IoServer);

Expand Down
10 changes: 5 additions & 5 deletions tests/unit/Wamp/ServerProtocolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function testSubscribe() {

public function testUnSubscribe() {
$uri = 'http://example.com/endpoint';
$clientMessage = array(6, $uri);
$clientMessage = [6, $uri];

$conn = $this->newConn();

Expand Down Expand Up @@ -190,9 +190,9 @@ public function testOnClosePropagation() {

$class = new \ReflectionClass('Ratchet\\Wamp\\WampConnection');
$method = $class->getMethod('getConnection');
$method->setAccessible(true);
// $method->setAccessible(true);

$check = $method->invokeArgs($this->_app->last['onClose'][0], array());
$check = $method->invokeArgs($this->_app->last['onClose'][0], []);

$this->assertSame($conn, $check);
}
Expand All @@ -207,9 +207,9 @@ public function testOnErrorPropagation() {

$class = new \ReflectionClass('Ratchet\\Wamp\\WampConnection');
$method = $class->getMethod('getConnection');
$method->setAccessible(true);
// $method->setAccessible(true);

$check = $method->invokeArgs($this->_app->last['onError'][0], array());
$check = $method->invokeArgs($this->_app->last['onError'][0], []);

$this->assertSame($conn, $check);
$this->assertSame($e, $this->_app->last['onError'][1]);
Expand Down
28 changes: 14 additions & 14 deletions tests/unit/Wamp/TopicManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public function setUpManager() {
public function testGetTopicReturnsTopicObject() {
$class = new \ReflectionClass('Ratchet\Wamp\TopicManager');
$method = $class->getMethod('getTopic');
$method->setAccessible(true);
// $method->setAccessible(true);

$topic = $method->invokeArgs($this->mngr, array('The Topic'));
$topic = $method->invokeArgs($this->mngr, ['The Topic']);

$this->assertInstanceOf('Ratchet\Wamp\Topic', $topic);
}
Expand All @@ -46,20 +46,20 @@ public function testGetTopicCreatesTopicWithSameName() {

$class = new \ReflectionClass('Ratchet\Wamp\TopicManager');
$method = $class->getMethod('getTopic');
$method->setAccessible(true);
//$method->setAccessible(true);

$topic = $method->invokeArgs($this->mngr, array($name));
$topic = $method->invokeArgs($this->mngr, [$name]);

$this->assertEquals($name, $topic->getId());
}

public function testGetTopicReturnsSameObject() {
$class = new \ReflectionClass('Ratchet\Wamp\TopicManager');
$method = $class->getMethod('getTopic');
$method->setAccessible(true);
// $method->setAccessible(true);

$topic = $method->invokeArgs($this->mngr, array('No copy'));
$again = $method->invokeArgs($this->mngr, array('No copy'));
$topic = $method->invokeArgs($this->mngr, ['No copy']);
$again = $method->invokeArgs($this->mngr, ['No copy']);

$this->assertSame($topic, $again);
}
Expand Down Expand Up @@ -95,13 +95,13 @@ public function testTopicIsInConnectionOnSubscribe() {

$class = new \ReflectionClass('Ratchet\Wamp\TopicManager');
$method = $class->getMethod('getTopic');
$method->setAccessible(true);
// $method->setAccessible(true);

$topic = $method->invokeArgs($this->mngr, array($name));
$topic = $method->invokeArgs($this->mngr, [$name]);

$this->mngr->onSubscribe($this->conn, $name);

$this->assertTrue($this->conn->WAMP->subscriptions->contains($topic));
$this->assertTrue($this->conn->WAMP->subscriptions->offsetExists($topic));
}

public function testDoubleSubscriptionFiresOnce() {
Expand Down Expand Up @@ -135,14 +135,14 @@ public function testUnsubscribeRemovesTopicFromConnection() {

$class = new \ReflectionClass('Ratchet\Wamp\TopicManager');
$method = $class->getMethod('getTopic');
$method->setAccessible(true);
//$method->setAccessible(true);

$topic = $method->invokeArgs($this->mngr, array($name));

$this->mngr->onSubscribe($this->conn, $name);
$this->mngr->onUnsubscribe($this->conn, $name);

$this->assertFalse($this->conn->WAMP->subscriptions->contains($topic));
$this->assertFalse($this->conn->WAMP->subscriptions->offsetExists($topic));
}

public function testOnPublishBubbles() {
Expand All @@ -167,10 +167,10 @@ public function testOnCloseBubbles() {
protected function topicProvider($name) {
$class = new \ReflectionClass('Ratchet\Wamp\TopicManager');
$method = $class->getMethod('getTopic');
$method->setAccessible(true);
//$method->setAccessible(true);

$attribute = $class->getProperty('topicLookup');
$attribute->setAccessible(true);
//$attribute->setAccessible(true);

$topic = $method->invokeArgs($this->mngr, array($name));

Expand Down
Loading