Hello Pierre, Op vr 20 feb 2026 om 19:29 schreef Pierre Joye <[email protected]>: > > Hello Mirco, >
> In a context of __construct, disallow any return value can be detected > as well. Any return statement with anything used with it can be > rejected (and should). > > It is documented as void, we could "fix" it with a bug fix. - https://www.php.net/manual/en/language.oop5.decon.php#object.construct lists the __construct() function as void. - But the implementation of __construct() is mixed. > > Also, about this whole discussion , that __ construct, can still be > called as a normal method. Some relics of php 4-5 migration path and > then work around serialization or hydration challenges. > > Most maintained projects out there moved away from these hacks and > rely on new reliable solution for these challenges, like doctrine > or symfony serializer. I have found https://php-legacy-docs.zend.com/manual/php4/en/migration5. But I didn't find any specific __construct() instructions, other than https://php-legacy-docs.zend.com/manual/php4/en/language.oop5.decon. At that page, it is not mentioned the __construct() must not return a value. Could you explain on serialization or hydration challenges in more details? Perhaps with a theoretical example? An (old) real-world example would be even better, if you can find one. Kind regards, Mirco Babin
