Re: Type variants

From: Date: Sun, 12 Mar 2017 10:33:47 +0000
Subject: Re: Type variants
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-98503@lists.php.net to get a copy of this message
Hi Michael, On Sat, Mar 11, 2017 at 3:36 PM, Michael Vostrikov < michael.vostrikov@gmail.com> wrote: > > class Square variant of Rectangle > { > public function __match() > { > if ($this->width != $this->height) { > return ['width' => 'Width and height have to be the same']; > } > > return true; > } > } > DbC allows this kind of validation at development time. I suppose you would like to check requirement at runtime always. It would be nice to have feature, but I think something like __requrie() is better name for the method. IMO, C# like getter/setter is better though. http://stackoverflow.com/questions/11159438/looking-for-a-short-simple-example-of-getters-setters-in-c-sharp Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net

« previous php.internals (#98503) next »