Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101275 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92948 invoked from network); 9 Dec 2017 06:38:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Dec 2017 06:38:40 -0000 Authentication-Results: pb1.pair.com header.from=andreas@dqxtech.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=andreas@dqxtech.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dqxtech.net from 209.85.215.52 cause and error) X-PHP-List-Original-Sender: andreas@dqxtech.net X-Host-Fingerprint: 209.85.215.52 mail-lf0-f52.google.com Received: from [209.85.215.52] ([209.85.215.52:41102] helo=mail-lf0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/13-62356-FE48B2A5 for ; Sat, 09 Dec 2017 01:38:40 -0500 Received: by mail-lf0-f52.google.com with SMTP id f18so13974090lfg.8 for ; Fri, 08 Dec 2017 22:38:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=CiRegqtaCeCvMWnvIZWStVt/qWX018T+fSh77dodNgw=; b=eOCpsfpem06LH2OuyDYPoXqlqx0pzGQMi8nXHiDTAC2zufmPZVx0CFPucgqfG7fJZo Cbe/ZNjATT5RMcFGVtSBmUITQBLvlBMdiGVHmR+C7TEt31Z6JUQKz0DyPW2kF2vjOabX KqgKxH1UNeOCm38XxJHMlqb1wahSFA5+/z1GMNN/tVOKnd0TPpUqgx9OCw7QNaIfDp8d w4fSxxkiBA45929xEXKqsxdfvd5F3YkpcYd3bqPBDSTwS3qnk9FPiAyy31dO3RoRSYVm 68dc2MchlIXpcP4HUceLqH69oDuyBncBYNuyw7wITKraxb861z9Vqcg4UyjWv2OUd5OD 5eNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=CiRegqtaCeCvMWnvIZWStVt/qWX018T+fSh77dodNgw=; b=ZZFWh712XsqChrVExALhKYp36hFWBSO7ejmhoqXcZ5/MI2b5gxw7jgvUGetszGeXOO 6CP80enPMJKdWoYRvZntRbU1mycCuUGxaatmdKCMFi+H1B1rwTfd9sYYmf+CG9JmCbUS 6ktWFNo8rIQwuub0d6NdBLleLvUvWaqRjIf/al5D//j6tCq5q30zvmO1/c8Uy8eVmpNf jtIrECg4r10NcEtg3jfZKSTxovvK+L4gdGlVoOxyd8C9CfhcbJwb0Bni/bkVscQrdBqZ Jv5rc212jc6NvRy3lq6JPEUGzfqGPNPfPBw/Z3WjjIQscN475M0u42rPWXv+kB+e1J7W 1Rwg== X-Gm-Message-State: AJaThX7p59OmuYWfEVXipph/ia63GZYHQ+eMIaU2rrbs5iDlOyPwgFof eXzzBLsCQbVxdVvaGakiTCFu6sZn X-Google-Smtp-Source: AGs4zMZ+geRn6RtwTZKMoJy3lpB6Li3eIcJ5D5K/gbcNypeh+kaHmcPVaV205x7KOzTn3zi/ozNd/g== X-Received: by 10.46.95.28 with SMTP id t28mr17266110ljb.110.1512801516156; Fri, 08 Dec 2017 22:38:36 -0800 (PST) Received: from mail-lf0-f46.google.com (mail-lf0-f46.google.com. [209.85.215.46]) by smtp.googlemail.com with ESMTPSA id z68sm1796201lje.26.2017.12.08.22.38.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Dec 2017 22:38:35 -0800 (PST) Received: by mail-lf0-f46.google.com with SMTP id f20so13999264lfe.3 for ; Fri, 08 Dec 2017 22:38:35 -0800 (PST) X-Received: by 10.46.71.133 with SMTP id u127mr17054307lja.52.1512801515043; Fri, 08 Dec 2017 22:38:35 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.170.16 with HTTP; Fri, 8 Dec 2017 22:38:14 -0800 (PST) In-Reply-To: References: Date: Sat, 9 Dec 2017 07:38:14 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Kalle Sommer Nielsen Cc: Internals Content-Type: multipart/alternative; boundary="001a1140754ceb8020055fe28c08" Subject: Re: [PHP-DEV] instanceof survives non-object variables, but crashes on non-object constants. From: andreas@dqxtech.net (Andreas Hennings) --001a1140754ceb8020055fe28c08 Content-Type: text/plain; charset="UTF-8" Adding a warning to something that used to be ok would break existing code. I remember a number of cases where I used instanceof on possibly non-objects. if ($x instanceof C) { return $x; } elseif ($x === NULL) { ... } All such code would then produce warnings. On 9 December 2017 at 07:35, Kalle Sommer Nielsen wrote: > Hi > > We should just add a warning to the first example, it seems like an > oversight that it was left silent > > On 9 Dec 2017 07.29, "Andreas Hennings" wrote: > >> The following (https://3v4l.org/A2Tp6) is ok, it simply returns false: >> >> $x = 1; >> $x instanceof \stdClass; >> >> >> The following (https://3v4l.org/IdSBu) gives a fatal error: >> >> 1 instanceof \stdclass; >> >> t think this behavior is inconsistent, and we should consider changing it. >> >> There are two options, but only one is BC. >> >> - Let 1 instanceof \stdClass return false, instead of crashing. -> seems >> BC >> - Let $x instanceof \stdClass crash, if $x is not an object. -> BC break. >> >> So it seems the first would the option we should take. >> This is also what hhvm does, according to https://3v4l.org/IdSBu. >> > --001a1140754ceb8020055fe28c08--