Req #70919 [Com]: class declarations may not be nested - why not!?

From: Date: Mon, 16 Nov 2015 18:21:27 +0000
Subject: Req #70919 [Com]: class declarations may not be nested - why not!?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197287@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70919&edit=1 ID: 70919 Comment by: rahi at atsspec dot co Reported by: teo8976 at gmail dot com Summary: class declarations may not be nested - why not!? Status: Open Type: Feature/Change Request Package: Class/Object related PHP Version: 7.0.0RC7 Block user comment: N Private report: N New Comment: Neither should be valid; way too easy to write messed up code like this...declaring classes within functions, seriously? WTF There's no reason for that Sorter class to be declared within the function, can be declared outside of it like a normal class. Previous Comments: ------------------------------------------------------------------------ [2015-11-15 19:34:04] teo8976 at gmail dot com Description: ------------ If this is valid: https://3v4l.org/SUZs2 then so should this: https://3v4l.org/IhSjK Test script: --------------- https://3v4l.org/IhSjK Expected result: ---------------- output: 7 9 5 3 Actual result: -------------- Fatal error: Class declarations may not be nested in /in/IhSjK on line 17 Note: this does work in hhvm. The fix should be backported to all supported versions. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70919&edit=1

« previous php.bugs (#197287) next »