Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81660 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66656 invoked from network); 2 Feb 2015 21:42:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Feb 2015 21:42:58 -0000 Authentication-Results: pb1.pair.com header.from=mails@thomasbley.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=mails@thomasbley.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain thomasbley.de from 85.13.137.24 cause and error) X-PHP-List-Original-Sender: mails@thomasbley.de X-Host-Fingerprint: 85.13.137.24 dd15934.kasserver.com Received: from [85.13.137.24] ([85.13.137.24:52862] helo=dd15934.kasserver.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C0/D8-25089-16FEFC45 for ; Mon, 02 Feb 2015 16:42:58 -0500 Received: from dd15934.kasserver.com (dd0803.kasserver.com [85.13.146.34]) by dd15934.kasserver.com (Postfix) with ESMTPSA id BEB88261948; Mon, 2 Feb 2015 22:42:54 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-SenderIP: 178.19.222.74 User-Agent: ALL-INKL Webmail 2.11 In-Reply-To: <54CFE965.2080905@gmx.de> References: <20150202210349.6FB91261948@dd15934.kasserver.com><54CFE965.2080905@gmx.de> To: dmitry@zend.com, cmbecker69@gmx.de Cc: ajf@ajf.me, nikita.ppv@gmail.com, internals@lists.php.net Message-ID: <20150202214254.BEB88261948@dd15934.kasserver.com> Date: Mon, 2 Feb 2015 22:42:54 +0100 (CET) Subject: Re: [PHP-DEV] What do we need strict scalar type hints for? From: mails@thomasbley.de ("Thomas Bley") Yes, we currently have negative values for invoices and positive for vouchers ... Christoph Becker wrote on 02.02.2015 22:17: > 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 > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >