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
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- "8.2"
- "8.3"
- "8.4"
- "8.5"
dependencies:
- "highest"
include:
Expand All @@ -33,7 +34,7 @@ jobs:

steps:
- name: "Checkout"
uses: "actions/checkout@v4"
uses: "actions/checkout@v6"
with:
fetch-depth: 2

Expand All @@ -45,7 +46,7 @@ jobs:
ini-values: "zend.assertions=1"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v3"
uses: "ramsey/composer-install@v4"
with:
dependency-versions: "${{ matrix.dependencies }}"

Expand Down
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[] = array($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: 6 additions & 2 deletions tests/unit/AbstractConnectionDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public function testUnsetLevel2() {
public function testGetConnection() {
$class = new \ReflectionClass('Ratchet\\AbstractConnectionDecorator');
$method = $class->getMethod('getConnection');
$method->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

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

Expand All @@ -100,7 +102,9 @@ public function testGetConnection() {
public function testGetConnectionLevel2() {
$class = new \ReflectionClass('Ratchet\\AbstractConnectionDecorator');
$method = $class->getMethod('getConnection');
$method->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

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

Expand Down
4 changes: 3 additions & 1 deletion tests/unit/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public function testCtorWithoutArgumentsStartsListeningOnDefaultPorts() {
$app = new App();

$ref = new \ReflectionProperty($app, '_server');
$ref->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$ref->setAccessible(true);
}
$server = $ref->getValue($app);
assert($server instanceof IoServer);

Expand Down
4 changes: 3 additions & 1 deletion tests/unit/Session/SessionProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public function classCaseProvider() {
public function testToClassCase($in, $out) {
$ref = new \ReflectionClass('Ratchet\\Session\\SessionProvider');
$method = $ref->getMethod('toClassCase');
$method->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

$component = new SessionProvider($this->getMockBuilder($this->getComponentClassString())->getMock(), $this->getMockBuilder('SessionHandlerInterface')->getMock());
$this->assertEquals($out, $method->invokeArgs($component, array($in)));
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/Wamp/ServerProtocolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ public function testOnClosePropagation() {

$class = new \ReflectionClass('Ratchet\\Wamp\\WampConnection');
$method = $class->getMethod('getConnection');
$method->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

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

Expand All @@ -207,7 +209,9 @@ public function testOnErrorPropagation() {

$class = new \ReflectionClass('Ratchet\\Wamp\\WampConnection');
$method = $class->getMethod('getConnection');
$method->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

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

Expand Down
32 changes: 23 additions & 9 deletions tests/unit/Wamp/TopicManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public function setUpManager() {
public function testGetTopicReturnsTopicObject() {
$class = new \ReflectionClass('Ratchet\Wamp\TopicManager');
$method = $class->getMethod('getTopic');
$method->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

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

Expand All @@ -46,7 +48,9 @@ public function testGetTopicCreatesTopicWithSameName() {

$class = new \ReflectionClass('Ratchet\Wamp\TopicManager');
$method = $class->getMethod('getTopic');
$method->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

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

Expand All @@ -56,7 +60,9 @@ public function testGetTopicCreatesTopicWithSameName() {
public function testGetTopicReturnsSameObject() {
$class = new \ReflectionClass('Ratchet\Wamp\TopicManager');
$method = $class->getMethod('getTopic');
$method->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

$topic = $method->invokeArgs($this->mngr, array('No copy'));
$again = $method->invokeArgs($this->mngr, array('No copy'));
Expand Down Expand Up @@ -95,13 +101,15 @@ public function testTopicIsInConnectionOnSubscribe() {

$class = new \ReflectionClass('Ratchet\Wamp\TopicManager');
$method = $class->getMethod('getTopic');
$method->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

$topic = $method->invokeArgs($this->mngr, array($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 +143,16 @@ public function testUnsubscribeRemovesTopicFromConnection() {

$class = new \ReflectionClass('Ratchet\Wamp\TopicManager');
$method = $class->getMethod('getTopic');
$method->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$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 +177,14 @@ public function testOnCloseBubbles() {
protected function topicProvider($name) {
$class = new \ReflectionClass('Ratchet\Wamp\TopicManager');
$method = $class->getMethod('getTopic');
$method->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

$attribute = $class->getProperty('topicLookup');
$attribute->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$attribute->setAccessible(true);
}

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

Expand Down