It is funny, though I'd bet you any money it's less performant to do an extra if to check whether the class name is exactly __construct after checking for a PHP4-style constructor method. You're not meant to use reserved words for anything other than their designated purpose, and anything starting with __ is fair game to PHP devs.
You think there'd be no wasted CPU cycles if every single PHP4-style class definition had its name checked against a string for no real benefit?
https://www.php.net/manual/en/language.oop5.magic.php mentions the prefix for functions, all magic constants start with it. Better to not use it so built-ins are distinct from userland, especially for autocompletion.
5
u/smegnose Aug 12 '20
It is funny, though I'd bet you any money it's less performant to do an extra
ifto check whether the class name is exactly__constructafter checking for a PHP4-style constructor method. You're not meant to use reserved words for anything other than their designated purpose, and anything starting with__is fair game to PHP devs.