Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87745 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88719 invoked from network); 13 Aug 2015 17:01:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Aug 2015 17:01:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=me@daveyshafik.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=me@daveyshafik.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain daveyshafik.com from 209.85.213.182 cause and error) X-PHP-List-Original-Sender: me@daveyshafik.com X-Host-Fingerprint: 209.85.213.182 mail-ig0-f182.google.com Received: from [209.85.213.182] ([209.85.213.182:38909] helo=mail-ig0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BD/97-00702-A4DCCC55 for ; Thu, 13 Aug 2015 13:00:58 -0400 Received: by igfj19 with SMTP id j19so40366913igf.1 for ; Thu, 13 Aug 2015 10:00:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:date:message-id:subject:from :to:content-type; bh=BXHqtwsdXifVIBUtudTwxQLUj7shg6fmUMeH0szZDeE=; b=UL6as/MXGhChZBxaKGqR7H0s2DSnhXRGlM/tc4LkIhwo0EhaGt8U94pX1JTk5bYiTx /QnvNn8PEjsyaFytYSznOk6O/LfbeEgJ42kQiz9K91/JzPehzh/rCY0CUsQD/v0OkSeD /grVcOVVyZ90NUgN1XEXb5HFP0XlNF4gQI6s/Gpl/cbt1mWbg/iIZjOwFom8lSz3xbiO HavqUNuRGYGYdqY5K2z5bjZKR8t0A0yTovFSbfCU0qBZgFgLezZ8GPom1ATXK93LMGnP i4z2iiMjJdTEQhJeO5madBaQ4ZR02iA2mcELMkpFl5MmWFpseifJGDrrg9gVyeuorCph wv7g== X-Gm-Message-State: ALoCoQnSvHVi4r+udmbyteyALEbn++o6bvOzOtwqQAtBmGoA4xX+9LoTCevrN859SYXH2fWLaL0y MIME-Version: 1.0 X-Received: by 10.50.83.98 with SMTP id p2mr28691960igy.72.1439485255915; Thu, 13 Aug 2015 10:00:55 -0700 (PDT) Sender: me@daveyshafik.com Received: by 10.107.141.74 with HTTP; Thu, 13 Aug 2015 10:00:55 -0700 (PDT) Date: Thu, 13 Aug 2015 13:00:55 -0400 X-Google-Sender-Auth: jd_2b5ILBMbs613tr-Fz9KA_Z-g Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e0129457456bfeb051d344758 Subject: Warning (5.x) -> TypeError (7) for internal Constructors From: davey@php.net (Davey Shafik) --089e0129457456bfeb051d344758 Content-Type: text/plain; charset=UTF-8 Hi, I was trying to come up with an example for the https://wiki.php.net/rfc/internal_constructor_behaviour RFC and noticed some unexpected behavior. Based on one of the examples: In PHP 5.6 it will emit a Warning, and returns a unusable instance of ReflectionFunction, the latter of which should be resolved by the RFC above. Warning: ReflectionFunction::__construct() expects parameter 1 to be string, array given In PHP 7b3 (and going back to b1 at least), it now throws a TypeError on the mis-match. I would expect this behavior in strict type mode, but not by default. (see: http://3v4l.org/jQQtX). The same if you do new PDO([]); but it would have returned a null previously. Yes, the result is the same, in both cases, an exception should be thrown, but it should be Constructor failed (the exact exception seems to change depending on the class you're instantiating). In some cases, this behavior is as expected: new MessageFormatter('en_US', null); Will result in an IntlException with message "Constructor failed" (see: http://3v4l.org/uAjUr) I discussed this with Anthony and he pointed out this commit by nikic as the change that introduced this behavior: https://github.com/php/php-src/pull/1215 I believe that internal functions and methods should only emit a warning (as per 5.x) for incorrect argument types, unless (1) it's a constructor failure, and (2) you're not using strict mode. Thoughts? --089e0129457456bfeb051d344758--