Req #46974 [Opn->Fbk]: Closure and Namespaces bug! FATAL ERROR

From: Date: Sat, 16 Jan 2016 13:34:54 +0000
Subject: Req #46974 [Opn->Fbk]: Closure and Namespaces bug! FATAL ERROR
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198716@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=46974&edit=1 ID: 46974 Updated by: danack@php.net Reported by: info at netmosfera dot it Summary: Closure and Namespaces bug! FATAL ERROR -Status: Open +Status: Feedback Type: Feature/Change Request Package: Scripting Engine problem Operating System: * PHP Version: 5.3.0alpha3 Block user comment: N Private report: N New Comment: The initial code reported as a bug works, and the request for namespaced autoloaders is possible in userland code with no new core functionality needed. If there is still an issue, please cam you clarify what it is? Previous Comments: ------------------------------------------------------------------------ [2009-01-09 18:55:57] stas@php.net I think you can easily implement it in user-space by using either one autoloader checking class name or using multiple autoloaders and http://www.php.net/manual/en/function.spl-autoload-register.php I'm not sure it is practical to do it in the engine as it would require a lot of search around for autoloaders by the engine. I think it's better done in user-space. ------------------------------------------------------------------------ [2009-01-02 01:11:21] info at netmosfera dot it hi, thanks for accepting this bug i have one request, is possible to make autoloads for namespaces? is this back compatible? namespace a { function __autoload(){echo "a";} new Pippo(); } namespace b { function __autoload(){echo "b";} new Pippo(); } thank you ------------------------------------------------------------------------ [2008-12-30 17:19:24] info at netmosfera dot it ok, with __autoload in global namespace works if you remove the closure but works too where's the problem? ------------------------------------------------------------------------ [2008-12-30 16:50:06] info at netmosfera dot it uhm... autoload is not called! another suggest: Closure is a special class\type so it must be global in a namespace i have to use public function method(\Closure $x){} instead of public function method(Closure $x){} is it correct? Closure is a special type and final too ------------------------------------------------------------------------ [2008-12-30 16:40:22] info at netmosfera dot it Description: ------------ hi, i noticed there is a bug that causes a FATAL ERROR please read the code thank you for your time Reproduce code: --------------- file index.php: <?php namespace Clsure; spl_autoload_register(function($c){ echo $c = str_replace("\\", "-", $c) . ".php"; require($c); }); // TRY TO UNCOMMENT THIS LINE: // $b=function(){}; $a = new Testing(); ?> file Clsure-Testing.php: <?php namespace Clsure; class Testing{function __construct(){echo "constructor";}} ?> Actual result: -------------- Fatal error: Class 'Clsure\Testing' not found in on line 12 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=46974&edit=1

« previous php.bugs (#198716) next »