My team uses named arguments for all arguments if possible. I was using nullOrString and got a 'Missing first argument' error.
After some debugging, I found out that when using the following code:
Assertion::nullOrString(value: $myVar);
What gets passed to __callStatic's $arg parameter is a non-zero indexed array ([value => $myVar]) according to xdebug. Since __callStatic looks for index 0, a 'Missing first argument' exception is thrown.
For now, I can go through and remove the named parameter for all nullOr calls.
I think you could call array_values on the $arg parameter before checking for index 0. This would reindex the array to prevent this error, but I don't konw if that would mess up something somewhere else.
Edit: corrected the index from 1 to value in the array that is passed to __callStatic.
My team uses named arguments for all arguments if possible. I was using
nullOrStringand got a 'Missing first argument' error.After some debugging, I found out that when using the following code:
What gets passed to
__callStatic's$argparameter is a non-zero indexed array ([value => $myVar]) according to xdebug. Since__callStaticlooks for index 0, a 'Missing first argument' exception is thrown.For now, I can go through and remove the named parameter for all
nullOrcalls.I think you could call
array_valueson the$argparameter before checking for index0. This would reindex the array to prevent this error, but I don't konw if that would mess up something somewhere else.Edit: corrected the index from
1tovaluein the array that is passed to__callStatic.