Bug #80508 [Opn->Nab]: Union types in class not working properly

From: Date: Sun, 13 Dec 2020 02:07:20 +0000
Subject: Bug #80508 [Opn->Nab]: Union types in class not working properly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231046@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80508&edit=1 ID: 80508 Updated by: requinix@php.net Reported by: dvworkmail2017 at gmail dot com Summary: Union types in class not working properly -Status: Open +Status: Not a bug Type: Bug Package: *General Issues Operating System: ubuntu 20 PHP Version: 8.0.0 Block user comment: N Private report: N New Comment: You didn't enable strict_types. Previous Comments: ------------------------------------------------------------------------ [2020-12-13 02:05:02] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80508&edit=1

« previous php.bugs (#231046) next »