Hi Robert, hi Guilliam > > So, how does this change our mental models when writing PHP? For > > example, I generally consider `const` to be a "compile-time" constant > > (ie, generated/created before any code is actually executed). So would > > this allow code to actually execute before any other code (ie, by > > putting code in a __get()) and thus cause issues due to database > > drivers and etc to not be loaded yet -- or cause them to be loaded > > prematurely? > > True but that's already the case since PHP 8.1 and > https://wiki.php.net/rfc/new_in_initializers > (https://github.com/php/php-src/pull/7153), e.g. > https://3v4l.org/MSWi0: > > ``` > class Foo { > public function __construct() { > echo "Side effect!\n"; > } > } > > const C = new Foo(); > ```
Exactly. In fact, the only way you could invoke arbitrary userland code through __get is in combination with `new`, where side-effects are already possible via constructor. Enums themselves don't allow __get and thus can't lead to side-effects in constant expressions. If there are no other concerns I'd like to open the voting phase by the end of the week. Ilija -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php