PHP RFC: Your Title Here
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.
Backward Incompatible Changes
The ini setting
assert.exception defaults to 1, meaning that exceptions will be thrown on an assertion failure instead of emitting a warning.
Proposed PHP Version(s)
This RFC targets PHP 8.0.
- hardcoded default value: 1
- php.ini-development value: 1, and no longer commented out
- php.ini-production value: 1, and no longer commented out
Make sure there are no open issues when the vote starts!
Unaffected PHP Functionality
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.
Proposed Voting Choices
This vote will be a single yes or no vote to accept the RFC, requiring two-thirds of votes to be “yes” to pass.
Patches and Tests
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
- the version(s) it was merged into
- a link to the git commit(s)
- a link to the PHP manual entry for the feature
- a link to the language specification section (if any)
Links to external references, discussions or RFCs
Keep this updated with features that were discussed on the mail lists.