rfc:autofunc
This is an old revision of the document!
Request for Comments: Function autoloading through spl_autoload*
- Version: 1.0
- Date: 2011-08-05
- Author: Ferenc Kovacs tyra3l@gmail.com
- Status: Draftz
- First Published at: https://wiki.php.net/rfc/autofunc
Introduction
The topic of supporting function autoloading was brought up many times in the past, this RFC tries to introduce a potential implementation which would be consistent with what we have for autoloading classes.
Proposal
The suggested change would be pretty straigtforward and BC compatible:
- add a fourth optional parameter for spl_autoload_register called $types with the default value of T_CLASS(this would keep the BC)
- as you would guess, this would work the same way as the $error_types parameter works for set_error_handler: you can specify for which type(s) of missing tokens should be the autoloader called.
- the type for the missing token should be also passed to the $autoload_function callback as a second param.
- this is needed to be able to handle multiple types of tokens with a common callback.
- Note that passing more parameter to a function than it has in it's definition is valid, this would be also backward compatible change.
Patch
Non yet, but shouldn't be too hard to implement.
Related RFCs
Related discussions
rfc/autofunc.1312503851.txt.gz · Last modified: 2025/04/03 13:08 (external edit)