Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97265 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94397 invoked from network); 2 Dec 2016 14:58:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Dec 2016 14:58:34 -0000 Authentication-Results: pb1.pair.com header.from=bowersbros@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=bowersbros@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: bowersbros@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-wm0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:36963] helo=mail-wm0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 39/2D-01781-91C81485 for ; Fri, 02 Dec 2016 09:58:33 -0500 Received: by mail-wm0-f54.google.com with SMTP id t79so18093003wmt.0 for ; Fri, 02 Dec 2016 06:58:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=rMiCmSomx2DlpiSG2aANiP07d1ARvk5xU7xNx+/+H3U=; b=ZnL4lDRdcmKdldifgkmudWEUrTvI/X9y45Ef5nClVBjeN5cZqeGBR73W1ZfZPgbQmW pVy/geZ46to4k08mttwHYGSyu8ndMFqarvEY2qxJlw2hySDZTRpXdDLlEG2+AJ6kfimn nAU+mkILLLqwatDfNbWOPIDUV0dChJsh5AlBivVp1E8eBprT5Y5ixLZVDwbQu6Dkta8A EL7bSEfZM6Q2uYkzlsc1i1ccoI6Vtgr4gNwR0uJYoYf1a+ldlOshhhzTpLViPtwtTTs8 go0h6G6eQ5Orix8EvV5hCKKnUrC8xoj7SgY8hyI5SyoZzXJ0iCYkjoJccxzEMu845uck /NEg== 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:cc; bh=rMiCmSomx2DlpiSG2aANiP07d1ARvk5xU7xNx+/+H3U=; b=b20ayjsS7K0poRVGlGzmrhSMxgpSS6c+a8RAzORUlkoKutRZ1m4fRmRLf9wMbYHbrR hFjODDR0vcCz3/QVnOSm+E0hB7DBty5T4/eHdAsvVe6x6xh2Q+TFWcZ8qtldJFW0112w obx2bsSv6SQFQumrkgkDc158eriN9Q8Tjg7mcR8SpD2AE9oV+Csad8hioXUPIpwco5ts YJqmQuKLIFmyw9HAVj9ILJdAWU6Nrfqv/EDQqelG3tp6xyCKD2R0Vda/j39JY49gR5f6 YyOFindDIKPKmrwKlSA/b8Cg4iVOCrqPOYvEgzBNQYBAh9RYizPiqaeMEANLEDMzj8kZ SqJA== X-Gm-Message-State: AKaTC02IZ7s0n/jN0MqQq2DyF7abNJMhzGMivGFxtBppVwaL2PjrLLRXUJCr+tineH5VbAAj7fuJAU2cB22Ewg== X-Received: by 10.28.139.12 with SMTP id n12mr3194798wmd.79.1480690710267; Fri, 02 Dec 2016 06:58:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.232.77 with HTTP; Fri, 2 Dec 2016 06:58:29 -0800 (PST) In-Reply-To: References: Date: Fri, 2 Dec 2016 14:58:29 +0000 Message-ID: To: Andrey Andreev Cc: PHP Content-Type: multipart/alternative; boundary=001a11444d94cecdd70542ae2b44 Subject: Re: [PHP-DEV] Re: [Concept] Magic Casting From: bowersbros@gmail.com (Alex Bowers) --001a11444d94cecdd70542ae2b44 Content-Type: text/plain; charset=UTF-8 Sorry for dupe, hit reply not reply-all. 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. 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. Arguably, this feature would resolve some bugs in peoples code, because it can allow better enforcing of types. Currently, a place that accepts a Collection would not be able to type hint it if it wants to also accept an array, instead it would have to check and change inside the method, but that shouldn't be the role of the method. The method just wants to assume, and work on the assumption that it is the correct type, but without losing flexibility. The ability to cast to your own type automatically would help with this assumption, as now everywhere would be able to assume Collection, and use it as so, but allow the current flexibility of arrays being passed in also. --001a11444d94cecdd70542ae2b44--