Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97255 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81854 invoked from network); 2 Dec 2016 14:46:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Dec 2016 14:46:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=narf@devilix.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=narf@devilix.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain devilix.net designates 209.85.218.52 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 209.85.218.52 mail-oi0-f52.google.com Received: from [209.85.218.52] ([209.85.218.52:36327] helo=mail-oi0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 49/3A-01781-F4981485 for ; Fri, 02 Dec 2016 09:46:40 -0500 Received: by mail-oi0-f52.google.com with SMTP id v84so267411996oie.3 for ; Fri, 02 Dec 2016 06:46:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devilix.net; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=2MIqY7Iv76XJ0KB8dZuUy4ziBNvja6GgbTU7okcneJM=; b=jndeyNOqyZH7KnfuBHuF2vYRru0JSWCshe6+IgiYBHLf5gB867Ym2i4TqL+G3O+TCU pPsbHLu33fp3EnRw35VSsDg+/gT6kSTDH0heiRqgMZyZbT7K7Qdex5qu+ocUcJ2bxUOa gKAN0UtEgOWYXEOtscc6ORYaEou0D05eBBD84= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=2MIqY7Iv76XJ0KB8dZuUy4ziBNvja6GgbTU7okcneJM=; b=OWqJFMokJ5PCt3AtOd7u0YocjBnw8fEszz1RzpjcTXiJrW6UPpMCJ+WTFbEo35wJj7 /gfH8wVeOnQUYtqUwjTm43wvpR680SB4Rpq5SiWT/hQcgN2X9WqgQqVz8yNaob0i0i6W ccAnHLQPJpn2zoLy7YFIL9/TIrlyjeqdjemr+q248DBxX83ZWJWg4qZ+zobaRyPTpF23 89Exvn6CfEvlVArPyJVL2iM3ccMdbucRc5RTlTLfuz+JEKdycwEMfsATYa4DFQxeMmQP 9ARfLtlhx+3oRZgvknb0wjkxsCRNAPK7Al5Pwx8+qPIer80dnUbT8DqCGlZQogKwXDvG 88HQ== X-Gm-Message-State: AKaTC02VP52ob9iOmQLoOuUmVP+XRnNgy7N4U8jalGvNg6WqtoXCShrvcCrGvXf+WS0T5E6mWYdzQUXU1kHVzg== X-Received: by 10.202.169.81 with SMTP id s78mr23815993oie.81.1480689997084; Fri, 02 Dec 2016 06:46:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.202.252.88 with HTTP; Fri, 2 Dec 2016 06:46:36 -0800 (PST) In-Reply-To: References: Date: Fri, 2 Dec 2016 16:46:36 +0200 Message-ID: To: Alex Bowers , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a113cdbc04c9a230542ae0188 Subject: Re: [PHP-DEV] Re: [Concept] Magic Casting From: narf@devilix.net (Andrey Andreev) --001a113cdbc04c9a230542ae0188 Content-Type: text/plain; charset=UTF-8 Hi again, On Fri, Dec 2, 2016 at 4:19 PM, Alex Bowers wrote: > I don't see how the interface is equivalent. > > The benefit of this, is that you can convert types passed into a method to > the type you expect automagically, Castable wouldn't allow that, only a new > magic method (or reflection and user land code possibly?) would allow this. > A magic method is essentially an implicit interface ... The interface itself does nothing. But when it is implemented, the engine will know that the class constructor is public and accepts a single parameter - thus, also knowing that it could try to do a new ClassName($yourParameterHere) > > As for the limitation of only one parameter being accepted, what would the > other possible parameters be? > > Since this is based entirely on the casted variable, there can only > possibly be one variable there, the one passed into that position in the > functions arguments. > > What I meant is - you cannot cast to a class that requires more than one dependency to be instantiated - that's the obvious limitation. > Arguably, this feature would resolve some bugs in peoples code, because it > can allow better enforcing of types. > It enables magic behavior, that's the opposite of enforcement ... If you want to enFORCE something, you force the developer to do something, you don't auto-magically do the thing for them. P.S.: I suppose you've hit "Reply" instead of "Reply All"? I was the only recepient of the message I'm quoting. Cheers, Andrey. --001a113cdbc04c9a230542ae0188--