Req #60305 [Opn->Nab]: myClass::unset() keyword conflict

From: Date: Tue, 03 Apr 2012 01:43:23 +0000
Subject: Req #60305 [Opn->Nab]: myClass::unset() keyword conflict
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-169175@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60305&edit=1

 ID:                 60305
 Updated by:         yohgaki@php.net
 Reported by:        matty023 at gmail dot com
 Summary:            myClass::unset() keyword conflict
-Status:             Open
+Status:             Not a bug
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 PHP Version:        5.4.0RC1
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

unset is keyword, so you cannot use it as previous comment describes.


Previous Comments:
------------------------------------------------------------------------
[2011-11-21 03:50:41] anon at anon dot anon

@francois: It's not a bug. It's a feature.

It's kind of accepted that all programming languages have some keywords you can't use as
identifier names. The general solution is to just choose a synonym. Possible alternative verbs for
"unset" include:
- clear
- remove
- delete
- dispose
- drop
- erase

Unusually, the language limitation is actually fixable for "unset" because of its obvious
function-like syntax. It's probably not a priority though. Also, at best, it would break the
history of PHP syntax-coloring editors turning "unset" keyword color.

------------------------------------------------------------------------
[2011-11-15 19:32:03] francois dot dambrine at isen-lille dot fr

This bug also happen in php 5.3.6 (ubuntu 11.10 default version).

------------------------------------------------------------------------
[2011-11-15 02:19:37] matty023 at gmail dot com

Description:
------------
While "keywords" and "language constructs" cannot be used as function names, I
find myself with the need to have a function in my class named "unset", I also see that
list is a very common and useful term.

After the introduction of classes and namespaces it's time to look at enabling usage of these
common terms in classes and namespaces.



Test script:
---------------
<?php
namespace whatever;
class unsetTest{
	function unset($whatever){
		
	}
}

Expected result:
----------------
Happiness

Actual result:
--------------
//Parse error: syntax error, unexpected 'unset' (T_UNSET), expecting identifier (T_STRING)
in E:\_www\x.php on line #


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60305&edit=1


Thread (4 messages)

« previous php.bugs (#169175) next »