Req #10743 [Opn->Dup]: Allow using list, new, etc. as class method names
| From: | nikic@php.net | Date: | Tue, 05 Jun 2012 22:59:56 +0000 |
| Subject: | Req #10743 [Opn->Dup]: Allow using list, new, etc. as class method names | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-171054@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=10743&edit=1
ID: 10743
Updated by: nikic@php.net
Reported by: jjones at net-conex dot com
Summary: Allow using list, new, etc. as class method names
-Status: Open
+Status: Duplicate
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: *
PHP Version: *
Block user comment: N
Private report: N
New Comment:
Closing this as a duplicate to https://bugs.php.net/bug.php?id=28261. It's
newer, but it has a bit more discussion and a (not yet correctly working) patch.
Previous Comments:
------------------------------------------------------------------------
[2003-08-11 16:21:37] destes at ix dot netcom dot com
yes, but couldn't any later calls to those new() and list() functions result in parsing
clashes? If so, perhaps the error message should be clarified.
That's one of the few glaring insufficiencies in PHP right now - the clarity of its errors,
especially its parse errors.
If the parser isn't going to be made intelligent enough to allow you to make functions like a
new() or list() - and I can see the argument, considering some language constructs can be invoked
using function syntax - then at least make a prettier error message =)
-Steve
------------------------------------------------------------------------
[2001-05-09 05:02:59] hholzgra@php.net
IMHO the parser should be clever enough to get the
clue when using new() or list() in a class/method
context that these can't be referencing the language
constructs here
moved to feature requests
------------------------------------------------------------------------
[2001-05-09 03:52:20] derick@php.net
New and list are language contructs, and not functions in PHP. That's why those don't
work.
This is not a bug, so bugusfying this report.
------------------------------------------------------------------------
[2001-05-09 03:42:00] jjones at net-conex dot com
Okay.. this has been bugging me for a while..
consider the following:
class test {
function mail () { print ("Bah\n"); }
function fopen () { print ("Bah\n"); }
function new () { print ("Bah\n"); }
function list () { print ("Bah\n"); }
}
$temp = new test;
$temp->mail();
etc, etc..
This will generate a parse error (expecting `T_STRING') until the new() and list() functions
are removed from the class. mail() and fopen() will work.
Now.. my question is why the inconsistency?
Is there some super-secret reasoning behind not letting me name my classes' objects the same as
only a few predefined functions?
I'm lazy.. you guys took all the good function names.. why must you tease me with them?!
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=10743&edit=1