Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87926 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31181 invoked from network); 26 Aug 2015 10:11:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Aug 2015 10:11:36 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; 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:32815] helo=mail-wi0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 20/C0-17883-6D09DD55 for ; Wed, 26 Aug 2015 06:11:34 -0400 Received: by wijn1 with SMTP id n1so19042616wij.0 for ; Wed, 26 Aug 2015 03:11:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=xODNLMntKdixZfmtAhPVuNZpJzHtLRY8Q0TnRvZfBPg=; b=SaFJpgbJjwyufZbAVYra8I/4CdmrMhzUmb7cZdjOWUTHEOj31pQIzhZvaAsvMm8te8 tpjj9WfQvYtFiUVxshjfVsWJqAXakwnPXIOFJVPiIyD33ezrB3y7Wrp+LbkI3ZOlPsLB Dgnp/M0BaiofXD4uBrj/ot9kOQOI7F0oFyxT0/npDsj0Mr/wjCva1cbOO8u01Hg7SQD8 oMk+rIwR3zU6mJ8+PS/mBgM0egR+cbEyoEGRi2nGldAAO02nhQqNZUp1SDdYJ1OFwG2y 4f5UY/R1xZnzqKKtlF3BN48QUbQDz8oNmj4rGYmuxUfpP/XTw/JBY0N1rWu0hk/49z5U 2wIg== X-Received: by 10.194.175.200 with SMTP id cc8mr59925770wjc.87.1440583891097; Wed, 26 Aug 2015 03:11:31 -0700 (PDT) Received: from [192.168.0.83] ([62.189.198.114]) by smtp.googlemail.com with ESMTPSA id cw8sm3034303wjb.49.2015.08.26.03.11.30 for (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Aug 2015 03:11:30 -0700 (PDT) To: internals@lists.php.net References: Message-ID: <55DD909A.30907@gmail.com> Date: Wed, 26 Aug 2015 11:10:34 +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: 7bit Subject: Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28? From: rowan.collins@gmail.com (Rowan Collins) Scott Arciszewski wrote on 26/08/2015 04:09: > Hi everybody, > > Would anyone be interested in adding another helper like > isset()/empty() simply called exists() which would return true if the > variable is defined in the current scope (i.e. without raising an > E_NOTICE)? My answer to this would be a very loud "no". I have written at length about this on StackOverflow: http://stackoverflow.com/a/18646568/157957 In short, if your algorithm relies on knowing whether, anywhere in the preceding scope, a variable has been implicitly "declared" (in as much as that concept has any meaning in PHP), that algorithm is broken. If it relies on knowing whether a variable has been changed from its initial state, then isset() will do exactly what you want. Note that many people looking for examples of this "problem" start mentioning array keys and object properties; we have functions for checking existence of those, so please don't waste time on such examples. Regards, -- Rowan Collins [IMSoP]