Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86216 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46817 invoked from network); 14 May 2015 09:51:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 May 2015 09:51:26 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.44 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 74.125.82.44 mail-wg0-f44.google.com Received: from [74.125.82.44] ([74.125.82.44:34206] helo=mail-wg0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5B/56-31470-D1074555 for ; Thu, 14 May 2015 05:51:26 -0400 Received: by wguv19 with SMTP id v19so7404244wgu.1 for ; Thu, 14 May 2015 02:51:23 -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 :cc:content-type; bh=6gVtMVqKdHslkTZDgNBL5IDof5QzfMCLgce2T1jaVyI=; b=szw7MuRLen1uQrkEfWZUXGzl5puo7lR81/rLErUnt9AagYjVZiJ7JL0U0qiIoP5afA N27pJt8fERxkYsTyQLMTX6Spp2dksBQ2BiYhCMpZDSajmEW3CBhoUwHCeybxAnZOIpSI 8R3ZlXcAFYCJsscqHV+EOHAUzz0wcsLMOGwNQxNJ4JvDrBOtij6cw4RXh+OCI8hhuYjw Y9t1i7K03Q+1NhYdusb7xMEGhnfTdFrAp+qBMu4LpoqXb78FbgG34lS1HKubbJ5pJn3h YxKq+Dk3KdGIWLu6TNFyd2tBhH7nHU+Pg66xEsbCMEgknpxvTyRW6HZALAO2svvqAGjj AD7g== MIME-Version: 1.0 X-Received: by 10.194.97.196 with SMTP id ec4mr6468539wjb.3.1431597083230; Thu, 14 May 2015 02:51:23 -0700 (PDT) Received: by 10.27.86.133 with HTTP; Thu, 14 May 2015 02:51:23 -0700 (PDT) In-Reply-To: References: Date: Thu, 14 May 2015 11:51:23 +0200 Message-ID: To: Yasuo Ohgaki Cc: Anthony Ferrara , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=047d7bf0ef189b85f8051607abbf Subject: Re: [PHP-DEV] PHP7 scalar type hint error bug? From: nikita.ppv@gmail.com (Nikita Popov) --047d7bf0ef189b85f8051607abbf Content-Type: text/plain; charset=UTF-8 On Thu, May 14, 2015 at 11:46 AM, Yasuo Ohgaki wrote: > Hi Anthony, > > I'm experimenting type hints to write how it could be useful. > > http://3v4l.org/nhI61 > > I thought too large value error in weak mode is E_RECOVERABLE_ERROR, > but it's not. The RFC ( https://wiki.php.net/rfc/scalar_type_hints_v5 ) > does not > state how it behaves for too large values. > > E_ERROR is too severe for too large values. Behavior like this > > http://3v4l.org/avsW4 > > is preferred because it's much easier to handle errors nicely. > > E_ERROR is too severe even for strict_types=1, IMHO, because > user does not have chance to handle errors nicely at all. > > http://3v4l.org/aEpP8 > > Is this behavior is agreed behavior by discussion or a bug? > > In the RFC > > https://wiki.php.net/rfc/scalar_type_hints_v5#behaviour_of_strict_type_checks > it says > > --------------------- > Behaviour of strict type checks > > A strictly type-checked call to an extension or built-in PHP function > changes the behaviour of zend_parse_parameters. In particular, it will > produceE_RECOVERABLE_ERROR rather than E_WARNING on failure, and it follows > strict type checking rules for scalar typed parameters, rather than the > traditional weak type checking rules. > --------------------- > > It seems intended error level is E_WARNING/E_RECOVERABLE_ERROR according to > the RFC. > The output is a bit confusing: This will actually throw a TypeException, it's just currently rendered like a fatal error (known issue, will have to be resolved at some point). If you wrap your code with a catch (TypeException $e) you'll be able to handle argument type errors - this includes both errors for user typehints and for internal function types. Nikita --047d7bf0ef189b85f8051607abbf--