@@ -70,37 +70,50 @@ void Callable::initialize(zend_function_entry *entry, const char *classname, int
7070 entry->flags = flags;
7171
7272 // we should fill the first argument as well
73- #if PHP_VERSION_ID >= 50400
74- initialize ((zend_internal_function_info *)entry->arg_info , classname);
75- #endif
73+ initialize ((zend_arg_info *)entry->arg_info , classname);
7674}
7775
7876/* *
7977 * Fill a function entry
8078 * @param info Info to be filled
8179 * @param classname Optional classname
8280 */
83- #if PHP_VERSION_ID >= 50400
84- void Callable::initialize (zend_internal_function_info *info, const char *classname) const
81+ void Callable::initialize (zend_arg_info *info, const char *classname) const
8582{
83+ #if PHP_VERSION_ID >= 50400
84+ // up until php 5.3, the first info object is filled with alternative information,
85+ // later it is casted to a zend_internal_function object
86+ auto *finfo = (zend_internal_function_info *)info;
87+
8688 // fill in all the members, note that return reference is false by default,
8789 // because we do not support returning references in PHP-CPP, although Zend
8890 // engine allows it. Inside the name we hide a pointer to the current object
89- info ->_name = _ptr;
90- info ->_name_len = strlen (_ptr);
91- info ->_class_name = classname;
91+ finfo ->_name = _ptr;
92+ finfo ->_name_len = strlen (_ptr);
93+ finfo ->_class_name = classname;
9294
9395 // number of required arguments, and the expected return type
94- info ->required_num_args = _required;
95- info ->_type_hint = (unsigned char )_return;
96+ finfo ->required_num_args = _required;
97+ finfo ->_type_hint = (unsigned char )_return;
9698
9799 // we do not support return-by-reference
98- info ->return_reference = false ;
100+ finfo ->return_reference = false ;
99101
100102 // passing by reference is not used
101- info->pass_rest_by_reference = false ;
102- }
103+ finfo->pass_rest_by_reference = false ;
104+ #else
105+ // php 5.3 code
106+ info->name = nullptr ;
107+ info->name_len = 0 ;
108+ info->class_name = nullptr ;
109+ info->class_name_len = 0 ;
110+ info->array_type_hint = false ;
111+ info->allow_null = false ;
112+ info->pass_by_reference = false ;
113+ info->return_reference = false ;
114+ info->required_num_args = _required;
103115#endif
116+ }
104117
105118/* *
106119 * End of namespace
0 commit comments