Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:35847 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42116 invoked by uid 1010); 28 Feb 2008 12:48:17 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 42101 invoked from network); 28 Feb 2008 12:48:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Feb 2008 12:48:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=rewbs.soal@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rewbs.soal@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.132.247 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rewbs.soal@gmail.com X-Host-Fingerprint: 209.85.132.247 an-out-0708.google.com Received: from [209.85.132.247] ([209.85.132.247:58093] helo=an-out-0708.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 47/A5-08995-09DA6C74 for ; Thu, 28 Feb 2008 07:48:16 -0500 Received: by an-out-0708.google.com with SMTP id c18so671190anc.1 for ; Thu, 28 Feb 2008 04:48:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=tO3gzWErYz/79+sVu6/7ZWy/2K88uPgRdKluIR0AzPQ=; b=a5KheAZyhLZtviu0qopUzJbWuiuG8OZteQ8lmA4Mcg+t+zIeSR1tE9hGYIBv1O7OqKI/yWhdwpXWR9auBgL5KvtCS9Jjgr+aAq739HZXcQFOnfoORXVeO1qoyO3HSvKYw8Cuc/xksPUpCLWt+A7xiBV2MvmkXb1TvtXimvS9SGk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=wliXknl7UPtJ7uoRf3FqME/mCgnsJlMd/2VKmElBc6C1LJ+nX61EFOLSnlMA3UeNPc48i2kMPiluWP6czu1SB2kqZK75/W4/6JvOrcR8iJW3lvl7pOFJ/0VNW9WAoypwq4fWs61Jqm9LKxBKN0wbVadoYY1Rjq0tyFKNBRyXnyE= Received: by 10.100.143.12 with SMTP id q12mr15519939and.89.1204202894127; Thu, 28 Feb 2008 04:48:14 -0800 (PST) Received: by 10.100.47.7 with HTTP; Thu, 28 Feb 2008 04:48:14 -0800 (PST) Message-ID: <5a8807d10802280448w3a105a70yb29b81423bb784c@mail.gmail.com> Date: Thu, 28 Feb 2008 12:48:14 +0000 Reply-To: robin@soal.org To: internals@lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: [PHP-DEV] get_defined_vars() inconsistencies and op_array->uses_this From: rewbs.soal@gmail.com ("Robin Fernandes") Hi all, At compile time, the engine detects whether $this is used in an op array (using opline_is_fetch_this()). If so, it sets the flag op_array->uses_this. At the start of each execute loop, if this flag is set and a context object is available, a reference to the context object is added to the locals map. Thus the userspace $this reference is created. Problem is, the compile time check does not detect dynamic uses of $this, resulting in inconsistent behaviour in several areas, such as: --> When using get_defined_vars(). --> When accessing $this as a variable variable. Illustration here: http://pastebin.ca/920973 This could be solved by creating $this regardless of the op_array->uses_this flag - i.e. only if an appropriate context object has been set. Simple patch: http://pastebin.ca/920986. I tried it, and it only breaks one test: Zend\tests\get_defined_vars.phpt (with the patch, get_defined_vars() shows $this, which is arguably the correct behaviour). So the compile-time decision to avoid adding $this as a local userspace variable clearly has disadvantages. What are the advantages? If it's for performance only, is the optimisation worth the inconsistency that it causes? Regards, Robin