Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58821 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98562 invoked from network); 9 Mar 2012 14:27:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Mar 2012 14:27:31 -0000 Authentication-Results: pb1.pair.com smtp.mail=simonsimcity@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=simonsimcity@googlemail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: simonsimcity@googlemail.com X-Host-Fingerprint: 209.85.214.170 mail-tul01m020-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:40298] helo=mail-tul01m020-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E8/AE-10820-3531A5F4 for ; Fri, 09 Mar 2012 09:27:31 -0500 Received: by obbwd1 with SMTP id wd1so2332040obb.29 for ; Fri, 09 Mar 2012 06:27:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=rE45jnTUKG/EARlSYmQdEGHOwYojTcJNekQMSCD3E/k=; b=npUkcRK8oZuzZaPf4wFIW4D4jxUB/CUyFHJSN+drzRWDW9ON6CGRrYa9iyyK49XRi1 wMoNb4OJpHtP0+viuMmXAgmx5r4Rm5TIbMJlBq8HClUI0xcfxnh4PvfbrC/So9lpjNwS byskk5WUm4B0GPAjWLrKeFvTABi5ar/zuJ9+Mif/e3f/fQiDgwy1vY5hp6J1bHpXym9W DY9Lt6fn675L+wlG2/T/NmbVZLwQv9MfZvNTeDmos4n9IgtjqNpJCKTsqhh0hO+xR5uK Z+xym6ZfYFW3mCxi7DgPFVHcvpkp42TzNjgOBcMOFpPtJeY+qjIZPLvv53YmpVhLr8ve P0rQ== MIME-Version: 1.0 Received: by 10.182.155.68 with SMTP id vu4mr928840obb.61.1331303248332; Fri, 09 Mar 2012 06:27:28 -0800 (PST) Received: by 10.60.63.70 with HTTP; Fri, 9 Mar 2012 06:27:28 -0800 (PST) In-Reply-To: References: Date: Fri, 9 Mar 2012 15:27:28 +0100 Message-ID: To: Lazare Inepologlou Cc: Anthony Ferrara , internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [POC - Patch] Scalar Type Hinting - A-La zend_parse_parameters From: simonsimcity@googlemail.com (Simon Schick) 2012/3/9 Lazare Inepologlou > > Yes, like that, only better. Since automatic type casting is central in > PHP, as this is evident after all this discussion, I believe that it > should > be better supported. There are two thinks that I would like to see here: > > 1. No more magic methods, please. > 2. It should cover (eventually) casting to and from any type. > > :-) > > Lazare INEPOLOGLOU > Ing=C3=A9nieur Logiciel > Hi, Lazare As you mentioned it in another thread, I like the idea of C# you described = ... Draw a line between explicit and implicit casting. What the current idea would be is an implicit casting (as I understood it right). Let me just repeat your examples: 2012/3/7 Lazare Inepologlou > function test_float( float test ) { ... } > test_float( 1.0 ); // ok > test_float( 1 ); // implicit int to float cast, ok > > function test_array( array test ) { ... } > test_array( array() ); // ok > test_array( 1 ); // no implicit int to array cast, error! > test_array( (array)1 ); // explicit int to array cast, ok An explicit type-cast should be always possible and try to get the very last bit of useful information out of the given bunch. Here it makes sense to have magic functions for integer, float, string etc. But as we're here talking about an implicit casting when passing a class to a function, I don't like the idea of calling the magic-functions if you paste a class in here as it changes the content of the variable. This won't make it easy passing a variable as reference. If you just switch to another type, you can afterwards do whatever you was able to do before. Bye Simon