|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-10-26 11:21 UTC] derick@php.net
[2005-10-26 11:22 UTC] tony2001@php.net
[2005-10-26 15:59 UTC] olympic at dino-online dot de
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 13:00:01 2025 UTC |
Description: ------------ In static calls $this is set. While in theory it might make sense to allow objects of the same class (or derived class) to "use" this feature, it's a potential pitfall and from my point of view it's bug. I think if a non static method is called statically then $this can't be any object that hasn't been created by this or a derive class. No other language has such a "feature" :) If it's not a bug, then read my bugreport as "remove this feature". If it's a bug, add a runtime checking for $this is object created by same or derived class. Reproduce code: --------------- Example: Noone can really say that this is "transparen" ok: class Foo { private $hallo="I am from Foo"; function dontCallMe() { return $this->hallo; } } class Bar { public $hallo="I am from Bar"; function testMe() { return Foo::dontCallMe(); } } $x=new Bar(); echo ($x->testMe()); // expected runtime error... Expected result: ---------------- Runtime error. Actual result: -------------- output is: "I am from Bar" This return the member var of Bar, what you would NEVER expect.