Re: [PATCH] Consistent type names in error messages

From: Date: Sun, 14 Dec 2014 18:41:39 +0000
Subject: Re: [PATCH] Consistent type names in error messages
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-79638@lists.php.net to get a copy of this message
2014-12-14 19:35 GMT+01:00 Andrea Faulds <ajf@ajf.me>: > Good evening, > > Unfortunately, zend_parse_parameters and userland type hint error messages use outdated type > names, and don’t 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 “expect” a “long”, yet when the > expected type isn’t an integer and an integer is passed, it says “integer given”. Alongside > this, both userland type hint errors and zend_parse_parameters errors refer to “double” and not > “float”. > > 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’t 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. -- regards, Kalle Sommer Nielsen kalle@php.net

« previous php.internals (#79638) next »