php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44771 Calling nonstatic methods in context of another objects
Submitted: 2008-04-18 06:58 UTC Modified: 2008-06-01 13:38 UTC
From: igor at webta dot net Assigned: dmitry (profile)
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3CVS-2008-04-18 (snap) OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: igor at webta dot net
New email:
PHP Version: OS:

 

 [2008-04-18 06:58 UTC] 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)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-01 13:38 UTC] felipe@php.net
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 ...

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 14:01:36 2025 UTC