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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 23:01:29 2024 UTC