Re: Re: Clarification on the Enum language structure
| From: | Derick Rethans | Date: | Wed, 23 Feb 2011 16:21:11 +0000 |
| Subject: | Re: Re: Clarification on the Enum language structure | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-51519@lists.php.net to get a copy of this message | ||
On Wed, 23 Feb 2011, Stas Malyshev wrote:
> > > > public function Killjoy(MyEnum $x)
> > >
> > > What would be the purpose of such code? What would it do if 5 is
> > > passed as $x?
> >
> > IMHO, it should fail (unless 5 is the value explicitly mentioned in
> > MyEnum definition)
>
> So before calling this method you better check it's argument against all
> possible enum values, otherwise it's fatal error, right? Doesn't seem as very
> helpful interface to me.
You'd rather correct it to the closest value in the Enum, just like
casting typehints? ;-)
cheers,
Derick