1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Antidot\React; |
6
|
|
|
|
7
|
|
|
use Antidot\Application\Http\RouteFactory; |
8
|
|
|
use Antidot\Application\Http\Router; |
9
|
|
|
use Antidot\Application\Http\WebServerApplication; |
|
|
|
|
10
|
|
|
use Antidot\Container\MiddlewareFactory; |
11
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
12
|
|
|
use React\EventLoop\LoopInterface; |
13
|
|
|
use React\Promise\Promise; |
14
|
|
|
use React\Promise\PromiseInterface; |
15
|
|
|
use Recoil\React\ReactKernel; |
16
|
|
|
use Throwable; |
17
|
|
|
use Zend\HttpHandlerRunner\RequestHandlerRunner; |
18
|
|
|
use function React\Promise\resolve; |
19
|
|
|
|
20
|
|
|
class ReactPHPApplication extends WebServerApplication |
21
|
|
|
{ |
22
|
|
|
private $kernel; |
23
|
|
|
|
24
|
|
|
public function __construct( |
25
|
|
|
RequestHandlerRunner $runner, |
26
|
|
|
Resettable $pipeline, |
27
|
|
|
Router $router, |
28
|
|
|
MiddlewareFactory $middlewareFactory, |
29
|
|
|
RouteFactory $routeFactory, |
30
|
|
|
LoopInterface $loop |
31
|
|
|
) { |
32
|
|
|
parent::__construct($runner, $pipeline, $router, $middlewareFactory, $routeFactory); |
33
|
|
|
$this->kernel = ReactKernel::create($loop); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function __invoke(ServerRequestInterface $request): PromiseInterface |
37
|
|
|
{ |
38
|
|
|
return new Promise(function ($resolve, $reject) use ($request) { |
39
|
|
|
$this->kernel->execute(function () use ($resolve, $reject, $request) { |
40
|
|
|
try { |
41
|
|
|
$response = $this->pipeline->handle($request); |
42
|
|
|
$this->pipeline->reset(); |
43
|
|
|
$response = resolve($response); |
44
|
|
|
$response = (yield $response); |
45
|
|
|
$resolve($response); |
46
|
|
|
} catch (Throwable $throwable) { |
47
|
|
|
$this->pipeline->reset(); |
48
|
|
|
$reject($throwable); |
49
|
|
|
} |
50
|
|
|
}); |
51
|
|
|
}); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths