Re: Design by Contract

From: Date: Tue, 10 Feb 2015 07:33:38 +0000
Subject: Re: Design by Contract
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  Groups: php.internals 
Request: Send a blank email to internals+get-82345@lists.php.net to get a copy of this message
Am 10.02.2015 08:08 schrieb "Yasuo Ohgaki" <yohgaki@ohgaki.net>: > > One reason I would like to use __invariant() is to allow overriding parents. > I think we should have way for it, but I don't have good idea now. > I'm still thinking. Hmm, Idea... Imagine the require keyword, in the context of classes, as an alternative to the function keyword. One could write any of these: class foo { require (expr); // like anonymous function. nonoverridable static require (expr); // same for nonmethod calls // _named_ form require something (expr); // overrides static require otherthing (expr); // overrides } This way selective overriding would be possible for individual conditions. The namespace for these invariant expression names could / should be wholly separate from the method namespace itself. best regards Patrick

« previous php.internals (#82345) next »