2021-04-01 10:24 GMT+02:00, Arnold Daniels <arnold.adaniels...@gmail.com>: > Hi, > > The documentation of `assert` > ([https://php.net/assert)](https://www.php.net/manual/en/function.assert.php)) > states that's debugging only. This is further enforced by php.ini flags to > disable assertions in production. > > Why are the use cases of this feature being limited to debugging? We can see > from the popularity of user-space assertion libraries, like > [webmozart/asset](https://packagist.org/packages/webmozart/assert) and > [beberlei/assert](https://packagist.org/packages/beberlei/assert), that > there is a need for runtime assertions. > > [Arnold Daniels - Chat @ > Spike](https://spikenow.com/r/a/?ref=spike-organic-signature&_ts=yux2k) > [yux2k]
Dunno about the motivation of the implementors, but usually assertions are used for internal invariants and mental checks while exceptions should be used for interaction with the outside world (database errors, user input errors etc). If you follow this, an assert error will never be useful for a user, it will always be an "internal error", and that's why it can (should?) be disabled in production. Olle -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php