|
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_module_entry; |
|
17
|
|
|
use PhpProfiler\Lib\FFI\Cast; |
|
18
|
|
|
use PhpProfiler\Lib\PhpInternals\CastedCData; |
|
19
|
|
|
use PhpProfiler\Lib\PhpInternals\Types\C\RawString; |
|
20
|
|
|
use PhpProfiler\Lib\Process\Pointer\Dereferencable; |
|
21
|
|
|
use PhpProfiler\Lib\Process\Pointer\Dereferencer; |
|
22
|
|
|
use PhpProfiler\Lib\Process\Pointer\Pointer; |
|
23
|
|
|
|
|
24
|
|
|
final class ZendModuleEntry implements Dereferencable |
|
25
|
|
|
{ |
|
26
|
|
|
/** @psalm-suppress PropertyNotSetInConstructor */ |
|
27
|
|
|
public bool $zts; |
|
28
|
|
|
/** |
|
29
|
|
|
* @psalm-suppress PropertyNotSetInConstructor |
|
30
|
|
|
* @var Pointer<RawString> |
|
31
|
|
|
*/ |
|
32
|
|
|
public Pointer $version; |
|
33
|
|
|
|
|
34
|
|
|
/** @param CastedCData<zend_module_entry> $casted_cdata */ |
|
35
|
|
|
public function __construct( |
|
36
|
|
|
private CastedCData $casted_cdata, |
|
37
|
|
|
) { |
|
38
|
|
|
unset($this->zts); |
|
39
|
|
|
unset($this->version); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function __get(string $field_name): mixed |
|
43
|
|
|
{ |
|
44
|
|
|
return match ($field_name) { |
|
45
|
|
|
'zts' => $this->zts = (bool)$this->casted_cdata->casted->zts, |
|
46
|
|
|
'version' => $this->version = new Pointer( |
|
47
|
|
|
RawString::class, |
|
48
|
|
|
Cast::castPointerToInt($this->casted_cdata->casted->version), |
|
49
|
|
|
3, |
|
50
|
|
|
), |
|
51
|
|
|
}; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function getVersion(Dereferencer $dereferencer): string |
|
55
|
|
|
{ |
|
56
|
|
|
return (string)$dereferencer->deref($this->version); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public static function getCTypeName(): string |
|
60
|
|
|
{ |
|
61
|
|
|
return 'zend_module_entry'; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public static function fromCastedCData( |
|
65
|
|
|
CastedCData $casted_cdata, |
|
66
|
|
|
Pointer $pointer |
|
67
|
|
|
): static { |
|
68
|
|
|
/** @var CastedCData<zend_module_entry> $casted_cdata */ |
|
69
|
|
|
return new self($casted_cdata); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|