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

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -611,11 +611,18 @@ static PHP_METHOD(V8Object, SetNativeDataProperty) {
611611

612612
static PHP_METHOD(V8Object, GetPropertyNames) {
613613
zval *context_zv;
614+
zend_long mode = static_cast<zend_long>(v8::KeyCollectionMode::kOwnOnly);
615+
zend_long property_filter = static_cast<zend_long>(v8::PropertyFilter::ALL_PROPERTIES);
616+
zend_long index_filter = static_cast<zend_long>(v8::IndexFilter::kIncludeIndices);
614617

615-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &context_zv) == FAILURE) {
618+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o|lll", &context_zv, &mode, &property_filter, &index_filter) == FAILURE) {
616619
return;
617620
}
618621

622+
mode = mode ? mode & PHP_V8_KEY_COLLECTION_MODE_FLAGS : mode;
623+
property_filter = property_filter ? property_filter & PHP_V8_PROPERTY_FILTER_FLAGS : property_filter;
624+
index_filter = index_filter ? index_filter & PHP_V8_INDEX_FILTER_FLAGS : index_filter;
625+
619626
PHP_V8_VALUE_FETCH_WITH_CHECK(getThis(), php_v8_value);
620627
PHP_V8_CONTEXT_FETCH_WITH_CHECK(context_zv, php_v8_context);
621628

@@ -629,7 +636,10 @@ static PHP_METHOD(V8Object, GetPropertyNames) {
629636
PHP_V8_TRY_CATCH(isolate);
630637
PHP_V8_INIT_ISOLATE_LIMITS_ON_OBJECT_VALUE(php_v8_value);
631638

632-
v8::MaybeLocal<v8::Array> maybe_local_array = local_object->GetPropertyNames(context);
639+
v8::MaybeLocal<v8::Array> maybe_local_array = local_object->GetPropertyNames(context,
640+
static_cast<v8::KeyCollectionMode>(mode),
641+
static_cast<v8::PropertyFilter >(property_filter),
642+
static_cast<v8::IndexFilter>(index_filter));
633643

634644
PHP_V8_MAYBE_CATCH(php_v8_context, try_catch);
635645
PHP_V8_THROW_EXCEPTION_WHEN_EMPTY(maybe_local_array, "Failed to get property names")
@@ -641,10 +651,12 @@ static PHP_METHOD(V8Object, GetPropertyNames) {
641651

642652
static PHP_METHOD(V8Object, GetOwnPropertyNames) {
643653
zval *context_zv;
654+
zend_long filter = static_cast<zend_long>(v8::PropertyFilter::ALL_PROPERTIES);
644655

645-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &context_zv) == FAILURE) {
656+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o|l", &context_zv, &filter) == FAILURE) {
646657
return;
647658
}
659+
filter = filter ? filter & PHP_V8_PROPERTY_FILTER_FLAGS : filter;
648660

649661
PHP_V8_VALUE_FETCH_WITH_CHECK(getThis(), php_v8_value);
650662
PHP_V8_CONTEXT_FETCH_WITH_CHECK(context_zv, php_v8_context);
@@ -659,7 +671,7 @@ static PHP_METHOD(V8Object, GetOwnPropertyNames) {
659671
PHP_V8_TRY_CATCH(isolate);
660672
PHP_V8_INIT_ISOLATE_LIMITS_ON_OBJECT_VALUE(php_v8_value);
661673

662-
v8::MaybeLocal<v8::Array> maybe_local_array = local_object->GetOwnPropertyNames(context);
674+
v8::MaybeLocal<v8::Array> maybe_local_array = local_object->GetOwnPropertyNames(context, static_cast<v8::PropertyFilter >(filter));
663675

664676
PHP_V8_MAYBE_CATCH(php_v8_context, try_catch);
665677
PHP_V8_THROW_EXCEPTION_WHEN_EMPTY(maybe_local_array, "Failed to get own property names")
@@ -1357,10 +1369,14 @@ ZEND_END_ARG_INFO()
13571369

13581370
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_php_v8_object_GetPropertyNames, ZEND_RETURN_VALUE, 1, V8\\ArrayObject, 0)
13591371
ZEND_ARG_OBJ_INFO(0, context, V8\\Context, 0)
1372+
ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0)
1373+
ZEND_ARG_TYPE_INFO(0, property_filter, IS_LONG, 0)
1374+
ZEND_ARG_TYPE_INFO(0, index_filter, IS_LONG, 0)
13601375
ZEND_END_ARG_INFO()
13611376

13621377
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_php_v8_object_GetOwnPropertyNames, ZEND_RETURN_VALUE, 1, V8\\ArrayObject, 0)
13631378
ZEND_ARG_OBJ_INFO(0, context, V8\\Context, 0)
1379+
ZEND_ARG_TYPE_INFO(0, filter, IS_LONG, 0)
13641380
ZEND_END_ARG_INFO()
13651381

13661382
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_php_v8_object_Get, ZEND_RETURN_VALUE, 0, V8\\Value, 0)
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717

1818
class IndexFilter
1919
{
20-
const kIncludesIndices = 0; // allows for integer indices to be collected, while
20+
const kIncludeIndices = 0; // allows for integer indices to be collected, while
2121
const kSkipIndices = 1; // will exclude integer indicies from being collected.
2222
}
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,18 @@ public function SetNativeDataProperty(
202202
* be enumerated by a for-in statement over this object.
203203
*
204204
* @param Context $context
205+
* @param int $mode One of KeyCollectionMode options
206+
* @param int $property_filter One or multiple PropertyFilter options
207+
* @param int $index_filter One or multiple IndexFilter options
205208
*
206-
*
207-
* @return \V8\ArrayObject
209+
* @return ArrayObject
208210
*/
209-
public function GetPropertyNames(Context $context): ArrayObject
210-
{
211+
public function GetPropertyNames(
212+
Context $context,
213+
int $mode = KeyCollectionMode::kOwnOnly,
214+
int $property_filter = PropertyFilter::ALL_PROPERTIES,
215+
int $index_filter = IndexFilter::kIncludeIndices
216+
): ArrayObject {
211217
}
212218

213219
/**
@@ -216,11 +222,11 @@ public function GetPropertyNames(Context $context): ArrayObject
216222
* objects.
217223
*
218224
* @param Context $context
225+
* @param int $filter One or multiple PropertyFilter options
219226
*
220-
*
221-
* @return \V8\ArrayObject
227+
* @return ArrayObject
222228
*/
223-
public function GetOwnPropertyNames(Context $context): ArrayObject
229+
public function GetOwnPropertyNames(Context $context, int $filter = PropertyFilter::ALL_PROPERTIES): ArrayObject
224230
{
225231
}
226232

0 commit comments

Comments
 (0)