diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd322b8b..cc762523 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,7 @@ jobs: - "8.2" - "8.3" - "8.4" + - "8.5" dependencies: - "highest" include: @@ -33,7 +34,7 @@ jobs: steps: - name: "Checkout" - uses: "actions/checkout@v4" + uses: "actions/checkout@v6" with: fetch-depth: 2 @@ -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 }}" diff --git a/src/Ratchet/Server/FlashPolicy.php b/src/Ratchet/Server/FlashPolicy.php index 4a1b8bdf..c8636ae8 100644 --- a/src/Ratchet/Server/FlashPolicy.php +++ b/src/Ratchet/Server/FlashPolicy.php @@ -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; diff --git a/src/Ratchet/Wamp/ServerProtocol.php b/src/Ratchet/Wamp/ServerProtocol.php index 2d6d799c..781a5964 100644 --- a/src/Ratchet/Wamp/ServerProtocol.php +++ b/src/Ratchet/Wamp/ServerProtocol.php @@ -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); } @@ -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 = []; @@ -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); } diff --git a/src/Ratchet/Wamp/Topic.php b/src/Ratchet/Wamp/Topic.php index 675b236e..a1a0580c 100644 --- a/src/Ratchet/Wamp/Topic.php +++ b/src/Ratchet/Wamp/Topic.php @@ -58,7 +58,7 @@ 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); } /** @@ -66,7 +66,7 @@ public function has(ConnectionInterface $conn) { * @return Topic */ public function add(ConnectionInterface $conn) { - $this->subscribers->attach($conn); + $this->subscribers->offsetSet($conn); return $this; } @@ -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; diff --git a/src/Ratchet/Wamp/TopicManager.php b/src/Ratchet/Wamp/TopicManager.php index dd06ada4..e2b2936c 100644 --- a/src/Ratchet/Wamp/TopicManager.php +++ b/src/Ratchet/Wamp/TopicManager.php @@ -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); } @@ -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; } @@ -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); diff --git a/src/Ratchet/WebSocket/WsServer.php b/src/Ratchet/WebSocket/WsServer.php index 88c56348..67218fe8 100644 --- a/src/Ratchet/WebSocket/WsServer.php +++ b/src/Ratchet/WebSocket/WsServer.php @@ -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); } @@ -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); } @@ -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(); @@ -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); } }; @@ -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); } }); } diff --git a/tests/unit/AbstractConnectionDecoratorTest.php b/tests/unit/AbstractConnectionDecoratorTest.php index 8c5b379c..b3fff560 100644 --- a/tests/unit/AbstractConnectionDecoratorTest.php +++ b/tests/unit/AbstractConnectionDecoratorTest.php @@ -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()); @@ -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()); diff --git a/tests/unit/AppTest.php b/tests/unit/AppTest.php index b3c879e3..645ccf80 100644 --- a/tests/unit/AppTest.php +++ b/tests/unit/AppTest.php @@ -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); diff --git a/tests/unit/Session/SessionProviderTest.php b/tests/unit/Session/SessionProviderTest.php index 2bec51b0..7100db24 100644 --- a/tests/unit/Session/SessionProviderTest.php +++ b/tests/unit/Session/SessionProviderTest.php @@ -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))); diff --git a/tests/unit/Wamp/ServerProtocolTest.php b/tests/unit/Wamp/ServerProtocolTest.php index 4e4983fa..9d4bdd89 100644 --- a/tests/unit/Wamp/ServerProtocolTest.php +++ b/tests/unit/Wamp/ServerProtocolTest.php @@ -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()); @@ -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()); diff --git a/tests/unit/Wamp/TopicManagerTest.php b/tests/unit/Wamp/TopicManagerTest.php index fd67fdd5..bd6c0149 100644 --- a/tests/unit/Wamp/TopicManagerTest.php +++ b/tests/unit/Wamp/TopicManagerTest.php @@ -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')); @@ -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)); @@ -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')); @@ -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() { @@ -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() { @@ -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));