Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:75444 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54906 invoked from network); 14 Jul 2014 12:47:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jul 2014 12:47:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.174 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.174 mail-qc0-f174.google.com Received: from [209.85.216.174] ([209.85.216.174:35944] helo=mail-qc0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D6/D1-43645-261D3C35 for ; Mon, 14 Jul 2014 08:47:30 -0400 Received: by mail-qc0-f174.google.com with SMTP id o8so496473qcw.19 for ; Mon, 14 Jul 2014 05:47:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=BSkr74579MnTahMjBRM9NmghzBudbJqcQxaLVNhsJi0=; b=vSCgwPvLZCTokpfwprsa4KZZSTH+hO2np3XCR/YBhDuK47sqgi/a4zTpEQIAJ6Gmq8 Qka1WpSMyigeLluhAFuaSutjCA2VzmOxMgsO1MvA/seUvi9Srj15+vmX/B97scHJWpPd rNiN1wusFt68Q86gxONlT7m8A43umWZ6GJxdJj+8dvUG1C8/DpNa7VXV4u1rU0LYnuUy aCEuYr/gLww+yrxK0VFic1G1djbSZjBMOYQFEgMasyHMRKePIUZuB2CfEf7WPSdMSCGK kjXlreyguW+yHunaiiPSOOHmtYyQWYBaADdgZlDgNTNJlqLN9oOT9AxJ1X76hXl3GGm+ 17OA== MIME-Version: 1.0 X-Received: by 10.224.136.200 with SMTP id s8mr22104987qat.85.1405342047290; Mon, 14 Jul 2014 05:47:27 -0700 (PDT) Received: by 10.140.101.135 with HTTP; Mon, 14 Jul 2014 05:47:27 -0700 (PDT) In-Reply-To: <20140714123556.GH6540@phcomp.co.uk> References: <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> <53C2178E.7070705@sugarcrm.com> <53C24061.6050503@lsces.co.uk> <20140713101840.GR6540@phcomp.co.uk> <20140714123556.GH6540@phcomp.co.uk> Date: Mon, 14 Jul 2014 14:47:27 +0200 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary=001a11c2caa2844e1704fe26b127 Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) From: tyra3l@gmail.com (Ferenc Kovacs) --001a11c2caa2844e1704fe26b127 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, Jul 14, 2014 at 2:35 PM, Alain Williams wrote: > On Mon, Jul 14, 2014 at 02:19:15PM +0200, Ferenc Kovacs wrote: > > > > function foo(int $a) > > > { > > > var $b; // $b has no type hinting > > > var float $c; // $c is a float > > > string $d; // alternative to the syntax used for $c (see > below) > > > } > > > I think it would be better to reuse declare() instead of reusing var. > > As a matter of curiosity, why ? > > The nice thing about 'var' is that it is the syntax used by other > languages, eg > Javascript. > in javascript var itself only defines the variable scope/context. what you really proposing here is "strict" mode (use strict in javascript), and for that declare would be suitable, as that is the current method of passing information for the compiler about a file or a codeblock. > > > What error level would it emit though? > > I anything below E_RECOVERABLE_ERROR, then it doesn't do anything, but > > prints a line to the error log(and or displays it), which we already do= , > > because using an undefined variable will emit an E_NOTICE > > I think it is a good thing if we make it easier to spot programming > errors > > and bail out early instead of trying to guess the developer's intention= , > > but I don't think that adding more fatal errors or > > E_RECOVERABLE_ERRORs(which will be fatal if there is no userland error > > handler defined which explicitly allows to continue the execution). > > This sort of error should be picked up the first time that the script is > compiled, it does not need to be executed (other than conditional > includes). > This means that these errors will be picked up very quickly. > > that's true, but you didn't really answered my question about the error level. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --001a11c2caa2844e1704fe26b127--