Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:48573 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23690 invoked from network); 30 May 2010 18:37:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 May 2010 18:37:24 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.83.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 74.125.83.42 mail-gw0-f42.google.com Received: from [74.125.83.42] ([74.125.83.42:46248] helo=mail-gw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AA/88-05644-260B20C4 for ; Sun, 30 May 2010 14:37:23 -0400 Received: by gwj16 with SMTP id 16so2307136gwj.29 for ; Sun, 30 May 2010 11:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:reply-to:from :date:message-id:subject:to:content-type; bh=QyDK1C+q0ml/MOLxPQ7km5kl9AGnNUP4OcAvrK2tICA=; b=wxLmFuymhOj6a3r+rSoMgFS2J9iDagqBzIiqvFyQLrW4+YdhIYYlMTsnjJEslHNIdI 96PqjYpMBCNIcxHbgO87z8qwMOmDIbs0JKSh8WBuRhvkDyS8ZXlBiIS7e4o2qg5O91Sm FK/6TrqHOE9GxBo48194qOiH8kzMd59jlbzQA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:from:date:message-id:subject:to:content-type; b=w8srjXeNAmEsqGnOvv1dzSEnY72ltMhRyUMzcBWC+if682YeMeK1kaydfJ8vrigOs+ ioXYcrbY0LxSExmIDRd2IwEU9zY5WM83A/t4EkxmHFOL69boU7JMHuw9VW5QfiC+5Om2 Au7DRe8wlCGySKqdYh0jWU+FeMUZ+UwpNfQfE= Received: by 10.101.2.32 with SMTP id e32mr3346627ani.73.1275244639448; Sun, 30 May 2010 11:37:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.12.20 with HTTP; Sun, 30 May 2010 11:36:59 -0700 (PDT) Reply-To: RQuadling@googlemail.com Date: Sun, 30 May 2010 19:36:59 +0100 Message-ID: To: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Type hinting / auto-conversion suggestion. From: rquadling@gmail.com (Richard Quadling) Hi. This is one of those "out there" ideas. Not sure about the feasibility of it. So ... Currently, there are not a massive number of functions that can detail what has been supplied to a function. Currently, the most useful is func_get_args(). func_get_args() has no parameters and simply returns what has been supplied. Would the following core amendments be possible/feasible/etc. 1 - Enhance func_get_args() to ... array func_get_args([bool $verbose = false]) The verbose option returns an array, where each element contains ... [supplied_value] [supplied_type] [received_value] [received_type] [clean_conversion] 2 - Introduce a new function ... bool func_args_match_hints() Simply a true/false if the conversion were clean. 3 - If E_STRICT is not active, then there are no errors/warnings/notices for the consumer. 4 - If E_STRICT is active, then notices for conversions that are not 100%. 5 - Boolean castings must be treated in the same way that PHP would handle it in an if() clause. e.g. if (0), if ('') and if(false) are all valid boolean false. Everything else is boolean true and essentially you cannot fail a boolean conversion. 6 - Possibly a truebool type if a === bool test is needed ( but I don't think so really ). To me, it would seem that the API developer can call a single function to determine if the parameters were cleanly converted. The API consumer (if running E_STRICT) can take advantage of the hints and notices. So, even though hinting is "optional", a consumer would operate in exactly the same way. E_STRICT provides the additional information to the consumer. The onus is still on the developer to deal with what has been supplied, but core is assisting in this by casting and recording what happens. Regards, Richard. -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling