MCPcopy Create free account
hub / github.com/deuill/go-php / value_array_keys

Function value_array_keys

engine/value.c:235–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235engine_value *value_array_keys(engine_value *arr) {
236 HashTable *h = NULL;
237 engine_value *keys = value_new();
238
239 value_set_array(keys, value_array_size(arr));
240
241 switch (arr->kind) {
242 case KIND_ARRAY:
243 case KIND_MAP:
244 case KIND_OBJECT:
245 if (arr->kind == KIND_OBJECT) {
246 h = Z_OBJPROP_P(arr->internal);
247 } else {
248 h = Z_ARRVAL_P(arr->internal);
249 }
250
251 unsigned long i = 0;
252
253 for (zend_hash_internal_pointer_reset(h); i < h->nNumOfElements; i++) {
254 HASH_SET_CURRENT_KEY(h, keys->internal);
255 zend_hash_move_forward(h);
256 }
257
258 break;
259 case KIND_NULL:
260 // Null values are considered empty.
261 break;
262 default:
263 // Non-array or object values are considered to contain a single key, '0'.
264 add_next_index_long(keys->internal, 0);
265 }
266
267 return keys;
268}
269
270void value_array_reset(engine_value *arr) {
271 HashTable *h = NULL;

Callers

nothing calls this directly

Calls 3

value_newFunction · 0.85
value_set_arrayFunction · 0.85
value_array_sizeFunction · 0.85

Tested by

no test coverage detected