assert.exception INI setting is deprecated
Description
assert.exception controls whether a failed assert() throws an AssertionError (the default since PHP 7) or falls back to the legacy behavior of emitting a warning and continuing execution.
Disabling exceptions for assertions revives pre-PHP 7 behavior that is inconsistent with the rest of the language, where failures are normally reported through exceptions or errors. As part of the cleanup of the legacy assert.* configuration, this directive is now deprecated.
The deprecation notice is triggered whenever assert.exception is set to a falsy value, either in php.ini or through ini_set().
Example
<?php
ini_set('assert.exception', '0');
?>
Alternatives
- Keep
assert.exceptionenabled (the default) and catchAssertionErrorwhere a failed assertion needs to be handled instead of propagating. - Remove
ini_set()/ini_get()calls involvingassert.exceptionfrom the code.
Related error messages
- assert.active-ini-setting-is-deprecated
- assert.bail-ini-setting-is-deprecated
- assert.warning-ini-setting-is-deprecated
In previous PHP versions, this error message used to be :ref:assert.bail-ini-setting-is-deprecated.
In more recent PHP versions, this error message is now :ref:assert.warning-ini-setting-is-deprecated.
Changed Behavior
This error may appear following an evolution in behavior, in previous versions. See assert