Edit report at https://bugs.php.net/bug.php?id=60182&edit=1
ID: 60182
Comment by: francois dot dambrine at isen-lille dot fr
Reported by: pavel dot zubkou at gmail dot com
Summary: Implicit call to spl_autoload_call() does not throw
exceptions
Status: Open
Type: Bug
Package: SPL related
Operating System: Debian GNU/Linux
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
As I run the test with 5.4b1 the result is :
#0 autoload(A)
#1 spl_autoload_call(A) called at [/home/isen/essai.php:12]
Erreur de segmentation
Previous Comments:
------------------------------------------------------------------------
[2011-10-31 22:41:23] pavel dot zubkou at gmail dot com
Description:
------------
Exceptions thrown from custom autoload function are not thrown outside the
spl_autoload_call() function when it is implicitly called on expressions like
'A::someMethod();' and '$b = A::CONSTANT;', i.e. when accessing static methods
and constants of the class.
Test script:
---------------
<?php
function autoload($class)
{
debug_print_backtrace();
throw new Exception('Test message');
}
spl_autoload_register('autoload');
try {
A::$someVariable;
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
A::someMethod();
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
Expected result:
----------------
#0 autoload(A)
#1 spl_autoload_call(A) called at [/tmp/1.php:12]
Test message
#0 autoload(A)
#1 spl_autoload_call(A) called at [/tmp/1.php:18]
Test message
Actual result:
--------------
#0 autoload(A)
#1 spl_autoload_call(A) called at [/tmp/1.php:12]
Test message
#0 autoload(A)
#1 spl_autoload_call(A) called at [/tmp/1.php:18]
PHP Fatal error: Class 'A' not found in /tmp/1.php on line 18
PHP Stack trace:
PHP 1. {main}() /tmp/1.php:0
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60182&edit=1