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
+43-2Lines changed: 43 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -52,8 +52,12 @@ class Callable
52
52
}
53
53
54
54
// initialize the extra argument
55
+
#if PHP_VERSION_ID < 70200
55
56
_argv[i].class_name = nullptr;
56
57
_argv[i].name = nullptr;
58
+
#else
59
+
_argv[i].type = 0;
60
+
#endif
57
61
}
58
62
59
63
/**
@@ -167,13 +171,18 @@ class Callable
167
171
// fill members
168
172
info->name = arg.name();
169
173
174
+
#if PHP_VERSION_ID < 70200
170
175
// are we filling an object
171
176
if (arg.type() == Type::Object) info->class_name = arg.classname();
172
177
else info->class_name = nullptr;
173
178
179
+
info->allow_null = arg.allowNull();
180
+
#endif
181
+
174
182
// set the correct type-hint
175
183
switch (arg.type())
176
184
{
185
+
#if PHP_VERSION_ID < 70200
177
186
case Type::Undefined: info->type_hint = IS_UNDEF; break; // undefined means we'll accept any type
178
187
case Type::Null: info->type_hint = IS_UNDEF; break; // this is likely an error, what good would accepting NULL be? accept anything
179
188
case Type::False: info->type_hint = _IS_BOOL; break; // accept true as well ;)
@@ -186,7 +195,41 @@ class Callable
186
195
case Type::Object: info->type_hint = IS_OBJECT; break; // must be an object of the given classname
187
196
case Type::Callable: info->type_hint = IS_CALLABLE; break; // anything that can be invoked
188
197
default: info->type_hint = IS_UNDEF; break; // if not specified we allow anything
198
+
#else
199
+
case Type::Undefined: info->type = ZEND_TYPE_ENCODE(IS_UNDEF, arg.allowNull()); break; // undefined means we'll accept any type
200
+
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
201
+
case Type::False: info->type = ZEND_TYPE_ENCODE(_IS_BOOL, arg.allowNull()); break; // accept true as well ;)
202
+
case Type::True: info->type = ZEND_TYPE_ENCODE(_IS_BOOL, arg.allowNull()); break; // accept false as well
203
+
case Type::Bool: info->type = ZEND_TYPE_ENCODE(_IS_BOOL, arg.allowNull()); break; // any bool will do, true, false, the options are limitless
204
+
case Type::Numeric: info->type = ZEND_TYPE_ENCODE(IS_LONG, arg.allowNull()); break; // accept integers here
205
+
case Type::Float: info->type = ZEND_TYPE_ENCODE(IS_DOUBLE, arg.allowNull()); break; // floating-point values welcome too
206
+
case Type::String: info->type = ZEND_TYPE_ENCODE(IS_STRING, arg.allowNull()); break; // accept strings, should auto-cast objects with __toString as well
207
+
case Type::Array: info->type = ZEND_TYPE_ENCODE(IS_ARRAY, arg.allowNull()); break; // array of anything (individual members cannot be restricted)
208
+
case Type::Object: // must be an object of the given classname
0 commit comments