Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.6 Support for Symfony 7 #1053

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
122c322
Bump PHP7 version and PHPUnit
simPod Jan 12, 2020
e135ace
Drop @covers annotation for interfaces
simPod Mar 4, 2020
d29903c
Drop hhvm and composer deprecated --dev arg from travis
simPod Mar 4, 2020
b6f8e2d
Rename OptionsHandler to OptionsHandlerInterface
mbonneau May 21, 2020
e22966a
Rename PhpOptionsHandler to IniOptionsHandler
simPod May 26, 2020
6082c10
rRemove BC breaks that are not BC breaks
simPod May 26, 2020
0469b63
Merge pull request #773 from simPod/php7
cboden May 28, 2020
3931437
Use Throwable instead of Exception
simPod Jan 12, 2020
04b4599
Merge pull request #774 from simPod/exc
cboden Jun 4, 2020
4b8df6e
Merge branch 'master' into v0.5
simPod Sep 29, 2020
b341601
Merge pull request #833 from simPod/merged
cboden Sep 29, 2020
0a04977
Add Github actions so CI runs
simPod Jan 26, 2021
25b0549
Tweak CI for v0.5
simPod Jan 26, 2021
636ba99
Upgrade react/socket to v1.0+
simPod Jan 26, 2021
166b49e
For tests we need react/event-loop v1+ and therefore also react/strea…
simPod Jan 26, 2021
121be73
Keep old react/socket
simPod Jan 27, 2021
da9fe4d
Merge pull request #857 from simPod/ga-05
cboden Jan 27, 2021
a830b87
Allow PHP 8
simPod Jan 27, 2021
3cf60fe
Drop EOLed PHP 7.2 support
simPod Jan 26, 2021
0998af5
Merge pull request #854 from simPod/allow-php8
cboden Jan 27, 2021
ed5ce39
Merge branch 'v0.5' into drop-eol
cboden Jan 27, 2021
60b2121
Merge pull request #855 from simPod/drop-eol
cboden Jan 27, 2021
8aeabde
Merge remote-tracking branch 'origin/v0.5' into symfony_7.0
joeOLB Feb 1, 2024
494ad9f
Added the idea directory to git ignore file
joeOLB Feb 1, 2024
e0c6899
update dependencies in composer for symfony 7 usage
joeOLB Feb 1, 2024
8fb84e6
Updates for PHP 8 and Symfony 7
joeOLB Mar 19, 2024
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
9 changes: 2 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,14 @@ jobs:
strategy:
matrix:
php-version:
- "5.4"
- "5.5"
- "5.6"
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
dependencies:
- "highest"
include:
- dependencies: "lowest"
php-version: "5.4"
php-version: "7.3"

steps:
- name: "Checkout"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
phpunit.xml
reports
sandbox
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ CHANGELOG
* "BF": Bug fix

---
* 0.5.0
* PHP 7.2 is minimum supported version
* BC: `Ratchet\Session\Storage\Proxy\VirtualSessionStorage` requires `Ratchet\Session\OptionsHandler`
* `ComponentInterface::onError()` now accepts `Throwable` instead of `Exception`

