php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42955 Public method can be call as static method
Submitted: 2007-10-13 09:46 UTC Modified: 2007-10-13 11:47 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: nicolas_boiteux at yahoo dot fr Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.4 OS: all
Private report: No CVE-ID: None
 [2007-10-13 09:46 UTC] nicolas_boiteux at yahoo dot fr
Description:
------------
Without instanciate object, its methods can be call directly as static methods.

This bug is also relative to this one:
http://bugs.php.net/bug.php?id=42016


Reproduce code:
---------------
<?php

class job{

public function doit(){
echo("yes");
}

}

job::doit();
?>

other exemple which return the normal error message:
<?php
class job{
private $foo;

public function doit(){
echo($this->foo);
}

}

job::doit();
?>

error message returned:

Fatal error: Using $this when not in object context in 


Expected result:
----------------
should return a fatal error:

Fatal error: Using public method when not in object context in .. on line...

as doit is not a static method, and not in an objet context.

Actual result:
--------------
print "yes"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-13 11:47 UTC] bjori@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

PHP Strict Standards:  Non-static method job::doit() should not be called statically in /home/bjori/- on line 11

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC