#44771 [Asn->Bgs]: Calling nonstatic methods in context of another objects

From: Date: Sun, 01 Jun 2008 13:38:41 +0000
Subject: #44771 [Asn->Bgs]: Calling nonstatic methods in context of another objects
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-125407@lists.php.net to get a copy of this message
 ID:          44771
 Updated by:  felipe@php.net
 Reported By: igor at webta dot net
-Status:      Assigned
+Status:      Bogus
 Bug Type:    Scripting Engine problem
 PHP Version: 5.3CVS-2008-04-18 (snap)
 Assigned To: dmitry
 New Comment:

Exception? This isn't expected. Currently, an E_STRICT is issued.

Strict Standards: Non-static method A::bar() should not be called
statically, assuming $this from incompatible context in ...



Previous Comments:
------------------------------------------------------------------------

[2008-04-18 06:58:30] igor at webta dot net

Description:
------------
Calling nonstatic methods in context of another objects

Reproduce code:
---------------
class A
         {
                 public function bar ()
                 {
                         sort($this->arr);
                 }
         }
 
         class B
         {
                 public $arr = array('a', 'c', 'b');
                 
                 function run ()
                 {
                         A::bar();
                         var_dump($this->arr);
                 }
         }
         
         $b = new B();
         $b->run();

Expected result:
----------------
Exception

Actual result:
--------------
Sorted array:

array
  0 => string 'a' (length=1)
  1 => string 'b' (length=1)
  2 => string 'c' (length=1)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44771&edit=1



Thread (3 messages)

« previous php.bugs (#125407) next »