jolicode / slack-php-api

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

setNormalizer() must implement interface Symfony\Component\Serializer\Normalizer\NormalizerInterface #148

Closed tommy-ec closed 1 year ago

tommy-ec commented 2 years ago

Hi,

I am trying to use the normalizer to convert the protected channel object to an array but I keep getting the following error: Fatal error: Uncaught TypeError: Argument 1 passed to JoliCode\Slack\Api\Normalizer\ConversationsListGetResponse200Normalizer::setNormalizer() must implement interface Symfony\Component\Serializer\Normalizer\NormalizerInterface, null given, called in /vendor/jolicode/slack-php-api/generated/Normalizer/JaneObjectNormalizer.php on line 78 and defined in /vendor/symfony/serializer/Normalizer/NormalizerAwareTrait.php:24 Stack trace: #0 /vendor/jolicode/slack-php-api/generated/Normalizer/JaneObjectNormalizer.php(78): JoliCode\Slack\Api\Normalizer\ConversationsListGetResponse200Normalizer->setNormalizer() #1 /vendor/jolicode/slack-php-api/generated/Normalizer/JaneObjectNormalizer.php(72): JoliCode\Slack\Api\Normalizer\JaneObjectNormalizer->initN in /vendor/symfony/serializer/Normalizer/NormalizerAwareTrait.php on line 24

The code I am using is below:

use JoliCode\Slack\Api\Normalizer\JaneObjectNormalizer;
use JoliCode\Slack\Api\Model\ObjsUser;
use JoliCode\Slack\ClientFactory;
use JoliCode\Slack\Exception\SlackErrorResponse;

require_once __DIR__.'/vendor/autoload.php';

$client = ClientFactory::create("xoxb-123456789");
$normalizer = new JaneObjectNormalizer;

$channels = $client->conversationsList();
$channels = $normalizer->normalize($channels);
lyrixx commented 1 year ago

Hello,

This is a know issue with the Serializer component. Unfortunatelly, we cannot solve this issue without bumping to PHP 8.1 (we need intersection type)