Bug #52339 [Com]: SPL autoloader breaks class_exists()

From: Date: Wed, 09 Sep 2015 20:21:04 +0000
Subject: Bug #52339 [Com]: SPL autoloader breaks class_exists()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195929@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=52339&edit=1

 ID:                 52339
 Comment by:         wolfen at gmail dot com
 Reported by:        dangerous dot ben at gmail dot com
 Summary:            SPL autoloader breaks class_exists()
 Status:             Re-Opened
 Type:               Bug
 Package:            SPL related
 Operating System:   any (debian)
 PHP Version:        5.3.3RC2
 Block user comment: N
 Private report:     N

 New Comment:

I echo the sentiments of matthew dot bonner if not his choice of words. If the purpose of
class_exists() is to indicate whether or not a given class has been defined in the current scope or
loaded into the current scope via include/require directives, then I simply cannot imagine a
scenario in which it is acceptable for this function to throw an Exception.


Previous Comments:
------------------------------------------------------------------------
[2015-09-09 18:35:52] matthew dot bonner at gmail dot com

It shouldn't throw an exception or cause an error. This is exactly why people move to C#
because we don't have to put up with any of this bullshit for 5 years. An exception should be
thrown when something happens that is not expected to happen, you expect class_exists to return
false when the class does not exist, it is bonkers to think that we want to be wasting our lives
catching stupid exceptions that should not be thrown in the first place, either that or catch the
bloody exception in the body of the class_exists function for crying out loud. How hard is it
really?

------------------------------------------------------------------------
[2015-09-08 20:22:20] cmb@php.net

Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=337786
Log: spl_autoload() may throw LogicException (related to #52339)

------------------------------------------------------------------------
[2015-09-08 20:14:46] cmb@php.net

> My understanding of the underlying code is that it generates an
> error in this case. Perhaps it should generate an exception,
> which can be caught an handled.

The code already throws an exception, see <https://3v4l.org/AaURG>.

------------------------------------------------------------------------
[2014-10-13 10:33:31] aden at fraserjilani dot com

v5.5.9 - still broken.

------------------------------------------------------------------------
[2014-10-08 06:51:01] john dot fragkoulis at gmail dot com

v5.5.3 still broken

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=52339


--
Edit this bug report at https://bugs.php.net/bug.php?id=52339&edit=1


Thread (18 messages)

« previous php.bugs (#195929) next »