@@ -38,13 +38,16 @@ class SessionProvider implements HttpServerInterface {
3838 protected $ _serializer ;
3939
4040 /**
41- * @param \Ratchet\Http\HttpServerInterface $app
42- * @param \SessionHandlerInterface $handler
43- * @param array $options
44- * @param \Ratchet\Session\Serialize\HandlerInterface $serializer
41+ * @param \Ratchet\Http\HttpServerInterface $app
42+ * @param \SessionHandlerInterface $handler
43+ * @param array $options
44+ * @param ? \Ratchet\Session\Serialize\HandlerInterface $serializer
4545 * @throws \RuntimeException
4646 */
47- public function __construct (HttpServerInterface $ app , \SessionHandlerInterface $ handler , array $ options = array (), HandlerInterface $ serializer = null ) {
47+ public function __construct (HttpServerInterface $ app , \SessionHandlerInterface $ handler , array $ options = array (), $ serializer = null ) {
48+ if ($ serializer !== null && !$ serializer instanceof HandlerInterface) { // manual type check to support legacy PHP < 7.1
49+ throw new \InvalidArgumentException ('Argument #4 ($serializer) expected null|Ratchet\Session\Serialize\HandlerInterface ' );
50+ }
4851 $ this ->_app = $ app ;
4952 $ this ->_handler = $ handler ;
5053 $ this ->_null = new NullSessionHandler ;
@@ -70,7 +73,8 @@ public function __construct(HttpServerInterface $app, \SessionHandlerInterface $
7073 /**
7174 * {@inheritdoc}
7275 */
73- public function onOpen (ConnectionInterface $ conn , RequestInterface $ request = null ) {
76+ #[HackSupportForPHP8] public function onOpen (ConnectionInterface $ conn , ?RequestInterface $ request = null ) { /*
77+ public function onOpen(ConnectionInterface $conn, RequestInterface $request = null) { /**/
7478 $ sessionName = ini_get ('session.name ' );
7579
7680 $ id = array_reduce ($ request ->getHeader ('Cookie ' ), function ($ accumulator , $ cookie ) use ($ sessionName ) {
0 commit comments