This RFC was abandoned due to time constraints by the author. However, the portion that sets assert.exception
to default to 1
has been merged for PHP 8. If anyone picks up this RFC, it only needs to deal with assert_options
and potentially INI settings.
In PHP 7.0, the assert
statement received some enhancements. Notably, it added the ability to throw exceptions on failures (but off by ini default) and the code to assert could now be directly given to assert, instead of only through a string argument. In 7.2, the string argument was officially deprecated, and support has been removed from master for PHP 8. The assert_options
function has been discouraged in the official documentation for PHP 7. This RFC proposes the continued cleanup of assert behavior.
This RFC proposes that:
1. The ini setting ''assert.exception'' defaults to 1, meaning that exceptions will be thrown on an assertion failure instead of emitting a warning. 2. The function ''assert_options'' is officially deprecated in code, not just discouraged in documentation.
Since a failing assertion means that the program is in an unexpected state, throwing an exception or otherwise exiting are the only viable actions; continuing after emitting a warning is unwise and further issues in the program runtime are expected to occur. In the worst case, the program will exhibit different behavior without any other symptoms; if the the logs are not checked, it is possible this bug might go unnoticed. Changing the default to now throw exceptions will probably leave programs using the default settings in a more correct state than they were prior to this change.
The ini setting assert.exception
defaults to 1, meaning that exceptions will be thrown on an assertion failure instead of emitting a warning.
This RFC targets PHP 8.0.
assert.exceptions
:
Make sure there are no open issues when the vote starts!
List existing areas/features of PHP that will not be changed by the RFC.
This helps avoid any ambiguity, shows that you have thought deeply about the RFC's impact, and helps reduces mail list noise.
This section details areas where the feature might be improved in future, but that are not currently proposed in this RFC.
This vote will be a single yes or no vote to accept the RFC, requiring two-thirds of votes to be “yes” to pass.
There is no patch at this time. It is an incredibly small patch, so I am not worried about not having one yet.
After the project is implemented, this section should contain
Links to external references, discussions or RFCs
Keep this updated with features that were discussed on the mail lists.