ekinhbayar /
gitamp
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 | // @todo unuglify this |
||
|
0 ignored issues
–
show
Coding Style
Best Practice
introduced
by
Loading history...
|
|||
| 25 | if (isset($configuration['ssl'])) { |
||
| 26 | $origin = 'https://' . $configuration['hostname']; |
||
| 27 | |||
| 28 | if ($configuration['ssl']['port'] !== 443) $origin .= ':' . $configuration['ssl']['port']; |
||
| 29 | } else { |
||
| 30 | $origin = 'http://' . $configuration['hostname']; |
||
| 31 | |||
| 32 | if ($configuration['expose']['port'] !== 80) $origin .= ':' . $configuration['expose']['port']; |
||
| 33 | } |
||
| 34 | |||
| 35 | $injector->define(Handler::class, [ |
||
| 36 | ':origin' => $origin, |
||
| 37 | ]); |
||
| 38 | |||
| 39 | $injector->define(Client::class, [ |
||
| 40 | ':uri' => $configuration['redis'] |
||
| 41 | ]); |
||
| 42 | |||
| 43 | $websocket = $injector->make(Handler::class); |
||
| 44 | |||
| 45 | $router = router()->get("/ws", websocket($websocket)); |
||
| 46 | |||
| 47 | if (isset($configuration['ssl'])) { |
||
| 48 | (new Host()) |
||
| 49 | ->name($configuration['hostname']) |
||
| 50 | ->expose($configuration['expose']['ip'], $configuration['expose']['port']) |
||
| 51 | ->redirect('https://' . $configuration['hostname']) |
||
| 52 | ; |
||
| 53 | |||
| 54 | (new Host()) |
||
| 55 | ->name($configuration['hostname']) |
||
| 56 | ->expose($configuration['ssl']['ip'], $configuration['ssl']['port']) |
||
| 57 | ->encrypt($configuration['ssl']['certificate'], $configuration['ssl']['key']) |
||
| 58 | ->use($router) |
||
| 59 | ->use(root(__DIR__ . '/public')) |
||
| 60 | ; |
||
| 61 | |||
| 62 | return; |
||
| 63 | } |
||
| 64 | |||
| 65 | (new Host()) |
||
| 66 | ->name($configuration['hostname']) |
||
| 67 | ->expose($configuration['expose']['ip'], $configuration['expose']['port']) |
||
| 68 | ->use($router) |
||
| 69 | ->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...
|
|||
| 70 | ; |
||
| 71 |