Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92286 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8029 invoked from network); 14 Apr 2016 09:25:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Apr 2016 09:25:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Received: from [82.113.146.227] ([82.113.146.227:37834] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6E/75-12455-6F16F075 for ; Thu, 14 Apr 2016 05:25:10 -0400 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 9F054DEFBC; Thu, 14 Apr 2016 10:25:07 +0100 (BST) Date: Thu, 14 Apr 2016 10:25:07 +0100 (BST) X-X-Sender: derick@whisky.home.derickrethans.nl To: Lin Yo-An cc: Levi Morrison , internals In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Subject: Re: [PHP-DEV] [RFC] Union Types From: derick@php.net (Derick Rethans) On Thu, 14 Apr 2016, Lin Yo-An wrote: > On Thu, Apr 14, 2016 at 5:12 PM, Derick Rethans wrote: > > > I think what I am missing in the RFC is behaviour with scalar (weak) > > typehints, and which type the variable in a class would be converted to. > > Take for example: > > > > function foo(int|bool $var) { echo get_type( $var ), "\n"; } > > > > foo(5); I guess int(5) > > foo(false); I guess bool(false) > > foo(0.5); It could be either int(1) or bool(true) > > > > And what if the hint would be "bool|int" ? > > I think type conversion shouldn't be done internally, implicitly. > > Implicit conversion leads more confusion in the language. when you > pass variables, you have to remember these conversion rules. Sorry, we already have this with our weak scalar types. You can't make union types not work with that. cheers, Derick