Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83897 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12614 invoked from network); 26 Feb 2015 15:40:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Feb 2015 15:40:20 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.51 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.192.51 mail-qg0-f51.google.com Received: from [209.85.192.51] ([209.85.192.51:41534] helo=mail-qg0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 73/52-32582-36E3FE45 for ; Thu, 26 Feb 2015 10:40:19 -0500 Received: by mail-qg0-f51.google.com with SMTP id z60so9101171qgd.10 for ; Thu, 26 Feb 2015 07:40:17 -0800 (PST) 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 :cc:content-type; bh=Dv37asWIk4iES2s8I9wmS8aIkAr7yAGUKQVk748IFjo=; b=r4VxMn8gfgYpdpL+I3Oz8cyWorfQ6CX69oPoyVBGfN3yy380tbqVBAvM672CsfYLKm bE77ldv5V93wiF3H+OhNoLF2Jq0gDxqelUJ2I5oxkCozkeAq7HMM9oTIPaFflwXrEbXi T/86XUIPcpZPdt5ytdm6kXvZreNVVbZ0cjGks7q6rh1bVOL7KSPUXQn89nhitSiyT8is kundB3AptFOAjS+2Jh+3OLQ190grAcR8enooCWEdF0/7DLmSaGLxoqH7SaPk1MVy+vYa Vn4bt7ApmDZ1Y0wwYV2nXEASc8RpPsMYmgXEwp/yLEx30R+ebWYsC4sNeVdpLm+HwBuy YEag== MIME-Version: 1.0 X-Received: by 10.140.102.165 with SMTP id w34mr19150990qge.26.1424965217022; Thu, 26 Feb 2015 07:40:17 -0800 (PST) Received: by 10.96.39.195 with HTTP; Thu, 26 Feb 2015 07:40:16 -0800 (PST) In-Reply-To: References: Date: Thu, 26 Feb 2015 07:40:16 -0800 Message-ID: To: Dmitry Stogov Cc: Anthony Ferrara , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Strict typing and callback vs declare() From: pierre.php@gmail.com (Pierre Joye) On Thu, Feb 26, 2015 at 2:10 AM, Dmitry Stogov wrote: > Hi Anthony, > > What do you think about using a user level callback for strict type checks > instead of declare(). It won't allow changing behavior per file, but this > has its own cons and pros. > > set_strict_type_checker(function ($class_name, $function_nume, $arg_num, > $expected_type, $value, $file, $line) { > ... > return false; > }); > include("orig_index.php"); > ?> > > If callback is not set, arguments are converted according to standard > rules, if set and returns false - fatal error or exception is thrown. > > The implementation should be simpler and more efficient than using > declare(). It is too complex for what we need. The declare statement is as simple as "use.." present as the top of the file, has to be checked just like "use", no brainer for the users. Cheers, -- Pierre @pierrejoye | http://www.libgd.org