* 0.4.4 (2021-12-11)
* Correct and update dependencies for forward compatibility
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class MyChat implements MessageComponentInterface {
conn.onopen = function(e) { conn.send('Hello Me!'); };
```

[GA Image]: https://github.com/ratchetphp/Ratchet/workflows/CI/badge.svg
[GA Image]: https://github.com/ratchetphp/Ratchet/workflows/CI/badge.svg?branch=v0.5

[GA Link]: https://github.com/ratchetphp/Ratchet/actions?query=workflow%3A%22CI%22+branch=v0.5

[GA Link]: https://github.com/ratchetphp/Ratchet/actions?query=workflow%3A%22CI%22+branch%3Amaster
22 changes: 14 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,22 @@
"Ratchet\\": "src/Ratchet"
}
}
, "autoload-dev": {
"psr-4": {
"Ratchet\\Tests\\": "tests/"
}
}
, "require": {
"php": ">=5.4.2"
, "ratchet/rfc6455": "^0.3.1"
, "react/socket": "^1.0 || ^0.8 || ^0.7 || ^0.6 || ^0.5"
, "react/event-loop": ">=0.4"
, "guzzlehttp/psr7": "^1.7|^2.0"
, "symfony/http-foundation": "^2.6|^3.0|^4.0|^5.0|^6.0"
, "symfony/routing": "^2.6|^3.0|^4.0|^5.0|^6.0"
"php": "^7.3 || ^8.0"
, "ratchet/rfc6455": "^0.3"
, "react/socket": "^1.0 || ^0.8 || ^0.7 || ^0.6 || ^0.5 || ^v1.15"
, "react/event-loop": ">=v1.5.0"
Comment on lines +36 to +37

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
, "react/socket": "^1.0 || ^0.8 || ^0.7 || ^0.6 || ^0.5 || ^v1.15"
, "react/event-loop": ">=v1.5.0"
, "react/socket": "^1.0 || ^0.8 || ^0.7 || ^0.6 || ^0.5"
, "react/event-loop": ">=0.4"

*Those changes are unnecessary because the previous range already allows those newer versions

, "guzzlehttp/psr7": "^1.7|^2.0|^2.6"
, "symfony/http-foundation": "^2.6|^3.0|^4.0|^5.0|^6.0|^v7.0"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
, "symfony/http-foundation": "^2.6|^3.0|^4.0|^5.0|^6.0|^v7.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": "~4.8"
"phpunit/phpunit": "^8.5|^10.5",
"react/stream": "^1.0|^1.3"
}
}
15 changes: 3 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
forceCoversAnnotation="true"
mapTestClassNameToCoveredClassName="true"
bootstrap="tests/bootstrap.php"
colors="true"
backupGlobals="false"
backupStaticAttributes="false"
syntaxCheck="false"
stopOnError="false"
>

<testsuites>
Expand All @@ -16,15 +13,9 @@
</testsuite>
</testsuites>

<testsuites>
<testsuite name="integration">
<directory>./tests/integration/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./src/</directory>
</whitelist>
</filter>
</phpunit>
</phpunit>
16 changes: 9 additions & 7 deletions src/Ratchet/ComponentInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Ratchet;

use Throwable;

/**
* This is the interface to build a Ratchet application with.
* It implements the decorator pattern to build an application stack
Expand All @@ -9,23 +11,23 @@ interface ComponentInterface {
/**
* When a new connection is opened it will be passed to this method
* @param ConnectionInterface $conn The socket/connection that just connected to your application
* @throws \Exception
* @throws Throwable
*/
function onOpen(ConnectionInterface $conn);

/**
* This is called before or after a socket is closed (depends on how it's closed). SendMessage to $conn will not result in an error if it has already been closed.
* @param ConnectionInterface $conn The socket/connection that is closing/closed
* @throws \Exception
* @throws Throwable
*/
function onClose(ConnectionInterface $conn);

/**
* If there is an error with one of the sockets, or somewhere in the application where an Exception is thrown,
* the Exception is sent back down the stack, handled by the Server and bubbled back up the application through this method
* If there is an error with one of the sockets, or somewhere in the application where an Throwable is thrown,
* the Throwable is sent back down the stack, handled by the Server and bubbled back up the application through this method
* @param ConnectionInterface $conn
* @param \Exception $e
* @throws \Exception
* @param Throwable $e
* @throws Throwable
*/
function onError(ConnectionInterface $conn, \Exception $e);
function onError(ConnectionInterface $conn, Throwable $e);
}
3 changes: 2 additions & 1 deletion src/Ratchet/Http/HttpServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Ratchet\Http;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
use Throwable;

class HttpServer implements MessageComponentInterface {
use CloseResponseTrait;
Expand Down Expand Up @@ -66,7 +67,7 @@ public function onClose(ConnectionInterface $conn) {
/**
* {@inheritdoc}
*/
public function onError(ConnectionInterface $conn, \Exception $e) {
public function onError(ConnectionInterface $conn, Throwable $e) {
if ($conn->httpHeadersReceived) {
$this->_httpServer->onError($conn, $e);
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/Ratchet/Http/NoOpHttpServerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Ratchet\Http;
use Ratchet\ConnectionInterface;
use Psr\Http\Message\RequestInterface;
use Throwable;

class NoOpHttpServerController implements HttpServerInterface {
public function onOpen(ConnectionInterface $conn, RequestInterface $request = null) {
Expand All @@ -13,6 +14,6 @@ public function onMessage(ConnectionInterface $from, $msg) {
public function onClose(ConnectionInterface $conn) {
}

public function onError(ConnectionInterface $conn, \Exception $e) {
public function onError(ConnectionInterface $conn, Throwable $e) {
}
}
5 changes: 3 additions & 2 deletions src/Ratchet/Http/OriginCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Ratchet\ConnectionInterface;
use Ratchet\MessageComponentInterface;
use Psr\Http\Message\RequestInterface;
use Throwable;

/**
* A middleware to ensure JavaScript clients connecting are from the expected domain.
Expand Down Expand Up @@ -59,7 +60,7 @@ function onClose(ConnectionInterface $conn) {
/**
* {@inheritdoc}
*/
function onError(ConnectionInterface $conn, \Exception $e) {
function onError(ConnectionInterface $conn, Throwable $e) {
return $this->_component->onError($conn, $e);
}
}
}
5 changes: 3 additions & 2 deletions src/Ratchet/Http/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use GuzzleHttp\Psr7\Query;
Copy link

@Tofandel Tofandel Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This namespace removal causes fatal errors because Query::parse and Query::build have not been replaced, in fact it's not even used

use GuzzleHttp\Psr7 as gPsr;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use GuzzleHttp\Psr7 as gPsr;
use GuzzleHttp\Psr7\Query;

use Throwable;

class Router implements HttpServerInterface {
use CloseResponseTrait;
Expand Down Expand Up @@ -88,7 +89,7 @@ public function onClose(ConnectionInterface $conn) {
/**
* {@inheritdoc}
*/
public function onError(ConnectionInterface $conn, \Exception $e) {
public function onError(ConnectionInterface $conn, Throwable $e) {
if (isset($conn->controller)) {
$conn->controller->onError($conn, $e);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Ratchet/MessageInterface.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php
namespace Ratchet;

use Throwable;

interface MessageInterface {
/**
* Triggered when a client sends data through the socket
* @param \Ratchet\ConnectionInterface $from The socket/connection that sent the message to your application
* @param string $msg The message received
* @throws \Exception
* @throws Throwable
*/
function onMessage(ConnectionInterface $from, $msg);
}
3 changes: 2 additions & 1 deletion src/Ratchet/Server/EchoServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Ratchet\Server;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
use Throwable;

/**
* A simple Ratchet application that will reply to all messages with the message it received
Expand All @@ -17,7 +18,7 @@ public function onMessage(ConnectionInterface $from, $msg) {
public function onClose(ConnectionInterface $conn) {
}

public function onError(ConnectionInterface $conn, \Exception $e) {
public function onError(ConnectionInterface $conn, Throwable $e) {
$conn->close();
}
}
3 changes: 2 additions & 1 deletion src/Ratchet/Server/FlashPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Ratchet\Server;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
use Throwable;

/**
* An app to go on a server stack to pass a policy file to a Flash socket
Expand Down Expand Up @@ -132,7 +133,7 @@ public function onClose(ConnectionInterface $conn) {
/**
* {@inheritdoc}
*/
public function onError(ConnectionInterface $conn, \Exception $e) {
public function onError(ConnectionInterface $conn, Throwable $e) {
$conn->close();
}

Expand Down
11 changes: 6 additions & 5 deletions src/Ratchet/Server/IoServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use React\EventLoop\Factory as LoopFactory;
use React\Socket\Server as Reactor;
use React\Socket\SecureServer as SecureReactor;
use Throwable;

/**
* Creates an open-ended socket to listen on a port for incoming connections.
Expand Down Expand Up @@ -97,7 +98,7 @@ public function handleConnect($conn) {
$conn->on('close', function () use ($conn) {
$this->handleEnd($conn);
});
$conn->on('error', function (\Exception $e) use ($conn) {
$conn->on('error', function (Throwable $e) use ($conn) {
$this->handleError($e, $conn);
});
}
Expand All @@ -110,7 +111,7 @@ public function handleConnect($conn) {
public function handleData($data, $conn) {
try {
$this->app->onMessage($conn->decor, $data);
} catch (\Exception $e) {
} catch (Throwable $e) {
$this->handleError($e, $conn);
}
}
Expand All @@ -122,7 +123,7 @@ public function handleData($data, $conn) {
public function handleEnd($conn) {
try {
$this->app->onClose($conn->decor);
} catch (\Exception $e) {
} catch (Throwable $e) {
$this->handleError($e, $conn);
}

Expand All @@ -131,10 +132,10 @@ public function handleEnd($conn) {

/**
* An error has occurred, let the listening application know
* @param \Exception $e
* @param Throwable $e
* @param \React\Socket\ConnectionInterface $conn
*/
public function handleError(\Exception $e, $conn) {
public function handleError(Throwable $e, $conn) {
$this->app->onError($conn->decor, $e);
}
}
5 changes: 3 additions & 2 deletions src/Ratchet/Server/IpBlackList.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Ratchet\Server;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
use Throwable;

class IpBlackList implements MessageComponentInterface {
/**
Expand Down Expand Up @@ -67,7 +68,7 @@ public function getBlockedAddresses() {
*/
public function filterAddress($address) {
if (strstr($address, ':') && substr_count($address, '.') == 3) {
list($address, $port) = explode(':', $address);
[$address, $port] = explode(':', $address);
}

return $address;
Expand Down Expand Up @@ -103,7 +104,7 @@ function onClose(ConnectionInterface $conn) {
/**
* {@inheritdoc}
*/
function onError(ConnectionInterface $conn, \Exception $e) {
function onError(ConnectionInterface $conn, Throwable $e) {
if (!$this->isBlocked($conn->remoteAddress)) {
$this->_decorating->onError($conn, $e);
}
Expand Down
19 changes: 19 additions & 0 deletions src/Ratchet/Session/IniOptionsHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Ratchet\Session;

use function ini_get;
use function ini_set;

final class IniOptionsHandler implements OptionsHandlerInterface
{
public function get(string $name) : string
{
return ini_get($name);
}

public function set(string $name, $value) : void
{
ini_set($name, $value);
}
}
13 changes: 13 additions & 0 deletions src/Ratchet/Session/OptionsHandlerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Ratchet\Session;

interface OptionsHandlerInterface
{
public function get(string $name) : string;

/**
* @param mixed $value
*/
public function set(string $name, $value) : void;
}
Loading