Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44710 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7376 invoked from network); 4 Jul 2009 21:12:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jul 2009 21:12:44 -0000 Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 63.205.162.117 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 63.205.162.117 us-mr1.zend.com Linux 2.4/2.6 Received: from [63.205.162.117] ([63.205.162.117:34314] helo=us-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6E/00-06746-AC5CF4A4 for ; Sat, 04 Jul 2009 17:12:43 -0400 Received: from us-gw1.zend.com (us-ex1.zend.net [192.168.16.5]) by us-mr1.zend.com (Postfix) with ESMTP id 464E4E12BB; Sat, 4 Jul 2009 14:01:31 -0700 (PDT) Received: from [192.168.27.29] ([192.168.27.29]) by us-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Sat, 4 Jul 2009 14:13:17 -0700 Message-ID: <4A4FC5C6.1010201@zend.com> Date: Sat, 04 Jul 2009 14:12:38 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 CC: Ilia Alshanetsky , PHP internals References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 04 Jul 2009 21:13:17.0762 (UTC) FILETIME=[40469A20:01C9FCEC] Subject: Re: [PHP-DEV] RFC: Type hinting revisited for PHP 5.3 From: stas@zend.com (Stanislav Malyshev) Hi! > RE your second patch, from http://ilia.ws/patch/type_hint_53_v2.txt Some notes on this patch: - I still think the matter of interfaces and inheritance should be dealt with (and just comparing hints is not enough, it should be full LSP-compliant check). - It looks like you can't have class named "string" anymore, or at least you can't use it in typehints (you can in 5.3). Same with all other type names there. - I see no reflection method that allows to get the type of the parameter (as opposed to checking if the parameter belongs to a certain type) - The patch contains the check that the constant for an optional parameter is not an object. AFAIK you can't have constant with object type in PHP. Which also means initializer for any object type can only be null. - There seems to be no way to have default value with IS_NUMERIC typecheck since the check Z_TYPE(initialization->u.constant) != class_type->u.constant.type will always fail for IS_NUMERIC - there's no zval carrying type IS_NUMERIC. Same for IS_SCALAR. - Also, I'm not sure what would happen there if I have: function foo(numeric $param = CONSTANT) and the value of CONSTANT may be not known in the compile-time. Looks like right now it would just fail since CONSTANT has IS_CONSTANT type. That would be confusing if you couldn't use constants for default values with typehints. - Shuouldn't this: if (Z_TYPE_P(arg) == cur_arg_info->array_type_hint || Z_TYPE_P(arg) == (cur_arg_info->array_type_hint ^ (1<<7))) { be this: if (Z_TYPE_P(arg) == (cur_arg_info->array_type_hint & 0x7F)) { this would be one check instead of two, and the type of argument zval can't really be FORCE_*, can it? - Are you sure with FORCE_* argument converting operation shouldn't be convert_to_*_ex? -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com