Passed
Push — renovate/php-8.x ( bfb893...222c0a )
by
unknown
02:20
created

RemoteProcessDereferencer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 5
rs 10
1
<?php
2
3
/**
4
 * This file is part of the sj-i/php-profiler package.
5
 *
6
 * (c) sji <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace PhpProfiler\Lib\Process\Pointer;
15
16
use PhpProfiler\Lib\FFI\CastedTypeProvider;
17
use PhpProfiler\Lib\Process\MemoryReader\MemoryReaderInterface;
18
use PhpProfiler\Lib\Process\ProcessSpecifier;
19
20
class RemoteProcessDereferencer implements Dereferencer
21
{
22
    public function __construct(
23
        private MemoryReaderInterface $memory_reader,
24
        private ProcessSpecifier $process_specifier,
25
        private CastedTypeProvider $ctype_provider,
26
    ) {
27
    }
28
29
    /**
30
     * @template T of Dereferencable
31
     * @param Pointer<T> $pointer
32
     * @return T
0 ignored issues
show
Bug introduced by
The type PhpProfiler\Lib\Process\Pointer\T 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...
33
     */
34
    public function deref(Pointer $pointer): mixed
35
    {
36
        $buffer = $this->memory_reader->read(
37
            $this->process_specifier->pid,
38
            $pointer->address,
39
            $pointer->size
40
        );
41
        $casted_cdata = $this->ctype_provider->readAs(
42
            $pointer->getCTypeName(),
43
            $buffer
44
        );
45
46
        return $pointer->fromCastedCData($casted_cdata, $pointer);
47
    }
48
}
49