Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit cad9598

Browse files
committed
Rename HeapStatistics methods to match PSR-2, closes #38
1 parent b62b02f commit cad9598

File tree

3 files changed

+74
-45
lines changed

3 files changed

+74
-45
lines changed

src/php_v8_heap_statistics.cc

+27-27
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static PHP_METHOD(HeapStatistics, __construct) {
7070
zend_update_property_bool(this_ce, getThis(), ZEND_STRL("does_zap_garbage"), does_zap_garbage);
7171
}
7272

73-
static PHP_METHOD(HeapStatistics, total_heap_size) {
73+
static PHP_METHOD(HeapStatistics, getTotalHeapSize) {
7474
zval rv;
7575

7676
if (zend_parse_parameters_none() == FAILURE) {
@@ -80,7 +80,7 @@ static PHP_METHOD(HeapStatistics, total_heap_size) {
8080
RETVAL_ZVAL(zend_read_property(this_ce, getThis(), ZEND_STRL("total_heap_size"), 0, &rv), 1, 0);
8181
}
8282

83-
static PHP_METHOD(HeapStatistics, total_heap_size_executable) {
83+
static PHP_METHOD(HeapStatistics, getTotalHeapSizeExecutable) {
8484
zval rv;
8585

8686
if (zend_parse_parameters_none() == FAILURE) {
@@ -90,7 +90,7 @@ static PHP_METHOD(HeapStatistics, total_heap_size_executable) {
9090
RETVAL_ZVAL(zend_read_property(this_ce, getThis(), ZEND_STRL("total_heap_size_executable"), 0, &rv), 1, 0);
9191
}
9292

93-
static PHP_METHOD(HeapStatistics, total_physical_size) {
93+
static PHP_METHOD(HeapStatistics, getTotalPhysicalSize) {
9494
zval rv;
9595

9696
if (zend_parse_parameters_none() == FAILURE) {
@@ -100,7 +100,7 @@ static PHP_METHOD(HeapStatistics, total_physical_size) {
100100
RETVAL_ZVAL(zend_read_property(this_ce, getThis(), ZEND_STRL("total_physical_size"), 0, &rv), 1, 0);
101101
}
102102

103-
static PHP_METHOD(HeapStatistics, total_available_size) {
103+
static PHP_METHOD(HeapStatistics, getTotalAvailableSize) {
104104
zval rv;
105105

106106
if (zend_parse_parameters_none() == FAILURE) {
@@ -110,7 +110,7 @@ static PHP_METHOD(HeapStatistics, total_available_size) {
110110
RETVAL_ZVAL(zend_read_property(this_ce, getThis(), ZEND_STRL("total_available_size"), 0, &rv), 1, 0);
111111
}
112112

113-
static PHP_METHOD(HeapStatistics, used_heap_size) {
113+
static PHP_METHOD(HeapStatistics, getUsedHeapSize) {
114114
zval rv;
115115

116116
if (zend_parse_parameters_none() == FAILURE) {
@@ -120,7 +120,7 @@ static PHP_METHOD(HeapStatistics, used_heap_size) {
120120
RETVAL_ZVAL(zend_read_property(this_ce, getThis(), ZEND_STRL("used_heap_size"), 0, &rv), 1, 0);
121121
}
122122

123-
static PHP_METHOD(HeapStatistics, heap_size_limit) {
123+
static PHP_METHOD(HeapStatistics, getHeapSizeLimit) {
124124
zval rv;
125125

126126
if (zend_parse_parameters_none() == FAILURE) {
@@ -130,7 +130,7 @@ static PHP_METHOD(HeapStatistics, heap_size_limit) {
130130
RETVAL_ZVAL(zend_read_property(this_ce, getThis(), ZEND_STRL("heap_size_limit"), 0, &rv), 1, 0);
131131
}
132132

133-
static PHP_METHOD(HeapStatistics, malloced_memory) {
133+
static PHP_METHOD(HeapStatistics, getMallocedMemory) {
134134
zval rv;
135135

136136
if (zend_parse_parameters_none() == FAILURE) {
@@ -140,7 +140,7 @@ static PHP_METHOD(HeapStatistics, malloced_memory) {
140140
RETVAL_ZVAL(zend_read_property(this_ce, getThis(), ZEND_STRL("malloced_memory"), 0, &rv), 1, 0);
141141
}
142142

143-
static PHP_METHOD(HeapStatistics, peak_malloced_memory) {
143+
static PHP_METHOD(HeapStatistics, getPeakMallocedMemory) {
144144
zval rv;
145145

146146
if (zend_parse_parameters_none() == FAILURE) {
@@ -150,7 +150,7 @@ static PHP_METHOD(HeapStatistics, peak_malloced_memory) {
150150
RETVAL_ZVAL(zend_read_property(this_ce, getThis(), ZEND_STRL("peak_malloced_memory"), 0, &rv), 1, 0);
151151
}
152152

153-
static PHP_METHOD(HeapStatistics, does_zap_garbage) {
153+
static PHP_METHOD(HeapStatistics, doesZapGarbage) {
154154
zval rv;
155155

156156
if (zend_parse_parameters_none() == FAILURE) {
@@ -175,46 +175,46 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE,
175175
ZEND_ARG_TYPE_INFO(0, does_zap_garbage, _IS_BOOL, 0)
176176
ZEND_END_ARG_INFO()
177177

178-
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_total_heap_size, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
178+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getTotalHeapSize, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
179179
ZEND_END_ARG_INFO()
180180

181-
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_total_heap_size_executable, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
181+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getTotalHeapSizeExecutable, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
182182
ZEND_END_ARG_INFO()
183183

184-
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_total_physical_size, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
184+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getTotalPhysicalSize, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
185185
ZEND_END_ARG_INFO()
186186

187-
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_total_available_size, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
187+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getTotalAvailableSize, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
188188
ZEND_END_ARG_INFO()
189189

190-
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_used_heap_size, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
190+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getUsedHeapSize, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
191191
ZEND_END_ARG_INFO()
192192

193-
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_heap_size_limit, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
193+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getHeapSizeLimit, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
194194
ZEND_END_ARG_INFO()
195195

196-
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_malloced_memory, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
196+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getMallocedMemory, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
197197
ZEND_END_ARG_INFO()
198198

199-
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_peak_malloced_memory, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
199+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_getPeakMallocedMemory, ZEND_RETURN_VALUE, 0, IS_DOUBLE, 0)
200200
ZEND_END_ARG_INFO()
201201

202-
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_does_zap_garbage, ZEND_RETURN_VALUE, 0, _IS_BOOL, 0)
202+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_doesZapGarbage, ZEND_RETURN_VALUE, 0, _IS_BOOL, 0)
203203
ZEND_END_ARG_INFO()
204204

205205

206206
static const zend_function_entry php_v8_heap_statistics_methods[] = {
207207
PHP_V8_ME(HeapStatistics, __construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
208208

209-
PHP_V8_ME(HeapStatistics, total_heap_size, ZEND_ACC_PUBLIC)
210-
PHP_V8_ME(HeapStatistics, total_heap_size_executable, ZEND_ACC_PUBLIC)
211-
PHP_V8_ME(HeapStatistics, total_physical_size, ZEND_ACC_PUBLIC)
212-
PHP_V8_ME(HeapStatistics, total_available_size, ZEND_ACC_PUBLIC)
213-
PHP_V8_ME(HeapStatistics, used_heap_size, ZEND_ACC_PUBLIC)
214-
PHP_V8_ME(HeapStatistics, heap_size_limit, ZEND_ACC_PUBLIC)
215-
PHP_V8_ME(HeapStatistics, malloced_memory, ZEND_ACC_PUBLIC)
216-
PHP_V8_ME(HeapStatistics, peak_malloced_memory, ZEND_ACC_PUBLIC)
217-
PHP_V8_ME(HeapStatistics, does_zap_garbage, ZEND_ACC_PUBLIC)
209+
PHP_V8_ME(HeapStatistics, getTotalHeapSize, ZEND_ACC_PUBLIC)
210+
PHP_V8_ME(HeapStatistics, getTotalHeapSizeExecutable, ZEND_ACC_PUBLIC)
211+
PHP_V8_ME(HeapStatistics, getTotalPhysicalSize, ZEND_ACC_PUBLIC)
212+
PHP_V8_ME(HeapStatistics, getTotalAvailableSize, ZEND_ACC_PUBLIC)
213+
PHP_V8_ME(HeapStatistics, getUsedHeapSize, ZEND_ACC_PUBLIC)
214+
PHP_V8_ME(HeapStatistics, getHeapSizeLimit, ZEND_ACC_PUBLIC)
215+
PHP_V8_ME(HeapStatistics, getMallocedMemory, ZEND_ACC_PUBLIC)
216+
PHP_V8_ME(HeapStatistics, getPeakMallocedMemory, ZEND_ACC_PUBLIC)
217+
PHP_V8_ME(HeapStatistics, doesZapGarbage, ZEND_ACC_PUBLIC)
218218

219219
PHP_FE_END
220220
};

stubs/src/HeapStatistics.php

+38-9
Original file line numberDiff line numberDiff line change
@@ -93,47 +93,76 @@ public function __construct(
9393
$this->does_zap_garbage = $does_zap_garbage;
9494
}
9595

96-
public function total_heap_size(): float
96+
/**
97+
* @return float
98+
*/
99+
public function getTotalHeapSize(): float
97100
{
98101
return $this->total_heap_size;
99102
}
100103

101-
public function total_heap_size_executable(): float
104+
/**
105+
* @return float
106+
*/
107+
public function getTotalHeapSizeExecutable(): float
102108
{
103109
return $this->total_heap_size_executable;
104110
}
105111

106-
public function total_physical_size(): float
112+
/**
113+
* @return float
114+
*/
115+
public function getTotalPhysicalSize(): float
107116
{
108117
return $this->total_physical_size;
109118
}
110119

111-
public function total_available_size(): float
120+
/**
121+
* @return float
122+
*/
123+
public function getTotalAvailableSize(): float
112124
{
113125
return $this->total_available_size;
114126
}
115127

116-
public function used_heap_size(): float
128+
/**
129+
* @return float
130+
*/
131+
public function getUsedHeapSize(): float
117132
{
118133
return $this->used_heap_size;
119134
}
120135

121-
public function heap_size_limit(): float
136+
/**
137+
* @return float
138+
*/
139+
public function getHeapSizeLimit(): float
122140
{
123141
return $this->heap_size_limit;
124142
}
125143

126-
public function malloced_memory(): float
144+
/**
145+
* @return float
146+
*/
147+
public function getMallocedMemory(): float
127148
{
128149
return $this->malloced_memory;
129150
}
130151

131-
public function peak_malloced_memory(): float
152+
/**
153+
* @return float
154+
*/
155+
public function getPeakMallocedMemory(): float
132156
{
133157
return $this->peak_malloced_memory;
134158
}
135159

136-
public function does_zap_garbage(): bool
160+
/**
161+
* Returns a boolean, which signifies whether the V8 overwrite heap garbage with a bit pattern.
162+
*
163+
* @return bool
164+
*/
165+
public function doesZapGarbage(): bool
137166
{
138167
return $this->does_zap_garbage;
139168
}

tests/V8HeapStatistics.phpt

+9-9
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ object(V8\HeapStatistics)#2 (9) {
4141
bool(true)
4242
}
4343

44-
V8\HeapStatistics->total_heap_size(): float(1)
45-
V8\HeapStatistics->total_heap_size_executable(): float(2)
46-
V8\HeapStatistics->total_physical_size(): float(3)
47-
V8\HeapStatistics->total_available_size(): float(4)
48-
V8\HeapStatistics->used_heap_size(): float(5)
49-
V8\HeapStatistics->heap_size_limit(): float(6)
50-
V8\HeapStatistics->malloced_memory(): float(7)
51-
V8\HeapStatistics->peak_malloced_memory(): float(8)
52-
V8\HeapStatistics->does_zap_garbage(): bool(true)
44+
V8\HeapStatistics->getTotalHeapSize(): float(1)
45+
V8\HeapStatistics->getTotalHeapSizeExecutable(): float(2)
46+
V8\HeapStatistics->getTotalPhysicalSize(): float(3)
47+
V8\HeapStatistics->getTotalAvailableSize(): float(4)
48+
V8\HeapStatistics->getUsedHeapSize(): float(5)
49+
V8\HeapStatistics->getHeapSizeLimit(): float(6)
50+
V8\HeapStatistics->getMallocedMemory(): float(7)
51+
V8\HeapStatistics->getPeakMallocedMemory(): float(8)
52+
V8\HeapStatistics->doesZapGarbage(): bool(true)

0 commit comments

Comments
 (0)