Bug #52339 [ReO->Csd]: SPL autoloader breaks class_exists()

From: Date: Fri, 18 Mar 2016 19:30:24 +0000
Subject: Bug #52339 [ReO->Csd]: SPL autoloader breaks class_exists()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199927@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 Updated by: nikic@php.net Reported by: dangerous dot ben at gmail dot com Summary: SPL autoloader breaks class_exists() -Status: Re-Opened +Status: Closed Type: Bug Package: SPL related Operating System: any (debian) PHP Version: 5.3.3RC2 Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikic Revision: http://git.php.net/?p=php-src.git;a=commit;h=8023204d219d353b83f19edb0133483d67aedcfb Log: Fixed bug #52339 Previous Comments: ------------------------------------------------------------------------ [2015-09-09 20:20:58] wolfen at gmail dot com 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. ------------------------------------------------------------------------ [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&amp;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. ------------------------------------------------------------------------ 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

« previous php.bugs (#199927) next »