Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88272 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75622 invoked from network); 16 Sep 2015 23:20:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2015 23:20:05 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.178 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.178 mail-wi0-f178.google.com Received: from [209.85.212.178] ([209.85.212.178:36480] helo=mail-wi0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6D/A6-41443-329F9F55 for ; Wed, 16 Sep 2015 19:20:04 -0400 Received: by wicgb1 with SMTP id gb1so94877574wic.1 for ; Wed, 16 Sep 2015 16:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type:subject:from:date:to :message-id; bh=nT3TmwbZQaXZT21n/RWFLGqOA8q7dc7MyNZa/rZOUVs=; b=WcA+sXZ4G+Gc/DL4W+4kHhITGVfZNFdicL5pYC/NyEyCSPWLy9sDSPkBs5awI5n1xX KhwsRNWn91p1E/xfdK95ikrxDADLiYyiBIbS6Ls8xzYA6lDAQOiZpcbMQCAB+BmEtYY3 Y1eW8RASeyfeQbkefD1E51mb6pc3cxdeD1ZAc5//2R4n31GwaqANrPVZYjS84Np7+pyd wvV6P1xQfD48MLOd8jAgG2hBBk7dFzViBkwubocC5CusbXH8lrVU/E2Brc6m22xnhsc2 xz6GDVCbe/3OuCEy80T7OGZptHMlyciH4qi6JXQrJtBUSeFppPTx9mzLBSyUletmYAZR 0uvw== X-Received: by 10.194.9.42 with SMTP id w10mr23687266wja.146.1442445600715; Wed, 16 Sep 2015 16:20:00 -0700 (PDT) Received: from [192.168.0.6] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by smtp.gmail.com with ESMTPSA id kj5sm155379wjb.19.2015.09.16.16.20.00 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 16 Sep 2015 16:20:00 -0700 (PDT) User-Agent: K-9 Mail for Android In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Date: Thu, 17 Sep 2015 00:17:49 +0100 To: Yasuo Ohgaki ,"internals@lists.php.net" Message-ID: <9BA68930-8604-4841-90E9-3888733B0661@gmail.com> Subject: Re: [PHP-DEV] Make strict mode more strict? From: rowan.collins@gmail.com (Rowan Collins) On 16 September 2015 23:10:55 BST, Yasuo Ohgaki wrote: >The idea is as follows: > >declare(strict_types=1); > >function foo(int &$i) { > $i = "string"; // Raise error > $i = function_returns_string(); // Raise error > $i = 1234.5678; // Raise error > $i = function_returns_float(); // Raise error I think the problem here would be the same as with declaring types on object properties - it would require a major change to how the engine works so that every assignment operation had a potential for type checking, and strictness could stick to variables. The reason the current type annotations can be enforced more easily is that they exist only on the boundary of a function, where variables are being copied into local parameters, and the function signature can readily hold the metadata. There is also the question from the language design point of view of whether this is too "un-PHP-like". If you want something like PHP but with full type annotations, try Hack. Regards, -- Rowan Collins [IMSoP]