Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88271 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 73788 invoked from network); 16 Sep 2015 23:14:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2015 23:14:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=francois@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=francois@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 212.27.42.6 as permitted sender) X-PHP-List-Original-Sender: francois@php.net X-Host-Fingerprint: 212.27.42.6 smtp6-g21.free.fr Received: from [212.27.42.6] ([212.27.42.6:53195] helo=smtp6-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/46-41443-2C7F9F55 for ; Wed, 16 Sep 2015 19:14:10 -0400 Received: from [127.0.0.1] (unknown [82.232.41.54]) (Authenticated sender: flaupretre@free.fr) by smtp6-g21.free.fr (Postfix) with ESMTPSA id 1560382248; Thu, 17 Sep 2015 01:06:26 +0200 (CEST) To: Yasuo Ohgaki , "internals@lists.php.net" References: Message-ID: <55F9F7BD.4070303@php.net> Date: Thu, 17 Sep 2015 01:14:05 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Antivirus: avast! (VPS 150916-2, 16/09/2015), Outbound message X-Antivirus-Status: Clean Subject: Re: [PHP-DEV] Make strict mode more strict? From: francois@php.net (=?UTF-8?Q?Fran=c3=a7ois_Laupretre?=) Hi Yasuo, Le 17/09/2015 00:10, Yasuo Ohgaki a écrit : > Hi all, > > Assigning different type to already initialized variable is a bug most > likely. There may be cases that variable should have several types, > e.g. return INT for success and FALSE for failure, but programmers can > use different variable or return value directly or make BOOL/NULL > exception. While I don't like the idea of 'auto-typing' a variable (assign it an immutable type depending on the first assignment), the idea is quite similar to one I proposed when we were discussing scalar type hinting : the possibility to assign a type hint to every variable/property. In order to be really usable, it requires compound types but that's a detail because, anyway, we will need compound types. The problem is that, AFAIK, it implies a mechanism to attach an optional type hint to a zval, and check it each time a value is assigned. While this would be extremely powerful and could dramatically change the way PHP types are considered and handled, this is a huge and complex work, especially in terms of performance. IMO, this may be an idea for 8.0, not before. Anyway, I may be wrong, if you see a simpler way to implement your concept, I'm interested. Regards François