PageRenderTime 58ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/Zend/zend_execute.c

http://github.com/php/php-src
C | 4504 lines | 3832 code | 504 blank | 168 comment | 1279 complexity | 7c5eab72c2e4612efe22639a649ff2bb MD5 | raw file
Possible License(s): BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. +----------------------------------------------------------------------+
  3. | Zend Engine |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 2.00 of the Zend 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.zend.com/license/2_00.txt. |
  11. | If you did not receive a copy of the Zend license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@zend.com so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Andi Gutmans <andi@php.net> |
  16. | Zeev Suraski <zeev@php.net> |
  17. | Dmitry Stogov <dmitry@php.net> |
  18. +----------------------------------------------------------------------+
  19. */
  20. #define ZEND_INTENSIVE_DEBUGGING 0
  21. #include <stdio.h>
  22. #include <signal.h>
  23. #include "zend.h"
  24. #include "zend_compile.h"
  25. #include "zend_execute.h"
  26. #include "zend_API.h"
  27. #include "zend_ptr_stack.h"
  28. #include "zend_constants.h"
  29. #include "zend_extensions.h"
  30. #include "zend_ini.h"
  31. #include "zend_exceptions.h"
  32. #include "zend_interfaces.h"
  33. #include "zend_closures.h"
  34. #include "zend_generators.h"
  35. #include "zend_vm.h"
  36. #include "zend_dtrace.h"
  37. #include "zend_inheritance.h"
  38. #include "zend_type_info.h"
  39. #include "zend_smart_str.h"
  40. /* Virtual current working directory support */
  41. #include "zend_virtual_cwd.h"
  42. #ifdef HAVE_GCC_GLOBAL_REGS
  43. # if defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(i386)
  44. # define ZEND_VM_FP_GLOBAL_REG "%esi"
  45. # define ZEND_VM_IP_GLOBAL_REG "%edi"
  46. # elif defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(__x86_64__)
  47. # define ZEND_VM_FP_GLOBAL_REG "%r14"
  48. # define ZEND_VM_IP_GLOBAL_REG "%r15"
  49. # elif defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(__powerpc64__)
  50. # define ZEND_VM_FP_GLOBAL_REG "r28"
  51. # define ZEND_VM_IP_GLOBAL_REG "r29"
  52. # elif defined(__IBMC__) && ZEND_GCC_VERSION >= 4002 && defined(__powerpc64__)
  53. # define ZEND_VM_FP_GLOBAL_REG "r28"
  54. # define ZEND_VM_IP_GLOBAL_REG "r29"
  55. # elif defined(__GNUC__) && ZEND_GCC_VERSION >= 4008 && defined(__aarch64__)
  56. # define ZEND_VM_FP_GLOBAL_REG "x27"
  57. # define ZEND_VM_IP_GLOBAL_REG "x28"
  58. # endif
  59. #endif
  60. #if defined(ZEND_VM_FP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
  61. # pragma GCC diagnostic ignored "-Wvolatile-register-var"
  62. register zend_execute_data* volatile execute_data __asm__(ZEND_VM_FP_GLOBAL_REG);
  63. # pragma GCC diagnostic warning "-Wvolatile-register-var"
  64. #endif
  65. #if defined(ZEND_VM_FP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
  66. # define EXECUTE_DATA_D void
  67. # define EXECUTE_DATA_C
  68. # define EXECUTE_DATA_DC
  69. # define EXECUTE_DATA_CC
  70. # define NO_EXECUTE_DATA_CC
  71. #else
  72. # define EXECUTE_DATA_D zend_execute_data* execute_data
  73. # define EXECUTE_DATA_C execute_data
  74. # define EXECUTE_DATA_DC , EXECUTE_DATA_D
  75. # define EXECUTE_DATA_CC , EXECUTE_DATA_C
  76. # define NO_EXECUTE_DATA_CC , NULL
  77. #endif
  78. #if defined(ZEND_VM_FP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
  79. # define OPLINE_D void
  80. # define OPLINE_C
  81. # define OPLINE_DC
  82. # define OPLINE_CC
  83. #else
  84. # define OPLINE_D const zend_op* opline
  85. # define OPLINE_C opline
  86. # define OPLINE_DC , OPLINE_D
  87. # define OPLINE_CC , OPLINE_C
  88. #endif
  89. #if defined(ZEND_VM_IP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
  90. # pragma GCC diagnostic ignored "-Wvolatile-register-var"
  91. register const zend_op* volatile opline __asm__(ZEND_VM_IP_GLOBAL_REG);
  92. # pragma GCC diagnostic warning "-Wvolatile-register-var"
  93. #else
  94. #endif
  95. #define _CONST_CODE 0
  96. #define _TMP_CODE 1
  97. #define _VAR_CODE 2
  98. #define _UNUSED_CODE 3
  99. #define _CV_CODE 4
  100. typedef int (ZEND_FASTCALL *incdec_t)(zval *);
  101. #define get_zval_ptr(op_type, node, type) _get_zval_ptr(op_type, node, type EXECUTE_DATA_CC OPLINE_CC)
  102. #define get_zval_ptr_deref(op_type, node, type) _get_zval_ptr_deref(op_type, node, type EXECUTE_DATA_CC OPLINE_CC)
  103. #define get_zval_ptr_undef(op_type, node, type) _get_zval_ptr_undef(op_type, node, type EXECUTE_DATA_CC OPLINE_CC)
  104. #define get_op_data_zval_ptr_r(op_type, node) _get_op_data_zval_ptr_r(op_type, node EXECUTE_DATA_CC OPLINE_CC)
  105. #define get_op_data_zval_ptr_deref_r(op_type, node) _get_op_data_zval_ptr_deref_r(op_type, node EXECUTE_DATA_CC OPLINE_CC)
  106. #define get_zval_ptr_ptr(op_type, node, type) _get_zval_ptr_ptr(op_type, node, type EXECUTE_DATA_CC)
  107. #define get_zval_ptr_ptr_undef(op_type, node, type) _get_zval_ptr_ptr(op_type, node, type EXECUTE_DATA_CC)
  108. #define get_obj_zval_ptr(op_type, node, type) _get_obj_zval_ptr(op_type, node, type EXECUTE_DATA_CC OPLINE_CC)
  109. #define get_obj_zval_ptr_undef(op_type, node, type) _get_obj_zval_ptr_undef(op_type, node, type EXECUTE_DATA_CC OPLINE_CC)
  110. #define get_obj_zval_ptr_ptr(op_type, node, type) _get_obj_zval_ptr_ptr(op_type, node, type EXECUTE_DATA_CC)
  111. #define RETURN_VALUE_USED(opline) ((opline)->result_type != IS_UNUSED)
  112. static ZEND_FUNCTION(pass)
  113. {
  114. }
  115. ZEND_API const zend_internal_function zend_pass_function = {
  116. ZEND_INTERNAL_FUNCTION, /* type */
  117. {0, 0, 0}, /* arg_flags */
  118. 0, /* fn_flags */
  119. NULL, /* name */
  120. NULL, /* scope */
  121. NULL, /* prototype */
  122. 0, /* num_args */
  123. 0, /* required_num_args */
  124. NULL, /* arg_info */
  125. ZEND_FN(pass), /* handler */
  126. NULL, /* module */
  127. {NULL,NULL,NULL,NULL} /* reserved */
  128. };
  129. #define FREE_VAR_PTR_AND_EXTRACT_RESULT_IF_NECESSARY(free_var) do { \
  130. zval *__container_to_free = EX_VAR(free_var); \
  131. if (UNEXPECTED(Z_REFCOUNTED_P(__container_to_free))) { \
  132. zend_refcounted *__ref = Z_COUNTED_P(__container_to_free); \
  133. if (UNEXPECTED(!GC_DELREF(__ref))) { \
  134. zval *__zv = EX_VAR(opline->result.var); \
  135. if (EXPECTED(Z_TYPE_P(__zv) == IS_INDIRECT)) { \
  136. ZVAL_COPY(__zv, Z_INDIRECT_P(__zv)); \
  137. } \
  138. rc_dtor_func(__ref); \
  139. } \
  140. } \
  141. } while (0)
  142. #define FREE_OP(type, var) \
  143. if ((type) & (IS_TMP_VAR|IS_VAR)) { \
  144. zval_ptr_dtor_nogc(EX_VAR(var)); \
  145. }
  146. #define FREE_UNFETCHED_OP(type, var) \
  147. FREE_OP(type, var)
  148. #define FREE_OP_VAR_PTR(type, var) \
  149. FREE_OP(type, var)
  150. #define CV_DEF_OF(i) (EX(func)->op_array.vars[i])
  151. #define ZEND_VM_STACK_PAGE_SLOTS (16 * 1024) /* should be a power of 2 */
  152. #define ZEND_VM_STACK_PAGE_SIZE (ZEND_VM_STACK_PAGE_SLOTS * sizeof(zval))
  153. #define ZEND_VM_STACK_PAGE_ALIGNED_SIZE(size, page_size) \
  154. (((size) + ZEND_VM_STACK_HEADER_SLOTS * sizeof(zval) \
  155. + ((page_size) - 1)) & ~((page_size) - 1))
  156. static zend_always_inline zend_vm_stack zend_vm_stack_new_page(size_t size, zend_vm_stack prev) {
  157. zend_vm_stack page = (zend_vm_stack)emalloc(size);
  158. page->top = ZEND_VM_STACK_ELEMENTS(page);
  159. page->end = (zval*)((char*)page + size);
  160. page->prev = prev;
  161. return page;
  162. }
  163. ZEND_API void zend_vm_stack_init(void)
  164. {
  165. EG(vm_stack_page_size) = ZEND_VM_STACK_PAGE_SIZE;
  166. EG(vm_stack) = zend_vm_stack_new_page(ZEND_VM_STACK_PAGE_SIZE, NULL);
  167. EG(vm_stack_top) = EG(vm_stack)->top;
  168. EG(vm_stack_end) = EG(vm_stack)->end;
  169. }
  170. ZEND_API void zend_vm_stack_init_ex(size_t page_size)
  171. {
  172. /* page_size must be a power of 2 */
  173. ZEND_ASSERT(page_size > 0 && (page_size & (page_size - 1)) == 0);
  174. EG(vm_stack_page_size) = page_size;
  175. EG(vm_stack) = zend_vm_stack_new_page(page_size, NULL);
  176. EG(vm_stack_top) = EG(vm_stack)->top;
  177. EG(vm_stack_end) = EG(vm_stack)->end;
  178. }
  179. ZEND_API void zend_vm_stack_destroy(void)
  180. {
  181. zend_vm_stack stack = EG(vm_stack);
  182. while (stack != NULL) {
  183. zend_vm_stack p = stack->prev;
  184. efree(stack);
  185. stack = p;
  186. }
  187. }
  188. ZEND_API void* zend_vm_stack_extend(size_t size)
  189. {
  190. zend_vm_stack stack;
  191. void *ptr;
  192. stack = EG(vm_stack);
  193. stack->top = EG(vm_stack_top);
  194. EG(vm_stack) = stack = zend_vm_stack_new_page(
  195. EXPECTED(size < EG(vm_stack_page_size) - (ZEND_VM_STACK_HEADER_SLOTS * sizeof(zval))) ?
  196. EG(vm_stack_page_size) : ZEND_VM_STACK_PAGE_ALIGNED_SIZE(size, EG(vm_stack_page_size)),
  197. stack);
  198. ptr = stack->top;
  199. EG(vm_stack_top) = (void*)(((char*)ptr) + size);
  200. EG(vm_stack_end) = stack->end;
  201. return ptr;
  202. }
  203. ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data, uint32_t var)
  204. {
  205. return EX_VAR(var);
  206. }
  207. static zend_always_inline zval *_get_zval_ptr_tmp(uint32_t var EXECUTE_DATA_DC)
  208. {
  209. zval *ret = EX_VAR(var);
  210. ZEND_ASSERT(Z_TYPE_P(ret) != IS_REFERENCE);
  211. return ret;
  212. }
  213. static zend_always_inline zval *_get_zval_ptr_var(uint32_t var EXECUTE_DATA_DC)
  214. {
  215. zval *ret = EX_VAR(var);
  216. return ret;
  217. }
  218. static zend_always_inline zval *_get_zval_ptr_var_deref(uint32_t var EXECUTE_DATA_DC)
  219. {
  220. zval *ret = EX_VAR(var);
  221. ZVAL_DEREF(ret);
  222. return ret;
  223. }
  224. static zend_never_inline ZEND_COLD zval* zval_undefined_cv(uint32_t var EXECUTE_DATA_DC)
  225. {
  226. if (EXPECTED(EG(exception) == NULL)) {
  227. zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var));
  228. zend_error(E_WARNING, "Undefined variable $%s", ZSTR_VAL(cv));
  229. }
  230. return &EG(uninitialized_zval);
  231. }
  232. static zend_never_inline ZEND_COLD zval* ZEND_FASTCALL _zval_undefined_op1(EXECUTE_DATA_D)
  233. {
  234. return zval_undefined_cv(EX(opline)->op1.var EXECUTE_DATA_CC);
  235. }
  236. static zend_never_inline ZEND_COLD zval* ZEND_FASTCALL _zval_undefined_op2(EXECUTE_DATA_D)
  237. {
  238. return zval_undefined_cv(EX(opline)->op2.var EXECUTE_DATA_CC);
  239. }
  240. #define ZVAL_UNDEFINED_OP1() _zval_undefined_op1(EXECUTE_DATA_C)
  241. #define ZVAL_UNDEFINED_OP2() _zval_undefined_op2(EXECUTE_DATA_C)
  242. static zend_never_inline ZEND_COLD zval *_get_zval_cv_lookup(zval *ptr, uint32_t var, int type EXECUTE_DATA_DC)
  243. {
  244. switch (type) {
  245. case BP_VAR_R:
  246. case BP_VAR_UNSET:
  247. ptr = zval_undefined_cv(var EXECUTE_DATA_CC);
  248. break;
  249. case BP_VAR_IS:
  250. ptr = &EG(uninitialized_zval);
  251. break;
  252. case BP_VAR_RW:
  253. zval_undefined_cv(var EXECUTE_DATA_CC);
  254. /* break missing intentionally */
  255. case BP_VAR_W:
  256. ZVAL_NULL(ptr);
  257. break;
  258. }
  259. return ptr;
  260. }
  261. static zend_always_inline zval *_get_zval_ptr_cv(uint32_t var, int type EXECUTE_DATA_DC)
  262. {
  263. zval *ret = EX_VAR(var);
  264. if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
  265. if (type == BP_VAR_W) {
  266. ZVAL_NULL(ret);
  267. } else {
  268. return _get_zval_cv_lookup(ret, var, type EXECUTE_DATA_CC);
  269. }
  270. }
  271. return ret;
  272. }
  273. static zend_always_inline zval *_get_zval_ptr_cv_deref(uint32_t var, int type EXECUTE_DATA_DC)
  274. {
  275. zval *ret = EX_VAR(var);
  276. if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
  277. if (type == BP_VAR_W) {
  278. ZVAL_NULL(ret);
  279. return ret;
  280. } else {
  281. return _get_zval_cv_lookup(ret, var, type EXECUTE_DATA_CC);
  282. }
  283. }
  284. ZVAL_DEREF(ret);
  285. return ret;
  286. }
  287. static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_R(uint32_t var EXECUTE_DATA_DC)
  288. {
  289. zval *ret = EX_VAR(var);
  290. if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
  291. return zval_undefined_cv(var EXECUTE_DATA_CC);
  292. }
  293. return ret;
  294. }
  295. static zend_always_inline zval *_get_zval_ptr_cv_deref_BP_VAR_R(uint32_t var EXECUTE_DATA_DC)
  296. {
  297. zval *ret = EX_VAR(var);
  298. if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
  299. return zval_undefined_cv(var EXECUTE_DATA_CC);
  300. }
  301. ZVAL_DEREF(ret);
  302. return ret;
  303. }
  304. static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(uint32_t var EXECUTE_DATA_DC)
  305. {
  306. zval *ret = EX_VAR(var);
  307. return ret;
  308. }
  309. static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_RW(uint32_t var EXECUTE_DATA_DC)
  310. {
  311. zval *ret = EX_VAR(var);
  312. if (UNEXPECTED(Z_TYPE_P(ret) == IS_UNDEF)) {
  313. ZVAL_NULL(ret);
  314. zval_undefined_cv(var EXECUTE_DATA_CC);
  315. return ret;
  316. }
  317. return ret;
  318. }
  319. static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(uint32_t var EXECUTE_DATA_DC)
  320. {
  321. zval *ret = EX_VAR(var);
  322. if (Z_TYPE_P(ret) == IS_UNDEF) {
  323. ZVAL_NULL(ret);
  324. }
  325. return ret;
  326. }
  327. static zend_always_inline zval *_get_zval_ptr(int op_type, znode_op node, int type EXECUTE_DATA_DC OPLINE_DC)
  328. {
  329. if (op_type & (IS_TMP_VAR|IS_VAR)) {
  330. if (!ZEND_DEBUG || op_type == IS_VAR) {
  331. return _get_zval_ptr_var(node.var EXECUTE_DATA_CC);
  332. } else {
  333. ZEND_ASSERT(op_type == IS_TMP_VAR);
  334. return _get_zval_ptr_tmp(node.var EXECUTE_DATA_CC);
  335. }
  336. } else {
  337. if (op_type == IS_CONST) {
  338. return RT_CONSTANT(opline, node);
  339. } else if (op_type == IS_CV) {
  340. return _get_zval_ptr_cv(node.var, type EXECUTE_DATA_CC);
  341. } else {
  342. return NULL;
  343. }
  344. }
  345. }
  346. static zend_always_inline zval *_get_op_data_zval_ptr_r(int op_type, znode_op node EXECUTE_DATA_DC OPLINE_DC)
  347. {
  348. if (op_type & (IS_TMP_VAR|IS_VAR)) {
  349. if (!ZEND_DEBUG || op_type == IS_VAR) {
  350. return _get_zval_ptr_var(node.var EXECUTE_DATA_CC);
  351. } else {
  352. ZEND_ASSERT(op_type == IS_TMP_VAR);
  353. return _get_zval_ptr_tmp(node.var EXECUTE_DATA_CC);
  354. }
  355. } else {
  356. if (op_type == IS_CONST) {
  357. return RT_CONSTANT(opline + 1, node);
  358. } else if (op_type == IS_CV) {
  359. return _get_zval_ptr_cv_BP_VAR_R(node.var EXECUTE_DATA_CC);
  360. } else {
  361. return NULL;
  362. }
  363. }
  364. }
  365. static zend_always_inline ZEND_ATTRIBUTE_UNUSED zval *_get_zval_ptr_deref(int op_type, znode_op node, int type EXECUTE_DATA_DC OPLINE_DC)
  366. {
  367. if (op_type & (IS_TMP_VAR|IS_VAR)) {
  368. if (op_type == IS_TMP_VAR) {
  369. return _get_zval_ptr_tmp(node.var EXECUTE_DATA_CC);
  370. } else {
  371. ZEND_ASSERT(op_type == IS_VAR);
  372. return _get_zval_ptr_var_deref(node.var EXECUTE_DATA_CC);
  373. }
  374. } else {
  375. if (op_type == IS_CONST) {
  376. return RT_CONSTANT(opline, node);
  377. } else if (op_type == IS_CV) {
  378. return _get_zval_ptr_cv_deref(node.var, type EXECUTE_DATA_CC);
  379. } else {
  380. return NULL;
  381. }
  382. }
  383. }
  384. static zend_always_inline ZEND_ATTRIBUTE_UNUSED zval *_get_op_data_zval_ptr_deref_r(int op_type, znode_op node EXECUTE_DATA_DC OPLINE_DC)
  385. {
  386. if (op_type & (IS_TMP_VAR|IS_VAR)) {
  387. if (op_type == IS_TMP_VAR) {
  388. return _get_zval_ptr_tmp(node.var EXECUTE_DATA_CC);
  389. } else {
  390. ZEND_ASSERT(op_type == IS_VAR);
  391. return _get_zval_ptr_var_deref(node.var EXECUTE_DATA_CC);
  392. }
  393. } else {
  394. if (op_type == IS_CONST) {
  395. return RT_CONSTANT(opline + 1, node);
  396. } else if (op_type == IS_CV) {
  397. return _get_zval_ptr_cv_deref_BP_VAR_R(node.var EXECUTE_DATA_CC);
  398. } else {
  399. return NULL;
  400. }
  401. }
  402. }
  403. static zend_always_inline zval *_get_zval_ptr_undef(int op_type, znode_op node, int type EXECUTE_DATA_DC OPLINE_DC)
  404. {
  405. if (op_type & (IS_TMP_VAR|IS_VAR)) {
  406. if (!ZEND_DEBUG || op_type == IS_VAR) {
  407. return _get_zval_ptr_var(node.var EXECUTE_DATA_CC);
  408. } else {
  409. ZEND_ASSERT(op_type == IS_TMP_VAR);
  410. return _get_zval_ptr_tmp(node.var EXECUTE_DATA_CC);
  411. }
  412. } else {
  413. if (op_type == IS_CONST) {
  414. return RT_CONSTANT(opline, node);
  415. } else if (op_type == IS_CV) {
  416. return EX_VAR(node.var);
  417. } else {
  418. return NULL;
  419. }
  420. }
  421. }
  422. static zend_always_inline zval *_get_zval_ptr_ptr_var(uint32_t var EXECUTE_DATA_DC)
  423. {
  424. zval *ret = EX_VAR(var);
  425. if (EXPECTED(Z_TYPE_P(ret) == IS_INDIRECT)) {
  426. ret = Z_INDIRECT_P(ret);
  427. }
  428. return ret;
  429. }
  430. static inline zval *_get_zval_ptr_ptr(int op_type, znode_op node, int type EXECUTE_DATA_DC)
  431. {
  432. if (op_type == IS_CV) {
  433. return _get_zval_ptr_cv(node.var, type EXECUTE_DATA_CC);
  434. } else /* if (op_type == IS_VAR) */ {
  435. ZEND_ASSERT(op_type == IS_VAR);
  436. return _get_zval_ptr_ptr_var(node.var EXECUTE_DATA_CC);
  437. }
  438. }
  439. static inline ZEND_ATTRIBUTE_UNUSED zval *_get_obj_zval_ptr(int op_type, znode_op op, int type EXECUTE_DATA_DC OPLINE_DC)
  440. {
  441. if (op_type == IS_UNUSED) {
  442. return &EX(This);
  443. }
  444. return get_zval_ptr(op_type, op, type);
  445. }
  446. static inline ZEND_ATTRIBUTE_UNUSED zval *_get_obj_zval_ptr_undef(int op_type, znode_op op, int type EXECUTE_DATA_DC OPLINE_DC)
  447. {
  448. if (op_type == IS_UNUSED) {
  449. return &EX(This);
  450. }
  451. return get_zval_ptr_undef(op_type, op, type);
  452. }
  453. static inline ZEND_ATTRIBUTE_UNUSED zval *_get_obj_zval_ptr_ptr(int op_type, znode_op node, int type EXECUTE_DATA_DC)
  454. {
  455. if (op_type == IS_UNUSED) {
  456. return &EX(This);
  457. }
  458. return get_zval_ptr_ptr(op_type, node, type);
  459. }
  460. static inline void zend_assign_to_variable_reference(zval *variable_ptr, zval *value_ptr)
  461. {
  462. zend_reference *ref;
  463. if (EXPECTED(!Z_ISREF_P(value_ptr))) {
  464. ZVAL_NEW_REF(value_ptr, value_ptr);
  465. } else if (UNEXPECTED(variable_ptr == value_ptr)) {
  466. return;
  467. }
  468. ref = Z_REF_P(value_ptr);
  469. GC_ADDREF(ref);
  470. if (Z_REFCOUNTED_P(variable_ptr)) {
  471. zend_refcounted *garbage = Z_COUNTED_P(variable_ptr);
  472. if (GC_DELREF(garbage) == 0) {
  473. ZVAL_REF(variable_ptr, ref);
  474. rc_dtor_func(garbage);
  475. return;
  476. } else {
  477. gc_check_possible_root(garbage);
  478. }
  479. }
  480. ZVAL_REF(variable_ptr, ref);
  481. }
  482. static zend_never_inline zval* zend_assign_to_typed_property_reference(zend_property_info *prop_info, zval *prop, zval *value_ptr EXECUTE_DATA_DC)
  483. {
  484. if (!zend_verify_prop_assignable_by_ref(prop_info, value_ptr, EX_USES_STRICT_TYPES())) {
  485. return &EG(uninitialized_zval);
  486. }
  487. if (Z_ISREF_P(prop)) {
  488. ZEND_REF_DEL_TYPE_SOURCE(Z_REF_P(prop), prop_info);
  489. }
  490. zend_assign_to_variable_reference(prop, value_ptr);
  491. ZEND_REF_ADD_TYPE_SOURCE(Z_REF_P(prop), prop_info);
  492. return prop;
  493. }
  494. static zend_never_inline ZEND_COLD int zend_wrong_assign_to_variable_reference(zval *variable_ptr, zval *value_ptr OPLINE_DC EXECUTE_DATA_DC)
  495. {
  496. zend_error(E_NOTICE, "Only variables should be assigned by reference");
  497. if (UNEXPECTED(EG(exception) != NULL)) {
  498. return 0;
  499. }
  500. /* Use IS_TMP_VAR instead of IS_VAR to avoid ISREF check */
  501. Z_TRY_ADDREF_P(value_ptr);
  502. value_ptr = zend_assign_to_variable(variable_ptr, value_ptr, IS_TMP_VAR, EX_USES_STRICT_TYPES());
  503. return 1;
  504. }
  505. static zend_never_inline ZEND_COLD void zend_throw_auto_init_in_prop_error(zend_property_info *prop, const char *type) {
  506. zend_string *type_str = zend_type_to_string(prop->type);
  507. zend_type_error(
  508. "Cannot auto-initialize an %s inside property %s::$%s of type %s",
  509. type,
  510. ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name),
  511. ZSTR_VAL(type_str)
  512. );
  513. zend_string_release(type_str);
  514. }
  515. static zend_never_inline ZEND_COLD void zend_throw_auto_init_in_ref_error(zend_property_info *prop, const char *type) {
  516. zend_string *type_str = zend_type_to_string(prop->type);
  517. zend_type_error(
  518. "Cannot auto-initialize an %s inside a reference held by property %s::$%s of type %s",
  519. type,
  520. ZSTR_VAL(prop->ce->name), zend_get_unmangled_property_name(prop->name),
  521. ZSTR_VAL(type_str)
  522. );
  523. zend_string_release(type_str);
  524. }
  525. static zend_never_inline ZEND_COLD void zend_throw_access_uninit_prop_by_ref_error(
  526. zend_property_info *prop) {
  527. zend_throw_error(NULL,
  528. "Cannot access uninitialized non-nullable property %s::$%s by reference",
  529. ZSTR_VAL(prop->ce->name),
  530. zend_get_unmangled_property_name(prop->name));
  531. }
  532. /* this should modify object only if it's empty */
  533. static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_throw_non_object_error(zval *object, zval *property OPLINE_DC EXECUTE_DATA_DC)
  534. {
  535. zend_string *tmp_property_name;
  536. zend_string *property_name = zval_get_tmp_string(property, &tmp_property_name);
  537. if (opline->opcode == ZEND_PRE_INC_OBJ
  538. || opline->opcode == ZEND_PRE_DEC_OBJ
  539. || opline->opcode == ZEND_POST_INC_OBJ
  540. || opline->opcode == ZEND_POST_DEC_OBJ) {
  541. zend_throw_error(NULL,
  542. "Attempt to increment/decrement property '%s' of non-object",
  543. ZSTR_VAL(property_name));
  544. } else if (opline->opcode == ZEND_FETCH_OBJ_W
  545. || opline->opcode == ZEND_FETCH_OBJ_RW
  546. || opline->opcode == ZEND_FETCH_OBJ_FUNC_ARG
  547. || opline->opcode == ZEND_ASSIGN_OBJ_REF) {
  548. zend_throw_error(NULL,
  549. "Attempt to modify property '%s' of non-object", ZSTR_VAL(property_name));
  550. } else {
  551. zend_throw_error(NULL,
  552. "Attempt to assign property '%s' of non-object", ZSTR_VAL(property_name));
  553. }
  554. zend_tmp_string_release(tmp_property_name);
  555. if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
  556. ZVAL_NULL(EX_VAR(opline->result.var));
  557. }
  558. }
  559. static ZEND_COLD void zend_verify_type_error_common(
  560. const zend_function *zf, const zend_arg_info *arg_info,
  561. void **cache_slot, zval *value,
  562. const char **fname, const char **fsep, const char **fclass,
  563. zend_string **need_msg, const char **given_kind)
  564. {
  565. *fname = ZSTR_VAL(zf->common.function_name);
  566. if (zf->common.scope) {
  567. *fsep = "::";
  568. *fclass = ZSTR_VAL(zf->common.scope->name);
  569. } else {
  570. *fsep = "";
  571. *fclass = "";
  572. }
  573. *need_msg = zend_type_to_string_resolved(arg_info->type, zf->common.scope);
  574. if (value) {
  575. zend_bool has_class = ZEND_TYPE_HAS_CLASS(arg_info->type)
  576. || (ZEND_TYPE_FULL_MASK(arg_info->type) & MAY_BE_STATIC);
  577. if (has_class && Z_TYPE_P(value) == IS_OBJECT) {
  578. *given_kind = ZSTR_VAL(Z_OBJCE_P(value)->name);
  579. } else {
  580. *given_kind = zend_zval_type_name(value);
  581. }
  582. } else {
  583. *given_kind = "none";
  584. }
  585. }
  586. ZEND_API ZEND_COLD void zend_verify_arg_error(
  587. const zend_function *zf, const zend_arg_info *arg_info,
  588. int arg_num, void **cache_slot, zval *value)
  589. {
  590. zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data;
  591. const char *fname, *fsep, *fclass;
  592. zend_string *need_msg;
  593. const char *given_msg;
  594. if (EG(exception)) {
  595. /* The type verification itself might have already thrown an exception
  596. * through a promoted warning. */
  597. return;
  598. }
  599. if (value) {
  600. zend_verify_type_error_common(
  601. zf, arg_info, cache_slot, value,
  602. &fname, &fsep, &fclass, &need_msg, &given_msg);
  603. if (zf->common.type == ZEND_USER_FUNCTION) {
  604. if (ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) {
  605. zend_type_error("%s%s%s(): Argument #%d ($%s) must be of type %s, %s given, called in %s on line %d",
  606. fclass, fsep, fname,
  607. arg_num, ZSTR_VAL(arg_info->name),
  608. ZSTR_VAL(need_msg), given_msg,
  609. ZSTR_VAL(ptr->func->op_array.filename), ptr->opline->lineno
  610. );
  611. } else {
  612. zend_type_error("%s%s%s(): Argument #%d ($%s) must be of type %s, %s given",
  613. fclass, fsep, fname, arg_num, ZSTR_VAL(arg_info->name), ZSTR_VAL(need_msg), given_msg
  614. );
  615. }
  616. } else {
  617. zend_type_error("%s%s%s(): Argument #%d ($%s) must be of type %s, %s given",
  618. fclass, fsep, fname, arg_num, ((zend_internal_arg_info*) arg_info)->name, ZSTR_VAL(need_msg), given_msg
  619. );
  620. }
  621. zend_string_release(need_msg);
  622. } else {
  623. zend_missing_arg_error(ptr);
  624. }
  625. }
  626. static zend_bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg)
  627. {
  628. zend_long lval;
  629. double dval;
  630. zend_string *str;
  631. zend_bool bval;
  632. /* Type preference order: int -> float -> string -> bool */
  633. if (type_mask & MAY_BE_LONG) {
  634. /* For an int|float union type and string value,
  635. * determine chosen type by is_numeric_string() semantics. */
  636. if ((type_mask & MAY_BE_DOUBLE) && Z_TYPE_P(arg) == IS_STRING) {
  637. zend_uchar type = is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), &lval, &dval, -1);
  638. if (type == IS_LONG) {
  639. zend_string_release(Z_STR_P(arg));
  640. ZVAL_LONG(arg, lval);
  641. return 1;
  642. }
  643. if (type == IS_DOUBLE) {
  644. zend_string_release(Z_STR_P(arg));
  645. ZVAL_DOUBLE(arg, dval);
  646. return 1;
  647. }
  648. } else if (zend_parse_arg_long_weak(arg, &lval)) {
  649. zval_ptr_dtor(arg);
  650. ZVAL_LONG(arg, lval);
  651. return 1;
  652. }
  653. }
  654. if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval)) {
  655. zval_ptr_dtor(arg);
  656. ZVAL_DOUBLE(arg, dval);
  657. return 1;
  658. }
  659. if ((type_mask & MAY_BE_STRING) && zend_parse_arg_str_weak(arg, &str)) {
  660. /* on success "arg" is converted to IS_STRING */
  661. return 1;
  662. }
  663. if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval)) {
  664. zval_ptr_dtor(arg);
  665. ZVAL_BOOL(arg, bval);
  666. return 1;
  667. }
  668. return 0;
  669. }
  670. #if ZEND_DEBUG
  671. /* Used to sanity-check internal arginfo types without performing any actual type conversions. */
  672. static zend_bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_mask, zval *arg)
  673. {
  674. zend_long lval;
  675. double dval;
  676. zend_bool bval;
  677. if (type_mask & MAY_BE_LONG) {
  678. if (Z_TYPE_P(arg) == IS_STRING) {
  679. /* Handle this case separately to avoid the "non well-formed" warning */
  680. zend_uchar type = is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), NULL, &dval, 1);
  681. if (type == IS_LONG) {
  682. return 1;
  683. }
  684. if (type == IS_DOUBLE) {
  685. if ((type_mask & MAY_BE_DOUBLE)
  686. || (!zend_isnan(dval) && ZEND_DOUBLE_FITS_LONG(dval))) {
  687. return 1;
  688. }
  689. }
  690. }
  691. if (zend_parse_arg_long_weak(arg, &lval)) {
  692. return 1;
  693. }
  694. }
  695. if (type_mask & MAY_BE_DOUBLE) {
  696. if (Z_TYPE_P(arg) == IS_STRING) {
  697. /* Handle this case separately to avoid the "non well-formed" warning */
  698. if (is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), NULL, NULL, 1) != 0) {
  699. return 1;
  700. }
  701. }
  702. if (zend_parse_arg_double_weak(arg, &dval)) {
  703. return 1;
  704. }
  705. }
  706. /* We don't call cast_object here, because this check must be side-effect free. As this
  707. * is only used for a sanity check of arginfo/zpp consistency, it's okay if we accept
  708. * more than actually allowed here. */
  709. if ((type_mask & MAY_BE_STRING) && (Z_TYPE_P(arg) < IS_STRING || Z_TYPE_P(arg) == IS_OBJECT)) {
  710. return 1;
  711. }
  712. if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval)) {
  713. return 1;
  714. }
  715. return 0;
  716. }
  717. #endif
  718. ZEND_API zend_bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, zend_bool strict, zend_bool is_internal_arg)
  719. {
  720. if (UNEXPECTED(strict)) {
  721. /* SSTH Exception: IS_LONG may be accepted as IS_DOUBLE (converted) */
  722. if (!(type_mask & MAY_BE_DOUBLE) || Z_TYPE_P(arg) != IS_LONG) {
  723. return 0;
  724. }
  725. } else if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
  726. /* NULL may be accepted only by nullable hints (this is already checked).
  727. * As an exception for internal functions, null is allowed for scalar types in weak mode. */
  728. return is_internal_arg
  729. && (type_mask & (MAY_BE_TRUE|MAY_BE_FALSE|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_STRING));
  730. }
  731. #if ZEND_DEBUG
  732. if (is_internal_arg) {
  733. return zend_verify_weak_scalar_type_hint_no_sideeffect(type_mask, arg);
  734. }
  735. #endif
  736. return zend_verify_weak_scalar_type_hint(type_mask, arg);
  737. }
  738. ZEND_COLD zend_never_inline void zend_verify_property_type_error(zend_property_info *info, zval *property)
  739. {
  740. zend_string *type_str;
  741. /* we _may_ land here in case reading already errored and runtime cache thus has not been updated (i.e. it contains a valid but unrelated info) */
  742. if (EG(exception)) {
  743. return;
  744. }
  745. type_str = zend_type_to_string(info->type);
  746. zend_type_error("Cannot assign %s to property %s::$%s of type %s",
  747. Z_TYPE_P(property) == IS_OBJECT ? ZSTR_VAL(Z_OBJCE_P(property)->name) : zend_get_type_by_const(Z_TYPE_P(property)),
  748. ZSTR_VAL(info->ce->name),
  749. zend_get_unmangled_property_name(info->name),
  750. ZSTR_VAL(type_str));
  751. zend_string_release(type_str);
  752. }
  753. static zend_class_entry *resolve_single_class_type(zend_string *name, zend_class_entry *self_ce) {
  754. if (zend_string_equals_literal_ci(name, "self")) {
  755. /* We need to explicitly check for this here, to avoid updating the type in the trait and
  756. * later using the wrong "self" when the trait is used in a class. */
  757. if (UNEXPECTED((self_ce->ce_flags & ZEND_ACC_TRAIT) != 0)) {
  758. return NULL;
  759. }
  760. return self_ce;
  761. } else if (zend_string_equals_literal_ci(name, "parent")) {
  762. return self_ce->parent;
  763. } else {
  764. return zend_lookup_class_ex(name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
  765. }
  766. }
  767. static zend_bool zend_check_and_resolve_property_class_type(
  768. zend_property_info *info, zend_class_entry *object_ce) {
  769. zend_class_entry *ce;
  770. if (ZEND_TYPE_HAS_LIST(info->type)) {
  771. zend_type *list_type;
  772. ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(info->type), list_type) {
  773. if (ZEND_TYPE_HAS_NAME(*list_type)) {
  774. zend_string *name = ZEND_TYPE_NAME(*list_type);
  775. ce = resolve_single_class_type(name, info->ce);
  776. if (!ce) {
  777. continue;
  778. }
  779. zend_string_release(name);
  780. ZEND_TYPE_SET_CE(*list_type, ce);
  781. } else {
  782. ce = ZEND_TYPE_CE(*list_type);
  783. }
  784. if (instanceof_function(object_ce, ce)) {
  785. return 1;
  786. }
  787. } ZEND_TYPE_LIST_FOREACH_END();
  788. return 0;
  789. } else {
  790. if (UNEXPECTED(ZEND_TYPE_HAS_NAME(info->type))) {
  791. zend_string *name = ZEND_TYPE_NAME(info->type);
  792. ce = resolve_single_class_type(name, info->ce);
  793. if (UNEXPECTED(!ce)) {
  794. return 0;
  795. }
  796. zend_string_release(name);
  797. ZEND_TYPE_SET_CE(info->type, ce);
  798. } else {
  799. ce = ZEND_TYPE_CE(info->type);
  800. }
  801. return instanceof_function(object_ce, ce);
  802. }
  803. }
  804. static zend_always_inline zend_bool i_zend_check_property_type(zend_property_info *info, zval *property, zend_bool strict)
  805. {
  806. ZEND_ASSERT(!Z_ISREF_P(property));
  807. if (EXPECTED(ZEND_TYPE_CONTAINS_CODE(info->type, Z_TYPE_P(property)))) {
  808. return 1;
  809. }
  810. if (ZEND_TYPE_HAS_CLASS(info->type) && Z_TYPE_P(property) == IS_OBJECT
  811. && zend_check_and_resolve_property_class_type(info, Z_OBJCE_P(property))) {
  812. return 1;
  813. }
  814. uint32_t type_mask = ZEND_TYPE_FULL_MASK(info->type);
  815. ZEND_ASSERT(!(type_mask & (MAY_BE_CALLABLE|MAY_BE_STATIC)));
  816. if ((type_mask & MAY_BE_ITERABLE) && zend_is_iterable(property)) {
  817. return 1;
  818. }
  819. return zend_verify_scalar_type_hint(type_mask, property, strict, 0);
  820. }
  821. static zend_always_inline zend_bool i_zend_verify_property_type(zend_property_info *info, zval *property, zend_bool strict)
  822. {
  823. if (i_zend_check_property_type(info, property, strict)) {
  824. return 1;
  825. }
  826. zend_verify_property_type_error(info, property);
  827. return 0;
  828. }
  829. zend_bool zend_never_inline zend_verify_property_type(zend_property_info *info, zval *property, zend_bool strict) {
  830. return i_zend_verify_property_type(info, property, strict);
  831. }
  832. static zend_never_inline zval* zend_assign_to_typed_prop(zend_property_info *info, zval *property_val, zval *value EXECUTE_DATA_DC)
  833. {
  834. zval tmp;
  835. ZVAL_DEREF(value);
  836. ZVAL_COPY(&tmp, value);
  837. if (UNEXPECTED(!i_zend_verify_property_type(info, &tmp, EX_USES_STRICT_TYPES()))) {
  838. zval_ptr_dtor(&tmp);
  839. return &EG(uninitialized_zval);
  840. }
  841. return zend_assign_to_variable(property_val, &tmp, IS_TMP_VAR, EX_USES_STRICT_TYPES());
  842. }
  843. ZEND_API zend_bool zend_value_instanceof_static(zval *zv) {
  844. if (Z_TYPE_P(zv) != IS_OBJECT) {
  845. return 0;
  846. }
  847. zend_class_entry *called_scope = zend_get_called_scope(EG(current_execute_data));
  848. if (!called_scope) {
  849. return 0;
  850. }
  851. return instanceof_function(Z_OBJCE_P(zv), called_scope);
  852. }
  853. static zend_always_inline zend_bool zend_check_type_slow(
  854. zend_type type, zval *arg, zend_reference *ref, void **cache_slot, zend_class_entry *scope,
  855. zend_bool is_return_type, zend_bool is_internal)
  856. {
  857. uint32_t type_mask;
  858. if (ZEND_TYPE_HAS_CLASS(type) && Z_TYPE_P(arg) == IS_OBJECT) {
  859. zend_class_entry *ce;
  860. if (ZEND_TYPE_HAS_LIST(type)) {
  861. zend_type *list_type;
  862. ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(type), list_type) {
  863. if (*cache_slot) {
  864. ce = *cache_slot;
  865. } else {
  866. ce = zend_fetch_class(ZEND_TYPE_NAME(*list_type),
  867. (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD));
  868. if (!ce) {
  869. cache_slot++;
  870. continue;
  871. }
  872. *cache_slot = ce;
  873. }
  874. if (instanceof_function(Z_OBJCE_P(arg), ce)) {
  875. return 1;
  876. }
  877. cache_slot++;
  878. } ZEND_TYPE_LIST_FOREACH_END();
  879. } else {
  880. if (EXPECTED(*cache_slot)) {
  881. ce = (zend_class_entry *) *cache_slot;
  882. } else {
  883. ce = zend_fetch_class(ZEND_TYPE_NAME(type), (ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD));
  884. if (UNEXPECTED(!ce)) {
  885. goto builtin_types;
  886. }
  887. *cache_slot = (void *) ce;
  888. }
  889. if (instanceof_function(Z_OBJCE_P(arg), ce)) {
  890. return 1;
  891. }
  892. }
  893. }
  894. builtin_types:
  895. type_mask = ZEND_TYPE_FULL_MASK(type);
  896. if ((type_mask & MAY_BE_CALLABLE) && zend_is_callable(arg, 0, NULL)) {
  897. return 1;
  898. }
  899. if ((type_mask & MAY_BE_ITERABLE) && zend_is_iterable(arg)) {
  900. return 1;
  901. }
  902. if ((type_mask & MAY_BE_STATIC) && zend_value_instanceof_static(arg)) {
  903. return 1;
  904. }
  905. if (ref && ZEND_REF_HAS_TYPE_SOURCES(ref)) {
  906. /* We cannot have conversions for typed refs. */
  907. return 0;
  908. }
  909. if (is_internal && is_return_type) {
  910. /* For internal returns, the type has to match exactly, because we're not
  911. * going to check it for non-debug builds, and there will be no chance to
  912. * apply coercions. */
  913. return 0;
  914. }
  915. return zend_verify_scalar_type_hint(type_mask, arg,
  916. is_return_type ? ZEND_RET_USES_STRICT_TYPES() : ZEND_ARG_USES_STRICT_TYPES(),
  917. is_internal);
  918. /* Special handling for IS_VOID is not necessary (for return types),
  919. * because this case is already checked at compile-time. */
  920. }
  921. static zend_always_inline zend_bool zend_check_type(
  922. zend_type type, zval *arg, void **cache_slot, zend_class_entry *scope,
  923. zend_bool is_return_type, zend_bool is_internal)
  924. {
  925. zend_reference *ref = NULL;
  926. ZEND_ASSERT(ZEND_TYPE_IS_SET(type));
  927. if (UNEXPECTED(Z_ISREF_P(arg))) {
  928. ref = Z_REF_P(arg);
  929. arg = Z_REFVAL_P(arg);
  930. }
  931. if (EXPECTED(ZEND_TYPE_CONTAINS_CODE(type, Z_TYPE_P(arg)))) {
  932. return 1;
  933. }
  934. return zend_check_type_slow(type, arg, ref, cache_slot, scope, is_return_type, is_internal);
  935. }
  936. static zend_always_inline int zend_verify_recv_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, void **cache_slot)
  937. {
  938. zend_arg_info *cur_arg_info;
  939. ZEND_ASSERT(arg_num <= zf->common.num_args);
  940. cur_arg_info = &zf->common.arg_info[arg_num-1];
  941. if (ZEND_TYPE_IS_SET(cur_arg_info->type)
  942. && UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, cache_slot, zf->common.scope, 0, 0))) {
  943. zend_verify_arg_error(zf, cur_arg_info, arg_num, cache_slot, arg);
  944. return 0;
  945. }
  946. return 1;
  947. }
  948. static zend_always_inline int zend_verify_variadic_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, void **cache_slot)
  949. {
  950. zend_arg_info *cur_arg_info;
  951. ZEND_ASSERT(arg_num > zf->common.num_args);
  952. ZEND_ASSERT(zf->common.fn_flags & ZEND_ACC_VARIADIC);
  953. cur_arg_info = &zf->common.arg_info[zf->common.num_args];
  954. if (ZEND_TYPE_IS_SET(cur_arg_info->type)
  955. && UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, cache_slot, zf->common.scope, 0, 0))) {
  956. zend_verify_arg_error(zf, cur_arg_info, arg_num, cache_slot, arg);
  957. return 0;
  958. }
  959. return 1;
  960. }
  961. static zend_never_inline ZEND_ATTRIBUTE_UNUSED int zend_verify_internal_arg_types(zend_function *fbc, zend_execute_data *call)
  962. {
  963. uint32_t i;
  964. uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
  965. zval *arg = ZEND_CALL_ARG(call, 1);
  966. for (i = 0; i < num_args; ++i) {
  967. zend_arg_info *cur_arg_info;
  968. void *dummy_cache_slot = NULL;
  969. if (EXPECTED(i < fbc->common.num_args)) {
  970. cur_arg_info = &fbc->common.arg_info[i];
  971. } else if (UNEXPECTED(fbc->common.fn_flags & ZEND_ACC_VARIADIC)) {
  972. cur_arg_info = &fbc->common.arg_info[fbc->common.num_args];
  973. } else {
  974. break;
  975. }
  976. if (ZEND_TYPE_IS_SET(cur_arg_info->type)
  977. && UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, &dummy_cache_slot, fbc->common.scope, 0, /* is_internal */ 1))) {
  978. return 0;
  979. }
  980. arg++;
  981. }
  982. return 1;
  983. }
  984. #if ZEND_DEBUG
  985. /* Determine whether an internal call should throw, because the passed arguments violate
  986. * an arginfo constraint. This is only checked in debug builds. In release builds, we
  987. * trust that arginfo matches what is enforced by zend_parse_parameters. */
  988. static zend_always_inline zend_bool zend_internal_call_should_throw(zend_function *fbc, zend_execute_data *call)
  989. {
  990. if (fbc->common.required_num_args > ZEND_CALL_NUM_ARGS(call)) {
  991. return 1;
  992. }
  993. if ((fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) &&
  994. !zend_verify_internal_arg_types(fbc, call)) {
  995. return 1;
  996. }
  997. return 0;
  998. }
  999. static ZEND_COLD void zend_internal_call_arginfo_violation(zend_function *fbc)
  1000. {
  1001. zend_error(E_CORE_ERROR, "Arginfo / zpp mismatch during call of %s%s%s()",
  1002. fbc->common.scope ? ZSTR_VAL(fbc->common.scope->name) : "",
  1003. fbc->common.scope ? "::" : "",
  1004. ZSTR_VAL(fbc->common.function_name));
  1005. }
  1006. #endif
  1007. ZEND_API ZEND_COLD void ZEND_FASTCALL zend_missing_arg_error(zend_execute_data *execute_data)
  1008. {
  1009. zend_execute_data *ptr = EX(prev_execute_data);
  1010. if (ptr && ptr->func && ZEND_USER_CODE(ptr->func->common.type)) {
  1011. zend_throw_error(zend_ce_argument_count_error, "Too few arguments to function %s%s%s(), %d passed in %s on line %d and %s %d expected",
  1012. EX(func)->common.scope ? ZSTR_VAL(EX(func)->common.scope->name) : "",
  1013. EX(func)->common.scope ? "::" : "",
  1014. ZSTR_VAL(EX(func)->common.function_name),
  1015. EX_NUM_ARGS(),
  1016. ZSTR_VAL(ptr->func->op_array.filename),
  1017. ptr->opline->lineno,
  1018. EX(func)->common.required_num_args == EX(func)->common.num_args ? "exactly" : "at least",
  1019. EX(func)->common.required_num_args);
  1020. } else {
  1021. zend_throw_error(zend_ce_argument_count_error, "Too few arguments to function %s%s%s(), %d passed and %s %d expected",
  1022. EX(func)->common.scope ? ZSTR_VAL(EX(func)->common.scope->name) : "",
  1023. EX(func)->common.scope ? "::" : "",
  1024. ZSTR_VAL(EX(func)->common.function_name),
  1025. EX_NUM_ARGS(),
  1026. EX(func)->common.required_num_args == EX(func)->common.num_args ? "exactly" : "at least",
  1027. EX(func)->common.required_num_args);
  1028. }
  1029. }
  1030. ZEND_API ZEND_COLD void zend_verify_return_error(
  1031. const zend_function *zf, void **cache_slot, zval *value)
  1032. {
  1033. const zend_arg_info *arg_info = &zf->common.arg_info[-1];
  1034. const char *fname, *fsep, *fclass;
  1035. zend_string *need_msg;
  1036. const char *given_msg;
  1037. zend_verify_type_error_common(
  1038. zf, arg_info, cache_slot, value,
  1039. &fname, &fsep, &fclass, &need_msg, &given_msg);
  1040. zend_type_error("Return value of %s%s%s() must be of type %s, %s returned",
  1041. fclass, fsep, fname, ZSTR_VAL(need_msg), given_msg);
  1042. zend_string_release(need_msg);
  1043. }
  1044. #if ZEND_DEBUG
  1045. static ZEND_COLD void zend_verify_internal_return_error(
  1046. const zend_function *zf, void **cache_slot, zval *value)
  1047. {
  1048. const zend_arg_info *arg_info = &zf->common.arg_info[-1];
  1049. const char *fname, *fsep, *fclass;
  1050. zend_string *need_msg;
  1051. const char *given_msg;
  1052. zend_verify_type_error_common(
  1053. zf, arg_info, cache_slot, value,
  1054. &fname, &fsep, &fclass, &need_msg, &given_msg);
  1055. zend_error_noreturn(E_CORE_ERROR, "Return value of %s%s%s() must be of type %s, %s returned",
  1056. fclass, fsep, fname, ZSTR_VAL(need_msg), given_msg);
  1057. }
  1058. static ZEND_COLD void zend_verify_void_return_error(const zend_function *zf, const char *returned_msg, const char *returned_kind)
  1059. {
  1060. const char *fname = ZSTR_VAL(zf->common.function_name);
  1061. const char *fsep;
  1062. const char *fclass;
  1063. if (zf->common.scope) {
  1064. fsep = "::";
  1065. fclass = ZSTR_VAL(zf->common.scope->name);
  1066. } else {
  1067. fsep = "";
  1068. fclass = "";
  1069. }
  1070. zend_type_error("%s%s%s() must not return a value, %s%s returned",
  1071. fclass, fsep, fname, returned_msg, returned_kind);
  1072. }
  1073. static int zend_verify_internal_return_type(zend_function *zf, zval *ret)
  1074. {
  1075. zend_internal_arg_info *ret_info = zf->internal_function.arg_info - 1;
  1076. void *dummy_cache_slot = NULL;
  1077. if (ZEND_TYPE_FULL_MASK(ret_info->type) & MAY_BE_VOID) {
  1078. if (UNEXPECTED(Z_TYPE_P(ret) != IS_NULL)) {
  1079. zend_verify_void_return_error(zf, zend_zval_type_name(ret), "");
  1080. return 0;
  1081. }
  1082. return 1;
  1083. }
  1084. if (UNEXPECTED(!zend_check_type(ret_info->type, ret, &dummy_cache_slot, NULL, 1, /* is_internal */ 1))) {
  1085. zend_verify_internal_return_error(zf, &dummy_cache_slot, ret);
  1086. return 0;
  1087. }
  1088. return 1;
  1089. }
  1090. #endif
  1091. static ZEND_COLD int zend_verify_missing_return_type(const zend_function *zf, void **cache_slot)
  1092. {
  1093. /* VERIFY_RETURN_TYPE is not emitted for "void" functions, so this is always an error. */
  1094. zend_verify_return_error(zf, cache_slot, NULL);
  1095. return 0;
  1096. }
  1097. static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(void)
  1098. {
  1099. zend_throw_error(NULL, "Cannot use object as array");
  1100. }
  1101. static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_illegal_offset(void)
  1102. {
  1103. zend_type_error("Illegal offset type");
  1104. }
  1105. static zend_never_inline void zend_assign_to_object_dim(zval *object, zval *dim, zval *value OPLINE_DC EXECUTE_DATA_DC)
  1106. {
  1107. Z_OBJ_HT_P(object)->write_dimension(Z_OBJ_P(object), dim, value);
  1108. if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
  1109. ZVAL_COPY(EX_VAR(opline->result.var), value);
  1110. }
  1111. }
  1112. static zend_always_inline int zend_binary_op(zval *ret, zval *op1, zval *op2 OPLINE_DC)
  1113. {
  1114. static const binary_op_type zend_binary_ops[] = {
  1115. add_function,
  1116. sub_function,
  1117. mul_function,
  1118. div_function,
  1119. mod_function,
  1120. shift_left_function,
  1121. shift_right_function,
  1122. concat_function,
  1123. bitwise_or_function,
  1124. bitwise_and_function,
  1125. bitwise_xor_function,
  1126. pow_function
  1127. };
  1128. /* size_t cast makes GCC to better optimize 64-bit PIC code */
  1129. size_t opcode = (size_t)opline->extended_value;
  1130. return zend_binary_ops[opcode - ZEND_ADD](ret, op1, op2);
  1131. }
  1132. static zend_never_inline void zend_binary_assign_op_obj_dim(zval *object, zval *property OPLINE_DC EXECUTE_DATA_DC)
  1133. {
  1134. zval *value;
  1135. zval *z;
  1136. zval rv, res;
  1137. value = get_op_data_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1);
  1138. if ((z = Z_OBJ_HT_P(object)->read_dimension(Z_OBJ_P(object), property, BP_VAR_R, &rv)) != NULL) {
  1139. if (zend_binary_op(&res, z, value OPLINE_CC) == SUCCESS) {
  1140. Z_OBJ_HT_P(object)->write_dimension(Z_OBJ_P(object), property, &res);
  1141. }
  1142. if (z == &rv) {
  1143. zval_ptr_dtor(&rv);
  1144. }
  1145. if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
  1146. ZVAL_COPY(EX_VAR(opline->result.var), &res);
  1147. }
  1148. zval_ptr_dtor(&res);
  1149. } else {
  1150. zend_use_object_as_array();
  1151. if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
  1152. ZVAL_NULL(EX_VAR(opline->result.var));
  1153. }
  1154. }
  1155. FREE_OP((opline+1)->op1_type, (opline+1)->op1.var);
  1156. }
  1157. static zend_never_inline void zend_binary_assign_op_typed_ref(zend_reference *ref, zval *value OPLINE_DC EXECUTE_DATA_DC)
  1158. {
  1159. zval z_copy;
  1160. zend_binary_op(&z_copy, &ref->val, value OPLINE_CC);
  1161. if (EXPECTED(zend_verify_ref_assignable_zval(ref, &z_copy, EX_USES_STRICT_TYPES()))) {
  1162. zval_ptr_dtor(&ref->val);
  1163. ZVAL_COPY_VALUE(&ref->val, &z_copy);
  1164. } else {
  1165. zval_ptr_dtor(&z_copy);
  1166. }
  1167. }
  1168. static zend_never_inline void zend_binary_assign_op_typed_prop(zend_property_info *prop_info, zval *zptr, zval *value OPLINE_DC EXECUTE_DATA_DC)
  1169. {
  1170. zval z_copy;
  1171. zend_binary_op(&z_copy, zptr, value OPLINE_CC);
  1172. if (EXPECTED(zend_verify_property_type(prop_info, &z_copy, EX_USES_STRICT_TYPES()))) {
  1173. zval_ptr_dtor(zptr);
  1174. ZVAL_COPY_VALUE(zptr, &z_copy);
  1175. } else {
  1176. zval_ptr_dtor(&z_copy);
  1177. }
  1178. }
  1179. static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type EXECUTE_DATA_DC)
  1180. {
  1181. zend_long offset;
  1182. try_again:
  1183. if (UNEXPECTED(Z_TYPE_P(dim) != IS_LONG)) {
  1184. switch(Z_TYPE_P(dim)) {
  1185. case IS_STRING:
  1186. if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) {
  1187. break;
  1188. }
  1189. if (type != BP_VAR_UNSET) {
  1190. zend_error(E_WARNING, "Illegal string offset '%s'", Z_STRVAL_P(dim));
  1191. }
  1192. break;
  1193. case IS_UNDEF:
  1194. ZVAL_UNDEFINED_OP2();
  1195. case IS_DOUBLE:
  1196. case IS_NULL:
  1197. case IS_FALSE:
  1198. case IS_TRUE:
  1199. zend_error(E_WARNING, "String offset cast occurred");
  1200. break;
  1201. case IS_REFERENCE:
  1202. dim = Z_REFVAL_P(dim);
  1203. goto try_again;
  1204. default:
  1205. zend_illegal_offset();
  1206. break;
  1207. }
  1208. offset = zval_get_long_func(dim);
  1209. } else {
  1210. offset = Z_LVAL_P(dim);
  1211. }
  1212. return offset;
  1213. }
  1214. static zend_never_inline ZEND_COLD void zend_wrong_string_offset(EXECUTE_DATA_D)
  1215. {
  1216. const char *msg = NULL;
  1217. const zend_op *opline = EX(opline);
  1218. const zend_op *end;
  1219. uint32_t var;
  1220. if (UNEXPECTED(EG(exception) != NULL)) {
  1221. return;
  1222. }
  1223. switch (opline->opcode) {
  1224. case ZEND_ASSIGN_OP:
  1225. case ZEND_ASSIGN_DIM_OP:
  1226. case ZEND_ASSIGN_OBJ_OP:
  1227. case ZEND_ASSIGN_STATIC_PROP_OP:
  1228. msg = "Cannot use assign-op operators with string offsets";
  1229. break;
  1230. case ZEND_FETCH_DIM_W:
  1231. case ZEND_FETCH_DIM_RW:
  1232. case ZEND_FETCH_DIM_FUNC_ARG:
  1233. case ZEND_FETCH_DIM_UNSET:
  1234. case ZEND_FETCH_LIST_W:
  1235. /* TODO: Encode the "reason" into opline->extended_value??? */
  1236. var = opline->result.var;
  1237. opline++;
  1238. end = EG(current_execute_data)->func->op_array.opcodes +
  1239. EG(current_execute_data)->func->op_array.last;
  1240. while (opline < end) {
  1241. if (opline->op1_type == IS_VAR && opline->op1.var == var) {
  1242. switch (opline->opcode) {
  1243. case ZEND_ASSIGN_OBJ_OP:
  1244. msg = "Cannot use string offset as an object";
  1245. break;
  1246. case ZEND_ASSIGN_DIM_OP:
  1247. msg = "Cannot use string offset as an array";
  1248. break;
  1249. case ZEND_ASSIGN_STATIC_PROP_OP:
  1250. case ZEND_ASSIGN_OP:
  1251. msg = "Cannot use assign-op operators with string offsets";
  1252. break;
  1253. case ZEND_PRE_INC_OBJ:
  1254. case ZEND_PRE_DEC_OBJ:
  1255. case ZEND_POST_INC_OBJ:
  1256. case ZEND_POST_DEC_OBJ:
  1257. case ZEND_PRE_INC:
  1258. case ZEND_PRE_DEC:
  1259. case ZEND_POST_INC:
  1260. case ZEND_POST_DEC:
  1261. msg = "Cannot increment/decrement string offsets";
  1262. break;
  1263. case ZEND_FETCH_DIM_W:
  1264. case ZEND_FETCH_DIM_RW:
  1265. case ZEND_FETCH_DIM_FUNC_ARG:
  1266. case ZEND_FETCH_DIM_UNSET:
  1267. case ZEND_FETCH_LIST_W:
  1268. case ZEND_ASSIGN_DIM:
  1269. msg = "Cannot use string offset as an array";
  1270. break;
  1271. case ZEND_FETCH_OBJ_W:
  1272. case ZEND_FETCH_OBJ_RW:
  1273. case ZEND_FETCH_OBJ_FUNC_ARG:
  1274. case ZEND_FETCH_OBJ_UNSET:
  1275. case ZEND_ASSIGN_OBJ:
  1276. msg = "Cannot use string offset as an object";
  1277. break;
  1278. case ZEND_ASSIGN_REF:
  1279. case ZEND_ADD_ARRAY_ELEMENT:
  1280. case ZEND_INIT_ARRAY:
  1281. case ZEND_MAKE_REF:
  1282. msg = "Cannot create references to/from string offsets";
  1283. break;
  1284. case ZEND_RETURN_BY_REF:
  1285. case ZEND_VERIFY_RETURN_TYPE:
  1286. msg = "Cannot return string offsets by reference";
  1287. break;
  1288. case ZEND_UNSET_DIM:
  1289. case ZEND_UNSET_OBJ:
  1290. msg = "Cannot unset string offsets";
  1291. break;
  1292. case ZEND_YIELD:
  1293. msg = "Cannot yield string offsets by reference";
  1294. break;
  1295. case ZEND_SEND_REF:
  1296. case ZEND_SEND_VAR_EX:
  1297. case ZEND_SEND_FUNC_ARG:
  1298. msg = "Only variables can be passed by reference";
  1299. break;
  1300. case ZEND_FE_RESET_RW:
  1301. msg = "Cannot iterate on string offsets by reference";
  1302. break;
  1303. EMPTY_SWITCH_DEFAULT_CASE();
  1304. }
  1305. break;
  1306. }
  1307. if (opline->op2_type == IS_VAR && opline->op2.var == var) {
  1308. ZEND_ASSERT(opline->opcode == ZEND_ASSIGN_REF);
  1309. msg = "Cannot create references to/from string offsets";
  1310. break;
  1311. }
  1312. }
  1313. break;
  1314. EMPTY_SWITCH_DEFAULT_CASE();
  1315. }
  1316. ZEND_ASSERT(msg != NULL);
  1317. zend_throw_error(NULL, "%s", msg);
  1318. }
  1319. static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_wrong_property_read(zval *property)
  1320. {
  1321. zend_string *tmp_property_name;
  1322. zend_string *property_name = zval_get_tmp_string(property, &tmp_property_name);
  1323. zend_error(E_WARNING, "Trying to get property '%s' of non-object", ZSTR_VAL(property_name));
  1324. zend_tmp_string_release(tmp_property_name);
  1325. }
  1326. static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_function *fbc)
  1327. {
  1328. zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
  1329. fbc->common.scope ? ZSTR_VAL(fbc->common.scope->name) : "",
  1330. fbc->common.scope ? "::" : "",
  1331. ZSTR_VAL(fbc->common.function_name));
  1332. }
  1333. static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim, zval *value OPLINE_DC EXECUTE_DATA_DC)
  1334. {
  1335. zend_uchar c;
  1336. size_t string_len;
  1337. zend_long offset;
  1338. offset = zend_check_string_offset(dim, BP_VAR_W EXECUTE_DATA_CC);
  1339. if (offset < -(zend_long)Z_STRLEN_P(str)) {
  1340. /* Error on negative offset */
  1341. zend_error(E_WARNING, "Illegal string offset: " ZEND_LONG_FMT, offset);
  1342. if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
  1343. ZVAL_NULL(EX_VAR(opline->result.var));
  1344. }
  1345. return;
  1346. }
  1347. if (Z_TYPE_P(value) != IS_STRING) {
  1348. /* Convert to string, just the time to pick the 1st byte */
  1349. zend_string *tmp = zval_try_get_string_func(value);
  1350. if (UNEXPECTED(!tmp)) {
  1351. if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
  1352. ZVAL_UNDEF(EX_VAR(opline->result.var));
  1353. }
  1354. return;
  1355. }
  1356. string_len = ZSTR_LEN(tmp);
  1357. c = (zend_uchar)ZSTR_VAL(tmp)[0];
  1358. zend_string_release_ex(tmp, 0);
  1359. } else {
  1360. string_len = Z_STRLEN_P(value);
  1361. c = (zend_uchar)Z_STRVAL_P(value)[0];
  1362. }
  1363. if (string_len != 1) {
  1364. if (string_len == 0) {
  1365. /* Error on empty input string */
  1366. zend_throw_error(NULL, "Cannot assign an empty string to a string offset");
  1367. if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
  1368. ZVAL_NULL(EX_VAR(opline->result.var));
  1369. }
  1370. return;
  1371. }
  1372. zend_error(E_WARNING, "Only the first byte will be assigned to the string offset");
  1373. }
  1374. if (offset < 0) { /* Handle negative offset */
  1375. offset += (zend_long)Z_STRLEN_P(str);
  1376. }
  1377. if ((size_t)offset >= Z_STRLEN_P(str)) {
  1378. /* Extend string if needed */
  1379. zend_long old_len = Z_STRLEN_P(str);
  1380. ZVAL_NEW_STR(str, zend_string_extend(Z_STR_P(str), offset + 1, 0));
  1381. memset(Z_STRVAL_P(str) + old_len, ' ', offset - old_len);
  1382. Z_STRVAL_P(str)[offset+1] = 0;
  1383. } else if (!Z_REFCOUNTED_P(str)) {
  1384. ZVAL_NEW_STR(str, zend_string_init(Z_STRVAL_P(str), Z_STRLEN_P(str), 0));
  1385. } else if (Z_REFCOUNT_P(str) > 1) {
  1386. Z_DELREF_P(str);
  1387. ZVAL_NEW_STR(str, zend_string_init(Z_STRVAL_P(str), Z_STRLEN_P(str), 0));
  1388. } else {
  1389. zend_string_forget_hash_val(Z_STR_P(str));
  1390. }
  1391. Z_STRVAL_P(str)[offset] = c;
  1392. if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
  1393. /* Return the new character */
  1394. ZVAL_INTERNED_STR(EX_VAR(opline->result.var), ZSTR_CHAR(c));
  1395. }
  1396. }
  1397. static zend_property_info *zend_get_prop_not_accepting_double(zend_reference *ref)
  1398. {
  1399. zend_property_info *prop;
  1400. ZEND_REF_FOREACH_TYPE_SOURCES(ref, prop) {
  1401. if (!(ZEND_TYPE_FULL_MASK(prop->type) & MAY_BE_DOUBLE)) {
  1402. return prop;
  1403. }
  1404. } ZEND_REF_FOREACH_TYPE_SOURCES_END();
  1405. return NULL;
  1406. }
  1407. static ZEND_COLD zend_long zend_throw_incdec_ref_error(
  1408. zend_reference *ref, zend_property_info *error_prop OPLINE_DC)
  1409. {
  1410. zend_string *type_str = zend_type_to_string(error_prop->type);
  1411. if (ZEND_IS_INCREMENT(opline->opcode)) {
  1412. zend_type_error(
  1413. "Cannot increment a reference held by property %s::$%s of type %s past its maximal value",
  1414. ZSTR_VAL(error_prop->ce->name),
  1415. zend_get_unmangled_property_name(error_prop->name),
  1416. ZSTR_VAL(type_str));
  1417. zend_string_release(type_str);
  1418. return ZEND_LONG_MAX;
  1419. } else {
  1420. zend_type_error(
  1421. "Cannot decrement a reference held by property %s::$%…

Large files files are truncated, but you can click here to view the full file