You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Strange error response when passing null rather then nothing. #1309
Warning: array_merge(): Argument #2 is not an array in C:\xampp\htdocs\Google-PHP-Genreated-Samples\vendor\google\apiclient-services\src\Google\Service\Drive\Resource\Files.php on line 204
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\Google-PHP-Genreated-Samples\vendor\google\apiclient\src\Google\Service\Resource.php on line 136
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\Google-PHP-Genreated-Samples\vendor\google\apiclient\src\Google\Service\Resource.php on line 268
In your opinion what is the best way for users to do this? I was hoping to be able to have a single function which would take the parameters. I am worried your option two will confuse users.
I am in the process of building the generated sample templates for this library. Any guidance you can to give in building solid samples which will follow your best practice guidelines would be appreciated. Google-APIs-PHP-Samples
Activity
bshaffer commentedon Sep 25, 2017
The reason is when you pass
nullin, you are replacing the default parameter. The default parameter isarray(), as you can see here.It would be better to use typehints, so
listFileswould throw a type exception instead.LindaLawton commentedon Sep 25, 2017
so sending an empty array would be acceptable?
bshaffer commentedon Sep 25, 2017
Yes, the parameters are optional. Sending an empty array is equivalent to calling the method with no parameters:
LindaLawton commentedon Sep 26, 2017
In your opinion what is the best way for users to do this? I was hoping to be able to have a single function which would take the parameters. I am worried your option two will confuse users.
I am in the process of building the generated sample templates for this library. Any guidance you can to give in building solid samples which will follow your best practice guidelines would be appreciated. Google-APIs-PHP-Samples