php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78402 Converting null to string in error message is bad DX
Submitted: 2019-08-11 20:29 UTC Modified: -
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: danack@php.net Assigned:
Status: Closed Package: *General Issues
PHP Version: 7.3.8 OS:
Private report: No CVE-ID: None
 [2019-08-11 20:29 UTC] 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.

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-17 18:19 UTC] kentaro at ranvis dot com
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
 [2019-12-20 10:03 UTC] nikic@php.net
Automatic comment on behalf of kentaro@ranvis.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=cbb0efaeeb265ff8026dee1d049d57a8d2b5c133
Log: Fix #78402: pcntl_signal() misleading error message
 [2019-12-20 10:03 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 11:01:28 2024 UTC