googleworkspace / php-samples

PHP samples for Google Workspace APIs
Apache License 2.0
292 stars 348 forks source link

Throughout PHP samples incorrect argmentes array([]) #141

Closed ssu-carlsoni closed 2 years ago

ssu-carlsoni commented 2 years ago

While working to get up and running with Google API's in PHP I've been constantly having to correct sample code's incorrect array arguments to class construction and function calls. Looks like maybe an automated tools damaged all the sample PHP trying to updated from array() to []. The problem is too numerous to point out all examples.

Example in repo:

https://github.com/googleworkspace/php-samples/blob/4c121d9c2635da8f90830316311f497a51855444/drive/snippets/drive_v3/src/DriveShareFile.php#L37

Example wrong code block:

                $userPermission = new Drive\Permission(array([
                    'type' => 'user',
                    'role' => 'writer',
                    'emailAddress' => 'user@example.com'
                ]));

Example corrected code block:

                $userPermission = new Drive\Permission([
                    'type' => 'user',
                    'role' => 'writer',
                    'emailAddress' => 'user@example.com'
                ]);
sqrrrl commented 2 years ago

Updated samples to remove the double arrays