Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58583 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36282 invoked from network); 4 Mar 2012 16:34:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Mar 2012 16:34:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=dragoonis@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dragoonis@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: dragoonis@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:63782] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B2/65-12048-F79935F4 for ; Sun, 04 Mar 2012 11:34:08 -0500 Received: by lahl5 with SMTP id l5so4117235lah.29 for ; Sun, 04 Mar 2012 08:34:04 -0800 (PST) Received-SPF: pass (google.com: domain of dragoonis@gmail.com designates 10.152.110.102 as permitted sender) client-ip=10.152.110.102; Authentication-Results: mr.google.com; spf=pass (google.com: domain of dragoonis@gmail.com designates 10.152.110.102 as permitted sender) smtp.mail=dragoonis@gmail.com; dkim=pass header.i=dragoonis@gmail.com Received: from mr.google.com ([10.152.110.102]) by 10.152.110.102 with SMTP id hz6mr17155216lab.21.1330878844486 (num_hops = 1); Sun, 04 Mar 2012 08:34:04 -0800 (PST) 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:content-transfer-encoding; bh=0vX+Yajuw7VKalQdRykzwkP0NKalA7xgkcIjU0plS9k=; b=TG5qyTX8EyHZJefsr5Uxey9WAQC4q2GIZuWlkQZtij6TC5mDObHgWTYAKFK0lTkYZt ya+pdwyRjojLFh741BrX8vJvLiG7/rPe/qVC0aEaIbukbDW43ZU6KoWFu4HvQR7l2p5I wFd151O4nyOxgrvOQtDDvBOL1MK2eHyYGbbPkn3Yxoz2zNgq5deQFwbt8QQ1n2gYpkUQ oOZRLRZBJClmOz1fTCd0FYYPKvzcIe2wW+lNwXvTxhCRFyA24tL8VyqfSOPJuWpIhYQE GGe3/iwNkmkSM1MRwl7jWPd7cBtLWqc/fqQJiB9p0TguJYGOa0wCKnAjxj1UAE8U6ieX oiNw== MIME-Version: 1.0 Received: by 10.152.110.102 with SMTP id hz6mr14061530lab.21.1330878844363; Sun, 04 Mar 2012 08:34:04 -0800 (PST) Received: by 10.152.13.40 with HTTP; Sun, 4 Mar 2012 08:34:04 -0800 (PST) In-Reply-To: References: Date: Sun, 4 Mar 2012 16:34:04 +0000 Message-ID: To: Lazare Inepologlou Cc: Anthony Ferrara , internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC - Discussion] Parameter Type Casting Hints From: dragoonis@gmail.com (Paul Dragoonis) Is (DateInterval) a valid cast currently in PHP ? If not, then we're not looking to add new fancy casting options, just give casting options on the simple existing ones. - Paul. On Sun, Mar 4, 2012 at 4:26 PM, Lazare Inepologlou wro= te: >> 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 { > =A0 ... > =A0 public function add( (DateInterval) $interval ) { ... } > =A0 ... > } > $date =3D new DateTime; > $date->add( 'P3D' ); // string to DateInterval casting > $date->add( 3600 ); =A0// 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 th= e > passed argument if of the correct type and, if not, try to cast it. Failu= re > to do so will lead to the E_RECOVERABLE_ERROR as today. ] > > > Lazare INEPOLOGLOU > Ing=E9nieur 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. =A0Attached 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 >> >