Issues (35)

src/Handlers/TracedOutgoing.php (3 issues)

Labels
Severity
1
<?php
2
/**
3
 * HTTP response outgoing (server returned)
4
 * User: moyo
5
 * Date: 23/11/2017
6
 * Time: 12:20 PM
7
 */
8
9
namespace Carno\HRPC\Handlers;
10
11
use Carno\Chain\Layered;
12
use Carno\Coroutine\Context;
13
use Carno\HRPC\Client\Chips\ErrorsClassify;
14
use Carno\HTTP\Standard\Response;
15
use Carno\Tracing\Contracts\Vars\TAG;
0 ignored issues
show
The type Carno\Tracing\Contracts\Vars\TAG 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...
16
use Carno\Tracing\Utils\SpansCreator;
0 ignored issues
show
The type Carno\Tracing\Utils\SpansCreator 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...
17
use Carno\Tracing\Utils\SpansExporter;
0 ignored issues
show
The type Carno\Tracing\Utils\SpansExporter 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...
18
use Throwable;
19
20
class TracedOutgoing implements Layered
21
{
22
    use SpansCreator;
23
    use SpansExporter;
24
    use ErrorsClassify;
25
26
    /**
27
     * @param mixed $message
28
     * @param Context $ctx
29
     * @return mixed
30
     */
31
    public function inbound($message, Context $ctx)
32
    {
33
        return $message;
34
    }
35
36
    /**
37
     * @param Response $response
38
     * @param Context $ctx
39
     * @return Response
40
     */
41
    public function outbound($response, Context $ctx) : Response
42
    {
43
        /**
44
         * @var Response $http
45
         */
46
        $http = $ctx->get(ServerWrapper::RESPONDING);
47
48
        $this->closeSpan($ctx, [TAG::HTTP_STATUS_CODE => $http->getStatusCode()]);
49
50
        $this->spanToHResponse($ctx, $http);
51
52
        return $response;
53
    }
54
55
    /**
56
     * @param Throwable $e
57
     * @param Context $ctx
58
     * @throws Throwable
59
     */
60
    public function exception(Throwable $e, Context $ctx) : void
61
    {
62
        /**
63
         * @var Response $http
64
         */
65
66
        if ($http = $ctx->get(ServerWrapper::RESPONDING)) {
67
            $code = $http->getStatusCode();
68
            $this->spanToHResponse($ctx, $http);
69
        }
70
71
        $this->isGenericException($e)
72
            ? $this->closeSpan($ctx, [TAG::HTTP_STATUS_CODE => $code ?? 200])
73
            : $this->errorSpan($ctx, $e)
74
        ;
75
76
        throw $e;
77
    }
78
}
79