Re: Return type hints

From: Date: Mon, 14 Apr 2008 17:04:23 +0000
Subject: Re: Return type hints
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-37005@lists.php.net to get a copy of this message
You are missing the point, why be strict on return types, and liberal on parameters? Be strict consistently or be liberal consistently. Or, keep php, php. I could care less as long as things are consistent, although I think only supporting scalar is silly regardless of type juggling. -Chris On Mon, Apr 14, 2008 at 7:28 AM, Christian Schneider <cschneid@cschneid.com> wrote: > Chris Stockton schrieb: > > Why on earth would you have int, string, resource, etc "return type > > hints" > > and then turn around and suggest for parameter hinting just add a scalar > > type? That makes no sense and is so inconsistent. > > > > static int function retarded(scalar $value) { > > return (int) $value; // lol.... > > } > > > > Let me turn your question around: Why on earth would someone restrict a > function to int when string works just as well? > > function int foo_flexible(scalar $x) { return $x + 42; } > $foo = foo_flexible($value); > > function int foo_retarded(int $x) { return $x + 42; } > $foo = foo_retarded((int)$value); # :-( > > That said, I'll be using > function foo($x) { return $x + 42; } > anyway and let PHP warnings take care of the rest ;-) > > - Chris > >

« previous php.internals (#37005) next »