tvt2410 / google-api-php-client

Automatically exported from code.google.com/p/google-api-php-client
Apache License 2.0
0 stars 0 forks source link

Class naming collisions between services #264

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The various Google services re-use identical class names in different files.  
This makes it impossible to include multiple different services in the same 
runtime environment.

For example:

./lib/google-api-php-client/src/contrib/Google_PlusPagesService.php:  class 
Google_CommentsServiceResource extends Google_ServiceResource {
./lib/google-api-php-client/src/contrib/Google_DriveService.php:  class 
Google_CommentsServiceResource extends Google_ServiceResource {
./lib/google-api-php-client/src/contrib/Google_BloggerService.php:  class 
Google_CommentsServiceResource extends Google_ServiceResource {
./lib/google-api-php-client/src/contrib/Google_PlusService.php:  class 
Google_CommentsServiceResource extends Google_ServiceResource {
./lib/google-api-php-client/src/contrib/Google_OrkutService.php:  class 
Google_CommentsServiceResource extends Google_ServiceResource {

The two ideal solutions to this are:

1.  Use PHP 5.3 namespaces e.g.  "\Google\Blogger\CommentsServiceResource", 
"\Google\Plus\CommentsServiceResource"

or 

2.  Use unique class names in each service.  e.g. 
"Google_BloggerCommentsServiceResource", "Google_PlusCommentsServiceResource"

Since PHP 5.2 reached its end of life over two years ago 
(http://php.net/eol.php), using Namespaces should obviously be the preferred 
method.

Original issue reported on code.google.com by krossi...@dlvr.it on 7 Feb 2013 at 11:03

GoogleCodeExporter commented 9 years ago

Original comment by ianbar...@google.com on 22 Mar 2013 at 2:32