Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81654 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52669 invoked from network); 2 Feb 2015 21:17:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Feb 2015 21:17:34 -0000 Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.15.18 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.15.18 mout.gmx.net Received: from [212.227.15.18] ([212.227.15.18:50109] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F7/B5-25089-C69EFC45 for ; Mon, 02 Feb 2015 16:17:33 -0500 Received: from [192.168.0.100] ([91.67.244.80]) by mail.gmx.com (mrgmx003) with ESMTPSA (Nemesis) id 0LwrPM-1XcMZB3bpY-016PYm; Mon, 02 Feb 2015 22:17:25 +0100 Message-ID: <54CFE965.2080905@gmx.de> Date: Mon, 02 Feb 2015 22:17:25 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Thomas Bley , dmitry@zend.com CC: ajf@ajf.me, nikita.ppv@gmail.com, internals@lists.php.net References: <20150202210349.6FB91261948@dd15934.kasserver.com> In-Reply-To: <20150202210349.6FB91261948@dd15934.kasserver.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:ve3O1hEn15SZvPAXTKucEwFVXwDz6pyfWuUppb6q13f12rII2tv fF9dX5LtseGPPi4+Nijoso4h9BYtEo3dwOU0Ust+OgPRN8FKyhgnhoxqgNtNcMy9YLqqe3B ha30aA/MwMTln7FvY/T+H7L9uTgyQiOPBgH4LpMYJO6Fd5NnzJSgH9mbFvtKC1zrZRhDmhY buUeEbdhf2XhM5ecPoFnQ== X-UI-Out-Filterresults: notjunk:1; Subject: Re: [PHP-DEV] What do we need strict scalar type hints for? From: cmbecker69@gmx.de (Christoph Becker) Thomas Bley wrote: > Here is a typical billing example which uses exceptions: > > ini_set('error_reporting', E_ALL); > ini_set('display_errors', 1); > > addVat('apples'); > > function addVat($amount) { > if (!is_int($amount) && !is_float($amount)) { > throw new InvalidArgumentException('Argument 1 passed to '.__FUNCTION__.' must be of the type int|float, '.gettype($amount).' given'); > } > return round($amount*1.19, 2); > } > > Instead of multiple strict scalar hints (e.g. function addVat(int|float $amount){...}), I would prefer to have "numeric" as strict type: > function addVat(numeric $amount){...} Have you considered addVat(-1); -- Christoph M. Becker