Am 25.11.2011 10:34, schrieb Rafael Kassner:
I think an autoloader can't be raise any kind of error. If the class
will be loaded by another autoloader on the stack and the first
throws
an Exception, this will be a wrong behavior.
Indeed, if autoloader can't include the class, PHP throws a fatal
error, and you can avoid it using class_exists function that calls
autoloader by its own.
You can do this, but the engine triggers still a fatal error. The call
"new NotExistingClass();" triggers the autoloader. The autoloader sees
that the class doesn't exists and continues silent. And now the engine
tries to instantiate a not existing class, which ends in a fatal error.
On Fri, Nov 25, 2011 at 6:06 AM, Christian Kaps
<christian.k...@mohiva.com> wrote:
Am 25.11.2011 08:24, schrieb Michael Wallner:
On Thu, 24 Nov 2011 23:28:35 +0100, Christian Kaps wrote:
https://wiki.php.net/rfc/autoloader_error_handling
Throwing an exception or fatal error in an autoloader
absolutely does not make any sense in my eyes.
Projects doing this should step back and think a
minute about what they dare.
Mike
Hi,
how would you bring your application in a consistent state after a
class
couldn't be loaded. I do this by adding a try/catch block around my
code.
try {
new Application();
} catch (Exception) {
// collect data
// send mail
// redirect to maintenance page
}
An other question is, if the autoloader work silent and I write:
new NotExistingClass();
I think in this case the engine will also trigger a fatal error. So
in my
eyes it is regardless of whether it trigger a fatal error in the
autoloader
or the autoloader works silent. Both cases ends in a fatal error. Or
am i
wrong here?
Christian
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
--
Atenciosamente,
Rafael Kassner
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php