com_handlers.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 7 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2018 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Author: Wez Furlong <wez@thebrainroom.com> |
  16. +----------------------------------------------------------------------+
  17. */
  18. #ifdef HAVE_CONFIG_H
  19. #include "config.h"
  20. #endif
  21. #include "php.h"
  22. #include "php_ini.h"
  23. #include "ext/standard/info.h"
  24. #include "php_com_dotnet.h"
  25. #include "php_com_dotnet_internal.h"
  26. #include "Zend/zend_exceptions.h"
  27. static zval *com_property_read(zval *object, zval *member, int type, void **cahce_slot, zval *rv)
  28. {
  29. php_com_dotnet_object *obj;
  30. VARIANT v;
  31. HRESULT res;
  32. ZVAL_NULL(rv);
  33. obj = CDNO_FETCH(object);
  34. if (V_VT(&obj->v) == VT_DISPATCH) {
  35. VariantInit(&v);
  36. convert_to_string_ex(member);
  37. res = php_com_do_invoke(obj, Z_STRVAL_P(member), Z_STRLEN_P(member),
  38. DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, 0, NULL, 1);
  39. if (res == SUCCESS) {
  40. php_com_zval_from_variant(rv, &v, obj->code_page);
  41. VariantClear(&v);
  42. } else if (res == DISP_E_BADPARAMCOUNT) {
  43. php_com_saproxy_create(object, rv, member);
  44. }
  45. } else {
  46. php_com_throw_exception(E_INVALIDARG, "this variant has no properties");
  47. }
  48. return rv;
  49. }
  50. static void com_property_write(zval *object, zval *member, zval *value, void **cache_slot)
  51. {
  52. php_com_dotnet_object *obj;
  53. VARIANT v;
  54. obj = CDNO_FETCH(object);
  55. if (V_VT(&obj->v) == VT_DISPATCH) {
  56. VariantInit(&v);
  57. convert_to_string_ex(member);
  58. if (SUCCESS == php_com_do_invoke(obj, Z_STRVAL_P(member), Z_STRLEN_P(member),
  59. DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF, &v, 1, value, 0)) {
  60. VariantClear(&v);
  61. }
  62. } else {
  63. php_com_throw_exception(E_INVALIDARG, "this variant has no properties");
  64. }
  65. }
  66. static zval *com_read_dimension(zval *object, zval *offset, int type, zval *rv)
  67. {
  68. php_com_dotnet_object *obj;
  69. VARIANT v;
  70. ZVAL_NULL(rv);
  71. obj = CDNO_FETCH(object);
  72. if (V_VT(&obj->v) == VT_DISPATCH) {
  73. VariantInit(&v);
  74. if (SUCCESS == php_com_do_invoke_by_id(obj, DISPID_VALUE,
  75. DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, 1, offset, 0, 0)) {
  76. php_com_zval_from_variant(rv, &v, obj->code_page);
  77. VariantClear(&v);
  78. }
  79. } else if (V_ISARRAY(&obj->v)) {
  80. convert_to_long(offset);
  81. if (SafeArrayGetDim(V_ARRAY(&obj->v)) == 1) {
  82. if (php_com_safearray_get_elem(&obj->v, &v, (LONG)Z_LVAL_P(offset))) {
  83. php_com_wrap_variant(rv, &v, obj->code_page);
  84. VariantClear(&v);
  85. }
  86. } else {
  87. php_com_saproxy_create(object, rv, offset);
  88. }
  89. } else {
  90. php_com_throw_exception(E_INVALIDARG, "this variant is not an array type");
  91. }
  92. return rv;
  93. }
  94. static void com_write_dimension(zval *object, zval *offset, zval *value)
  95. {
  96. php_com_dotnet_object *obj;
  97. zval args[2];
  98. VARIANT v;
  99. HRESULT res;
  100. obj = CDNO_FETCH(object);
  101. if (offset == NULL) {
  102. php_com_throw_exception(DISP_E_BADINDEX, "appending to variants is not supported");
  103. return;
  104. }
  105. if (V_VT(&obj->v) == VT_DISPATCH) {
  106. ZVAL_COPY_VALUE(&args[0], offset);
  107. ZVAL_COPY_VALUE(&args[1], value);
  108. VariantInit(&v);
  109. if (SUCCESS == php_com_do_invoke_by_id(obj, DISPID_VALUE,
  110. DISPATCH_METHOD|DISPATCH_PROPERTYPUT, &v, 2, args, 0, 0)) {
  111. VariantClear(&v);
  112. }
  113. } else if (V_ISARRAY(&obj->v)) {
  114. LONG indices = 0;
  115. VARTYPE vt;
  116. if (SafeArrayGetDim(V_ARRAY(&obj->v)) == 1) {
  117. if (FAILED(SafeArrayGetVartype(V_ARRAY(&obj->v), &vt)) || vt == VT_EMPTY) {
  118. vt = V_VT(&obj->v) & ~VT_ARRAY;
  119. }
  120. convert_to_long(offset);
  121. indices = (LONG)Z_LVAL_P(offset);
  122. VariantInit(&v);
  123. php_com_variant_from_zval(&v, value, obj->code_page);
  124. if (V_VT(&v) != vt) {
  125. VariantChangeType(&v, &v, 0, vt);
  126. }
  127. if (vt == VT_VARIANT) {
  128. res = SafeArrayPutElement(V_ARRAY(&obj->v), &indices, &v);
  129. } else {
  130. res = SafeArrayPutElement(V_ARRAY(&obj->v), &indices, &v.lVal);
  131. }
  132. VariantClear(&v);
  133. if (FAILED(res)) {
  134. php_com_throw_exception(res, NULL);
  135. }
  136. } else {
  137. php_com_throw_exception(DISP_E_BADINDEX, "this variant has multiple dimensions; you can't set a new value without specifying *all* dimensions");
  138. }
  139. } else {
  140. php_com_throw_exception(E_INVALIDARG, "this variant is not an array type");
  141. }
  142. }
  143. #if 0
  144. static void com_object_set(zval **property, zval *value)
  145. {
  146. /* Not yet implemented in the engine */
  147. }
  148. static zval *com_object_get(zval *property)
  149. {
  150. /* Not yet implemented in the engine */
  151. return NULL;
  152. }
  153. #endif
  154. static int com_property_exists(zval *object, zval *member, int check_empty, void **cache_slot)
  155. {
  156. DISPID dispid;
  157. php_com_dotnet_object *obj;
  158. obj = CDNO_FETCH(object);
  159. if (V_VT(&obj->v) == VT_DISPATCH) {
  160. convert_to_string_ex(member);
  161. if (SUCCEEDED(php_com_get_id_of_name(obj, Z_STRVAL_P(member), Z_STRLEN_P(member), &dispid))) {
  162. /* TODO: distinguish between property and method! */
  163. return 1;
  164. }
  165. } else {
  166. /* TODO: check for safearray */
  167. }
  168. return 0;
  169. }
  170. static int com_dimension_exists(zval *object, zval *member, int check_empty)
  171. {
  172. php_error_docref(NULL, E_WARNING, "Operation not yet supported on a COM object");
  173. return 0;
  174. }
  175. static void com_property_delete(zval *object, zval *member, void **cache_slot)
  176. {
  177. php_error_docref(NULL, E_WARNING, "Cannot delete properties from a COM object");
  178. }
  179. static void com_dimension_delete(zval *object, zval *offset)
  180. {
  181. php_error_docref(NULL, E_WARNING, "Cannot delete properties from a COM object");
  182. }
  183. static HashTable *com_properties_get(zval *object)
  184. {
  185. /* TODO: use type-info to get all the names and values ?
  186. * DANGER: if we do that, there is a strong possibility for
  187. * infinite recursion when the hash is displayed via var_dump().
  188. * Perhaps it is best to leave it un-implemented.
  189. */
  190. return &zend_empty_array;
  191. }
  192. static void function_dtor(zval *zv)
  193. {
  194. zend_internal_function *f = (zend_internal_function*)Z_PTR_P(zv);
  195. zend_string_release_ex(f->function_name, 0);
  196. if (f->arg_info) {
  197. efree(f->arg_info);
  198. }
  199. efree(f);
  200. }
  201. static PHP_FUNCTION(com_method_handler)
  202. {
  203. zval *object = getThis();
  204. Z_OBJ_HANDLER_P(object, call_method)(
  205. ((zend_internal_function*)EX(func))->function_name,
  206. Z_OBJ_P(object),
  207. INTERNAL_FUNCTION_PARAM_PASSTHRU);
  208. }
  209. static union _zend_function *com_method_get(zend_object **object_ptr, zend_string *name, const zval *key)
  210. {
  211. zend_internal_function f, *fptr = NULL;
  212. union _zend_function *func;
  213. DISPID dummy;
  214. php_com_dotnet_object *obj = (php_com_dotnet_object*)*object_ptr;
  215. if (V_VT(&obj->v) != VT_DISPATCH) {
  216. return NULL;
  217. }
  218. if (FAILED(php_com_get_id_of_name(obj, name->val, name->len, &dummy))) {
  219. return NULL;
  220. }
  221. /* check cache */
  222. if (obj->method_cache == NULL || NULL == (fptr = zend_hash_find_ptr(obj->method_cache, name))) {
  223. f.type = ZEND_OVERLOADED_FUNCTION;
  224. f.num_args = 0;
  225. f.arg_info = NULL;
  226. f.scope = obj->ce;
  227. f.fn_flags = ZEND_ACC_CALL_VIA_HANDLER;
  228. f.function_name = zend_string_copy(name);
  229. f.handler = PHP_FN(com_method_handler);
  230. fptr = &f;
  231. if (obj->typeinfo) {
  232. /* look for byref params */
  233. ITypeComp *comp;
  234. ITypeInfo *TI = NULL;
  235. DESCKIND kind;
  236. BINDPTR bindptr;
  237. OLECHAR *olename;
  238. ULONG lhash;
  239. int i;
  240. if (SUCCEEDED(ITypeInfo_GetTypeComp(obj->typeinfo, &comp))) {
  241. olename = php_com_string_to_olestring(name->val, name->len, obj->code_page);
  242. lhash = LHashValOfNameSys(SYS_WIN32, LOCALE_SYSTEM_DEFAULT, olename);
  243. if (SUCCEEDED(ITypeComp_Bind(comp, olename, lhash, INVOKE_FUNC, &TI, &kind, &bindptr))) {
  244. switch (kind) {
  245. case DESCKIND_FUNCDESC:
  246. f.arg_info = ecalloc(bindptr.lpfuncdesc->cParams, sizeof(zend_arg_info));
  247. for (i = 0; i < bindptr.lpfuncdesc->cParams; i++) {
  248. f.arg_info[i].type = ZEND_TYPE_ENCODE(0,1);
  249. if (bindptr.lpfuncdesc->lprgelemdescParam[i].paramdesc.wParamFlags & PARAMFLAG_FOUT) {
  250. f.arg_info[i].pass_by_reference = ZEND_SEND_BY_REF;
  251. }
  252. }
  253. f.num_args = bindptr.lpfuncdesc->cParams;
  254. ITypeInfo_ReleaseFuncDesc(TI, bindptr.lpfuncdesc);
  255. break;
  256. /* these should not happen, but *might* happen if the user
  257. * screws up; lets avoid a leak in that case */
  258. case DESCKIND_VARDESC:
  259. ITypeInfo_ReleaseVarDesc(TI, bindptr.lpvardesc);
  260. break;
  261. case DESCKIND_TYPECOMP:
  262. ITypeComp_Release(bindptr.lptcomp);
  263. break;
  264. case DESCKIND_NONE:
  265. break;
  266. }
  267. if (TI) {
  268. ITypeInfo_Release(TI);
  269. }
  270. }
  271. ITypeComp_Release(comp);
  272. efree(olename);
  273. }
  274. }
  275. zend_set_function_arg_flags((zend_function*)&f);
  276. /* save this method in the cache */
  277. if (!obj->method_cache) {
  278. ALLOC_HASHTABLE(obj->method_cache);
  279. zend_hash_init(obj->method_cache, 2, NULL, function_dtor, 0);
  280. }
  281. zend_hash_update_mem(obj->method_cache, name, &f, sizeof(f));
  282. }
  283. if (fptr) {
  284. /* duplicate this into a new chunk of emalloc'd memory,
  285. * since the engine will efree it */
  286. func = emalloc(sizeof(*fptr));
  287. memcpy(func, fptr, sizeof(*fptr));
  288. return func;
  289. }
  290. return NULL;
  291. }
  292. static int com_call_method(zend_string *method, zend_object *object, INTERNAL_FUNCTION_PARAMETERS)
  293. {
  294. zval *args = NULL;
  295. php_com_dotnet_object *obj = (php_com_dotnet_object*)object;
  296. int nargs;
  297. VARIANT v;
  298. int ret = FAILURE;
  299. if (V_VT(&obj->v) != VT_DISPATCH) {
  300. return FAILURE;
  301. }
  302. nargs = ZEND_NUM_ARGS();
  303. if (nargs) {
  304. args = (zval *)safe_emalloc(sizeof(zval), nargs, 0);
  305. zend_get_parameters_array_ex(nargs, args);
  306. }
  307. VariantInit(&v);
  308. if (SUCCESS == php_com_do_invoke_byref(obj, (zend_internal_function*)EX(func), DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, nargs, args)) {
  309. php_com_zval_from_variant(return_value, &v, obj->code_page);
  310. ret = SUCCESS;
  311. VariantClear(&v);
  312. }
  313. if (args) {
  314. efree(args);
  315. }
  316. return ret;
  317. }
  318. static union _zend_function *com_constructor_get(zend_object *object)
  319. {
  320. php_com_dotnet_object *obj = (php_com_dotnet_object *) object;
  321. static zend_internal_function c, d, v;
  322. #define POPULATE_CTOR(f, fn) \
  323. f.type = ZEND_INTERNAL_FUNCTION; \
  324. f.function_name = obj->ce->name; \
  325. f.scope = obj->ce; \
  326. f.arg_info = NULL; \
  327. f.num_args = 0; \
  328. f.fn_flags = 0; \
  329. f.handler = ZEND_FN(fn); \
  330. return (union _zend_function*)&f;
  331. switch (obj->ce->name->val[0]) {
  332. #if HAVE_MSCOREE_H
  333. case 'd':
  334. POPULATE_CTOR(d, com_dotnet_create_instance);
  335. #endif
  336. case 'c':
  337. POPULATE_CTOR(c, com_create_instance);
  338. case 'v':
  339. POPULATE_CTOR(v, com_variant_create_instance);
  340. default:
  341. return NULL;
  342. }
  343. }
  344. static zend_string* com_class_name_get(const zend_object *object)
  345. {
  346. php_com_dotnet_object *obj = (php_com_dotnet_object *)object;
  347. return zend_string_copy(obj->ce->name);
  348. }
  349. /* This compares two variants for equality */
  350. static int com_objects_compare(zval *object1, zval *object2)
  351. {
  352. php_com_dotnet_object *obja, *objb;
  353. int ret;
  354. /* strange header bug problem here... the headers define the proto without the
  355. * flags parameter. However, the MSDN docs state that there is a flags parameter,
  356. * and my VC6 won't link unless the code uses the version with 4 parameters.
  357. * So, we have this declaration here to fix it */
  358. STDAPI VarCmp(LPVARIANT pvarLeft, LPVARIANT pvarRight, LCID lcid, DWORD flags);
  359. obja = CDNO_FETCH(object1);
  360. objb = CDNO_FETCH(object2);
  361. switch (VarCmp(&obja->v, &objb->v, LOCALE_SYSTEM_DEFAULT, 0)) {
  362. case VARCMP_LT:
  363. ret = -1;
  364. break;
  365. case VARCMP_GT:
  366. ret = 1;
  367. break;
  368. case VARCMP_EQ:
  369. ret = 0;
  370. break;
  371. default:
  372. /* either or both operands are NULL...
  373. * not 100% sure how to handle this */
  374. ret = -2;
  375. }
  376. return ret;
  377. }
  378. static int com_object_cast(zval *readobj, zval *writeobj, int type)
  379. {
  380. php_com_dotnet_object *obj;
  381. VARIANT v;
  382. VARTYPE vt = VT_EMPTY;
  383. HRESULT res = S_OK;
  384. obj = CDNO_FETCH(readobj);
  385. ZVAL_NULL(writeobj);
  386. VariantInit(&v);
  387. if (V_VT(&obj->v) == VT_DISPATCH) {
  388. if (SUCCESS != php_com_do_invoke_by_id(obj, DISPID_VALUE,
  389. DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, 0, NULL, 1, 0)) {
  390. VariantCopy(&v, &obj->v);
  391. }
  392. } else {
  393. VariantCopy(&v, &obj->v);
  394. }
  395. switch(type) {
  396. case IS_LONG:
  397. case _IS_NUMBER:
  398. vt = VT_INT;
  399. break;
  400. case IS_DOUBLE:
  401. vt = VT_R8;
  402. break;
  403. case IS_FALSE:
  404. case IS_TRUE:
  405. case _IS_BOOL:
  406. vt = VT_BOOL;
  407. break;
  408. case IS_STRING:
  409. vt = VT_BSTR;
  410. break;
  411. default:
  412. ;
  413. }
  414. if (vt != VT_EMPTY && vt != V_VT(&v)) {
  415. res = VariantChangeType(&v, &v, 0, vt);
  416. }
  417. if (SUCCEEDED(res)) {
  418. php_com_zval_from_variant(writeobj, &v, obj->code_page);
  419. }
  420. VariantClear(&v);
  421. if (SUCCEEDED(res)) {
  422. return SUCCESS;
  423. }
  424. return zend_std_cast_object_tostring(readobj, writeobj, type);
  425. }
  426. static int com_object_count(zval *object, zend_long *count)
  427. {
  428. php_com_dotnet_object *obj;
  429. LONG ubound = 0, lbound = 0;
  430. obj = CDNO_FETCH(object);
  431. if (!V_ISARRAY(&obj->v)) {
  432. return FAILURE;
  433. }
  434. SafeArrayGetLBound(V_ARRAY(&obj->v), 1, &lbound);
  435. SafeArrayGetUBound(V_ARRAY(&obj->v), 1, &ubound);
  436. *count = ubound - lbound + 1;
  437. return SUCCESS;
  438. }
  439. zend_object_handlers php_com_object_handlers = {
  440. 0,
  441. php_com_object_free_storage,
  442. zend_objects_destroy_object,
  443. php_com_object_clone,
  444. com_property_read,
  445. com_property_write,
  446. com_read_dimension,
  447. com_write_dimension,
  448. NULL,
  449. NULL, /* com_object_get, */
  450. NULL, /* com_object_set, */
  451. com_property_exists,
  452. com_property_delete,
  453. com_dimension_exists,
  454. com_dimension_delete,
  455. com_properties_get,
  456. com_method_get,
  457. com_call_method,
  458. com_constructor_get,
  459. com_class_name_get,
  460. com_objects_compare,
  461. com_object_cast,
  462. com_object_count,
  463. NULL, /* get_debug_info */
  464. NULL, /* get_closure */
  465. NULL, /* get_gc */
  466. };
  467. void php_com_object_enable_event_sink(php_com_dotnet_object *obj, int enable)
  468. {
  469. if (obj->sink_dispatch) {
  470. IConnectionPointContainer *cont;
  471. IConnectionPoint *point;
  472. if (SUCCEEDED(IDispatch_QueryInterface(V_DISPATCH(&obj->v),
  473. &IID_IConnectionPointContainer, (void**)&cont))) {
  474. if (SUCCEEDED(IConnectionPointContainer_FindConnectionPoint(cont,
  475. &obj->sink_id, &point))) {
  476. if (enable) {
  477. IConnectionPoint_Advise(point, (IUnknown*)obj->sink_dispatch, &obj->sink_cookie);
  478. } else {
  479. IConnectionPoint_Unadvise(point, obj->sink_cookie);
  480. }
  481. IConnectionPoint_Release(point);
  482. }
  483. IConnectionPointContainer_Release(cont);
  484. }
  485. }
  486. }
  487. void php_com_object_free_storage(zend_object *object)
  488. {
  489. php_com_dotnet_object *obj = (php_com_dotnet_object*)object;
  490. if (obj->typeinfo) {
  491. ITypeInfo_Release(obj->typeinfo);
  492. obj->typeinfo = NULL;
  493. }
  494. if (obj->sink_dispatch) {
  495. php_com_object_enable_event_sink(obj, FALSE);
  496. IDispatch_Release(obj->sink_dispatch);
  497. obj->sink_dispatch = NULL;
  498. }
  499. VariantClear(&obj->v);
  500. if (obj->method_cache) {
  501. zend_hash_destroy(obj->method_cache);
  502. FREE_HASHTABLE(obj->method_cache);
  503. }
  504. if (obj->id_of_name_cache) {
  505. zend_hash_destroy(obj->id_of_name_cache);
  506. FREE_HASHTABLE(obj->id_of_name_cache);
  507. }
  508. }
  509. zend_object* php_com_object_clone(zval *object)
  510. {
  511. php_com_dotnet_object *cloneobj, *origobject;
  512. origobject = (php_com_dotnet_object*)Z_OBJ_P(object);
  513. cloneobj = (php_com_dotnet_object*)emalloc(sizeof(php_com_dotnet_object));
  514. memcpy(cloneobj, origobject, sizeof(*cloneobj));
  515. /* VariantCopy will perform VariantClear; we don't want to clobber
  516. * the IDispatch that we memcpy'd, so we init a new variant in the
  517. * clone structure */
  518. VariantInit(&cloneobj->v);
  519. /* We use the Indirection-following version of the API since we
  520. * want to clone as much as possible */
  521. VariantCopyInd(&cloneobj->v, &origobject->v);
  522. if (cloneobj->typeinfo) {
  523. ITypeInfo_AddRef(cloneobj->typeinfo);
  524. }
  525. return (zend_object*)cloneobj;
  526. }
  527. zend_object* php_com_object_new(zend_class_entry *ce)
  528. {
  529. php_com_dotnet_object *obj;
  530. php_com_initialize();
  531. obj = emalloc(sizeof(*obj));
  532. memset(obj, 0, sizeof(*obj));
  533. VariantInit(&obj->v);
  534. obj->code_page = CP_ACP;
  535. obj->ce = ce;
  536. zend_object_std_init(&obj->zo, ce);
  537. obj->zo.handlers = &php_com_object_handlers;
  538. obj->typeinfo = NULL;
  539. return (zend_object*)obj;
  540. }