Doc #68364 [Nab]: Missing reserved keyword 'self'

From: Date: Mon, 10 Nov 2014 18:06:10 +0000
Subject: Doc #68364 [Nab]: Missing reserved keyword 'self'
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-11624@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68364&edit=1 ID: 68364 Updated by: bwoebi@php.net Reported by: nanne at huiges dot nl Summary: Missing reserved keyword 'self' Status: Not a bug Type: Documentation Problem Package: Documentation problem Operating System: Irrelevant PHP Version: Irrelevant Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2014-11-06 14:21:34] 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-06 13:45:45] 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 12:46:40] 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=68364&edit=1

« previous php.doc.bugs (#11624) next »