php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #42115 Should not allow static keyword before visibility keyword
Submitted: 2007-07-26 20:14 UTC Modified: 2007-07-27 09:03 UTC
From: mattsch at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.2.3 OS: Gentoo Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mattsch at gmail dot com
New email:
PHP Version: OS:

 

 [2007-07-26 20:14 UTC] mattsch at gmail dot com
Description:
------------
Contrary to the documentation, you're allowed to put the static keyword before the visibility keyword.  Shouldn't this throw an E_STRICT warning?

Reproduce code:
---------------
<?
class foo {
static public function bar($foo){
echo $foo;
}
}
foo::bar('test');
?>

Expected result:
----------------
E_STRICT: You cannot declare static before a visibility keyword.

Actual result:
--------------
Echoes "test" without warning.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-27 02:27 UTC] judas dot iscariote at gmail dot com
No, PHP is a dynamic language, I dont see why this should raise any kind of error

1. does not cause any problem.
2.it is perfectly valid code.
 [2007-07-27 03:33 UTC] mattsch at gmail dot com
I don't argue that php is a loosely typed language but it does have rules and it should either adhere by them or change the rules.  Currently the documentation says that static must come after visibility:

http://www.php.net/manual/en/language.oop5.static.php

"The static declaration must be after the visibility declaration."

So either emit an E_STRICT warning or change the documentation to include this syntax as well.
 [2007-07-27 07:12 UTC] derick@php.net
Documentation problem it is
 [2007-07-27 08:57 UTC] rquadling@php.net
Code: http://pastie.caboo.se/82738
Output: http://pastie.caboo.se/82739

It seems that the static can really go either side of the visibility keyword for all visibilities.

I can confirm that this is the case since V5.0.0 (just downloaded that from (3 years old this month).


 [2007-07-27 09:03 UTC] rquadling@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 13:01:31 2025 UTC