Bug #70283 [Com]: Misleading error message when attempting to instantiate a reserved class name
Edit report at https://bugs.php.net/bug.php?id=70283&edit=1
ID: 70283
Comment by: jonathan dot massuchetti at gmail dot com
Reported by: bugs dot php dot net at majkl578 dot cz
Summary: Misleading error message when attempting to
instantiate a reserved class name
Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: Linux
PHP Version: 7.0Git-2015-08-17 (Git)
Block user comment: N
Private report: N
New Comment:
PHP 5 behavior when trying to instantiate a reserved word, such as "new return", "new
class" or so, is a parse error :
Parse Error: syntax error, unexpected 'class' (T_CLASS)
So IMHO we should :
A) stick to that behavior and trigger a parse error
B) create a new error message for all reserved word usage attempt.
I vote A.
Previous Comments:
------------------------------------------------------------------------
[2015-08-17 16:55:03] bugs dot php dot net at majkl578 dot cz
Description:
------------
When trying to instantiate a reserved class name (e.g. string/int/float/resource), the message
should probably mention that the name is reserved, not that "class ____ not found".
Test script:
---------------
<?php
new string;
Expected result:
----------------
Somethig like:
Fatal error: Uncaught Error: Could not instantiate 'string', the name is reserved
Actual result:
--------------
Fatal error: Uncaught Error: Class 'string' not found
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70283&edit=1
Thread (5 messages)