Req #72459 [Opn]: please implement function autoloading

From: Date: Mon, 20 Jun 2016 14:09:35 +0000
Subject: Req #72459 [Opn]: please implement function autoloading
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201750@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72459&edit=1 ID: 72459 Updated by: cmb@php.net Reported by: berserkaa73 at hotmail dot com Summary: please implement function autoloading Status: Open Type: Feature/Change Request Package: *General Issues PHP Version: 7.1.0alpha1 Block user comment: N Private report: N New Comment: > I know there are plenty of bug reports about this, […] I quick search didn't show up any related tickets. Please point out the other reports, so all but one can be marked as duplicates. > Can we have this, please? I was expecting this to be possible in > 7.0 but apparently it's not going to happen even in 7.1: why? There has been a respective RFC[1] around for quite a while, but it hasn't been pursued. I'm not sure why. Maybe you'll grab that up? In that case you should contact Anthony (the author) first, whether he's fine with it. [1] <https://wiki.php.net/rfc/function_autoloading> Previous Comments: ------------------------------------------------------------------------ [2016-06-20 11:44:28] berserkaa73 at hotmail dot com Description: ------------ I know there are plenty of bug reports about this, but I want to be sure this gets the renewed attention it deserves. I've read some very stupid arguments against function autoloading, namely "just use OOP" "just use static methods" which are actual solutions, but hacks compared to what functional programming should look like. Or worse "you usually have one class per file, nobody wants one function per file" which is also stupid since one could do: function autoloadFunction($namespacedFunctionName){ $pos = strrpos($namespacedFunctionName, '\\'); $nsName = substr($namespacedFunctionName, 0, $pos); // strips the function name $file = $nsName . DIRECTORY_SEPARATOR . 'functions.php'; // contains all the functions in the NS require($file); } ... and would work perfectly fine. Not to mention that with opcache nobody worries of loading files performance as they are cached. Can we have this, please? I was expecting this to be possible in 7.0 but apparently it's not going to happen even in 7.1: why? Thank you ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72459&edit=1

« previous php.bugs (#201750) next »