rfc:core-autoloading
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:core-autoloading [2023/04/03 13:03] – created girgias | rfc:core-autoloading [2023/04/10 12:14] – Status: Under Discussion girgias | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Version: 0.1 | * Version: 0.1 | ||
* Date: 2023-04-03 | * Date: 2023-04-03 | ||
- | * Author: George Peter Banyard, < | + | * Author: George Peter Banyard, < |
- | * Status: | + | * Status: |
* Target Version: PHP 8.3 | * Target Version: PHP 8.3 | ||
* Implementation: | * Implementation: | ||
Line 16: | Line 16: | ||
The need for such a feature seems very clear as users will create " | The need for such a feature seems very clear as users will create " | ||
- | A previous [[draft RFC for function autoloading|https:// | + | A previous [[https:// |
This RFC has avoided that performance problem. | This RFC has avoided that performance problem. | ||
Line 94: | Line 94: | ||
</ | </ | ||
- | If a function named '' | + | If a function named '' |
This RFC preserves that fallback behaviour. | This RFC preserves that fallback behaviour. | ||
Line 100: | Line 100: | ||
When code tries to call a function that doesn' | When code tries to call a function that doesn' | ||
- | If an appropriately named function is not loaded during that call, the PHP engine will 'fallback' | + | If an appropriately named function is not loaded during that call, the PHP engine will fallback that function to the global namespace. |
If a function already exists with the global namespace name, that will be used, otherwise the function autoloader mechanism will call the registered function autoloaders once with the global function name. | If a function already exists with the global namespace name, that will be used, otherwise the function autoloader mechanism will call the registered function autoloaders once with the global function name. | ||
- | After a function autoload | + | After a function in a namespace is resolved (i.e. a function is located in the current namespace either because it already exists, or a function autoload |
This is possibly easier to understand through code: | This is possibly easier to understand through code: | ||
Line 185: | Line 185: | ||
The global fallback is not invoked for functions with absolute names. Absolute function names happen: | The global fallback is not invoked for functions with absolute names. Absolute function names happen: | ||
- | * In a PHP file that has an alias/ | + | |
- | * Functions that are directly invoked with an absolute name e.g. < | + | * Functions that are directly invoked with an absolute name e.g. < |
For functions that are not invoked with an absolute function name, the function autoloader will be called once per function name per namespace. After that, the function will be pinned to the function that was resolved. | For functions that are not invoked with an absolute function name, the function autoloader will be called once per function name per namespace. After that, the function will be pinned to the function that was resolved. | ||
Line 283: | Line 283: | ||
==== Higher performance through maps ==== | ==== Higher performance through maps ==== | ||
- | There is an ongoing conversation, | + | There is an ongoing conversation, |
+ | |||
+ | However, a basic implementation of that RFC has been created and can be tried with the implementation of this RFC: https:// | ||
====== Deprecating the SPL autoloader functions ====== | ====== Deprecating the SPL autoloader functions ====== |
rfc/core-autoloading.txt · Last modified: 2023/04/23 14:24 by danack