Deprecated: Required parameter $xxx follows optional parameter $yyy in...
Since upgrading to PHP 8.0 this error is thrown when running code like this:
function test_function(int $var1 = 2, int $var2) {
return $var1 / $var2;
}
This has worked in past versions of PHP without issue.
Change the order of the parameters, placing $xxx ahead of the optional parameter $yyy.
There is an answer to the question already. Doing what you suggest would mean rewriting every use of your function across your code base.
for a quick solution, use
function test_function(int $var1 = 2, int $var2=0)
, since where ever you are using the function, it is passing a value for$var2
. then in spare time, search and update your code.