#42595 [Opn->Bgs]: Static call of non static function inherets class

From: Date: Sun, 09 Sep 2007 10:27:30 +0000
Subject: #42595 [Opn->Bgs]: Static call of non static function inherets class
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-117324@lists.php.net to get a copy of this message
ID: 42595 Updated by: jani@php.net Reported By: agideonse at planet dot nl -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: Irrelevant PHP Version: 5.2.4 New Comment: See bug #42559 Previous Comments: ------------------------------------------------------------------------ [2007-09-08 02:02:46] agideonse at planet dot nl Description: ------------ When a function in a class is not declared static it can still be called as a static method (no problem). When this is done from another class the function seems to know the values from the class that it was called from. It is not clarified in the manual why this should be the case ($this is bound to class A, not class B) if this isn't a bug. Reproduce code: --------------- class A { function __construct() { $this->name = "Class A"; } function doeIets() { B::doeIetsAnders(); } } class B { function doeIetsAnders() { print_r($this); } } Expected result: ---------------- In strict mode, there should be a warning that $this does not have a value. Actual result: -------------- $this has te values of class A. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42595&edit=1

« previous php.bugs (#117324) next »