|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace BEAR\Resource\SemanticLog\Profile\Verbose; |
|
6
|
|
|
|
|
7
|
|
|
use BEAR\Resource\ResourceObject; |
|
8
|
|
|
use BEAR\Resource\SemanticLog\Profile\PhpProfile; |
|
9
|
|
|
use BEAR\Resource\SemanticLog\Profile\Profile; |
|
10
|
|
|
use BEAR\Resource\SemanticLog\Profile\XdebugTrace; |
|
11
|
|
|
use BEAR\Resource\SemanticLog\Profile\XHProfResult; |
|
12
|
|
|
use BEAR\Resource\Types; |
|
13
|
|
|
use JsonSerializable; |
|
14
|
|
|
use Koriym\SemanticLogger\AbstractContext; |
|
15
|
|
|
use Override; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @psalm-import-type Headers from Types |
|
19
|
|
|
* @psalm-import-type HttpBody from Types |
|
20
|
|
|
*/ |
|
21
|
|
|
final class CompleteContext extends AbstractContext implements JsonSerializable |
|
22
|
|
|
{ |
|
23
|
|
|
/** @psalm-suppress InvalidClassConstantType */ |
|
24
|
|
|
public const TYPE = 'bear_resource_complete'; |
|
25
|
|
|
|
|
26
|
|
|
/** @psalm-suppress InvalidClassConstantType */ |
|
27
|
|
|
public const SCHEMA_URL = 'https://bearsunday.github.io/BEAR.Resource/schemas/complete-context.json'; |
|
28
|
|
|
|
|
29
|
|
|
public readonly string $uri; |
|
30
|
|
|
public readonly int $code; |
|
31
|
|
|
|
|
32
|
|
|
/** @var Headers */ |
|
|
|
|
|
|
33
|
|
|
public readonly array $headers; |
|
34
|
|
|
|
|
35
|
|
|
/** @var HttpBody */ |
|
|
|
|
|
|
36
|
|
|
public readonly mixed $body; |
|
37
|
|
|
public readonly string $view; |
|
38
|
|
|
public readonly Profile $profile; |
|
39
|
|
|
|
|
40
|
|
|
public function __construct(ResourceObject $resource, OpenContext $openContext) |
|
|
|
|
|
|
41
|
|
|
{ |
|
42
|
|
|
// Trigger rendering to get view |
|
43
|
|
|
$resourceString = (string) $resource; |
|
44
|
|
|
unset($resourceString); |
|
45
|
|
|
$this->uri = (string) $resource->uri; |
|
|
|
|
|
|
46
|
|
|
$this->code = $resource->code; |
|
|
|
|
|
|
47
|
|
|
$this->headers = $resource->headers; |
|
|
|
|
|
|
48
|
|
|
/** @psalm-suppress MixedAssignment */ |
|
49
|
|
|
/** @phpstan-ignore-next-line */ |
|
50
|
|
|
$this->body = $resource->body; |
|
|
|
|
|
|
51
|
|
|
/** @psalm-suppress PossiblyNullPropertyAssignmentValue */ |
|
52
|
|
|
$this->view = $resource->view ?? ''; |
|
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
// Stop profiling and capture final profile data |
|
55
|
|
|
// Note: start() was called in OpenContext, now we stop and capture data |
|
56
|
|
|
$xhprofResult = (new XHProfResult())->stop($this->uri); |
|
57
|
|
|
$xdebugTrace = (new XdebugTrace())->stop(); |
|
58
|
|
|
$phpProfile = PhpProfile::capture(); |
|
59
|
|
|
|
|
60
|
|
|
$this->profile = new Profile( |
|
|
|
|
|
|
61
|
|
|
xhprof: $xhprofResult, |
|
62
|
|
|
xdebug: $xdebugTrace, |
|
63
|
|
|
php: $phpProfile, |
|
64
|
|
|
); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public static function create(ResourceObject $resource, OpenContext $openContext): self |
|
68
|
|
|
{ |
|
69
|
|
|
return new self($resource, $openContext); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** @return array<string, mixed> */ |
|
73
|
|
|
#[Override] |
|
74
|
|
|
public function jsonSerialize(): array |
|
75
|
|
|
{ |
|
76
|
|
|
return [ |
|
77
|
|
|
'uri' => $this->uri, |
|
78
|
|
|
'code' => $this->code, |
|
79
|
|
|
'headers' => $this->headers, |
|
80
|
|
|
'body' => $this->body, |
|
81
|
|
|
'view' => $this->view, |
|
82
|
|
|
'profile' => $this->profile, |
|
83
|
|
|
]; |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
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