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