Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98508 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47036 invoked from network); 12 Mar 2017 13:54:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Mar 2017 13:54:27 -0000 Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 77.244.243.85 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.85 mx104.easyname.com Received: from [77.244.243.85] ([77.244.243.85:34027] helo=mx104.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FE/3C-38004-11355C85 for ; Sun, 12 Mar 2017 08:54:26 -0500 Received: from cable-81-173-135-7.netcologne.de ([81.173.135.7] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1cn3x1-0008AR-4S; Sun, 12 Mar 2017 13:54:25 +0000 Reply-To: internals@lists.php.net References: <2a928258-af19-c15f-548f-eb348b3f5449@fleshgrinder.com> To: Michael Vostrikov , PHP Internals Message-ID: <8e4d7946-a7cf-7a02-a745-2451aab564d2@fleshgrinder.com> Date: Sun, 12 Mar 2017 14:54:17 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-DNSBL-PBLSPAMHAUS: YES Subject: Re: [PHP-DEV] Type variants From: php@fleshgrinder.com (Fleshgrinder) On 3/12/2017 2:49 PM, Michael Vostrikov wrote: > 2017-03-12 15:35 GMT+05:00 Fleshgrinder : >> `IncompleteOrder` is the one without date, address, and >> probably even products. You directly named it as such. Then you have >> `ProcessableOrder` where this is impossible > > Yes, this is Order and OrderForCheckout in my example. But they should not > be descendants of base class or each other. Because allowed class states > are not descendants of that class. > >> **BAM** all problems solved. > > Yeah, now we have: > base Order > IncompleteOrder extends Order > ProcessableOrder extends Order > PaidOrder extends Order // or ProcessableOrder? > > and later could get: > WholesaleOrder extends Order > > with a question how to extend classes in new branch. > > > Also the problem is how to use this tree in relations. > > There is class OrderItem with $order property. > There is class Customer with $orders property. > What classes should have these properties? Every time different? > > This is a part of another problem that we need to decide what exact class > should be created here or there before calling a function which uses it. > > > With type variants (hm, or invariants) it could be: > Order > ProcessableOrder variant of Order > PaidOrder variant of Order > WholesaleOrder variant of Order > > And everywhere we can create and use objects with class Order, and only in > some functions they will be considered as processable or not. > Post this on Stackoverflow and I'll give you some answers and possible approaches. ;) You are clearly struggling with architecture and design, but you are definitely not missing language constructs here. -- Richard "Fleshgrinder" Fussenegger