We have a main "constants.php" file that resides in git. The first line of constants.php includes local_constants.php, which is kept out of git. The idea is that we can "override" any of the constants on a per server basis.
constants.php: @define('dbserver','productiondb.example.com'); local_constants.php @define('dbserver','devdb.example.com'); If we start throwing exceptions, which can't be suppressed, it will make this much more difficult to read since the constants.php will have to be updated: if(!defined('dbserver')){ define('dbserver','productiondb.example.com'); } if(!defined('otherconstant')){ define('otherconstants','foobar'); } On Sat, Jan 22, 2022 at 10:29 PM Mark Randall <marand...@php.net> wrote: > Internals, > > While cleaning up some PRs I was prompted to re-visit one I had > outstanding about exception-throwing behaviour when redefining > constants, this applies to functions like define and language syntax > constructs such as const. > > There have been a few discussions in the past about the topic. > > Here is one from 2016 from Dmitry: > https://wiki.php.net/rfc/constant_redefinition > > Discussion: > https://externals.io/message/93885 > > My own PR: > https://github.com/php/php-src/pull/5265 > > Since Dmitry's RFC was made in 2016, and my PR a while ago, attempted > redeclaration was promoted from a notice to a warning, but I still think > it's sensible to go one step further. > > There was mention on github that there was some resistence to promotion > to exception in the past, but I think there is a strong possibility that > the mood may be different many years later, with PHPs positive moves > towards throwing on poorly defined or illogical behaviour. > > To gauge this, I'm throwing out a non-binding strawpoll to get the lay > of the land before doing anything else with it. If there is general > favour I'll fix up my patch and do a proper RFC. > > https://wiki.php.net/redefine_constants_exception_strawpoll > > Mark Randall > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > -- Chase Peeler chasepee...@gmail.com