Bug #66077 [Opn->Nab]: Cannot use __HALT_COMPILER(); with require() in namespace.

From: Date: Mon, 11 Nov 2013 16:28:12 +0000
Subject: Bug #66077 [Opn->Nab]: Cannot use __HALT_COMPILER(); with require() in namespace.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182707@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66077&edit=1 ID: 66077 Updated by: bwoebi@php.net Reported by: kevin at herrera dot io Summary: Cannot use __HALT_COMPILER(); with require() in namespace. -Status: Open +Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Ubuntu 12.04 LTS PHP Version: 5.5.5 Block user comment: N Private report: N New Comment: There are two documented things: No code outside of a namespace with brackets and __halt_compiler only in the outermost scope. So you simply can't use a __halt_compiler token in your code when you use namespaces with brackets. Previous Comments: ------------------------------------------------------------------------ [2013-11-11 06:12:25] kevin at herrera dot io The example demonstrates that this is not true in all cases. ------------------------------------------------------------------------ [2013-11-11 06:10:25] phpmpan at mpan dot pl "__halt_compiler() can only be used from the outermost scope." http://php.net/manual/function.halt-compiler.php ------------------------------------------------------------------------ [2013-11-11 03:23:14] kevin at herrera dot io Description: ------------ If I require() a file within "namespace {}", I cannot call __HALT_COMPILER(); at the end of the script. Instead, I receive a fatal error. Test script: --------------- https://gist.github.com/kherge/7407259 Expected result: ---------------- Hello, world! Actual result: -------------- PHP Fatal error: No code may exist outside of namespace {} in /home/kherrera/Testing/b.php on line 3 PHP Stack trace: PHP 1. {main}() /home/kherrera/Testing/a.php:0 Fatal error: No code may exist outside of namespace {} in /home/kherrera/Testing/b.php on line 3 Call Stack: 0.0001 235816 1. {main}() /home/kherrera/Testing/a.php:0 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66077&edit=1

« previous php.bugs (#182707) next »