Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88284 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31333 invoked from network); 17 Sep 2015 13:47:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Sep 2015 13:47:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.174 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.174 mail-wi0-f174.google.com Received: from [209.85.212.174] ([209.85.212.174:34330] helo=mail-wi0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F4/84-33947-184CAF55 for ; Thu, 17 Sep 2015 09:47:45 -0400 Received: by wicfx3 with SMTP id fx3so24686695wic.1 for ; Thu, 17 Sep 2015 06:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=51Gqk6Vct/eLZ0kHsYJdsBmtJ3D4N+WEDq3kpyQS08w=; b=vXXvZA+dbxPJ/Z2aKLMaI2k/Dj3aOqx7rBJtp1tuynzznyCmVoB8Mxq5AyjFNMzsPP UOcX3FbGF09cvtmyQ8lt/xmIsw+iyMESHcNF04SoXeEruu9J5zTUhzMJIA30mejZKtjJ 6Md9s750/3/7FV1K8AI4A7224krHNo5I3ffILnOzm0lc7g4KUKEk7is6AECVFpcgG4Q3 Tg9/RUXO9fjTehJJSKgjSvRNnvD1QVoavEJzpaea70YI2cmiIKZGDQVzJM7amSEgmksx LNbfQHg9unYXd4IKs43RmRPlYyMkkOzT+OO5PDgpE9TQpOUOgC1yuZeevZF5OMhZop2u pCCQ== X-Received: by 10.180.9.112 with SMTP id y16mr31043001wia.28.1442497662783; Thu, 17 Sep 2015 06:47:42 -0700 (PDT) Received: from [192.168.0.127] ([62.189.198.114]) by smtp.googlemail.com with ESMTPSA id hr17sm10214548wib.16.2015.09.17.06.47.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2015 06:47:42 -0700 (PDT) To: Terry Cullen References: <9AF329EC-99A5-412D-A52B-432627A5520F@gmail.com> <6F4D91EE-B56E-4B83-B1AF-598C3F6897FC@craigfrancis.co.uk> <55F07BA4.2000204@gmail.com> <55F6B911.9080400@gmail.com> <96BE7F01-D04B-483B-B1A3-B45CED6DFCDC@craigfrancis.co.uk> <55F6F08C.1020506@gmail.com> <0BEF6D82-CB5F-49F6-A3A4-3267924A0CDA@thesba.com> <55F72CA9.2060301@gmail.com> <09369945-76FE-4E08-9C2C-15FB0577AD27@thesba.com> <55F752E7.9070801@gmail.com> <55F9B4C7.3050700@gmail.com> <440C64A2-4B4F-4AEF-ACE3-F3A6637EBAB6@thesba.com> <55F9E5E7.3030408@gmail.com> <711C7F58-6187-4ED2-8314-EB217DF0EC2B@thesba.com> <55FAB790.9020905@gmail.com> Cc: internals Message-ID: <55FAC44A.8080409@gmail.com> Date: Thu, 17 Sep 2015 14:46:50 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28? From: rowan.collins@gmail.com (Rowan Collins) Terry Cullen wrote on 17/09/2015 14:09: > ​I agree that there is already ways around this issue, but I agree > with Bob that there is a hole that exists() would fill. I my world > where PHP is the glue between JSON requests and database queries, ​ > exists() would be a function I'd use way more the array_key_exists(), > property_exists(), isset() and empty(). Further, in some scenarios > exists($foo->bar) would replace isset($foo) && is_object($foo) && > property_exists($foo, 'bar'). Yes, I've proposed elsewhere in this thread an exists() function (maybe under a different name) that is just syntax sugar for array_key_exists/property_exists, and raises an error if used with a bare variable. This, it turns out, is exactly what Perl has: http://perldoc.perl.org/functions/exists.html So you'd write exists($foo->bar), and the compiler would basically turn that into property_exists('bar', $foo) with appropriate suppression of notices in the same way isset() and empty() have. There is still the problem that as this would be a language construct not a real function, there would be no way to polyfill it for older versions, so you couldn't use it until your code had a minimum version requirement of 7.1. A PECL extension *might* be able to backport it to older versions of PHP, but I doubt it would gain much adoption. Regards, -- Rowan Collins [IMSoP]