Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101398 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69350 invoked from network); 19 Dec 2017 22:10:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Dec 2017 22:10:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=tendoaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tendoaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.177 as permitted sender) X-PHP-List-Original-Sender: tendoaki@gmail.com X-Host-Fingerprint: 209.85.161.177 mail-yw0-f177.google.com Received: from [209.85.161.177] ([209.85.161.177:41016] helo=mail-yw0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 04/48-10479-63E893A5 for ; Tue, 19 Dec 2017 17:10:00 -0500 Received: by mail-yw0-f177.google.com with SMTP id f1so1057278ywd.8 for ; Tue, 19 Dec 2017 14:09:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=H7FvshOpH+kxl+cpuiVlPGYisfPOQRcNOIqCncTUZ/U=; b=YojhniHlfxcxk/k8f1dCvrIFhvN8hJ2BBiTm/Cd7Ps/rs0XT2T2feHoX5kBG6BdhG2 GUzhCpoh1tBHk+kHjAvefCEhgVuTtjz5/KiZ+aTWMW7szcHERSapNmjv6xFH9RWjkUyj of0iBiWQOMU9/dkChqV/BTWYoHkbbC4G34xjuXdv7+ZyyKmSfLkyM7YfEiZ5RZ+GCHAW 0aBCF6mcmBU3a64YvO0jpizB4Z6c1BR/qh5CP+W8pbp5RNVLWXGGWdx6yO50bFFFeqyH EVXSRo5OHwPzAighntT9AT0O4xZ/ztk1CzBnYWjyndJ0NBNUCN6kmXRTjuB5E8LfqOmc 6mFA== 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; bh=H7FvshOpH+kxl+cpuiVlPGYisfPOQRcNOIqCncTUZ/U=; b=VfybtwBQzRLfZSJyRwod1XMEV6Q40rUA8UvwQ3vpKy1kr8DQvi+fh/nXV63QCA9Gnw culRXd+1GfqzH/bAenDul4u+rMtX1pwmJIku4j+DO44jtIdC5eoQ+8tmDtjYnRCaVv+e InoXmNJGRpZORSTdgaEYbtnC8a0SY75BGAUMGtF84wRhU2zqBTg61iDyj3OFxMhYgclc 5lFQ5RaJBzhWANwUavYn5RIBhCKGE2y9MdaUleWeNoRVordoDPlh4Tv8qroQUdYW4t2h I/PvonaysxUe95WGHedWdzr91JLY46lW5reGPrCA+6/KkmJFlx/1zjC8cb+vtqrRXJ2D IncA== X-Gm-Message-State: AKGB3mI+SjDlOzflmg686SnZVBhPo7mJsbTMoowbTC02oGt8xXWDHoqi F/5s46ZL1zS8PSpUhn3LS68HNQPGa8IEwdKNNQ8= X-Google-Smtp-Source: ACJfBot2sxYp4WhirloPhrMJSelYuiDij8rQjpID5lSW6iBBgjRxySDR7fuH0lPWFKp/Nj9McXfhbqMVp61s/y6Mqec= X-Received: by 10.129.128.69 with SMTP id q66mr3606351ywf.81.1513721396206; Tue, 19 Dec 2017 14:09:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.201.7 with HTTP; Tue, 19 Dec 2017 14:09:55 -0800 (PST) In-Reply-To: References: Date: Tue, 19 Dec 2017 17:09:55 -0500 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="94eb2c030b641c222d0560b8bad7" Subject: Re: [PHP-DEV] instanceof survives non-object variables, but crashes on non-object constants. From: tendoaki@gmail.com (Michael Morris) --94eb2c030b641c222d0560b8bad7 Content-Type: text/plain; charset="UTF-8" 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 > --94eb2c030b641c222d0560b8bad7--