Bug #78402 [PATCH]: Converting null to string in error message is bad DX

From: Date: Tue, 17 Dec 2019 18:19:06 +0000
Subject: Bug #78402 [PATCH]: Converting null to string in error message is bad DX
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224367@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78402&edit=1

 ID:                 78402
 Patch added by:     kentaro@ranvis.com
 Reported by:        danack@php.net
 Summary:            Converting null to string in error message is bad DX
 Status:             Open
 Type:               Bug
 Package:            *General Issues
 PHP Version:        7.3.8
 Block user comment: N
 Private report:     N

 New Comment:

The following pull request has been associated:

Patch Name: Fix #78402: pcntl_signal() misleading error message
On GitHub:  https://github.com/php/php-src/pull/5023
Patch:      https://github.com/php/php-src/pull/5023.patch


Previous Comments:
------------------------------------------------------------------------
[2019-08-11 20:29:41] danack@php.net

Description:
------------
When pcntl_signal is passed a null variable instead of a callable, the error message should make it
clear that the variable is not allowed to be null. Currently the error message given is:

> 'pcntl_signal(): is not a callable function name error'

Presumably because it is converting the variable null to be a string of ''. 

Which means the developer needs to work backwards from a zero length string being present in the
error message, to the fact that they passed in null.

Test script:
---------------
static $fnSignalHandler = null;

// $fnSignalHandler is meant to be initialised here but isn't

pcntl_signal(SIGINT, $fnSignalHandler, false);

Expected result:
----------------
A clear error message that says I've passed null.

Actual result:
--------------
Me spending 15 minutes trying to figure out why pcntl_signal is not callable.


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=78402&edit=1


Thread (3 messages)

« previous php.bugs (#224367) next »