Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75439 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40848 invoked from network); 14 Jul 2014 10:10:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2014 10:10:06 -0000 Authentication-Results: pb1.pair.com header.from=arvids.godjuks@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=arvids.godjuks@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: arvids.godjuks@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qa0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:55843] helo=mail-qa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A0/31-24215-D7CA3C35 for ; Mon, 14 Jul 2014 06:10:06 -0400 Received: by mail-qa0-f42.google.com with SMTP id j15so3103963qaq.29 for ; Mon, 14 Jul 2014 03:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=hgzMb3IRKXnZEWds5yH2sP115JYTFbBIiTM2s3Nrews=; b=LQZ0oRf5VXMJUT0VYaOMa4wlFOylybjqtoGvC4AMU20BDBOWrunh2qr8Yu1SN8DwTf shquPjNq2hl3xFqAYG/60jRc4p7uudZmlGSBWcTGj9DK9LFGstsC/NH0o+qESBLP8CT0 xKL71r7Xa593UjuHlDzCnKIm8+w+1J3Pyx5JZV0/rgucOIvDY9es3BXTApHZ/iKf+TsR 2DiKGDHRuk9MnxfXlCLuMrfZrblo+unfZ814fZT2Ws2CwiF25xUfKhXFv5JVNmKDCq7Y P2DTCeG9/T330kHWFeZgsE87ui6rMYCvBkh72BBfeo0997FZG7WDirpttdzxl6WycQwz RPbA== X-Received: by 10.140.47.48 with SMTP id l45mr22520310qga.24.1405332603008; Mon, 14 Jul 2014 03:10:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.30.137 with HTTP; Mon, 14 Jul 2014 03:09:42 -0700 (PDT) In-Reply-To: <53C2DC03.2050609@gmail.com> References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> <027E65EF-C4FC-474C-92BB-D99EFADDEEED@ajf.me> <53C29EE4.3090808@gmail.com> <63e5b1c38d6e0c5111987e78d9b59be3@mail.gmail.com> <53C2AF35.40003@gmail.com> <93bb0c689ccca03a0af46c51abf0e11f@mail.gmail.com> <53C2C84A.6060308@garfieldtech.com> <49C63232-AB78-4B2C-A3E4-B21748D5D489@ajf.me> <53C2DC03.2050609@gmail.com> Date: Mon, 14 Jul 2014 13:09:42 +0300 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=001a11c16606980cad04fe247e8c Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: arvids.godjuks@gmail.com (Arvids Godjuks) --001a11c16606980cad04fe247e8c Content-Type: text/plain; charset=UTF-8 Hello! As a user land developer I do think that over thinking this is going to end up in disaster. We already have quite good implementation for the array and object hints, they do their job and do it good. No need to change those at all - leave them as is - no need to add magic with casts and all that. Function/method requires an array? Make casts explicitly and pass it an array and not an integer. Primitive type hints are a little different - they are easily cast into each other for the most part. The only edge case is when we loose data. In this case we need a E_STRICT or something like that (I would vote for E_TYPEHINT_CAST - because you will be able to disable only typehint warnings/errors without disabling E_STRICT), so we can collect these errors and fix our code by adding checks/casts/whatever. But this automatic casting should work only between string, integer, float, bool and null types and only between these. No automatic casting of these 5 to arrays or objects. PHP does not need a type hinting system forces you to first make a prototype without any type hints because you get catchable errors - you can handle them, but you can't actually just continue right where the error occurred. You just need to get a warning, that you can disable via error_reporting, and just make your prototype with all the type hints you need and deal with the cast warnings in the type hints later on. P.S. And on that "var integer $variable" in methods/functions. People, when you have internal functions returning null|array, bool|array and so on - this is pointless. --001a11c16606980cad04fe247e8c--