Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98489 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3979 invoked from network); 12 Mar 2017 06:41:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Mar 2017 06:41:19 -0000 Authentication-Results: pb1.pair.com smtp.mail=theanomaly.is@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=theanomaly.is@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.181 as permitted sender) X-PHP-List-Original-Sender: theanomaly.is@gmail.com X-Host-Fingerprint: 209.85.128.181 mail-wr0-f181.google.com Received: from [209.85.128.181] ([209.85.128.181:33500] helo=mail-wr0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A7/A5-38004-E8DE4C85 for ; Sun, 12 Mar 2017 01:41:19 -0500 Received: by mail-wr0-f181.google.com with SMTP id u48so86301971wrc.0 for ; Sat, 11 Mar 2017 22:41:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=A6mQ14NGo0c3oxJqd/HHQDUb/KHQwA/ZKIoR0JYMxTk=; b=iC5DinczqdaeRPGrW6lyALnj+Lbz9uYkeVNmEiCtamaLcOHCe6Um5nQZxXSmY5KvPC AROTf0GjHQVHX4o3IBlOwYKxy4AkalFS+qiU38OL4KI/bOqWpeXKWJOtnKl4JlkIXGiP a9rk/two2C46JLxphwCOZuOcJIzuQqDUeKUBp+E1Aq/2neewIPYioRvmwwdiXrtmaznP GswTz1RDFDNklVpDLC1RxZUolpovDPu3uGp5/a3bGrbuWLgo2iKxFW2gfCgwXdyx/wk8 lA4RVtlp8EVwb8dOHpb0LwlcC0RahvKbzZYIBbigeirqxWuqOp5zBCwA3Y+rLwcuv/bE ErhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=A6mQ14NGo0c3oxJqd/HHQDUb/KHQwA/ZKIoR0JYMxTk=; b=Dmrwk/AGVXYeqSrzGt7NS1goqLo0BV3wN7IMNPx46Yo7MFSedUIc1MXjseEP7GcSqC 4LqH4NNyyf467MC5HN5xdoSeYRENqRSalo6fhEferElNoaNb6M06HBjsdkSaCmag5CWe yi/fDmWK+oSdDST96UbhdSfC+gjMg+Oa7JJrX5TJ5ogY/i5igSJbFP9IV8xdf5yaOF9P 71vC7DXNl9O/p9HFcJm5W9Akqz7Nm85XYJ0gyPQRo9VYzjUOXY+Gglk0N2fcgSRyodXU +pIjU4GF34qcQFAWi6DxVBqY8PkHqyTG6VqfRRTiIn2J1sHHEs0fa0EUbZfHNRKF34JE ITvQ== X-Gm-Message-State: AMke39m0jnFaUmXDYlXfFY7GpSgo2HwA4f+IOyLqB/WvvFM50lZsvmSo60u1rVCkr3fA2fRPOm3S/cDlXatfRg== X-Received: by 10.223.132.37 with SMTP id 34mr21312939wrf.45.1489300875855; Sat, 11 Mar 2017 22:41:15 -0800 (PST) MIME-Version: 1.0 Received: by 10.80.143.35 with HTTP; Sat, 11 Mar 2017 22:41:15 -0800 (PST) In-Reply-To: References: Date: Sun, 12 Mar 2017 01:41:15 -0500 Message-ID: To: Michael Vostrikov Cc: PHP Internals Content-Type: multipart/alternative; boundary=94eb2c0d56ccab4ede054a82e1b3 Subject: Re: [PHP-DEV] Type variants From: theanomaly.is@gmail.com (Sherif Ramadan) --94eb2c0d56ccab4ede054a82e1b3 Content-Type: text/plain; charset=UTF-8 Yea, but how's that an improvement over using an interface? On Sun, Mar 12, 2017 at 1:38 AM, Michael Vostrikov < michael.vostrikov@gmail.com> wrote: > > 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. > --94eb2c0d56ccab4ede054a82e1b3--