diff options
| author | George Peter Banyard <girgias@php.net> | 2020-09-21 17:01:40 +0100 |
|---|---|---|
| committer | George Peter Banyard <girgias@php.net> | 2020-09-21 21:29:15 +0100 |
| commit | 2ee7e2982f5609ca6c3837c0b93ba9c5e89f84cb (patch) | |
| tree | 84b2245f4d3c1aa2c2d920956e727c85d116e887 /ext/standard/array.c | |
| parent | 5a085777b7f5fc015b885be928efc244a5e89e1f (diff) | |
| download | php-git-2ee7e2982f5609ca6c3837c0b93ba9c5e89f84cb.tar.gz | |
Promote count() warning to TypeError
Closes GH-6180
Diffstat (limited to 'ext/standard/array.c')
| -rw-r--r-- | ext/standard/array.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c index bd2823a407..f99af84611 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -740,11 +740,6 @@ PHP_FUNCTION(count) } switch (Z_TYPE_P(array)) { - case IS_NULL: - /* Intentionally not converted to an exception */ - php_error_docref(NULL, E_WARNING, "%s(): Argument #1 ($var) must be of type Countable|array, %s given", get_active_function_name(), zend_zval_type_name(array)); - RETURN_LONG(0); - break; case IS_ARRAY: if (mode != COUNT_RECURSIVE) { cnt = zend_array_count(Z_ARRVAL_P(array)); @@ -774,18 +769,11 @@ PHP_FUNCTION(count) } return; } - - /* If There's no handler and it doesn't implement Countable then add a warning */ - /* Intentionally not converted to an exception */ - php_error_docref(NULL, E_WARNING, "%s(): Argument #1 ($var) must be of type Countable|array, %s given", get_active_function_name(), zend_zval_type_name(array)); - RETURN_LONG(1); - break; } + /* fallthrough */ default: - /* Intentionally not converted to an exception */ - php_error_docref(NULL, E_WARNING, "%s(): Argument #1 ($var) must be of type Countable|array, %s given", get_active_function_name(), zend_zval_type_name(array)); - RETURN_LONG(1); - break; + zend_argument_type_error(1, "must be of type Countable|array, %s given", zend_zval_type_name(array)); + RETURN_THROWS(); } } /* }}} */ |
