|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-08-18 16:10 UTC] mattsch at gmail dot com
Description:
------------
When a ReflectionException is thrown for any reflection class, an exception code is not set (i.e. it always returns 0). This makes it quite difficult to identify what caused the exception. As a result, I am forced to parse the exception message to determine what went wrong instead of relying on a constant from the getCode method.
Test script:
---------------
<?php
try {
$reflectionFunction = new ReflectionFunction('foo');
} catch(Exception $e){
var_dump($e->getCode());
}
Expected result:
----------------
A non-zero code.
Actual result:
--------------
int(0)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 11:00:02 2025 UTC |
I have to agree that using a single exception type with the same code for all of this is not the best solution, but I think you can probe in advance for nearly all cases (e.g. in this case you can check function_exists('foo)) in advance, what appears to be preferable anyway.