Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37061 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89892 invoked from network); 17 Apr 2008 12:52:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2008 12:52:38 -0000 Authentication-Results: pb1.pair.com header.from=paul.biggar@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=paul.biggar@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.146.182 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: paul.biggar@gmail.com X-Host-Fingerprint: 209.85.146.182 wa-out-1112.google.com Received: from [209.85.146.182] ([209.85.146.182:57027] helo=wa-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F1/9A-38326-41847084 for ; Thu, 17 Apr 2008 08:52:37 -0400 Received: by wa-out-1112.google.com with SMTP id l24so80599waf.17 for ; Thu, 17 Apr 2008 05:52:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=CG0dmhH1Io07G3vnHPqQ5uAEIb+8MGwE6SSVG4yY1Fk=; b=QczlDH5gUj9m6/YmtRDDR09Dxe55SQqYFb8eF7rrMqqwb1HsgMQ6SF3CRnwxFrh/l1sT5M7DpYofdfC8s3xwmpn3mfUOjxAhMZEBIjuIh6pRrq+poD1EimeHXHoI/z41WbPMIaHq8ZN6uqrEUPAZ94RgGowWli0Rdjwvbicwd0Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=AkY2vGxaKbyfZ8om4MJTkW918xC7XWQusIWXi9Bwg6cCA7uNkUVmemO2jsMCkq+FYl6lx0NwNsLogY307eCxjgggwHcKwZaizVHNQqLnePSsYaAAHDXO608i2JN5pfVf6w0c0LdCB4skBPESD9RCAPIJTgahuo4J6N3Mve2gfuI= Received: by 10.114.157.1 with SMTP id f1mr1286746wae.214.1208436752466; Thu, 17 Apr 2008 05:52:32 -0700 (PDT) Received: by 10.114.255.17 with HTTP; Thu, 17 Apr 2008 05:52:32 -0700 (PDT) Message-ID: Date: Thu, 17 Apr 2008 14:52:32 +0200 To: "Felipe Pena" Cc: internals@lists.php.net In-Reply-To: <1208404255.5665.34.camel@pena> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1208404255.5665.34.camel@pena> Subject: Re: [PHP-DEV] [RFC] Type hints (parameter and return value) From: paul.biggar@gmail.com ("Paul Biggar") Hi, Your current implementation seems to be inconsistent with both itself and the rest of PHP. I hope this can be rectified before it is included. PHP is inconsisent enough without adding more. 1.) There are a number of is_* functions. It seems obvious that they should be consistent with this. So you're missing numeric and scalar. I'm not clear if there is a is_unicode(), but if so, that should be consistent too. (I believe scalar is particularly important, at a language level, since mixed and object are provided). 2.) is_int has different semantics to the int type hint. Numeric strings qualify as the latter, but not the former. In general this is a problem. It seems type hints can only be made consistent if they convert the actual parameter to the type which is hinted. (Note that for call-by-reference, this will change the value in the caller, not just the copy in the callee - I think this is a good idea). As an example, this will fail, which it shouldnt: function y (int $x) { assert (is_int($x); } y ("24"); 3.) This doesnt seem to be integrated with class type hints, in the codebase. I wonder why that is? (I don't care all that much, I'm just wondering). I hope we can get these ironed out. Thanks in advance. Paul On Thu, Apr 17, 2008 at 5:50 AM, Felipe Pena wrote: > Hello again! > > Now with both parameter and return value type hints. > > For parameter type hints, i have completed the actual implementation > with the leftover php types: > - string (binary string and unicode) > - integer (accepting numeric string too) > - double (accepting numeric string too) > - boolean ('0', '1', true, false) > - resource > - object > > (Yes, following our dynamic typing) > > > Since then, the patch also includes new methods to Reflection: > - isInt() > - isDouble() > - isBool() > - isString() > - isObject() > - isResource() > > > And for return value, i have modified and improved the previous patch, > and now it is using only the "(type)" notation. Hence, that > implementation doesn't make any BC break. > > > Examples, patches and tests: http://wiki.php.net/rfc/typehint > > > Thanks. > > -- > Regards, > Felipe Pena. > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Paul Biggar paul.biggar@gmail.com