Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79637 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43581 invoked from network); 14 Dec 2014 18:35:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Dec 2014 18:35:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.200 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.200 imap1-2.ox.privateemail.com Received: from [192.64.116.200] ([192.64.116.200:56196] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D1/02-26365-958DD845 for ; Sun, 14 Dec 2014 13:35:06 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id EDE13B00068 for ; Sun, 14 Dec 2014 13:35:02 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap1.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id N2eBW1JJBZIv for ; Sun, 14 Dec 2014 13:35:02 -0500 (EST) Received: from oa-res-26-240.wireless.abdn.ac.uk (oa-res-26-240.wireless.abdn.ac.uk [137.50.26.240]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 9535AB00058 for ; Sun, 14 Dec 2014 13:35:02 -0500 (EST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-ID: <2F9B99EF-538C-4225-95A4-943F57DADF69@ajf.me> Date: Sun, 14 Dec 2014 18:35:00 +0000 To: internals Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) X-Mailer: Apple Mail (2.1993) Subject: [PATCH] Consistent type names in error messages From: ajf@ajf.me (Andrea Faulds) Good evening, Unfortunately, zend_parse_parameters and userland type hint error = messages use outdated type names, and don=E2=80=99t even do so = consistently. For example: $ php -r 'fread(0, 0);' PHP Warning: fread() expects parameter 1 to be resource, integer given = in Command line code on line 1 $ php -r 'fread(fopen("data:text/plain,test", "r"), = fopen("data:text/plain,test", "r"));' PHP Warning: fread() expects parameter 2 to be long, resource given in = Command line code on line 1 $ php -r 'function foo(foobar $x) {} foo(1.0);' PHP Catchable fatal error: Argument 1 passed to foo() must be an = instance of foobar, double given, called in Command line code on line 1 = and defined in Command line code on line 1 Specifically, zend_parse_parameters will always =E2=80=9Cexpect=E2=80=9D = a =E2=80=9Clong=E2=80=9D, yet when the expected type isn=E2=80=99t an = integer and an integer is passed, it says =E2=80=9Cinteger given=E2=80=9D.= Alongside this, both userland type hint errors and = zend_parse_parameters errors refer to =E2=80=9Cdouble=E2=80=9D and not = =E2=80=9Cfloat=E2=80=9D. I want to change the type names to be consistent, because I think our = current inconsistency is confusing. Integers are sometimes ints or = integers, but other times longs. Floats are sometimes floats, but other = times doubles. If scalar type hints are ever added, then jettisoning the = old aliases means we don=E2=80=99t have to add extra reserved words. I=E2=80=99ve made a patch which makes zend_parse_parameters and userland = type hints consistently show =E2=80=9Cinteger=E2=80=9D and =E2=80=9Cfloat=E2= =80=9D rather than =E2=80=9Clong=E2=80=9D and =E2=80=9Cdouble=E2=80=9D: = https://github.com/php/php-src/pull/955 I also wrote a GNU sed script which I used to update the tests: = https://gist.github.com/TazeTSchnitzel/c0d780466def9f226318 Alongside error messages, there are some other places that could be = changed. Obviously the return value of gettype() shouldn=E2=80=99t be = changed, but I think that we should, for example, make is_long() an = alias of is_int() and not the other way around. Thoughts? -- Andrea Faulds http://ajf.me/