Re: Exceptions for method on non-object rather than fatal (desired feature?)
| From: | Larry Garfield | Date: | Wed, 22 Feb 2012 19:04:20 +0000 |
| Subject: | Re: Exceptions for method on non-object rather than fatal (desired feature?) | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-57956@lists.php.net to get a copy of this message | ||
On 2/22/12 12:37 PM, Peter Lind wrote:
How? What bad habit does this encourage? --Larry GarfieldI would also support this. There's a myriad reasons why something mayreturn NULL or FALSE when you expect it to return an object, some of them even legitimate. Any function/method whose documentation line is "returns the foo object, or NULL if someone screwed up and there isn't one" is perfectly reasonable in many cases, IMO, but makes all chains a potential fatal. An exception would make a lot more sense, and allow us to centralize handling of such "exceptional" cases rather than throwing if-checks everywhere. (Which is exactly what exceptions are for.)--Larry Garfield -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.phpSeems to me this change would encourage bad habits (breaking the law of Demeter) which would personally put me against it. Regards Peter