Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79638 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45108 invoked from network); 14 Dec 2014 18:41:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Dec 2014 18:41:45 -0000 Authentication-Results: pb1.pair.com smtp.mail=kalle.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=kalle.php@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.182 as permitted sender) X-PHP-List-Original-Sender: kalle.php@gmail.com X-Host-Fingerprint: 209.85.217.182 mail-lb0-f182.google.com Received: from [209.85.217.182] ([209.85.217.182:48374] helo=mail-lb0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 60/00-45071-6E9DD845 for ; Sun, 14 Dec 2014 13:41:43 -0500 Received: by mail-lb0-f182.google.com with SMTP id f15so8964933lbj.13 for ; Sun, 14 Dec 2014 10:41:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=pCTo8MqDvoQuGTWclqb3A9voqB6N0bOsg1Xt2GezcO8=; b=1ArTCrQVCM/N+2/HkUfYtm42vbL5NMSxUbenvwhsBnQQBtMCju0dAtgPxo+Rw9shlR 98fMezAFumPzRKVeqoeWHBiULizU/WvNNOLfu1iEkoBPt+XqkEJJOX3FyK/4ejF3roe/ SDv71OcsCpgKCoeC29roKB+Edm6ITPiE0TFwvGXtAcmEC26ds4yTW6pIg8AqSlm5osB6 4IpwrI5nt5H+SqhAJ1PgdfT5dFKy85V2BmU+sO9ghbYMX6f5sU7J7ybBghkS3FVMpNDy CT5vpWILxREDCblaBb9NaqKWPxx9uBf4FUoCAQiVAqzXglKO8tyVWMUQ50f5CNEO7bQh EHbg== MIME-Version: 1.0 X-Received: by 10.152.5.100 with SMTP id r4mr26508463lar.26.1418582500030; Sun, 14 Dec 2014 10:41:40 -0800 (PST) Sender: kalle.php@gmail.com Received: by 10.112.61.163 with HTTP; Sun, 14 Dec 2014 10:41:39 -0800 (PST) In-Reply-To: <2F9B99EF-538C-4225-95A4-943F57DADF69@ajf.me> References: <2F9B99EF-538C-4225-95A4-943F57DADF69@ajf.me> Date: Sun, 14 Dec 2014 19:41:39 +0100 X-Google-Sender-Auth: 1vw3Q8Pzj4S_0Z5Hte023qCs3sY Message-ID: To: Andrea Faulds Cc: internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [PATCH] Consistent type names in error messages From: kalle@php.net (Kalle Sommer Nielsen) 2014-12-14 19:35 GMT+01:00 Andrea Faulds : > Good evening, > > Unfortunately, zend_parse_parameters and userland type hint error message= s use outdated type names, and don=E2=80=99t even do so consistently. For e= xample: > > $ php -r 'fread(0, 0);' > PHP Warning: fread() expects parameter 1 to be resource, integer given i= n Command line code on line 1 > > $ php -r 'fread(fopen("data:text/plain,test", "r"), fopen("data:text/plai= n,test", "r"));' > PHP Warning: fread() expects parameter 2 to be long, resource given in C= ommand 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 instanc= e of foobar, double given, called in Command line code on line 1 and define= d 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 integ= er and an integer is passed, it says =E2=80=9Cinteger given=E2=80=9D. Along= side 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 cur= rent inconsistency is confusing. Integers are sometimes ints or integers, b= ut other times longs. Floats are sometimes floats, but other times doubles.= If scalar type hints are ever added, then jettisoning the old aliases mean= s we don=E2=80=99t have to add extra reserved words. > You forgot that they can also be 'real', but on a serious manner, I don't see any reason not to make the error messages consistent and I would say go ahead already. --=20 regards, Kalle Sommer Nielsen kalle@php.net