rfc:autofunc
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:autofunc [2011/08/06 11:16] – under discussion tyrael | rfc:autofunc [2014/04/08 22:46] – Inactive levim | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2011-08-05 | * Date: 2011-08-05 | ||
* Author: Ferenc Kovacs < | * Author: Ferenc Kovacs < | ||
- | * Status: | + | * Status: |
* First Published at: https:// | * First Published at: https:// | ||
Line 14: | Line 14: | ||
The suggested change would be pretty straightforward and BC compatible: | The suggested change would be pretty straightforward and BC compatible: | ||
- | * Add a fourth optional parameter for spl_autoload_register called $types with the default value of T_CLASS | + | |
+ | | ||
* As you would guess, this would work the same way as the $error_types parameter works for set_error_handler: | * As you would guess, this would work the same way as the $error_types parameter works for set_error_handler: | ||
* The type for the missing token should also be passed to the $autoload_function callback as a second param. | * The type for the missing token should also be 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. | * This is needed to be able to handle multiple types of tokens with a common callback. | ||
* Note that passing more parameters to a function than it has in its definition is valid, this would also be a backward compatible change. | * Note that passing more parameters to a function than it has in its definition is valid, this would also be a backward compatible change. | ||
- | * Change the current class autoloading to only call the autoloaders which match with the T_CLASS | + | * Change the current class autoloading to only call the autoloaders which match with the SPL_AUTOLOAD_CLASS |
- | * Add the function autoloading to only call the autoloaders which match with the T_FUNCTION | + | * Add the function autoloading to only call the autoloaders which match with the SPL_AUTOLOAD_FUNCTION |
==== Future improvements ==== | ==== Future improvements ==== | ||
- | Notice that currently only functions are proposed, but we could implement autoloading other tokens (T_DECLARE, T_CONST, etc.) with this interface. | + | Notice that currently only functions are proposed, but we could implement autoloading other tokens (SPL_AUTOLOAD_CONSTANT, etc.) with this interface. |
==== Examples ==== | ==== Examples ==== | ||
Line 45: | Line 46: | ||
true, | true, | ||
false, | false, | ||
- | | + | |
); | ); | ||
Line 52: | Line 53: | ||
function ($name, $type) { | function ($name, $type) { | ||
| | ||
- | case T_CLASS: | + | case SPL_AUTOLOAD_CLASS: |
/* ... */ | /* ... */ | ||
| | ||
- | case T_FUNCTION: | + | case SPL_AUTOLOAD_FUNCTION: |
/* ... */ | /* ... */ | ||
| | ||
Line 62: | Line 63: | ||
true, | true, | ||
false, | false, | ||
- | | + | |
); | ); | ||
</ | </ | ||
Line 80: | Line 81: | ||
* [[http:// | * [[http:// | ||
+ | ==== Changelog ==== | ||
+ | * 2011.08.17 - replace the T_* constants with SPL_AUTOLOAD_* | ||
rfc/autofunc.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1