php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26875 class, static keyword
Submitted: 2004-01-12 03:15 UTC Modified: 2004-01-12 07:58 UTC
From: jonas at datatal dot se Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.0.0b3 (beta3) OS: win2k
Private report: No CVE-ID: None
 [2004-01-12 03:15 UTC] jonas at datatal dot se
Description:
------------
It is possible to call a class function directly dispite that it doesnt have the static keyword.

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

class Test
{

function MyFunction()
{
  echo 'Hello';
}

}

Test::MyFunction();

?>

Expected result:
----------------
Should only be possible if the function have been defined with the static keyword.
<?php

class Test
{

static function MyFunction()
{
  echo 'Hello';
}

}

Test::MyFunction();

?>

Actual result:
--------------
The code works (it shouldnt).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-12 06:44 UTC] sniper@php.net
Wrong. It worked like that in PHP 4, of course it will work like this in PHP 5. (BC)

 [2004-01-12 06:56 UTC] jonas at datatal dot se
How about adding an option the php.ini that does some stricter checking in PHP5? (must declare variables, variables must exist, static keyword must exist etc etc)
 [2004-01-12 07:58 UTC] alan_k@php.net
E_STRICT is available, however, since parent::method() and self::method() basically use the same infrastructure as static method calls. - AFAIK putting in warnings in here may be problematic.. (and adds another run-time performance hit..)


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 10:02:33 2024 UTC