php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80367 Show false instead bool in exceptions
Submitted: 2020-11-13 23:10 UTC Modified: 2020-11-15 13:36 UTC
From: michael dot vorisek at email dot cz Assigned: cmb (profile)
Status: Wont fix Package: Scripting Engine problem
PHP Version: 7.4.12 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2020-11-13 23:10 UTC] michael dot vorisek at email dot cz
Description:
------------
see https://3v4l.org/ko1WZ

false is often an error return type of some previous action and showing explicitly "false" instead of "bool" improves the explanation value of the php output.

Test script:
---------------
<?php declare(strict_types=1);

function x(string $a) {}

x(false);

Expected result:
----------------
Fatal error: Uncaught TypeError: x(): Argument #1 ($a) must be of type string, false given

Actual result:
--------------
Fatal error: Uncaught TypeError: x(): Argument #1 ($a) must be of type string, bool given

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-15 13:36 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2020-11-15 13:36 UTC] cmb@php.net
false is not a standalone type[1] (and more like a pseudo-type).
I don't think it makes sense to report it as such.  If you
strongly feel about this, please bring that up on the internals
mailing list.

[1] <https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.union.false>
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Jan 19 15:01:23 2021 UTC