swarrot / SwarrotBundle

A symfony bundle for swarrot integration
MIT License
89 stars 59 forks source link

Problem when type hinting method process in PHP7 #152

Closed loicdev closed 5 years ago

loicdev commented 5 years ago

Hi, we are using a PHP 7.2 stack with SwarrotBundle and we 're font of a issue that can't passed PHP CS-Fixer rules:

We need to type-hinting the processor return with ?bool when using the middleware configurator swarrot.processor.ack.

So the resposability of ack/no'ack depends on this configurator.

How can we do that without "re-create" the ack processor ?

Thanks in advance

odolbeau commented 5 years ago

Hi, I don't really understand your problem.

Why do you need to type hint this processor with ?bool? Could you provide the PHP CS-Fixer error?

loicdev commented 5 years ago

Hi, the phpcs's suggestion :

-    public function process(Message $message, array $options)
+    public function process(Message $message, array $options): void

because i haven't got return in the method (the ack processor do it by itself) i go to the method definition in vendor and i saw the return was indeed ?bool. I try to ack the message by myself with a return true/false but i can can't reproduce the ack processor behaviour and it failed.

At this moment, i ignore my consumer file temporary to passed the phpcs tests.

odolbeau commented 5 years ago

For which file does PHPCS makes you this suggestion?

As the complete signature of the process method in the ProcessorInterface should be:

public function process(Message $message, array $options): bool;

Don't hesitate to return a boolean in your custom processors. We won't change the interface for now because it will result in a new major release but when we'll do it, you'll be ready. :)

loicdev commented 5 years ago

thanks u ;)

stof commented 5 years ago

And ProcessorInterface in swarrot defines @return bool|null in phpdoc. So that suggestion would even be wrong.