Re: Type variants

From: Date: Sun, 12 Mar 2017 06:38:04 +0000
Subject: Re: Type variants
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-98488@lists.php.net to get a copy of this message
> Example with Rectangle and Square IMO is an example of bad naming in this case. I used this example because this is known problem of inheritance. Type variants solve this problem. Square is a particular case (variant) of Rectangle. > PHP already has horizontal inheritance. They're called traits. How is this an improvement in anyway? Trait is just reusable implementation. I suggest type matching. This is extension of type hinting. It can be used in all cases where we need to check if an object matches some criterias before continue operation. It is a kind of defensive programming and a replacement for many 'if-throw' constructions.

« previous php.internals (#98488) next »