Edit report at https://bugs.php.net/bug.php?id=51709&edit=1
ID: 51709 Updated by: tyr...@php.net Reported by: razvan dot gavril at gmail dot com Summary: Naming a class method using a reserved keyword causes a parser error Status: Bogus Type: Bug Package: Scripting Engine problem Operating System: Ubuntu 10.04 LTS PHP Version: 5.3.2 Block user comment: N Private report: N New Comment: for the record: I've tested this, and the last 5.2 version(5.2.17) behaves the same way: Parse error: syntax error, unexpected T_FOR, expecting T_STRING in /home/tyrael/testbug.php on line 3 Tyrael Previous Comments: ------------------------------------------------------------------------ [2010-05-12 19:13:05] razvan dot gavril at gmail dot com I notice that the other bug you've pointed me to, states that the problem happens starting with version 5.3.2 also. ------------------------------------------------------------------------ [2010-05-12 19:05:24] razvan dot gavril at gmail dot com Strange, I've notice the bug after updating from Ubuntu karmic. Looking now at the package.ubuntu.com I see that karmic came with php 5.2.10 I'm 100% sure that I didn't had this bug before the update ------------------------------------------------------------------------ [2010-05-12 18:37:27] s...@php.net I don't know what your "previous" version was, but the same error occurs with PHP 5.1.6 so this has been a language feature for a very long time. Also see http://bugs.php.net/51782 about the introduction of new keywords in recent versions. ------------------------------------------------------------------------ [2010-04-30 22:33:12] razvan dot gavril at gmail dot com Description: ------------ Is no longer possible to name a class methods using names that are reserved keywords like : 'break', 'for', 'goto'. It used to work with previous php versions. If this is a 'feature', what's the point ? Test script: --------------- <?php class foo { static function for() { echo "1"; } static function goto() { echo "2"; } } foo::for(); foo::goto(); Expected result: ---------------- Display: 12 Actual result: -------------- PHP Parse error: syntax error, unexpected T_FOR, expecting T_STRING in /etc/asterisk/manager.d/test.php on line 4 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=51709&edit=1