|
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\PhpInternals\zend_op; |
|
17
|
|
|
use PhpProfiler\Lib\PhpInternals\CastedCData; |
|
18
|
|
|
use PhpProfiler\Lib\Process\Pointer\Dereferencable; |
|
19
|
|
|
use PhpProfiler\Lib\Process\Pointer\Pointer; |
|
20
|
|
|
|
|
21
|
|
|
final class ZendOp implements Dereferencable |
|
22
|
|
|
{ |
|
23
|
|
|
/** @psalm-suppress PropertyNotSetInConstructor */ |
|
24
|
|
|
public int $op1; |
|
25
|
|
|
/** @psalm-suppress PropertyNotSetInConstructor */ |
|
26
|
|
|
public int $op2; |
|
27
|
|
|
/** @psalm-suppress PropertyNotSetInConstructor */ |
|
28
|
|
|
public int $result; |
|
29
|
|
|
/** @psalm-suppress PropertyNotSetInConstructor */ |
|
30
|
|
|
public int $op1_type; |
|
31
|
|
|
/** @psalm-suppress PropertyNotSetInConstructor */ |
|
32
|
|
|
public int $op2_type; |
|
33
|
|
|
/** @psalm-suppress PropertyNotSetInConstructor */ |
|
34
|
|
|
public int $result_type; |
|
35
|
|
|
/** @psalm-suppress PropertyNotSetInConstructor */ |
|
36
|
|
|
public int $lineno; |
|
37
|
|
|
/** @psalm-suppress PropertyNotSetInConstructor */ |
|
38
|
|
|
public int $opcode; |
|
39
|
|
|
/** @psalm-suppress PropertyNotSetInConstructor */ |
|
40
|
|
|
public int $extended_value; |
|
41
|
|
|
|
|
42
|
|
|
/** @param CastedCData<zend_op> $casted_cdata */ |
|
43
|
|
|
public function __construct( |
|
44
|
|
|
private CastedCData $casted_cdata, |
|
45
|
|
|
) { |
|
46
|
|
|
unset($this->op1); |
|
47
|
|
|
unset($this->op2); |
|
48
|
|
|
unset($this->result); |
|
49
|
|
|
unset($this->op1_type); |
|
50
|
|
|
unset($this->op2_type); |
|
51
|
|
|
unset($this->result_type); |
|
52
|
|
|
unset($this->lineno); |
|
53
|
|
|
unset($this->opcode); |
|
54
|
|
|
unset($this->extended_value); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
public function __get(string $field_name) |
|
59
|
|
|
{ |
|
60
|
|
|
return match ($field_name) { |
|
61
|
|
|
'op1' => $this->op1 = (int)(\FFI::cast('int', $this->casted_cdata->casted->op1)?->cdata ?? -1), |
|
62
|
|
|
'op2' => $this->op2 = (int)(\FFI::cast('int', $this->casted_cdata->casted->op2)?->cdata ?? -1), |
|
63
|
|
|
'result' => $this->result = (int)(\FFI::cast('int', $this->casted_cdata->casted->result)?->cdata ?? -1), |
|
64
|
|
|
'op1_type' => $this->op1_type = $this->casted_cdata->casted->op1_type, |
|
65
|
|
|
'op2_type' => $this->op2_type = $this->casted_cdata->casted->op2_type, |
|
66
|
|
|
'result_type' => $this->result_type = $this->casted_cdata->casted->result_type, |
|
67
|
|
|
'lineno' => $this->lineno = $this->casted_cdata->casted->lineno, |
|
68
|
|
|
'opcode' => $this->opcode = $this->casted_cdata->casted->opcode, |
|
69
|
|
|
'extended_value' => $this->extended_value = $this->casted_cdata->casted->extended_value, |
|
70
|
|
|
}; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public static function getCTypeName(): string |
|
74
|
|
|
{ |
|
75
|
|
|
return 'zend_op'; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public static function fromCastedCData( |
|
79
|
|
|
CastedCData $casted_cdata, |
|
80
|
|
|
Pointer $pointer |
|
81
|
|
|
): static { |
|
82
|
|
|
/** @var CastedCData<zend_op> $casted_cdata */ |
|
83
|
|
|
return new self($casted_cdata); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|