#49982 [Com]: Inclusion of token/syntax keyword in namespace causes Parse error

From: Date: Sat, 24 Oct 2009 18:49:18 +0000
Subject: #49982 [Com]: Inclusion of token/syntax keyword in namespace causes Parse error
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-2999@lists.php.net to get a copy of this message
ID: 49982 Comment by: swquinn at gmail dot com Reported By: swquinn at gmail dot com Status: Open Bug Type: Documentation problem Operating System: Windows XP Professional PHP Version: 5.3.0 New Comment: Follow-up: Sorry for the double post. I went back and reviewed the documentation. Still couldn't find anything, but on the manual page "Defining Namespaces" (http://www.php.net/manual/en/language.namespaces.definition.php) there was a user comment that I missed when going through the documentation that mentions this issue as well. If its not in the actual manual, it would be great to note this some place! And, thank you for your response! Previous Comments: ------------------------------------------------------------------------ [2009-10-24 18:44:52] swquinn at gmail dot com Is there any possibility in the future (e.g. PHP 6+) that the acceptable vocabulary for namespaces could be expanded so that the use of a keyword in the namespace doesn't throw a parse error? ------------------------------------------------------------------------ [2009-10-24 02:00:09] johannes@php.net This is expected. Didn't check the docs, maybe this can be made clearer. ------------------------------------------------------------------------ [2009-10-24 01:34:07] swquinn at gmail dot com Description: ------------ Using a PHP language token, or syntactic keyword within a namespace causes a Parse error to be thrown by PHP. There is no documentation anywhere (that I could find) indicating whether keywords are permitted as part of a namespace name. If they are not, it would be nice if this is documented. If they should be, then this is clearly a defect. It would be _nice_ a keyword could contain any words (language syntax or otherwise). Reproduce code: --------------- <?php namespace my\default\ns; class Foo { public function bar() { return 0; } } $foo = new Foo(); echo $foo->bar(); ?> Expected result: ---------------- 0 Actual result: -------------- Parse error: syntax error, unexpected T_DEFAULT, expecting T_STRING in D:\PHP\tests\test.php on line 2 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49982&edit=1

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