Adding TypeError and ValueError to count() function
| From: | George Peter Banyard | Date: | Tue, 07 Jan 2020 20:57:44 +0000 |
| Subject: | Adding TypeError and ValueError to count() function | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-108026@lists.php.net to get a copy of this message | ||
Greetings internals,
I would like your input on adding TypeError and ValueError exceptions
to the count() function in respect to the Consistent type errors for
internal functions RFC [1], the initial PR [2] was denied as null was
not accepted as a value when it seems to be prevalent to use count()
as a substitute for isset() (this is currently done in the test runner
for php-src), although a "type error" warning was already emitted with
null.
So I've made an adjustment by still accepting null but deprecating it's
usage. An other option is to allow null as a value that always return 0.
I've also added a ValueError exception on invalid modes.
The new pull request is located at https://github.com/php/php-src/pull/4940
Any comments would be appreciated.
Best regards and happy new year.
George Peter Banyard
[1] https://wiki.php.net/rfc/consistent_type_errors
[2] https://github.com/php/php-src/pull/4572