| 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\Types; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use JsonSerializable; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Koriym\SemanticLogger\AbstractContext; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Koriym\SemanticLogger\Profiler\PhpProfile; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Koriym\SemanticLogger\Profiler\Profile; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Koriym\SemanticLogger\Profiler\XdebugTrace; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Koriym\SemanticLogger\Profiler\XHProfResult; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 |  |  |         // OpenContext is used for profiling coordination but not stored | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         unset($openContext); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |     public static function create(ResourceObject $resource, OpenContext $openContext): self | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |         return new self($resource, $openContext); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     /** @return array<string, mixed> */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     #[Override] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     public function jsonSerialize(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |             'uri' => $this->uri, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |             'code' => $this->code, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |             'headers' => $this->headers, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             'body' => $this->body, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |             'view' => $this->view, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |             'profile' => $this->profile, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 88 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 89 |  |  |  | 
            
                        
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