jolicode / slack-php-api

:hash: PHP Slack Client based on the official OpenAPI specification
https://jolicode.github.io/slack-php-api/
MIT License
222 stars 56 forks source link

Fatal error on chatPostMessage #54

Closed resslinger closed 4 years ago

resslinger commented 4 years ago

Hello,

since today, we get the following error, if we want to send a message over chatPostMessage: Fatal error: Declaration of JoliCode\Slack\Api\Endpoint\ChatPostMessage::getBody(Symfony\Component\Serializer\SerializerInterface $serializer, ?Http\Message\StreamFactory $streamFactory = NULL): array must be compatible with Jane\OpenApiRuntime\Client\BaseEndpoint::getBody(Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = NULL): array

The code is the following: $client = JoliCode\Slack\ClientFactory::create(SLACK_OAUTH_TOKEN);

        $result = $client->chatPostMessage([
            'username' => $username,
            'channel' => $channel,
            'text' => $text,
        ]);
pyrech commented 4 years ago

Hi,

Sorry you faced an issue with this SDK. :confused:

Regarding the signature of the endpoint JoliCode\Slack\Api\Endpoint\ChatPostMessage::getBody() (ie the typehint of the $streamFactory parameter), it looks like your are using this SDK in version < 2.1.

But the signature of the class Jane\OpenApiRuntime\Client\BaseEndpoint::getBody() do not have a typehint for this $streamFactory so you probably have jane-php/open-api-runtime installed in version >= 4.5.0

I suggest you to try to update this package in version >= 2.1. It should fix your issue :wink: :crossed_fingers:

resslinger commented 4 years ago

Hi,

we work with composer and the version 1.2.0, which is required in the composer file.

After composer update, the janephp lib was updated. Since this, the error exists. I think, the requirements for 1.2.0 are not correct in the composer file.

If I want to work with 1.2.0, a dependency for this project should not be updated.

pyrech commented 4 years ago

Hey @lacodimizer,

Good news, I just released 1.2.1 who requires jane-php/open-api-runtime in version < 4.5. I hope that should be ok for you.

Cheers

pyrech commented 4 years ago

Closing as the issue should be fixed now. Feel free to reopen if you face this bug again :wink: