Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101399 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70771 invoked from network); 19 Dec 2017 22:15:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Dec 2017 22:15:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=andreas@dqxtech.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=andreas@dqxtech.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dqxtech.net from 209.85.215.42 cause and error) X-PHP-List-Original-Sender: andreas@dqxtech.net X-Host-Fingerprint: 209.85.215.42 mail-lf0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:37310] helo=mail-lf0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C4/98-10479-57F893A5 for ; Tue, 19 Dec 2017 17:15:18 -0500 Received: by mail-lf0-f42.google.com with SMTP id a12so21864245lfe.4 for ; Tue, 19 Dec 2017 14:15:17 -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=tTJFuKER/PnSQi88lifC7Ehsk9jE7B5BPWnHox98HYU=; b=ImNk7BzELVHEyLBNTHj0JPc5vObHFkqDjlNs1IuC5AJVmCphsogHC9l37DK9Sglk+2 Oi6nbvBcJwp+Bq9c/qXPgiSh96oiUhGv7ch1JnVVLum1XkKQfvhBuFpZvDYrR7SKPEGK 0cmoc/jP+O2pAFZpGiu/IyX/IQqzX4G8PzYS5VsbYGSlBRYZfI4JeLLVuc7TLoHypNJT GUZLmW+1dsODZAUYAWG0RqTHP00UReSKNRG5L5JLITlG89R1xE+erzVOd1Xtl5AfCidd 305Z3WJDjVKJGuh178r1uPDRyR85NWqd0tI7Cv9MQ2NP25YEwNu9X9f1H8eFKit3ajuR U4kg== 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=tTJFuKER/PnSQi88lifC7Ehsk9jE7B5BPWnHox98HYU=; b=tSS9uQks2LrW+Y9tJo3k9+GzWCTnjNxLXHpblu2W4lYp2ihAPclWXX+UJD/zETbOge cDn97wZDVPlkXqxpwl1dmranqnlCXWvGI8GZJNf2hYs3djyljzdOgNQq5nxZUy+4FNuR 7GJ3jzol/Kd5SiG8w4NCkmMA/3q0mZ3EFsp5xiG60Hz2fir3yxkMErFEtHmwJRnXL3oG 8oWpccyu8mVdVczf70eKDTJM7ggCSdRC3uH6AwuzB22GbZqFT918Z7W+v3B956EbI64k OyjmNqx+4+Rp04+HShKB37YKQMzsVcRSJ13SpFd9tyPoy7zLJ2SrYs0WqEnNxb3arYKF RfxQ== X-Gm-Message-State: AKGB3mIkJEPCWajeRBhDsala3B0+GqKMKXEAHMtAG5lSZAjC9QNyEkFE R604zI6O/+nJdkna8HMq4GZq44H+ X-Google-Smtp-Source: ACJfBouelLvG37LyzfoBxjUUJuCKgoJ/gcGodqBIPQEqL0GPEhuGFe7jpousVJURd20Fmo1nqxkshQ== X-Received: by 10.25.32.68 with SMTP id g65mr2949366lfg.115.1513721714483; Tue, 19 Dec 2017 14:15:14 -0800 (PST) Received: from mail-lf0-f52.google.com (mail-lf0-f52.google.com. [209.85.215.52]) by smtp.googlemail.com with ESMTPSA id m7sm3542300lfg.43.2017.12.19.14.15.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Dec 2017 14:15:13 -0800 (PST) Received: by mail-lf0-f52.google.com with SMTP id u84so1900174lff.7 for ; Tue, 19 Dec 2017 14:15:13 -0800 (PST) X-Received: by 10.25.41.194 with SMTP id p185mr3092746lfp.125.1513721713065; Tue, 19 Dec 2017 14:15:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.170.16 with HTTP; Tue, 19 Dec 2017 14:14:52 -0800 (PST) In-Reply-To: References: Date: Tue, 19 Dec 2017 23:14:52 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Michael Morris Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] instanceof survives non-object variables, but crashes on non-object constants. From: andreas@dqxtech.net (Andreas Hennings) We can still do this as a follow-up. The current fix is easy and straighforward. What you suggest might be a good idea, but I think deserves more discussion. On 19 December 2017 at 23:09, Michael Morris wrote: > What would it hurt to allow instanceof to return types other than object? > > $x instanceof NULL > $x instanceof string > > and so on. This would be more powerful and useful than throwing an error > where one wasn't being thrown before. It also would let one operator detect > all the types, rather than the plethora of detect functions we currently > have. > > On Tue, Dec 19, 2017 at 4:48 PM, Nikita Popov wrote: > >> On Sat, Dec 9, 2017 at 7:28 AM, 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. >> > >> >> I've prepared a PR for this change: https://github.com/php/php- >> src/pull/2978 >> >> From the discussion I'm understanding that our consensus is to implement >> this change, so if there are no further objection I'll merge this in a few >> days. >> >> Nikita >>