|
40 | 40 | #include "php_math.h"
|
41 | 41 | #include "zend_smart_str.h"
|
42 | 42 | #include "zend_bitset.h"
|
| 43 | +#include "zend_exceptions.h" |
43 | 44 | #include "ext/spl/spl_array.h"
|
44 | 45 |
|
45 | 46 | /* {{{ defines */
|
@@ -765,6 +766,7 @@ PHP_FUNCTION(count)
|
765 | 766 |
|
766 | 767 | switch (Z_TYPE_P(array)) {
|
767 | 768 | case IS_NULL:
|
| 769 | + /* Intentionally not converted to an exception */ |
768 | 770 | php_error_docref(NULL, E_WARNING, "Parameter must be an array or an object that implements Countable");
|
769 | 771 | RETURN_LONG(0);
|
770 | 772 | break;
|
@@ -799,11 +801,13 @@ PHP_FUNCTION(count)
|
799 | 801 | }
|
800 | 802 |
|
801 | 803 | /* If There's no handler and it doesn't implement Countable then add a warning */
|
| 804 | + /* Intentionally not converted to an exception */ |
802 | 805 | php_error_docref(NULL, E_WARNING, "Parameter must be an array or an object that implements Countable");
|
803 | 806 | RETURN_LONG(1);
|
804 | 807 | break;
|
805 | 808 | }
|
806 | 809 | default:
|
| 810 | + /* Intentionally not converted to an exception */ |
807 | 811 | php_error_docref(NULL, E_WARNING, "Parameter must be an array or an object that implements Countable");
|
808 | 812 | RETURN_LONG(1);
|
809 | 813 | break;
|
@@ -5212,7 +5216,7 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
|
5212 | 5216 | param_spec = "+f";
|
5213 | 5217 | diff_data_compare_func = php_array_user_compare;
|
5214 | 5218 | } else {
|
5215 |
| - php_error_docref(NULL, E_WARNING, "data_compare_type is %d. This should never happen. Please report as a bug", data_compare_type); |
| 5219 | + zend_value_error("data_compare_type is %d. This should never happen. Please report as a bug", data_compare_type); |
5216 | 5220 | return;
|
5217 | 5221 | }
|
5218 | 5222 |
|
@@ -6349,9 +6353,25 @@ PHP_FUNCTION(array_key_exists)
|
6349 | 6353 | case IS_NULL:
|
6350 | 6354 | RETVAL_BOOL(zend_hash_exists_ind(ht, ZSTR_EMPTY_ALLOC()));
|
6351 | 6355 | break;
|
| 6356 | + case IS_DOUBLE: |
| 6357 | + RETVAL_BOOL(zend_hash_index_exists(ht, zend_dval_to_lval(Z_DVAL_P(key)))); |
| 6358 | + break; |
| 6359 | + case IS_FALSE: |
| 6360 | + RETVAL_BOOL(zend_hash_index_exists(ht, 0)); |
| 6361 | + break; |
| 6362 | + case IS_TRUE: |
| 6363 | + RETVAL_BOOL(zend_hash_index_exists(ht, 1)); |
| 6364 | + break; |
| 6365 | + case IS_RESOURCE: |
| 6366 | + zend_error(E_WARNING, "Resource ID#%d used as offset, casting to integer (%d)", Z_RES_HANDLE_P(key), Z_RES_HANDLE_P(key)); |
| 6367 | + RETVAL_BOOL(zend_hash_index_exists(ht, Z_RES_HANDLE_P(key))); |
| 6368 | + break; |
| 6369 | + case IS_UNDEF: |
| 6370 | + RETVAL_BOOL(zend_symtable_exists_ind(ht, ZSTR_EMPTY_ALLOC())); |
| 6371 | + break; |
6352 | 6372 | default:
|
6353 |
| - php_error_docref(NULL, E_WARNING, "The first argument should be either a string or an integer"); |
6354 |
| - RETVAL_FALSE; |
| 6373 | + zend_type_error("Illegal offset type"); |
| 6374 | + break; |
6355 | 6375 | }
|
6356 | 6376 | }
|
6357 | 6377 | /* }}} */
|
|
0 commit comments