Hello Mirco,
On Fri, Feb 20, 2026, 11:48 PM Mirco Babin <[email protected]> wrote: > Op vr 20 feb 2026 om 08:43 schreef Rowan Tommins [IMSoP] < > [email protected]>: > > > > On 19 February 2026 20:24:56 GMT, Mirco Babin <[email protected]> > wrote: > > > > > > >The Php scripting aspect makes it difficult in general > > >for untyped projects to fail early. > > > > > > This is a completely irrelevant statement. We're not talking about > > failing early "in general", we're talking about a compile-time check > > that PHP already makes in other contexts. > > Failing early is not always possible. The compiler can not always infere > the correct return type. E.g. this example will succeed to compile: > > ```php > class UnableToInfereReturnType > { > private function TruelyUnknown() : mixed > { > $a = time(); > if ($a % 2 === 0) { > return ['important']; > } > } > > private function ActAsVoid() : void > { > return $this->TruelyUnknown(); > } > > // Lets act as if the return type is implicitly void > public function __construct() // : void > { > return $this->ActAsVoid(); > } > } > > $it = new UnableToInfereReturnType(); > > // Runtime error, not a compile error. > // Fatal error: A void method must not return a value in /in/MJCjX on line > 15 > > ``` > Both can, and should, have errors before runtime. This is easily detected at compile time. Whether or not the return <some value> is used in a branch, it is seen before runtime, obviously. 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. 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. If anything, this whole cleanup could be done right, disallow returning value and finally make __construct what it is designed and made for, a constructor. Not a normal method. __ Pierre @pierrejoye | http://www.libgd.org >
