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
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: jonas at datatal dot se
New email:
PHP Version: OS:

 

 [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 12:01:34 2024 UTC