ID: 43324 Updated by: [EMAIL PROTECTED] Reported By: felipensp at gmail dot com Status: Bogus Bug Type: Scripting Engine problem PHP Version: 6CVS-2007-11-18 (snap) New Comment:
class foo { } Is considered by the engine to be an "unconditional class declaration". This allows the class to be bound to the execution context at compile time and the runtime instruction to be erased. { class foo { } } Is considered by the engine to be a "conditional class declaration". This prevents the compiler from performing an early (unconditional) class binding, so it has to leave the binding instruction in the runtime code. Since the instruction is executed at runtime, it is potentially performed more than once. Put more simply: $a = 'foo'; class bar { } $b = 'baz'; Is turned into: class bar { } $a = 'foo'; $b = 'baz'; Whereas: $a = 'foo'; { class bar { } } $b = 'baz'; Is left alone. This is a deliberate design in the engine meant to reduce the speed impact caused by classes. Previous Comments: ------------------------------------------------------------------------ [2007-11-18 17:00:23] [EMAIL PROTECTED] 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 There is no label scope... ------------------------------------------------------------------------ [2007-11-18 15:17:59] felipensp at gmail dot com Description: ------------ Only occur error when inside a block. (e.g. if, empty block, ...) Reproduce code: --------------- <?php $i = 0; a: // No error class foo { } // Produces error // Fatal error: Cannot redeclare class foo /* { class foo { } } */ if ($i++ != 4) goto a; Expected result: ---------------- Error ? Actual result: -------------- Error whenever declaring inside a block. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43324&edit=1