RE : [PHP-DEV] Namespaces and __autoload()
| From: | P) | Date: | Fri, 07 Sep 2007 15:19:47 +0000 |
| Subject: | RE : [PHP-DEV] Namespaces and __autoload() | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-32092@lists.php.net to get a copy of this message | ||
Hi,
> From: Dmitry Stogov [mailto:dmitry@zend.com]
>
> The patch provides an additional boolean argument to
> __autoload() that say if class is really required. In case if
> it false, user code shouldn't emit errors or throw exceptions.
Actually, an autoload handler should never emit errors or throw exceptions. With handlers registered
through SPL, it is already the case. When using an __autoload() functions, raising an error when a
symbol is not found is useless because we know that the PHP interpreter will do it. So, I propose to
have PHP ignore any error or exception raised from autoload handlers. This would make the additional
argument useless.
Actually, I also wanted to add a second argument to autoload handlers. It would give the type of the
symbol we are looking for. Today, we are unable to know if we are searching for a class or an
interface. So, an autoload handler like PHK's has to try both. It is not very important because
most existing autoload handlers are so primitive (generally filename-based) that they treat both the
same way. But, in the future, if we extend autoloading to functions and constants, we will need this
argument. I cannot work on that now but, as you are considering modifying the autoload handler
arguments, I thought you could be interested.
Regards
Francois