Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:376 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1059 invoked from network); 27 Mar 2003 17:33:01 -0000 Received: from unknown (HELO mail.dealnews.com) (129.41.69.137) by pb1.pair.com with SMTP; 27 Mar 2003 17:33:01 -0000 Received: (qmail 30609 invoked from network); 27 Mar 2003 17:29:43 -0000 Received: from unknown (HELO doughboy) (207.111.175.77) by 10.1.1.7 with SMTP; 27 Mar 2003 17:29:43 -0000 Message-ID: <014401c2f486$e972e010$0b02010a@doughboy> To: "Timm Friebe" , Cc: References: <1048781764.25691.593.camel@localhost> Date: Thu, 27 Mar 2003 11:32:59 -0600 Organization: dealnews.com, Inc. MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-Mimeole: Produced By Microsoft MimeOLE V6.00.2800.1106 Subject: Re: [PHP-DEV] Type hints revisited [IllegalArgumentException instead of E_ERROR] From: brianm@dealnews.com ("Brian Moon") Has type hinting for functions been implemented in ZE2? Brian. dealnews.com ----- Original Message ----- From: "Timm Friebe" To: Cc: Sent: Thursday, March 27, 2003 10:16 AM Subject: [PHP-DEV] Type hints revisited [IllegalArgumentException instead of E_ERROR] | I've implemented an additional feature for type hints that will throw an | exception instead of bailing out in case an incorrect type is passed. | | Test script: | | setLastchange(new Date()); | $a->setLastchange(NULL); // Passes | $a->setCreated_at(new Date()); | | try { | $a->setCreated_at(NULL); // Fails | } catch (IllegalArgumentException $e) { | echo "Caught: "; var_dump($e); | } | | $a->setCreated_at(1); // Fails | echo "Alive"; // Will not show up | ?> | | Output: | --------------------------------------------------------------------- | thekid@friebes:~/devel/php > ./php5/sapi/cli/php hints.php | article::setlastchange called with class date { | } | article::setlastchange called with NULL | article::setcreated_at called with class date { | } | Caught: object(illegalargumentexception)#2 (3) { | ["message"]=> | string(38) "Argument 1 must be an instance of date" | ["file"]=> | string(36) "/usr/home/thekid/devel/php/hints.php" | ["line"]=> | int(4) | } | | Fatal error: Uncaught exception! in Unknown on line 0 | --------------------------------------------------------------------- | | A unified diff is attached. | | - Timm | ---------------------------------------------------------------------------- ---- | -- | PHP Internals - PHP Runtime Development Mailing List | To unsubscribe, visit: http://www.php.net/unsub.php