Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96585 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32362 invoked from network); 24 Oct 2016 08:24:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Oct 2016 08:24:48 -0000 Authentication-Results: pb1.pair.com header.from=michal@brzuchalski.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=michal@brzuchalski.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain brzuchalski.com designates 188.165.245.118 as permitted sender) X-PHP-List-Original-Sender: michal@brzuchalski.com X-Host-Fingerprint: 188.165.245.118 ns220893.ip-188-165-245.eu Received: from [188.165.245.118] ([188.165.245.118:58551] helo=poczta.brzuchalski.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F2/8A-28528-845CD085 for ; Mon, 24 Oct 2016 04:24:41 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by poczta.brzuchalski.com (Postfix) with ESMTP id D658E2984236 for ; Mon, 24 Oct 2016 10:24:37 +0200 (CEST) Received: from poczta.brzuchalski.com ([127.0.0.1]) by localhost (poczta.brzuchalski.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ev3l3vhbH0gq for ; Mon, 24 Oct 2016 10:24:35 +0200 (CEST) Received: from mail-qk0-f170.google.com (unknown [209.85.220.170]) by poczta.brzuchalski.com (Postfix) with ESMTPSA id 8B7472984233 for ; Mon, 24 Oct 2016 10:24:35 +0200 (CEST) Received: by mail-qk0-f170.google.com with SMTP id z190so224598652qkc.2 for ; Mon, 24 Oct 2016 01:24:35 -0700 (PDT) X-Gm-Message-State: ABUngvdlMW1ZzmEGfQjCiquncrCN1pSQ9vxKW5CKohXjn9eUUMYzNEVaavmJjFFhzDjiL966cBT8KgZtrWYWKQ== X-Received: by 10.55.190.193 with SMTP id o184mr13463199qkf.31.1477297474730; Mon, 24 Oct 2016 01:24:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.45.238 with HTTP; Mon, 24 Oct 2016 01:24:34 -0700 (PDT) In-Reply-To: References: Date: Mon, 24 Oct 2016 10:24:34 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Michael Morris Cc: PHP Internals List Content-Type: multipart/alternative; boundary=94eb2c042f4e358310053f981f22 Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Object type hint From: michal@brzuchalski.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --94eb2c042f4e358310053f981f22 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2016-10-24 9:42 GMT+02:00 Michael Morris : > On Mon, Oct 24, 2016 at 3:21 AM, Micha=C5=82 Brzuchalski < > michal@brzuchalski.com> > wrote: > > > > > > > 2016-10-24 8:45 GMT+02:00 Michael Morris : > > > >> On Sun, Oct 23, 2016 at 3:39 AM, Micha=C5=82 Brzuchalski < > >> michal@brzuchalski.com> > >> wrote: > >> > >> > >> https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Comp > >> onent%21Assertion%21Inspector.php/function/Inspector%3A%3Aas > >> sertAllObjects/8.2.x > >> > > > > You're missing is_object on $member in foreach in your implementation > > > > Wrong - read the code more carefully. The function is variadic. If only 1 > argument is passed then is_object is checked against all members of the > array to test. If 2 or more arguments are passed than the instanceof > operator is used instead. This operator will return false when testing no= n > objects. > > > > and it won't be even needed if there where object type hint. > > > > > > Wrong again. The method tests a collection (array or traversable) to see = if > each member satisfies its test. Type hints do not work that way at all. > Even if they did, this code must work under PHP 5.5. > > If you're going to criticize someone's code at least read over it > carefully. And it wouldn't hurt to check the unit tests either since they > do exist for this method. See here: > You're right I didn't read it carefully. I was in my way to work and little bit hurry. also it is true that my patch doesn't affect your use case in any way you've pointed out. > > https://api.drupal.org/api/drupal/core%21tests%21Drupal% > 21Tests%21Component%21Assertion%21InspectorTest. > php/function/InspectorTest%3A%3AtestAssertAllObjects/8.2.x > > Best practice is to test for interfaces or more rarely classes. This RFC > encourages people to not do this so I'm not in favor of its inclusion. > --=20 regards / pozdrawiam, -- Micha=C5=82 Brzuchalski about.me/brzuchal brzuchalski.com --94eb2c042f4e358310053f981f22--