jolicode / slack-php-api

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

Issue with declaration of JaneObjectNormalizer #110

Closed vbaranovskiy-plesk closed 3 years ago

vbaranovskiy-plesk commented 3 years ago

Hello, I've tried to send test message to a channel but i've got an error:

$client = SlackFactory::create('my-token');
$this->client->chatPostMessage([
            'username' => 'example bot',
            'channel' => 'test-integration-channel',
            'text' => 'Hello world',
        ]); 

Declaration of JoliCode\Slack\Api\Normalizer\JaneObjectNormalizer::denormalize($data, $class, $format = NULL, array $context = Array) must be compatible with Symfony\Component\Serializer\Normalizer\DenormalizerInterface::denormalize($data, string $type, ?string $format = NULL, array $context = Array) in /app/vendor/jolicode/slack-php-api/generated/Normalizer/JaneObjectNormalizer.php:24

I looked into JaneObjectNormalizer https://github.com/jolicode/slack-php-api/blob/master/generated/Normalizer/JaneObjectNormalizer.php#L50 and DenormalizerInterface https://github.com/symfony/serializer/blob/5.x/Normalizer/DenormalizerInterface.php#L45 and it looks like their declarations are really different. Is this a bug?

Korbeil commented 3 years ago

Hey @vbaranovskiy-plesk and thanks for briging this issue ! Could you share us the jolicode/slack-php-api version you are using ? You can do that by typing: composer info jolicode/slack-php-api in your CLI and give us the output.

Thanks !

vbaranovskiy-plesk commented 3 years ago

Hello @Korbeil, composer info jolicode/slack-php-api gives the following results:

name     : jolicode/slack-php-api
descrip. : An up to date PHP client for Slack's API
keywords : api, client, openapi, sdk, slack, slackapi, swagger
versions : * v4.1.1
type     : library
license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
homepage :
source   : [git] https://github.com/jolicode/slack-php-api.git 65ae9fd575899f0fe6eae4d16595e49940c1261a
dist     : [zip] https://api.github.com/repos/jolicode/slack-php-api/zipball/65ae9fd575899f0fe6eae4d16595e49940c1261a 65ae9fd575899f0fe6eae4d16595e49940c1261a 

composer info symfony/http-client

name     : symfony/http-client
descrip. : Provides powerful methods to fetch HTTP resources synchronously or asynchronously
keywords :
versions : * v5.2.4
type     : library
license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
homepage : https://symfony.com
source   : [git] https://github.com/symfony/http-client.git c7d1f35a31ef153a302e3f80336170e1280b983d
dist     : [zip] https://api.github.com/repos/symfony/http-client/zipball/c7d1f35a31ef153a302e3f80336170e1280b983d c7d1f35a31ef153a302e3f80336170e1280b983d
damienalexandre commented 3 years ago

Thanks @vbaranovskiy-plesk - I just tested myself:

{
    "require": {
        "symfony/http-client": "^5.2",
        "nyholm/psr7": "^1.4",
        "jolicode/slack-php-api": "^4.1"
    }
}

And:

<?php

include("vendor/autoload.php");

$client = JoliCode\Slack\ClientFactory::create("secret");
$client->chatPostMessage([
            'username' => 'example bot',
            'channel' => 'CXXXXX',
            'text' => 'Hello world',
        ]); 

It provide v4.1.1 of jolicode/slack-php-api and there is no such error. As we cannot reproduce, could you provide an example where the error occurs?

What is SlackFactory? It does not belong to this project.

Also your code snippet declare a $client variable but use a "client" property ($this->client).

damienalexandre commented 3 years ago

Oh, just got another idea, can you show us your Serializer version? Because the error seems to come from it.

composer info symfony/serializer    

(I have v5.2.4 in my test).

vbaranovskiy-plesk commented 3 years ago

Checked in different project, thereis no such error, so i am closing this issue. But, please look into DenormalizerInterface (after composer install) & JaneObjectNormalizer. It is not really good that method "denormalize" has different declarations in class and interface