Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85982 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6142 invoked from network); 28 Apr 2015 04:14:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Apr 2015 04:14:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.180 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.213.180 mail-ig0-f180.google.com Received: from [209.85.213.180] ([209.85.213.180:33170] helo=mail-ig0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5C/AF-17556-9390F355 for ; Tue, 28 Apr 2015 00:14:51 -0400 Received: by igbpi8 with SMTP id pi8so81290891igb.0 for ; Mon, 27 Apr 2015 21:14:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=eksz+bH+csdhJ1AWsFdXfl4YMwi4Sw/DGFgxNbShPww=; b=mLjP1qY1CTrhxOgcxbqgoixua64LSGTf79+xRfadBTWlyBU8uA2X+Vrd6UXL7ERtn/ /fESq9Aq+O373R5JCdS07KMhptHi+4TC5Pk0Mc54x8yRNvCMn+sYzhJHGtCuX3mlyWc6 5NBJynBUpACZbA91wAO1bpIzmYIULzGE9CfDlK7wDgO11yORnn7Wzwz6JDOf1X9jnDNR KJc8rcQ7z/fX5cMWhwk/8GQnH4sx7o1QRBT0dnXPLQBZQeg45ezpuemQYQaaSqweghJb SBQhlJhW02BmC5Km3RSijjd0XtZ4Qb3jHkx78IgnQt/lhS6fLmJcnJVp+/mC02zVF19K I0zA== MIME-Version: 1.0 X-Received: by 10.42.133.197 with SMTP id i5mr16012900ict.5.1430194486550; Mon, 27 Apr 2015 21:14:46 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.79.98.67 with HTTP; Mon, 27 Apr 2015 21:14:46 -0700 (PDT) In-Reply-To: <1430169137.2886384.259330117.00E1734F@webmail.messagingengine.com> References: <1430169137.2886384.259330117.00E1734F@webmail.messagingengine.com> Date: Mon, 27 Apr 2015 22:14:46 -0600 X-Google-Sender-Auth: Ng42-MLgump0fO4E9WPZzALnvEI Message-ID: To: php@lvl.fastmail.com Cc: internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Resolution of static variables in the function scope not using forwarded calling information? From: levim@php.net (Levi Morrison) On Mon, Apr 27, 2015 at 3:12 PM, wrote: > Hello all, > > I ran into some very strange behavior while experimenting with static > function variables. It looks like a bug to me, but I couldn't find any > previous reports or discussions about the subject, so I wanted to gather > your input before submitting it as such. > > Static variables in the function scope appear to be resolved using late > static binding: the content of the variable in that function is shared > amongst all instances of a class, though each subclass gets its own > separate variable space. > > This is pretty logical and works fine. As an example, let's create > classes Base => Animal => {Cat,Dog}. Base has a function that describes > the class, and caches the result in a static function variable > $description. Calling describe() on the three different classes > correctly gives us three different results: http://3v4l.org/Qldve > > However, once you override the describe function in Animal and call > parent::describe() from within, it looks like all calling information is > lost: the resolution of $description in Base's function scope now always > points to Animal's variable space. For example: http://3v4l.org/qWrvf > > Overriding the function in one of the childmost classes like Dog gives > an even stranger result: $description is now correctly a separate value > in Cat vs Dog, but calling Animal::describe() now uses the value left by > its child class Cat?! See: http://3v4l.org/61P72 This last is the only one that seems to be a bug to me; I think if you step through the others you'll see why they are fine. Maybe the last isn't a bug either; I'll try to think about this more but it does appear to be a bug. > Any thoughts? > > Thanks, > Laszlo