@@ -45,28 +45,25 @@ class ArrayMapArgVisitor
4545 if (functionName == NULL ) return !EG (exception);
4646 if (!visitors::lowerEquals (functionName, " array_map" )) return true ;
4747
48- /* the callback argument - the positional first one or the one named
49- * "callback" - and every other argument */
50- zend_object *callbackArg = NULL ;
48+ /* every argument except the positional first one and the one named
49+ * "callback" */
5150 zv::Arr arrayArgs = zv::Arr::create (zend_hash_num_elements (Z_ARRVAL_P (args)));
5251 for (auto entry : zv::ArrRef (args)) {
5352 zv::Ref arg = entry.value ().deref ();
5453 if (!arg.isObject ()) continue ;
5554 zval *argName = argNameProp.of (arg.asObject ());
56- bool isCallback;
57- if (argName != NULL && Z_TYPE_P (argName) == IS_OBJECT ) {
55+ bool named = argName != NULL && Z_TYPE_P (argName) == IS_OBJECT ;
56+ bool firstPosition = entry.stringKeyOrNull () == NULL && entry.indexKey () == 0 ;
57+ if (!named && firstPosition) continue ;
58+ if (named) {
5859 zend_string *name = visitors::nameString (Z_OBJ_P (argName), identifierProp);
59- isCallback = name != NULL && zend_string_equals_literal (name, " callback" );
60- } else {
61- isCallback = entry.stringKeyOrNull () == NULL && entry.indexKey () == 0 ;
62- }
63- if (isCallback) {
64- callbackArg = arg.asObject ();
65- continue ;
60+ if (name != NULL && zend_string_equals_literal (name, " callback" )) continue ;
6661 }
6762 arrayArgs.push (arg);
6863 }
6964
65+ /* ArgumentsNormalizer::getArgByPositionOrName($args, 0, 'callback') */
66+ zend_object *callbackArg = visitors::argForParameter (args, 0 , " callback" );
7067 if (callbackArg == NULL || zend_hash_num_elements (arrayArgs.table ()) == 0 ) return true ;
7168 zval *value = argValueProp.of (callbackArg);
7269 if (value == NULL || Z_TYPE_P (value) != IS_OBJECT ) return true ;
0 commit comments