Zval   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 11
c 1
b 0
f 1
dl 0
loc 24
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __get() 0 6 1
A __construct() 0 6 1
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\PhpInternals\Types\Zend;
15
16
use FFI\CData;
17
18
class Zval
19
{
20
    /** @psalm-suppress PropertyNotSetInConstructor */
21
    public ZendValue $value;
22
    /** @psalm-suppress PropertyNotSetInConstructor */
23
    public ZvalU1 $u1;
24
    /** @psalm-suppress PropertyNotSetInConstructor */
25
    public ZvalU2 $u2;
26
27
    /** @param \FFI\PhpInternals\zval $cdata */
28
    public function __construct(
29
        private CData $cdata
30
    ) {
31
        unset($this->value);
32
        unset($this->u1);
33
        unset($this->u2);
34
    }
35
36
    public function __get(string $field_name): mixed
37
    {
38
        return match ($field_name) {
39
            'value' => $this->value = new ZendValue($this->cdata->value),
40
            'u1' => $this->u1 = new ZvalU1($this->cdata->u1),
41
            'u2' => $this->u2 = new ZvalU2($this->cdata->u2),
42
        };
43
    }
44
}
45