Re: Return Type Hinting for Methods RFC

From: Date: Thu, 22 Dec 2011 23:28:33 +0000
Subject: Re: Return Type Hinting for Methods RFC
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-57041@lists.php.net to get a copy of this message
Hi!
Most modern languages allow returning null in any case. This is a hail Mary in the event something happens, but throwing an exception is inappropriate. I see no reason to diverge from that.
In PHP, returning object if everything is OK and false if not is a very common pattern. Also, you understand that always allowing null means that this construct: $foo = $this->returnsFoo(); $foo->fooMethod(); is no longer safe as you wanted it to be when you made returnsFoo use strict typing? You'd have to check $foo anyway. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227

« previous php.internals (#57041) next »