openswoole / ext-openswoole

Programmatic server for PHP with async IO, coroutines and fibers

Home Page:https://openswoole.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PSR Interface wrongly implemented in OpenSwoole\Core\Psr\Middleware\StackHandler

medaqueno opened this issue · comments

commented
  1. What did you do? If possible, provide a simple script for reproducing the error.
    After building docker image from https://hub.docker.com/layers/openswoole/swoole/22.0.0-php8.2/images/sha256-6638b26204373464de0a4a1b31692b21c3b98daccfa81eae4bf04eb09c352b80?context=explore

And execute: composer require openswoole/core:22.1.0

I copied examples from https://openswoole.com/docs/psr and started container

  1. What did you expect to see?
    Server working seamlesly.

  2. What did you see instead?

Fatal error: Declaration of OpenSwoole\Core\Psr\Middleware\StackHandler::handle(Psr\Http\Message\ServerRequestInterface $request): ?Psr\Http\Message\ResponseInterface must be compatible with Psr\Http\Server\RequestHandlerInterface::handle(Psr\Http\Message\ServerRequestInterface $request): Psr\Http\Message\ResponseInterface in /var/www/vendor/openswoole/core/src/Psr/Middleware/StackHandler.php on line 32

The problem is an incompatibilty between interfaces the class:
OpenSwoole\Core\Psr\Middleware\StackHandler where typed response in method handle is ?ResponseInterface.

While While in Psr\Http\Server\RequestHandlerInterface, handle method response is: ResponseInterface (not nullable)

I edited directly StackHandler handle class and changed typed response, and it worked as it was expected.

  1. What version of OpenSwoole are you using (show your php --ri openswoole)?
Version => 22.0.0
Built => Dec 21 2022 22:10:40
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.1.1n  15 Mar 2022
dtls => enabled
http2 => enabled
hook-curl => enabled
zlib => 1.2.11
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => enabled
postgresql => enabled

Directive => Local Value => Master Value
openswoole.enable_coroutine => On => On
openswoole.enable_preemptive_scheduler => Off => Off
openswoole.display_errors => On => On
openswoole.unixsock_buffer_size => 8388608 => 8388608

  1. What is your machine environment used (show your uname -a & php -v & gcc -v) ?
    Irrelevant.

Fixed in composer require openswoole/core:22.1.1