php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #76314 Specify failure return type for soundex
Submitted: 2018-05-09 01:25 UTC Modified: 2021-02-12 15:21 UTC
From: roy-orbison at devo dot net dot au Assigned: cmb (profile)
Status: Closed Package: Strings related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: roy-orbison at devo dot net dot au
New email:
PHP Version: OS:

 

 [2018-05-09 01:25 UTC] roy-orbison at devo dot net dot au
Description:
------------
---
From manual page: http://www.php.net/function.soundex
---

No mention that it returns FALSE on failure.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-05-09 01:31 UTC] requinix@php.net
-Summary: Specify failure return type. +Summary: Specify failure return type for soundex -Package: Documentation problem +Package: Strings related
 [2018-05-09 01:31 UTC] requinix@php.net
...which only happens if the string is empty.
 [2018-05-09 01:40 UTC] 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:46 UTC] 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 02:07 UTC] roy-orbison at devo dot net dot au
Then why bother specifying return value(s) upon failure on other functions?
 [2018-05-09 13:03 UTC] 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?
 [2021-02-12 15:21 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2021-02-12 15:23 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=230b56bf45d3871657573097a2be90d77ed2bfc8
Log: Fix #76314: Specify failure return type for soundex
 [2021-02-12 15:23 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2021-02-13 09:34 UTC] mumumu@php.net
Automatic comment on behalf of mumumu@mumumu.org
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=0eb26f02aa7dee2624a42ad10e0fc62bb9c9ee22
Log: Fix #76314: Specify failure return type for soundex
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 07 14:01:27 2024 UTC