Tutorial: Solve PHP uncaught ArgumentCountError: Too few arguments to function

Solve PHP uncaught ArgumentCountError: Too few arguments to function

With the upcoming PHP 7.1, former warnings when passing too few arguments to a function got raised to an ArgumentCountError exception with the following format:


Fatal error: Uncaught ArgumentCountError: Too few arguments to function foobar()

This change only applies to own defined functions, not PHP internal functions.


That ArgumentCountError exception gets thrown when your software passes not the minimum required arguments to a user defined function.


To fix that error you need to have a look closer to the last part of the exception message, it will tell you in which file and what line too few arguments got passed and make sure you catch that part of the code with an



try {
// Code
} catch () {
// Exception
}

...block or make sure it will always have the minimum required arguments.


If you have further questions: Just left them below in the comments.


Source: PHP Manual