Doc #76314 [Opn->Ver]: Specify failure return type for soundex
Edit report at https://bugs.php.net/bug.php?id=76314&edit=1
ID: 76314
Updated by: cmb@php.net
Reported by: roy-orbison at devo dot net dot au
Summary: Specify failure return type for soundex
-Status: Open
+Status: Verified
Type: Documentation Problem
Package: Strings related
PHP Version: Irrelevant
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
See also <https://github.com/php/php-src/commit/aba0ee71b224ab11a4b940f06dd1146eddbd41a3>.
Previous Comments:
------------------------------------------------------------------------
[2018-05-09 13:03:04] requinix@php.net
Because accidentally trying to soundex an empty string (or something convertable to a string) is
understandable but calling it with an array doesn't make sense and suggests possible developer
error?
------------------------------------------------------------------------
[2018-05-09 02:07:29] roy-orbison at devo dot net dot au
Then why bother specifying return value(s) upon failure on other functions?
------------------------------------------------------------------------
[2018-05-09 01:46:17] requinix@php.net
http://php.net/manual/en/functions.internal.php
> Note: If the parameters given to a function are not what it expects, such as passing an array
> where a string is
> expected, the return value of the function is undefined. In this case it will likely return
> NULL but this is just a
> convention, and cannot be relied upon.
------------------------------------------------------------------------
[2018-05-09 01:40:44] roy-orbison at devo dot net dot au
Or a 0, or false, or null.
Or, if it gets an array (but only an array), it emits a warning and returns NULL.
There are plenty of ways bad data can be passed to a function, return types should be consistent and
documented.
------------------------------------------------------------------------
[2018-05-09 01:31:56] requinix@php.net
...which only happens if the string is empty.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=76314
--
Edit this bug report at https://bugs.php.net/bug.php?id=76314&edit=1
Thread (8 messages)