Bug #70283 [Com]: Misleading error message when attempting to instantiate a reserved class name

From: Date: Wed, 16 Sep 2015 13:42:28 +0000
Subject: Bug #70283 [Com]: Misleading error message when attempting to instantiate a reserved class name
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196040@lists.php.net to get a copy of this message
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)

« previous php.bugs (#196040) next »