Completed
Push — master ( 53783e...ee648a )
by Olivier
22s queued 20s
created

examples/00-basic-consumer.php (2 issues)

1
<?php
2
3
require_once __DIR__.'/../vendor/autoload.php';
4
5
use Swarrot\Broker\Message;
6
use Swarrot\Broker\PeclPackageMessageProvider;
0 ignored issues
show
The type Swarrot\Broker\PeclPackageMessageProvider was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Swarrot\Consumer;
8
use Swarrot\Processor\ProcessorInterface;
9
10
class Processor implements ProcessorInterface
11
{
12
    public function process(Message $message, array $options)
13
    {
14
        printf("Consume message #%d\n", $message->getId());
0 ignored issues
show
Bug Best Practice introduced by
The expression ImplicitReturnNode returns the type null which is incompatible with the return type mandated by Swarrot\Processor\ProcessorInterface::process() of boolean.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
15
    }
16
}
17
18
$connection = new \AMQPConnection();
19
$connection->connect();
20
$channel = new \AMQPChannel($connection);
21
$queue = new \AMQPQueue($channel);
22
$queue->setName('global');
23
24
$messageProvider = new PeclPackageMessageProvider($queue);
25
26
$consumer = new Consumer($messageProvider, new Processor());
27
$consumer->consume();
28