|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #74463 Reserved keywords as function name?
Submitted: 2017-04-18 04:37 UTC Modified: 2017-04-18 05:22 UTC
From: usr at airmail dot cc Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 7.1.4 OS: Mac OS X
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.
Block user comment
Status: Assign to:
Bug Type:
From: usr at airmail dot cc
New email:
PHP Version: OS:


 [2017-04-18 04:37 UTC] usr at airmail dot cc
The documentation says:

The following words cannot be used to name a class, interface or trait, and they are also prohibited from being used in namespaces.

But it does not mention the use of these words in function names.

Is it safe to use those in the provided manner (see test case)?

Test script:
/* This works??? */
namespace A\B {
	function String() {

namespace {

/* This breaks */
namespace A\B {
	function private() {

namespace {

/* This also breaks */
namespace A\B {
	class String {}
namespace {
	$str = new A\B\String();


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-18 04:58 UTC] wes at example dot org
Hi, please read
 [2017-04-18 05:13 UTC] usr at airmail dot cc
The RFC states 'restricted to OO scope only'.

However my question is not about OO but rather a function name, so this RFC does not really answer my question.

Or am I overseeing something?
 [2017-04-18 05:17 UTC] usr at airmail dot cc
What further confuses me is that `function Array` is invalid while `function String` is not.

I'm aware that `array()` is a language feature, but shouldn't the keyword enforcing be consistent?
 [2017-04-18 05:22 UTC]
-Status: Open +Status: Not a bug
 [2017-04-18 05:22 UTC]
When reading documentation, be sure to read *all* the documentation. Not just a couple pages of it.
"private" and "array" are covered there.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Feb 25 17:01:24 2021 UTC