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: Open Package: *General Issues
PHP Version: 7.3.8 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Sep 21 17:01:27 2019 UTC