Doc #64193 [NEW]: Nested Exceptions with autoloader
| From: | mostvotedplaya at gmail dot com | Date: | Tue, 12 Feb 2013 03:04:27 +0000 |
| Subject: | Doc #64193 [NEW]: Nested Exceptions with autoloader | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-9516@lists.php.net to get a copy of this message | ||
From: mostvotedplaya at gmail dot com
Operating system: Centos 6.3
PHP version: 5.4.11
Package: Dynamic loading
Bug Type: Documentation Problem
Bug description:Nested Exceptions with autoloader
Description:
------------
---
From manual page: http://www.php.net/manual/en/language.exceptions.php
---
I'm not sure if this is just a documentation bug or whether it goes further
but in the documentation regarding nested exceptions it shows that they can
be rethrown but in this case it doesn't appear that way, ReflectionClass
uses __autoload to attempt to load the subject and once an exception
arrives it just ignores the Reflection try block which for some people may
be correct because ReflectionException has lower priority of Exception with
it just being extended, but still the documentation should be updated to
reflect this.
Test script:
---------------
<?php
function __autoload( $f )
{
$f = sprintf( '%s.php', $f );
if ( is_readable( $f ) )
{
include $f;
return;
}
throw new Exception( "Failed to autoload: $f" );
}
try
{
try
{
$class = new ReflectionClass( "FooBar" );
if ( $class->isInstantiable() )
{
return;
}
}
catch ( ReflectionException $e )
{
throw $e;
}
}
catch ( Exception $e )
{
echo '<pre>', print_r( $e, true ), '</pre>';
}
Expected result:
----------------
ReflectionException Object
(
[message:protected] => Class FooBar does not exist
[string:Exception:private] =>
[code:protected] => -1
[file:protected] => /home/.../public_html/Reflection.php
[line:protected] => 25
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => /home/.../public_html/Reflection.php
[line] => 25
[function] => __construct
[class] => ReflectionClass
[type] => ->
[args] => Array
(
[0] => FooBar
)
)
)
[previous:Exception:private] =>
)
Actual result:
--------------
Exception Object
(
[message:protected] => Failed to autoload: FooBar.php
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => /home/.../public_html/Reflection.php
[line:protected] => 18
[trace:Exception:private] => Array
(
[0] => Array
(
[function] => __autoload
[args] => Array
(
[0] => FooBar
)
)
[1] => Array
(
[file] => /home/.../public_html/Reflection.php
[line] => 25
[function] => __construct
[class] => ReflectionClass
[type] => ->
[args] => Array
(
[0] => FooBar
)
)
)
[previous:Exception:private] =>
)
--
Edit bug report at https://bugs.php.net/bug.php?id=64193&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64193&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64193&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64193&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64193&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64193&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64193&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64193&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64193&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64193&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64193&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=64193&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=64193&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64193&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64193&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64193&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64193&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64193&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64193&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64193&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64193&r=mysqlcfg