Re: Why do disabled functions / classes generate a WARNING.
| From: | Leigh | Date: | Fri, 03 Aug 2012 11:59:37 +0000 |
| Subject: | Re: Why do disabled functions / classes generate a WARNING. | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62002@lists.php.net to get a copy of this message | ||
> Because there isn't anything actually wrong.
>
> A fatal error is reserved for things we cannot recover from, but a
> disabled function is easily recoverable.
I don't see how it is any more recoverable than the function/class not
existing at all. How much code do you know of that checks for the
existence of every function it expects to be there, before using it?
The matter is even worse with classes, since creating a disabled class
does not return null. It returns an instantiated object with no
methods.
When an unexpected function is disabled, the engine can recover, sure.
The code, probably not. In my opinion it's better to stop the code
doing something potentially harmful than allowing it to continue with
bad data.
It seems inconsistent to me.
--
$a = new UndefinedClass; // PHP Fatal error: Class 'UndefinedClass' not found
--
$a = new DisabledClass; // Warning
var_dump(get_class($a)); // string(13) "disabledclass"
--
$a = undefinedFunction(); // PHP Fatal error: Call to undefined
function undefinedFunction()
--
$a = disabledFunction(); // Warning
var_dump($a); // null