password_compat icon indicating copy to clipboard operation
password_compat copied to clipboard

Incompatible error when not enough parameters passed

Open sagikazarmark opened this issue 11 years ago • 2 comments

The error message in PHP core function is the same: password_hash() expects at least 2 parameters, 0 given

In the backported function, there is something like this: Missing argument 1....

This is not a major one, but still incompatible.

What I've done in backported function is that required arguments got a null default value (since type check is still necessary), so that I could trigger a proper error for less than enough argument count. The idea originates from ramsey/array_column.

sagikazarmark avatar Jan 11 '15 00:01 sagikazarmark

This belongs to PHP core. It cannot (and probably shouldn't) be addressed from plain PHP code:

function foo($a, $b) {
}
foo();

Output for 4.3.0 - 5.0.5, 5.1.0 - 5.6.30, 7.0.0 - 7.0.18 Warning: Missing argument 1 for foo() Warning: Missing argument 2 for foo() Output for 7.1.0 - 7.1.4 Fatal error: Uncaught ArgumentCountError: Too few arguments to function foo(), 0 passed

https://3v4l.org/ElVGo

kAlvaro avatar Apr 27 '17 14:04 kAlvaro

This belongs to PHP core. It cannot (and probably shouldn't) be addressed from plain PHP code:

Not true really. We could simulate what happens on the internal functions if we wanted to, I think.

GrahamCampbell avatar Apr 28 '17 17:04 GrahamCampbell