Re: Incorrect Argument Count Error

From: Date: Fri, 19 Aug 2016 14:27:56 +0000
Subject: Re: Incorrect Argument Count Error
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-95312@lists.php.net to get a copy of this message
2016-08-19 15:05 GMT+02:00 Davey Shafik <davey@php.net>: > Hey Internals, > > I'm working on the patch to change the error exception to > \ArgumentCountError instead of \Error when too few, or too many arguments > are passed in as discussed a couple of weeks ago. > > To be BC with 7.0, this extends \TypeError, which is the exception > currently thrown when strict_types=1 for both userland and internal > functions. > > I've run into an issue where things are inconsistent for internal functions. > > For example, the array_* functions, like array_diff, still have a warning > thrown, regardless of strict_types: > > php_error_docref(NULL, E_WARNING, "at least %d parameters are required, %d > given", req_args, ZEND_NUM_ARGS()); This seems more like an oversight than anything else, I guess cases with variable argument count may have some similar parameter parsing approaches. I think it should just be changed to the exception and to respect strict_types. Despite it being a BC break, I don't think that many will care to notice since its error handling for one and second of all, we did do that for a lot of things in 7.0, and I would assume that most of the userland developers expect us to continue converting into exceptions where reasonable, so the programs will *hopefully* quickly adapt. -- regards, Kalle Sommer Nielsen kalle@php.net

« previous php.internals (#95312) next »