Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:36837 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26096 invoked from network); 7 Apr 2008 11:07:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Apr 2008 11:07:42 -0000 Authentication-Results: pb1.pair.com smtp.mail=felipensp@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=felipensp@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.182.188 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: felipensp@gmail.com X-Host-Fingerprint: 64.233.182.188 nf-out-0910.google.com Received: from [64.233.182.188] ([64.233.182.188:30091] helo=nf-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CC/10-25237-B700AF74 for ; Mon, 07 Apr 2008 07:07:41 -0400 Received: by nf-out-0910.google.com with SMTP id e27so524713nfd.13 for ; Mon, 07 Apr 2008 04:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc:in-reply-to:references:content-type:date:message-id:mime-version:x-mailer:content-transfer-encoding; bh=To+yzgAocYLqS2M6c8CvFryzaVtEX5jf8Ebzfkp3L+I=; b=VRN9+IMRrBIT6JDC+BRmbYntwZ7QupH/lKONoaoBqcLg9h1x7VH5tZvnJuODjSTebQRax1WEOt9RIWvxuGgLKfF24KQjzhtGmnYdoH7ly5aeqnvfmXFeVFwXRSIj8cgRAS7BpO5ersJm5Rj3UWBVYrWuaNG+M4WPhf1jrM4M+z8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date:message-id:mime-version:x-mailer:content-transfer-encoding; b=cIVNeib6oMytmJEzA0aHs6XoxxlJbNNCL01JA494VMT6SrxicBmdNdrruiWqjWdSOq4aIu/+kgpoPpbu/SELh3EQwsoi1T9glejj1sudo9gby7iWCpF9dtszVoAZofpyEkI4atzs99T4Qg+qbEMWhd/GKgC+mM7qzpMkHQBxp3I= Received: by 10.150.154.6 with SMTP id b6mr2647815ybe.133.1207566456239; Mon, 07 Apr 2008 04:07:36 -0700 (PDT) Received: from ?10.0.18.8? ( [157.86.206.62]) by mx.google.com with ESMTPS id e76sm8857376hse.0.2008.04.07.04.07.34 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 07 Apr 2008 04:07:35 -0700 (PDT) To: Timothy Chandler Cc: internals@lists.php.net In-Reply-To: <47F9B5C2.7060308@s3.net.au> References: <1207539695.5736.42.camel@pena> <47F9B5C2.7060308@s3.net.au> Content-Type: text/plain; charset=utf-8 Date: Mon, 07 Apr 2008 08:07:31 -0300 Message-ID: <1207566451.5331.10.camel@felipe> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Return type hints From: felipensp@gmail.com (Felipe Pena) Em Seg, 2008-04-07 às 15:48 +1000, Timothy Chandler escreveu: > I guess I should say it before anyone else does... > > "It's not the PHP way" > Do you mean the way that i initially suggest? Anyway return type hints (probably)? will implemented, at least it was accepted in 'Minutes PHP Developers Meeting'. As far as i know, just wasn't decided the syntax. > - Timothy Chandler > Simple Site Solutions > > Felipe Pena wrote: > > Hello ladies and gentlemen, > > > > I made a patch that implements an experimental return type hint, > > therefore we need discuss much about this yet, right? :) > > > > My idea uses (php-type) and +className as notation, see below. > > > > - PHP types > > > > function (string) foo(...) { } // Unicode string too > > function (object) foo(...) { } // Strict > > function (array) foo(...) { } // Strict > > function (bool) foo(...) { } // Strict > > function (int) foo(...) { } // Accepts numeric string > > function (double) foo(...) { } // Accepts numeric string > > > > > > :: Question --------------------------- > > - Add (resource), (unicode), (void) ? | > > --------------------------------------- > > > > - Userland types (like actual parameter type-hint) > > > > function +className foo(...) { } > > function +interfaceName foo(...) { } > > // Uses the class/interface 'int', not the type > > function +int foo(...) { } > > > > :: Question ---------------------------- > > - Weird syntax? | > > ---------------------------------------- > > > > :: Examples ------------------------------------------------ > > > > interface Itest { } > > class bar implements Itest { } > > class foo extends bar { } > > > > class test { > > static public function +Itest testing($instance) { > > return $instance; > > } > > } > > > > test::testing(new bar); > > test::testing(new foo); > > test::testing(new stdclass); // Error! > > // Catchable fatal error: The returned value must implement interface > > Itest > > > > ----------------------------------------- > > > > class foo { > > public function +self getInstance() { > > return $this; > > } > > } > > > > $test = new foo; > > var_dump($test->getInstance()); // OK! > > > > object(foo)#1 (0) { > > } > > > > > > Finally, it's nice or poor syntax? > > > > What must be improved/changed? (All?) > > > > > > Patch: http://felipe.ath.cx/diff/return_type_hint.diff > > Tests: http://felipe.ath.cx/diff/tests/ > > > > > -- Regards, Felipe Pena.