Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77235 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31374 invoked from network); 16 Sep 2014 05:35:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2014 05:35:02 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@bof.de; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php@bof.de; sender-id=pass Received-SPF: pass (pb1.pair.com: domain bof.de designates 80.242.145.70 as permitted sender) X-PHP-List-Original-Sender: php@bof.de X-Host-Fingerprint: 80.242.145.70 mars.intermailgate.com Received: from [80.242.145.70] ([80.242.145.70:34411] helo=mars.intermailgate.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 40/39-64534-20CC7145 for ; Tue, 16 Sep 2014 01:35:01 -0400 Received: (qmail 28793 invoked by uid 1009); 16 Sep 2014 07:34:56 +0200 Received: from 209.85.216.43 by mars (envelope-from , uid 89) with qmail-scanner-1.25-st-qms (clamdscan: 0.96.2/19367. spamassassin: 3.3.1. perlscan: 1.25-st-qms. Clear:RC:1(209.85.216.43):. Processed in 0.101794 secs); 16 Sep 2014 05:34:56 -0000 X-Antivirus-MYDOMAIN-Mail-From: php@bof.de via mars X-Antivirus-MYDOMAIN: 1.25-st-qms (Clear:RC:1(209.85.216.43):. Processed in 0.101794 secs Process 28771) Received: from mail-qa0-f43.google.com (gmail@bof.de@209.85.216.43) by mars.intermailgate.com with RC4-SHA encrypted SMTP; 16 Sep 2014 07:34:55 +0200 Received: by mail-qa0-f43.google.com with SMTP id x12so5115529qac.30 for ; Mon, 15 Sep 2014 22:34:54 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.224.165.134 with SMTP id i6mr1959294qay.4.1410845694029; Mon, 15 Sep 2014 22:34:54 -0700 (PDT) Received: by 10.140.86.112 with HTTP; Mon, 15 Sep 2014 22:34:53 -0700 (PDT) Received: by 10.140.86.112 with HTTP; Mon, 15 Sep 2014 22:34:53 -0700 (PDT) In-Reply-To: References: <6893A97A-EC4C-4124-B804-96E2A26B953F@ajf.me> Date: Tue, 16 Sep 2014 07:34:53 +0200 Message-ID: To: Pierre Joye Cc: internals , Andrea Faulds Content-Type: multipart/alternative; boundary=089e015375d26cf9b30503281c58 Subject: Re: [PHP-DEV] [VOTE][RFC] Scalar Type Hinting with Cast From: php@bof.de (Patrick Schaaf) --089e015375d26cf9b30503281c58 Content-Type: text/plain; charset=UTF-8 Hello, thinking a bit again on the whole topic, which I thought I was pretty much completely opposed to because of the arbitrary-new-set-of-rules issue in die validation details, I noticed that from my writing PHP code, there _is_ a single thing that I really _would_ like to be able to express as a type hint. It would be a different kind of compromise. I wonder whether that would please enough of the mysterious group of people who want such a feature somehow. Idea: have a "scalar" type hint. Have it admit null, int, float etc, but not array, not object, and maybe not resource. No type juggling, casting, or anything else that messes with the passed in zval - just a check that it is scalar. I come to this idea because in practise, what I often find myself checking inside functions, is "if (is_array($arg) || is_object($arg)) fail; - because these kinds of arguments tend to immediately mess up when treated like scalars in further expressions in the function - while the usual type juggling for scalar types works out fine in most other cases. What do you think? best regards Patrick --089e015375d26cf9b30503281c58--