Thanks to visit codestin.com
Credit goes to github.com

Skip to content

There is a problem with the getHeader method in Psr/Message.php #6 #94

@federicomaffucci

Description

@federicomaffucci

Updating the package to version 22.2.0 broke everything for me due to an invalid typing in this snippet.

ERROR php_swoole_server_rshutdown() (ERRNO 503): Fatal error: Uncaught TypeError: OpenSwoole\Core\Psr\Message::getHeader(): Return value must be of type array, string returned in /var/www/vendor/openswoole/core/src/Psr/Message.php:111

    public function getHeader(string $name): array
    {
        return $this->hasHeader($name) ? $this->headers[strtolower($name)] : [];
    }

It's not always an array, in my case it's simply the retrieval of the "Authorization" header
Bearer xxxxxxxxxx.xxxxxxxxxx.xxxxxxx

I remedied the situation like this:

    public function getHeader(string $name): array|string
    {
        return $this->hasHeader($name) ? $this->headers[strtolower($name)] : [];
    }

What do you think? Have you encountered this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions