Completed
Push — master ( e11600...8ee61c )
by Pieter
02:27
created

server.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php declare(strict_types=1);
2
3
use Aerys\Host;
4
use Amp\Redis\Client;
5
use Auryn\Injector;
6
use ekinhbayar\GitAmp\Github\Credentials;
7
use ekinhbayar\GitAmp\Storage\Counter;
8
use ekinhbayar\GitAmp\Storage\RedisCounter;
9
use ekinhbayar\GitAmp\Websocket\Handler;
10
use function Aerys\root;
11
use function Aerys\router;
12
use function Aerys\websocket;
13
14
$configuration = require_once __DIR__ . '/config.php';
15
16
$injector = new Injector;
17
18
$injector->alias(Counter::class, RedisCounter::class);
19
20
$injector->alias(Credentials::class, get_class($configuration['github']));
21
22
$injector->share($configuration['github']);
23
24
$injector->define(Handler::class, [
25
    ":origins" => [
26
        "http://" . $configuration['origins']['websocket'],
27
        "http://" . $configuration['origins']['server'] ,
28
    ],
29
]);
30
31
$injector->define(Client::class, [
32
    ":uri" => "tcp://" . $configuration['redis']['hostname'] . ":" . $configuration['redis']['port']
33
]);
34
35
$websocket = $injector->make(Handler::class);
36
37
$router = router()->get("/ws", websocket($websocket));
38
39
(new Host)
40
    ->name($configuration['origins']['server'])
41
    ->expose($configuration['expose']['ip'], $configuration['expose']['port'])
42
    ->use($router)
43
    ->use(root(__DIR__ . "/public"));
0 ignored issues
show
\Aerys\root(__DIR__ . '/public') is of type object<Aerys\Bootable>, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
44