php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #68364 Missing reserved keyword 'self'
Submitted: 2014-11-06 12:46 UTC Modified: 2014-11-10 18:06 UTC
From: nanne at huiges dot nl Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
 [2014-11-06 12:46 UTC] nanne at huiges dot nl
Description:
------------
---
From manual page: http://www.php.net/reserved.keywords
---

The keyword 'self' is not featured in the list of reserved keywords, but it should be.

Test script:
---------------
<?php

class self{

}


Expected result:
----------------
The result "implied" by the manual is that this would work. 

(Not that I say the actual _expected_ result is empty by the way, this is obviously not a bug in code, but a bug in the manual). so you could say the expected 'result' is that it is in the manual :)


Actual result:
--------------
The correct

PHP Fatal error:  Cannot use 'self' as class name as it is reserved in test.php on line 3

is provided, even though it isn't in the documentation.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-06 13:45 UTC] bwoebi@php.net
-Status: Open +Status: Not a bug
 [2014-11-06 13:45 UTC] bwoebi@php.net
No, self (and parent) aren't keywords. You can declare a

function self() {} without problems. They're just forbidden to use in class contexts for resolving any ambiguity about what self:: and parent:: should address. The class itself/parent of the class or the classes self/parent?
 [2014-11-06 14:21 UTC] nanne at huiges dot nl
While technically correct, the issue should be obvious: the fact that a class cannot be called 'self' is missing from the documentation. Somewhere under the heading "List of Reserved Words" should be mention of this fact, don't you agree?

I accept the fact I mistakenly used the word "keyword" where it should not have been used and perhaps the page http://www.php.net/manual/en/reserved.php should have been referenced instead of the offending "reserved.keywords". Mea Culpa.

It is still an omission as far as I'm conserned, and it might be a good thing to have a ticket of that fact in the system, wouldn't you agree?
So I suggest that the ticket be amended rather then just closed, as that seems more productive really.

Have a good day!
 [2014-11-10 18:06 UTC] bwoebi@php.net
It is documented at http://php.net/manual/en/reserved.classes.php (see the last section). That's the right place too, as it's something specific to classes.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 13:01:30 2024 UTC