Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67865 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19633 invoked from network); 26 Jun 2013 13:27:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jun 2013 13:27:48 -0000 Authentication-Results: pb1.pair.com header.from=seva.lapsha@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=seva.lapsha@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.83.48 as permitted sender) X-PHP-List-Original-Sender: seva.lapsha@gmail.com X-Host-Fingerprint: 74.125.83.48 mail-ee0-f48.google.com Received: from [74.125.83.48] ([74.125.83.48:39441] helo=mail-ee0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 23/D6-18025-35CEAC15 for ; Wed, 26 Jun 2013 09:27:48 -0400 Received: by mail-ee0-f48.google.com with SMTP id b47so7408816eek.35 for ; Wed, 26 Jun 2013 06:27:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=f2cOU3zMnd0FnxYu9ZwwHjUSN6crs0UnMitoSl+j7cc=; b=eeKYFCi7X48sxRLnaVcis9rkDqVtUBL87RZlmgNt7ie1C8ZgC+mdSSFaEZQsi7WCI3 ezGgngCgP+M1y9WPh3tra2zqlU1nMF3xMWOFuaFvWfPT3TPn2CtTQjdnhgrlS+mKSCJe m6vKQyvUYb/r4JBvY/3abRILM1rtk6P18MCFJR1iEOfl5DQ+o8f7Kx0+xveHXqau1MQ6 KbiOSTQAnFaqtfOz2XSFksX4TqojiF7m1x786syPDWNDqrTWXn5xSp7qo99ED+EUYkP0 7zEYAZkKWcamU3T/puqzmskXLbM/5gWA8sdy7Pxi+Eiizi2VKxg1WQQGvMsBygXapalh yJTg== MIME-Version: 1.0 X-Received: by 10.14.106.195 with SMTP id m43mr4181461eeg.60.1372253264654; Wed, 26 Jun 2013 06:27:44 -0700 (PDT) Received: by 10.14.104.134 with HTTP; Wed, 26 Jun 2013 06:27:44 -0700 (PDT) In-Reply-To: References: <51CA16C2.2000100@sugarcrm.com> <51CA206A.9050002@sugarcrm.com> Date: Wed, 26 Jun 2013 09:27:44 -0400 Message-ID: To: Nikita Nefedov Cc: Anthony Ferrara , Stas Malyshev , Laruence , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c1b83061d57c04e00e9c9a Subject: Re: [PHP-DEV] RFC: Protocol Type Hinting From: seva.lapsha@gmail.com (Seva Lapsha) --001a11c1b83061d57c04e00e9c9a Content-Type: text/plain; charset=ISO-8859-1 Hi, As I see it, adapters not only serve declaration purpose, they also can adapt the method and param names and even alter or tune the execution flow. Imagine this simple case: You have a protocol Duck with method walk() with few concrete implementations. Later you have another instance of Duck, but its corresponding method is called walkAround(). What would be the sane pattern to solve this problem? Should we now implement an adapter for the protocol? I think if we're interested in simplification, there should be a more flexible way to create adapters instead, maybe with method/param mapping abilities. E.g.: class Duffy { function walkAround($speed, $distance) {} } interface Duck { function walk($distance, $speed); } adapter DuffyDuck extends Duffy implements Duck { function walk($distance, $speed) as walkAround($speed, $distance); } or in a simpler case - class Donald { function walk($distance, $speed); } adapter DonaldDuck extends Donald implements Duck {} It solves same problem as the proposal, but in explicit, maintainable and analyzable way, IMHO. On Wed, Jun 26, 2013 at 5:51 AM, Nikita Nefedov wrote: > Hi, > > > On Wed, 26 Jun 2013 02:57:46 +0400, Stas Malyshev > wrote: > > That means all you really need is to call method named "get", regardless >> of what it actually does. Usually the code doesn't work this way - you >> expect something to actually happen if you call get(), something >> specific. Interface ensures whoever wrote that object acknowledged that >> this is what he wants too. >> > > But you (as a library dev) still have interfaces. You still use them. > > This discussion got really big in a short period of time, but we all know > all this change does is gives us an ability to not write additional code. > Some people already stated it - you just won't need to create adapters and > it's cool. > There's a lot of cases where you need to wire to different libraries and > for that matter you create THIRD library and call it something like > %lib1-name%%lib2-name%Adapter where you, in the best case, should create > classes that inherit from some lib1's or lib2's classes (and just add > "implements Lib2Interface"), or if there's some static methods - you are > forced to create decorator which implements needed interfaces - and that is > what will give a far more overhead than some runtime engine-level checks. > > What about static analysis, it just lays on YOUR shoulders, if you so want > static analysis to work properly you just write code which implements > interfaces. But if it's fine for you, then it's fine, it's easy. > > PS sorry for caps in some places > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a11c1b83061d57c04e00e9c9a--