|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: dvworkmail2017 at gmail dot com
New email:
PHP Version: OS:


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

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


new Number("1.0");

Expected result:
Excepted Output should be: TypeError

Actual result:
Current Output is: double


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-12-13 02:07 UTC]
-Status: Open +Status: Not a bug
 [2020-12-13 02:07 UTC]
You didn't enable strict_types.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jul 04 03:03:50 2022 UTC