php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80508 Union types in class not working properly
Submitted: 2020-12-13 02:05 UTC Modified: 2020-12-13 02:07 UTC
From: dvworkmail2017 at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 8.0.0 OS: ubuntu 20
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dvworkmail2017 at gmail dot com
New email:
PHP Version: OS:

 

 [2020-12-13 02:05 UTC] dvworkmail2017 at gmail dot com
Description:
------------
Union types in class return double instead type error

Test script:
---------------
class Number
{
    public function __construct(
        private int | float $number
    ) {

        print_r(gettype($number));
        exit();
    }
}

new Number("1.0");

Expected result:
----------------
Excepted Output should be: TypeError


Actual result:
--------------
Current Output is: double

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-13 02:07 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2020-12-13 02:07 UTC] requinix@php.net
You didn't enable strict_types.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 13:01:30 2024 UTC