Advertisement
Guest User

Untitled

a guest
May 24th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.73 KB | None | 0 0
  1. Index: Zend/zend.h
  2. ===================================================================
  3. --- Zend/zend.h (revision 323850)
  4. +++ Zend/zend.h (working copy)
  5. @@ -486,6 +486,10 @@
  6. union _zend_function *__call;
  7. union _zend_function *__callstatic;
  8. union _zend_function *__tostring;
  9. + union _zend_function *__toint;
  10. + union _zend_function *__tofloat;
  11. + union _zend_function *__toarray;
  12. + union _zend_function *__toscalar;
  13. union _zend_function *serialize_func;
  14. union _zend_function *unserialize_func;
  15.  
  16. Index: Zend/zend_object_handlers.c
  17. ===================================================================
  18. --- Zend/zend_object_handlers.c (revision 323850)
  19. +++ Zend/zend_object_handlers.c (working copy)
  20. @@ -1482,6 +1482,49 @@
  21. }
  22. /* }}} */
  23.  
  24. +ZEND_API int zend_std_cast_object(zval *readobj, zval *writeobj, int type TSRMLS_DC) /* {{{ */
  25. +{
  26. + zend_class_entry *ce = Z_OBJCE_P(readobj);
  27. + zval *retval = NULL;
  28. + switch (type) {
  29. + case IS_LONG:
  30. + if (ce->__toint) {
  31. + zend_call_method_with_0_params(&readobj, ce, &ce->__toint, "__toint", &retval);
  32. + }
  33. + break;
  34. + case IS_DOUBLE:
  35. + if (ce->__tofloat) {
  36. + zend_call_method_with_0_params(&readobj, ce, &ce->__tofloat, "__tofloat", &retval);
  37. + }
  38. + break;
  39. + case IS_ARRAY:
  40. + if (ce->__toarray) {
  41. + zend_call_method_with_0_params(&readobj, ce, &ce->__toarray, "__toarray", &retval);
  42. + }
  43. + break;
  44. + }
  45. + if (retval) {
  46. + ZVAL_ZVAL(writeobj, retval, 1, 1);
  47. + return SUCCESS;
  48. + }
  49. + return zend_std_cast_object_tostring(readobj, writeobj, type TSRMLS_CC);
  50. +
  51. +}
  52. +/* }}} */
  53. +
  54. +ZEND_API zval *zend_std_cast_object_get(zval *readobj TSRMLS_DC) /* {{{ */
  55. +{
  56. + zval *retval;
  57. + zend_class_entry *ce = Z_OBJCE_P(readobj);
  58. + ALLOC_INIT_ZVAL(retval);
  59. + if (ce->__toscalar && zend_call_method_with_0_params(&readobj, ce, &ce->__toscalar, "__toscalar", &retval)) {
  60. + return retval;
  61. + }
  62. + ZVAL_NULL(retval);
  63. + return retval;
  64. +}
  65. +/* }}} */
  66. +
  67. ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type TSRMLS_DC) /* {{{ */
  68. {
  69. zval *retval;
  70. @@ -1589,7 +1632,7 @@
  71. zend_std_read_dimension, /* read_dimension */
  72. zend_std_write_dimension, /* write_dimension */
  73. zend_std_get_property_ptr_ptr, /* get_property_ptr_ptr */
  74. - NULL, /* get */
  75. + zend_std_cast_object_get, /* get */
  76. NULL, /* set */
  77. zend_std_has_property, /* has_property */
  78. zend_std_unset_property, /* unset_property */
  79. @@ -1602,7 +1645,7 @@
  80. zend_std_object_get_class, /* get_class_entry */
  81. zend_std_object_get_class_name, /* get_class_name */
  82. zend_std_compare_objects, /* compare_objects */
  83. - zend_std_cast_object_tostring, /* cast_object */
  84. + zend_std_cast_object, /* cast_object */
  85. NULL, /* count_elements */
  86. NULL, /* get_debug_info */
  87. zend_std_get_closure, /* get_closure */
  88. Index: Zend/zend_compile.c
  89. ===================================================================
  90. --- Zend/zend_compile.c (revision 323850)
  91. +++ Zend/zend_compile.c (working copy)
  92. @@ -1617,6 +1617,22 @@
  93. if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
  94. zend_error(E_WARNING, "The magic method __toString() must have public visibility and cannot be static");
  95. }
  96. + } else if ((name_len == sizeof(ZEND_TOINT_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_TOINT_FUNC_NAME, sizeof(ZEND_TOINT_FUNC_NAME)-1))) {
  97. + if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
  98. + zend_error(E_WARNING, "The magic method __toInt() must have public visibility and cannot be static");
  99. + }
  100. + } else if ((name_len == sizeof(ZEND_TOFLOAT_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_TOFLOAT_FUNC_NAME, sizeof(ZEND_TOFLOAT_FUNC_NAME)-1))) {
  101. + if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
  102. + zend_error(E_WARNING, "The magic method __toFloat() must have public visibility and cannot be static");
  103. + }
  104. + } else if ((name_len == sizeof(ZEND_TOARRAY_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_TOARRAY_FUNC_NAME, sizeof(ZEND_TOARRAY_FUNC_NAME)-1))) {
  105. + if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
  106. + zend_error(E_WARNING, "The magic method __toArray() must have public visibility and cannot be static");
  107. + }
  108. + } else if ((name_len == sizeof(ZEND_TOSCALAR_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_TOSCALAR_FUNC_NAME, sizeof(ZEND_TOSCALAR_FUNC_NAME)-1))) {
  109. + if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
  110. + zend_error(E_WARNING, "The magic method __toScalar() must have public visibility and cannot be static");
  111. + }
  112. }
  113. } else {
  114. char *class_lcname;
  115. @@ -1673,6 +1689,26 @@
  116. zend_error(E_WARNING, "The magic method __toString() must have public visibility and cannot be static");
  117. }
  118. CG(active_class_entry)->__tostring = (zend_function *) CG(active_op_array);
  119. + } else if ((name_len == sizeof(ZEND_TOINT_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_TOINT_FUNC_NAME, sizeof(ZEND_TOINT_FUNC_NAME)-1))) {
  120. + if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
  121. + zend_error(E_WARNING, "The magic method __toInt() must have public visibility and cannot be static");
  122. + }
  123. + CG(active_class_entry)->__toint = (zend_function *) CG(active_op_array);
  124. + } else if ((name_len == sizeof(ZEND_TOFLOAT_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_TOFLOAT_FUNC_NAME, sizeof(ZEND_TOFLOAT_FUNC_NAME)-1))) {
  125. + if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
  126. + zend_error(E_WARNING, "The magic method __toFloat() must have public visibility and cannot be static");
  127. + }
  128. + CG(active_class_entry)->__tofloat = (zend_function *) CG(active_op_array);
  129. + } else if ((name_len == sizeof(ZEND_TOARRAY_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_TOARRAY_FUNC_NAME, sizeof(ZEND_TOARRAY_FUNC_NAME)-1))) {
  130. + if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
  131. + zend_error(E_WARNING, "The magic method __toArray() must have public visibility and cannot be static");
  132. + }
  133. + CG(active_class_entry)->__toarray = (zend_function *) CG(active_op_array);
  134. + } else if ((name_len == sizeof(ZEND_TOSCALAR_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_TOSCALAR_FUNC_NAME, sizeof(ZEND_TOSCALAR_FUNC_NAME)-1))) {
  135. + if (fn_flags & ((ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC) ^ ZEND_ACC_PUBLIC)) {
  136. + zend_error(E_WARNING, "The magic method __toScalar() must have public visibility and cannot be static");
  137. + }
  138. + CG(active_class_entry)->__toscalar = (zend_function *) CG(active_op_array);
  139. } else if (!(fn_flags & ZEND_ACC_STATIC)) {
  140. CG(active_op_array)->fn_flags |= ZEND_ACC_ALLOW_STATIC;
  141. }
  142. @@ -2839,6 +2875,18 @@
  143. if (!ce->__tostring) {
  144. ce->__tostring = ce->parent->__tostring;
  145. }
  146. + if (!ce->__toint) {
  147. + ce->__toint = ce->parent->__toint;
  148. + }
  149. + if (!ce->__tofloat) {
  150. + ce->__tofloat = ce->parent->__tofloat;
  151. + }
  152. + if (!ce->__toarray) {
  153. + ce->__toarray = ce->parent->__toarray;
  154. + }
  155. + if (!ce->__toscalar) {
  156. + ce->__toscalar = ce->parent->__toscalar;
  157. + }
  158. if (!ce->clone) {
  159. ce->clone = ce->parent->clone;
  160. }
  161. @@ -3734,6 +3782,14 @@
  162. ce->__callstatic = fe;
  163. } else if (!strncmp(mname, ZEND_TOSTRING_FUNC_NAME, mname_len)) {
  164. ce->__tostring = fe;
  165. + } else if (!strncmp(mname, ZEND_TOINT_FUNC_NAME, mname_len)) {
  166. + ce->__toint = fe;
  167. + } else if (!strncmp(mname, ZEND_TOFLOAT_FUNC_NAME, mname_len)) {
  168. + ce->__tofloat = fe;
  169. + } else if (!strncmp(mname, ZEND_TOARRAY_FUNC_NAME, mname_len)) {
  170. + ce->__toarray = fe;
  171. + } else if (!strncmp(mname, ZEND_TOSCALAR_FUNC_NAME, mname_len)) {
  172. + ce->__toscalar = fe;
  173. } else if (ce->name_length + 1 == mname_len) {
  174. char *lowercase_name = emalloc(ce->name_length + 1);
  175. zend_str_tolower_copy(lowercase_name, ce->name, ce->name_length);
  176. @@ -6742,6 +6798,10 @@
  177. ce->__call = NULL;
  178. ce->__callstatic = NULL;
  179. ce->__tostring = NULL;
  180. + ce->__toint = NULL;
  181. + ce->__tofloat = NULL;
  182. + ce->__toarray = NULL;
  183. + ce->__toscalar = NULL;
  184. ce->create_object = NULL;
  185. ce->get_iterator = NULL;
  186. ce->iterator_funcs.funcs = NULL;
  187. Index: Zend/zend_object_handlers.h
  188. ===================================================================
  189. --- Zend/zend_object_handlers.h (revision 323850)
  190. +++ Zend/zend_object_handlers.h (working copy)
  191. @@ -154,6 +154,8 @@
  192. ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zval *member, int silent TSRMLS_DC);
  193. ZEND_API HashTable *zend_std_get_properties(zval *object TSRMLS_DC);
  194. ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp TSRMLS_DC);
  195. +ZEND_API zval *zend_std_cast_object_get(zval *readobj TSRMLS_DC);
  196. +ZEND_API int zend_std_cast_object(zval *readobj, zval *writeobj, int type TSRMLS_DC);
  197. ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type TSRMLS_DC);
  198. ZEND_API void zend_std_write_property(zval *object, zval *member, zval *value, const struct _zend_literal *key TSRMLS_DC);
  199. ZEND_API void rebuild_object_properties(zend_object *zobj);
  200. Index: Zend/zend_compile.h
  201. ===================================================================
  202. --- Zend/zend_compile.h (revision 323850)
  203. +++ Zend/zend_compile.h (working copy)
  204. @@ -829,6 +829,10 @@
  205. #define ZEND_CALL_FUNC_NAME "__call"
  206. #define ZEND_CALLSTATIC_FUNC_NAME "__callstatic"
  207. #define ZEND_TOSTRING_FUNC_NAME "__tostring"
  208. +#define ZEND_TOINT_FUNC_NAME "__toint"
  209. +#define ZEND_TOFLOAT_FUNC_NAME "__tofloat"
  210. +#define ZEND_TOARRAY_FUNC_NAME "__toarray"
  211. +#define ZEND_TOSCALAR_FUNC_NAME "__toscalar"
  212. #define ZEND_AUTOLOAD_FUNC_NAME "__autoload"
  213.  
  214. /* The following constants may be combined in CG(compiler_options)
  215. Index: Zend/zend_API.c
  216. ===================================================================
  217. --- Zend/zend_API.c (revision 323850)
  218. +++ Zend/zend_API.c (working copy)
  219. @@ -27,6 +27,7 @@
  220. #include "zend_constants.h"
  221. #include "zend_exceptions.h"
  222. #include "zend_closures.h"
  223. +#include "zend_interfaces.h"
  224.  
  225. #ifdef HAVE_STDARG_H
  226. #include <stdarg.h>
  227. @@ -368,9 +369,25 @@
  228. convert_to_long_ex(arg);
  229. *p = Z_LVAL_PP(arg);
  230. break;
  231. -
  232. + case IS_OBJECT:
  233. + {
  234. + zend_class_entry *ce = Z_OBJCE_PP(arg);
  235. + zval *tmp = NULL;
  236. + if (ce->__toint) {
  237. + if (Z_ISREF_PP(arg)) {
  238. + zend_spprintf(error, 0, "to be an int, cannot cast referenced parameter from object");
  239. + return "long";
  240. + }
  241. + zend_call_method_with_0_params(arg, ce, &ce->__toint, "__toint", &tmp);
  242. + if (tmp && Z_TYPE_P(tmp) == IS_LONG) {
  243. + *p = Z_LVAL_P(tmp);
  244. + zval_ptr_dtor(&tmp);
  245. + break;
  246. + }
  247. + }
  248. + }
  249. + /* Fall through intentional */
  250. case IS_ARRAY:
  251. - case IS_OBJECT:
  252. case IS_RESOURCE:
  253. default:
  254. return "long";
  255. @@ -402,9 +419,25 @@
  256. convert_to_double_ex(arg);
  257. *p = Z_DVAL_PP(arg);
  258. break;
  259. -
  260. + case IS_OBJECT:
  261. + {
  262. + zend_class_entry *ce = Z_OBJCE_PP(arg);
  263. + zval *tmp = NULL;
  264. + if (ce->__tofloat) {
  265. + if (Z_ISREF_PP(arg)) {
  266. + zend_spprintf(error, 0, "to be a float, cannot cast referenced parameter from object");
  267. + return "double";
  268. + }
  269. + zend_call_method_with_0_params(arg, ce, &ce->__tofloat, "__tofloat", &tmp);
  270. + if (tmp && Z_TYPE_P(tmp) == IS_DOUBLE) {
  271. + *p = Z_DVAL_P(tmp);
  272. + zval_ptr_dtor(&tmp);
  273. + break;
  274. + }
  275. + }
  276. + }
  277. + /* Fall through intentional */
  278. case IS_ARRAY:
  279. - case IS_OBJECT:
  280. case IS_RESOURCE:
  281. default:
  282. return "double";
  283. @@ -506,6 +539,23 @@
  284. }
  285. if (Z_TYPE_PP(arg) == IS_ARRAY || (c == 'A' && Z_TYPE_PP(arg) == IS_OBJECT)) {
  286. *p = *arg;
  287. + } else if (Z_TYPE_PP(arg) == IS_OBJECT) {
  288. + zend_class_entry *ce = Z_OBJCE_PP(arg);
  289. + zval *tmp = NULL;
  290. + if (ce->__toarray) {
  291. + if (Z_ISREF_PP(arg)) {
  292. + zend_spprintf(error, 0, "to be an array, cannot cast referenced parameter from object");
  293. + return "array";
  294. + }
  295. + zend_call_method_with_0_params(arg, ce, &ce->__toarray, "__toarray", &tmp);
  296. + if (tmp && Z_TYPE_P(tmp) == IS_ARRAY) {
  297. + SEPARATE_ZVAL_IF_NOT_REF(arg);
  298. + ZVAL_ZVAL(*arg, tmp, 1, 1) ;
  299. + *p = *arg;
  300. + break;
  301. + }
  302. + }
  303. + return "array";
  304. } else {
  305. return "array";
  306. }
  307. @@ -526,6 +576,19 @@
  308. if(*p == NULL) {
  309. return "array";
  310. }
  311. + } else if (Z_TYPE_PP(arg) == IS_OBJECT) {
  312. + zend_class_entry *ce = Z_OBJCE_PP(arg);
  313. + zval *tmp = NULL;
  314. + if (ce->__toarray) {
  315. + zend_call_method_with_0_params(arg, ce, &ce->__toarray, "__toarray", &tmp);
  316. + if (tmp && Z_TYPE_P(tmp) == IS_ARRAY) {
  317. + SEPARATE_ZVAL_IF_NOT_REF(arg);
  318. + ZVAL_ZVAL(*arg, tmp, 1, 1);
  319. + *p = HASH_OF(*arg);
  320. + break;
  321. + }
  322. + }
  323. + return "array";
  324. } else {
  325. return "array";
  326. }
  327. @@ -1930,7 +1993,7 @@
  328. int count=0, unload=0, result=0;
  329. HashTable *target_function_table = function_table;
  330. int error_type;
  331. - zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL, *__callstatic = NULL, *__tostring = NULL;
  332. + zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL, *__callstatic = NULL, *__tostring = NULL, *__toint = NULL, *__tofloat = NULL, *__toarray = NULL, *__toscalar = NULL;
  333. const char *lowercase_name;
  334. int fname_len;
  335. const char *lc_class_name = NULL;
  336. @@ -2065,6 +2128,14 @@
  337. __callstatic = reg_function;
  338. } else if ((fname_len == sizeof(ZEND_TOSTRING_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_TOSTRING_FUNC_NAME, sizeof(ZEND_TOSTRING_FUNC_NAME))) {
  339. __tostring = reg_function;
  340. + } else if ((fname_len == sizeof(ZEND_TOINT_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_TOINT_FUNC_NAME, sizeof(ZEND_TOINT_FUNC_NAME))) {
  341. + __toint = reg_function;
  342. + } else if ((fname_len == sizeof(ZEND_TOFLOAT_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_TOFLOAT_FUNC_NAME, sizeof(ZEND_TOFLOAT_FUNC_NAME))) {
  343. + __tofloat = reg_function;
  344. + } else if ((fname_len == sizeof(ZEND_TOARRAY_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_TOARRAY_FUNC_NAME, sizeof(ZEND_TOARRAY_FUNC_NAME))) {
  345. + __toarray = reg_function;
  346. + } else if ((fname_len == sizeof(ZEND_TOSCALAR_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_TOSCALAR_FUNC_NAME, sizeof(ZEND_TOSCALAR_FUNC_NAME))) {
  347. + __toscalar = reg_function;
  348. } else if ((fname_len == sizeof(ZEND_GET_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_GET_FUNC_NAME, sizeof(ZEND_GET_FUNC_NAME))) {
  349. __get = reg_function;
  350. } else if ((fname_len == sizeof(ZEND_SET_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME))) {
  351. @@ -2107,6 +2178,10 @@
  352. scope->__call = __call;
  353. scope->__callstatic = __callstatic;
  354. scope->__tostring = __tostring;
  355. + scope->__toint = __toint;
  356. + scope->__tofloat = __tofloat;
  357. + scope->__toarray = __toarray;
  358. + scope->__toscalar = __toscalar;
  359. scope->__get = __get;
  360. scope->__set = __set;
  361. scope->__unset = __unset;
  362. @@ -2150,6 +2225,30 @@
  363. }
  364. __tostring->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
  365. }
  366. + if (__toint) {
  367. + if (__toint->common.fn_flags & ZEND_ACC_STATIC) {
  368. + zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __toint->common.function_name);
  369. + }
  370. + __toint->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
  371. + }
  372. + if (__tofloat) {
  373. + if (__tofloat->common.fn_flags & ZEND_ACC_STATIC) {
  374. + zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __tofloat->common.function_name);
  375. + }
  376. + __tofloat->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
  377. + }
  378. + if (__toarray) {
  379. + if (__toarray->common.fn_flags & ZEND_ACC_STATIC) {
  380. + zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __toarray->common.function_name);
  381. + }
  382. + __toarray->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
  383. + }
  384. + if (__toscalar) {
  385. + if (__toscalar->common.fn_flags & ZEND_ACC_STATIC) {
  386. + zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __toscalar->common.function_name);
  387. + }
  388. + __toscalar->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC;
  389. + }
  390. if (__get) {
  391. if (__get->common.fn_flags & ZEND_ACC_STATIC) {
  392. zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __get->common.function_name);
  393. Index: Zend/zend_operators.c
  394. ===================================================================
  395. --- Zend/zend_operators.c (revision 323850)
  396. +++ Zend/zend_operators.c (working copy)
  397. @@ -30,6 +30,7 @@
  398. #include "zend_strtod.h"
  399. #include "zend_exceptions.h"
  400. #include "zend_closures.h"
  401. +#include "zend_interfaces.h"
  402.  
  403. #if ZEND_USE_TOLOWER_L
  404. #include <locale.h>
  405. @@ -640,6 +641,7 @@
  406. case IS_OBJECT:
  407. {
  408. zval *tmp;
  409. + zend_class_entry *ce = Z_OBJCE_P(op);
  410. HashTable *ht;
  411.  
  412. ALLOC_HASHTABLE(ht);
  413. @@ -651,6 +653,15 @@
  414. FREE_HASHTABLE(ht);
  415. return;
  416. }
  417. + } else if (ce->__toarray) {
  418. + zend_call_method_with_0_params(&op, ce, &ce->__toarray, "__toarray", &tmp);
  419. + if (tmp && Z_TYPE_P(tmp) == IS_ARRAY) {
  420. + ZVAL_ZVAL(op, tmp, 1, 1);
  421. + zend_hash_destroy(ht);
  422. + FREE_HASHTABLE(ht);
  423. + return;
  424. + }
  425. + zend_error(E_WARNING, "%s::__toArray() must return an array", ce->name);
  426. } else if (Z_OBJ_HT_P(op)->get_properties) {
  427. HashTable *obj_ht = Z_OBJ_HT_P(op)->get_properties(op TSRMLS_CC);
  428. if (obj_ht) {
  429. Index: Zend/zend_API.h
  430. ===================================================================
  431. --- Zend/zend_API.h (revision 323850)
  432. +++ Zend/zend_API.h (working copy)
  433. @@ -186,6 +186,10 @@
  434. class_container.__call = handle_fcall; \
  435. class_container.__callstatic = NULL; \
  436. class_container.__tostring = NULL; \
  437. + class_container.__toint = NULL; \
  438. + class_container.__tofloat = NULL; \
  439. + class_container.__toarray = NULL; \
  440. + class_container.__toscalar = NULL; \
  441. class_container.__get = handle_propget; \
  442. class_container.__set = handle_propset; \
  443. class_container.__unset = handle_propunset; \
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement