Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58582 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32246 invoked from network); 4 Mar 2012 16:26:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Mar 2012 16:26:33 -0000 Authentication-Results: pb1.pair.com header.from=linepogl@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=linepogl@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.42 as permitted sender) X-PHP-List-Original-Sender: linepogl@gmail.com X-Host-Fingerprint: 209.85.213.42 mail-yw0-f42.google.com Received: from [209.85.213.42] ([209.85.213.42:37905] helo=mail-yw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/74-12048-8B7935F4 for ; Sun, 04 Mar 2012 11:26:33 -0500 Received: by yhfq11 with SMTP id q11so1546573yhf.29 for ; Sun, 04 Mar 2012 08:26:30 -0800 (PST) Received-SPF: pass (google.com: domain of linepogl@gmail.com designates 10.236.76.198 as permitted sender) client-ip=10.236.76.198; Authentication-Results: mr.google.com; spf=pass (google.com: domain of linepogl@gmail.com designates 10.236.76.198 as permitted sender) smtp.mail=linepogl@gmail.com; dkim=pass header.i=linepogl@gmail.com Received: from mr.google.com ([10.236.76.198]) by 10.236.76.198 with SMTP id b46mr22646900yhe.25.1330878390224 (num_hops = 1); Sun, 04 Mar 2012 08:26:30 -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:content-type; bh=534d5/aQ2ggHcrTERILbiIk0Y+Vde9iWIICit0LpSHc=; b=O9AoHfcL3E13rN6mgjqJWV3K12ttYqKxSWA0m89Et0UShkw6aRfpqVNDQSG8jEHq8D opk4ZRm18C6A5bf71kHGUjlRbeEFQ3AMOYvHqBI75G0CRMNfF58ALEkGV+gNKzfCgtJW zAI4gNjn92wbb5GSEnDOy0kHwmnq/qgLO9Mckg88LJC93+89vWc9RptypLMr5nd48ZrV /K8pl7ibFQcZ0MVlQ9SziKlQqnSTBfY9IZRsGXvnYp072plo5r+/+FUj4PFGBxbOyiQR CKwkJzqfgJ6BWH/vIdjQnf59Hw18+PyxADa82mUTJtip7EGTPv+wPWm+Jysrb9mVUj7V nb+w== Received: by 10.236.76.198 with SMTP id b46mr17991644yhe.25.1330878390170; Sun, 04 Mar 2012 08:26:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.147.125.8 with HTTP; Sun, 4 Mar 2012 08:26:10 -0800 (PST) In-Reply-To: References: Date: Sun, 4 Mar 2012 17:26:10 +0100 Message-ID: To: Paul Dragoonis Cc: Anthony Ferrara , internals@lists.php.net Content-Type: multipart/alternative; boundary=20cf300fb3a7af75f604ba6d4537 Subject: Re: [PHP-DEV] [RFC - Discussion] Parameter Type Casting Hints From: linepogl@gmail.com (Lazare Inepologlou) --20cf300fb3a7af75f604ba6d4537 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > > I wouldn't want people to put class typehints in there such as > function foo( (SomeClass) $foo) > Why not? I would definitely like something like that, in the future. Here is an example: class DateTime { ... public function add( (DateInterval) $interval ) { ... } ... } $date =3D new DateTime; $date->add( 'P3D' ); // string to DateInterval casting $date->add( 3600 ); // int (seconds) to DateInterval casting Personally, I find this to be much closer to free type-juggling PHP style than the current implementation with type hints ( http://www.php.net/manual/en/datetime.add.php). [ Actually, I would prefer even type hints to work like this. Check if the passed argument if of the correct type and, if not, try to cast it. Failure to do so will lead to the E_RECOVERABLE_ERROR as today. ] Lazare INEPOLOGLOU Ing=C3=A9nieur Logiciel 2012/3/4 Paul Dragoonis > Can you make sure that only scalar or array casts can be done? > > I wouldn't want people to put class typehints in there such as > function foo( (SomeClass) $foo) > > - Paul. > > On Sun, Mar 4, 2012 at 1:28 AM, Anthony Ferrara > wrote: > > Hey all, > > > > I've drafted an RFC for the Parameter type casting hint proposal that > > I posted to before. Attached to the RFC is a patch that's proposed > > for inclusion in core for functionality (it doesn't include news > > entries, or documentation, or any of the other steps that would be > > needed prior to commit). > > > > https://wiki.php.net/rfc/parameter_type_casting_hints > > > > Please provide feedback here on the implementation and RFC topics. > > > > Thanks, > > > > Anthony > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --20cf300fb3a7af75f604ba6d4537--