There is one key piece of information to keep in mind about this
proposal. This is based on the assumption that all autoloaders need to
do this type of include_path check. I (now) feel this is questionable
concerning that particular use case.
The best practice should be to only have autoloaders for a specific
namespace, this would mostly solve the "is it there?" type of
fopen/include_path check.
If NamespaceA registers an autoloader for itself, it should not try to
resolve and load files from other Namespaces, for example NamespaceB.
This idea is partially taken care of in the proposed SplClassLoader ..
http://gist.github.com/221634
.. assuming the above best practice, a namespcae should know whether or
not to try to include something inside it's own namespace, and if
something is not there, an E_FATAL (or potentially an exception) is the
best option when include does not work. I also have a question as to
how the argument: throw=true comes into play in the current
spl_autoload_register (does it affect this proposal too?)
http://github.com/php/php-src/blob/PHP_5_3_1/ext/spl/php_spl.c#L422
ON THE OTHER HAND, I think it is important that we should be able to
check for the existence of a relative to include_path location
regardless of autoloading consequences, and that is what sara attempted
with stream_resolve_include_path, even though I'm not fond of the name.
Regards,
Ralph Schindler
Lukas Kahwe Smith wrote:
Ahoi,
I have written an RFC for a more efficient solution to get rid of the
common fopen() hack inside autoloaders:
if ($fp = @fopen($file, 'r', true)) {
fclose($fp);
include $file;
}
Here is the gist of the proposal:
In order to solve the above issues this RFC proposes the addition of a
new construct/function for now called “autoload_include” for lack of a
better name that largely behaves like the “include” does today with the
following differences, that when the include failed because of a missing
file no warning is raised and php null is returned.
Further details can be found on the wiki:
http://wiki.php.net/rfc/autoload_include
As stated in the RFC, I am not happy with the name "autoload_include".
Suggestions welcome!
regards,
Lukas Kahwe Smith
m...@pooteeweet.org
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php