You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: zend/callable.h
+22-3Lines changed: 22 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -53,13 +53,14 @@ class Callable
53
53
54
54
// initialize all elements to null
55
55
_argv[i].name = nullptr;
56
+
#if PHP_VERSION_ID < 80000
56
57
_argv[i].is_variadic = false;
57
58
_argv[i].pass_by_reference = false;
58
-
59
+
#endif
59
60
// initialize the extra argument prior to 7.2
60
61
#if PHP_VERSION_ID < 70200
61
62
_argv[i].class_name = nullptr;
62
-
#else
63
+
#elif PHP_VERSION_ID < 80000
63
64
_argv[i].type = 0;
64
65
#endif
65
66
}
@@ -198,6 +199,23 @@ class Callable
198
199
case Type::Object: info->type_hint = IS_OBJECT; break; // must be an object of the given classname
199
200
case Type::Callable: info->type_hint = IS_CALLABLE; break; // anything that can be invoked
200
201
default: info->type_hint = IS_UNDEF; break; // if not specified we allow anything
202
+
#elif PHP_VERSION_ID >= 80000
203
+
case Type::Undefined: info->type = (zend_type) ZEND_TYPE_INIT_CODE(IS_UNDEF, arg.allowNull(), 0); break; // undefined means we'll accept any type
204
+
case Type::Null: info->type = (zend_type) ZEND_TYPE_INIT_CODE(IS_UNDEF, arg.allowNull(), 0); break; // this is likely an error, what good would accepting NULL be? accept anything
205
+
case Type::False: info->type = (zend_type) ZEND_TYPE_INIT_CODE(_IS_BOOL, arg.allowNull(), 0); break; // accept true as well ;)
206
+
case Type::True: info->type = (zend_type) ZEND_TYPE_INIT_CODE(_IS_BOOL, arg.allowNull(), 0); break; // accept false as well
207
+
case Type::Bool: info->type = (zend_type) ZEND_TYPE_INIT_CODE(_IS_BOOL, arg.allowNull(), 0); break; // any bool will do, true, false, the options are limitless
208
+
case Type::Numeric: info->type = (zend_type) ZEND_TYPE_INIT_CODE(IS_LONG, arg.allowNull(), 0); break; // accept integers here
209
+
case Type::Float: info->type = (zend_type) ZEND_TYPE_INIT_CODE(IS_DOUBLE, arg.allowNull(), 0); break; // floating-point values welcome too
210
+
case Type::String: info->type = (zend_type) ZEND_TYPE_INIT_CODE(IS_STRING, arg.allowNull(), 0); break; // accept strings, should auto-cast objects with __toString as well
211
+
case Type::Array: info->type = (zend_type) ZEND_TYPE_INIT_CODE(IS_ARRAY, arg.allowNull(), 0); break; // array of anything (individual members cannot be restricted)
212
+
case Type::Object: // if there is a classname and the argument is not nullable, it's simply the classname
213
+
if (!arg.classname()) info->type = (zend_type) ZEND_TYPE_INIT_CODE(IS_OBJECT, arg.allowNull(), 0);
214
+
// else info->type = (zend_type)arg.encoded();
215
+
break;
216
+
case Type::Callable: info->type = (zend_type) ZEND_TYPE_INIT_CODE(IS_CALLABLE, arg.allowNull(), 0); break; // anything that can be invoke
217
+
218
+
default: info->type = ZEND_TYPE_INIT_CODE(IS_UNDEF, 0, 0); break; // if not specified we allow anything
201
219
#else
202
220
case Type::Undefined: info->type = ZEND_TYPE_ENCODE(IS_UNDEF, arg.allowNull()); break; // undefined means we'll accept any type
203
221
case Type::Null: info->type = ZEND_TYPE_ENCODE(IS_UNDEF, arg.allowNull()); break; // this is likely an error, what good would accepting NULL be? accept anything
@@ -216,7 +234,7 @@ class Callable
216
234
default: info->type = ZEND_TYPE_ENCODE(IS_UNDEF, arg.allowNull()); break; // if not specified we allow anything
217
235
#endif
218
236
}
219
-
237
+
#if PHP_VERSION_ID < 80000
220
238
// from PHP 5.6 and onwards, an is_variadic property can be set, this
221
239
// specifies whether this argument is the first argument that specifies
222
240
// the type for a variable length list of arguments. For now we only
@@ -225,6 +243,7 @@ class Callable
225
243
226
244
// whether or not to pass the argument by reference
0 commit comments