Bug #55475 [Com]: is_a() triggers autoloader
| From: | tyrael@php.net | Date: | Mon, 29 Aug 2011 07:15:47 +0000 |
| Subject: | Bug #55475 [Com]: is_a() triggers autoloader | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-163003@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55475&edit=1
ID: 55475
Comment by: tyrael@php.net
Reported by: mads at gartneriet dot dk
Summary: is_a() triggers autoloader
Status: Assigned
Type: Bug
Package: Scripting Engine problem
PHP Version: 5.3.7
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
"note the "FALSE otherwise" ..."
note "if the object" ...
Tyrael
Previous Comments:
------------------------------------------------------------------------
[2011-08-26 10:24:39] kkaminski at itens dot pl
+1 for reverting change in 5.3 branch and implementing it in 5.4 (or giving up as it really CHANGES
BEHAVIOR)
Currently __autoload throws Exceptions to break code execution on some frameworks. This is clean
solution as if developer makes a typo, code still can handle missing class and for instance -
display a dedicated error report.
Unfortunately, with your latest 'fix' all PEAR packages are now broken on frameworks with
__autoload + exceptions - due to isError implementation.
Are you really sure is it MY duty to rewrite / repatch all code (external) code to work around your
'fix' ?
How I am supposed to handle missing classes in this case? With exceptions I can catch everything and
handle myself. Whats the other way?
------------------------------------------------------------------------
[2011-08-24 05:16:11] jha dot rajeev at gmail dot com
I have a question re. the correct behavior of custom __autoload() functions when
called from is_a() in 5.3.7. How do we handle/report missing classes? is is_a()
prepared to handle any sort of exceptions or does it assume that __autoload will
return TRUE/FALSE only?
what if I just did something like is_a("",ABCD)?
------------------------------------------------------------------------
[2011-08-24 01:59:04] alan at akbkhome dot com
For reference:
The workaround is to do this
if (is_a($a, 'B')) {
becomes
if (is_object($a) && is_a($a, 'B')) {
------------------------------------------------------------------------
[2011-08-23 14:24:59] jha dot rajeev at gmail dot com
This also affects HTML_Template_Flexy pear package that uses is_a to check
returned object against PEAR_Error class. No matter what behavior is right it
looks broken to me because I am patching this pear packages files right now!
------------------------------------------------------------------------
[2011-08-23 08:25:33] alan at akbkhome dot com
@stas - the point of un-depreciating and working with a string was the second
argument, not the first one.
eg.
is_a($something, 'might_be_not_loaded_class')
rather than
$something instanceof might_be_not_loaded_class
------------------------------------------------------------------------
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=55475
--
Edit this bug report at https://bugs.php.net/bug.php?id=55475&edit=1