Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101279 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9618 invoked from network); 9 Dec 2017 12:46:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Dec 2017 12:46:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.216 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.216 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.216] ([81.169.146.216:19234] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 25/25-62356-61BDB2A5 for ; Sat, 09 Dec 2017 07:46:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1512823572; s=domk; d=kelunik.com; h=Content-Type:Cc:To:Subject:Message-ID:Date:From:References: In-Reply-To:X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject; bh=9pSmCpGrLZYmBLKdfpJr5fE0/NlgUX0oFIocnYDHFSg=; b=pFmQrSEweq9u7fovceJd0TeKsvvrQrR8HgLnUB2JXFsoMpVgLbc4hXTL7MrqpaCEio hoI414XlUNRaTBGJl1LexAEEgrX9ML+A9gw2aM/bnkOwFzJnh89B2Rw2TYwZnuS6ky0y ufScDZ4kFhKFytscMOtpcnK2Njt6d+plBuSIw= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mlsGbEv0XHBzMIJSS+jKTzde5mDb8Db2nURiu3cA== X-RZG-CLASS-ID: mo00 Received: by mail-yw0-f170.google.com with SMTP id x199so5584711ywg.5 for ; Sat, 09 Dec 2017 04:46:11 -0800 (PST) X-Gm-Message-State: AJaThX6By1Q8bC/Z6jT8o0raODkwf9x0E5NglTH/yRnXc/op9PmkVwOz Nte8vCCIMukoB/cdDI9jbwidkR4ehEgeMseL++M= X-Google-Smtp-Source: AGs4zMYDNTnmeOA8DhhNula+ULa12LUX5x8hdUT3g9XtPzwDqDKQDjTncaWuxHmp7VBfZOcu7QVQGna0qOJDf5gf9mI= X-Received: by 10.13.231.3 with SMTP id q3mr22706949ywe.442.1512823571282; Sat, 09 Dec 2017 04:46:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.124.71 with HTTP; Sat, 9 Dec 2017 04:46:10 -0800 (PST) In-Reply-To: References: Date: Sat, 9 Dec 2017 13:46:10 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Kalle Sommer Nielsen Cc: Andreas Hennings , Internals Content-Type: multipart/alternative; boundary="94eb2c08050493015b055fe7af8b" Subject: Re: [PHP-DEV] instanceof survives non-object variables, but crashes on non-object constants. From: me@kelunik.com (Niklas Keller) --94eb2c08050493015b055fe7af8b Content-Type: text/plain; charset="UTF-8" > > That is fine for code that is broken in the first place. Similarly we added > a warning some years back about array to string conversions. > Code using instanceof on possible non-objects isn't broken. instanceof simply does an implicit is_object() check without needing an extra function call. I know that a change there would break Amp in quite a few places ( https://github.com/amphp/amp/search?utf8=%E2%9C%93&q=instanceof&type=) and I'm very sure that a lot of other applications would break, too. > The impact should be minimal as is, so persevering bc for broken usage is a > poor argument imo > Why is it broken? What's wrong with the implicit is_object() check? 1 instanceof XXX *is clearly broken* on the other hand, which can be statically verified to fail in all cases. Regards, Niklas --94eb2c08050493015b055fe7af8b--