Permalink
Browse files

fix PHP code generation to follow common accepted coding standards

remove hard dependency on python 2.6
  • Loading branch information...
1 parent c52b431 commit 7dfbb468ea3d2fe3a8601bcbe9d1be5d411a825d @robrichards robrichards committed Aug 16, 2012
Showing with 183 additions and 117 deletions.
  1. +1 −1 google-apis-client-generator/src/__init__.py
  2. +1 −1 google-apis-client-generator/src/googleapis/__init__.py
  3. BIN google-apis-client-generator/src/googleapis/__init__.pyc
  4. +1 −1 google-apis-client-generator/src/googleapis/codegen/__init__.py
  5. BIN google-apis-client-generator/src/googleapis/codegen/__init__.pyc
  6. +1 −1 google-apis-client-generator/src/googleapis/codegen/anyjson.py
  7. BIN google-apis-client-generator/src/googleapis/codegen/anyjson.pyc
  8. +1 −1 google-apis-client-generator/src/googleapis/codegen/api.py
  9. BIN google-apis-client-generator/src/googleapis/codegen/api.pyc
  10. +1 −1 google-apis-client-generator/src/googleapis/codegen/api_test.py
  11. +1 −1 google-apis-client-generator/src/googleapis/codegen/csharp_generator.py
  12. BIN google-apis-client-generator/src/googleapis/codegen/csharp_generator.pyc
  13. +1 −1 google-apis-client-generator/src/googleapis/codegen/data_types.py
  14. BIN google-apis-client-generator/src/googleapis/codegen/data_types.pyc
  15. +1 −1 google-apis-client-generator/src/googleapis/codegen/data_types_test.py
  16. +1 −1 google-apis-client-generator/src/googleapis/codegen/django_helpers.py
  17. BIN google-apis-client-generator/src/googleapis/codegen/django_helpers.pyc
  18. +1 −1 google-apis-client-generator/src/googleapis/codegen/filesystem_library_package.py
  19. BIN google-apis-client-generator/src/googleapis/codegen/filesystem_library_package.pyc
  20. +1 −1 google-apis-client-generator/src/googleapis/codegen/generate_library.py
  21. +1 −1 google-apis-client-generator/src/googleapis/codegen/generator.py
  22. BIN google-apis-client-generator/src/googleapis/codegen/generator.pyc
  23. +1 −1 google-apis-client-generator/src/googleapis/codegen/generator_test.py
  24. +1 −1 google-apis-client-generator/src/googleapis/codegen/go_generator.py
  25. BIN google-apis-client-generator/src/googleapis/codegen/go_generator.pyc
  26. +1 −1 google-apis-client-generator/src/googleapis/codegen/go_generator_test.py
  27. +1 −1 google-apis-client-generator/src/googleapis/codegen/gwt_generator.py
  28. BIN google-apis-client-generator/src/googleapis/codegen/gwt_generator.pyc
  29. +1 −1 google-apis-client-generator/src/googleapis/codegen/gwt_generator_test.py
  30. +1 −1 google-apis-client-generator/src/googleapis/codegen/html_stripper.py
  31. BIN google-apis-client-generator/src/googleapis/codegen/html_stripper.pyc
  32. +1 −1 google-apis-client-generator/src/googleapis/codegen/import_definition.py
  33. BIN google-apis-client-generator/src/googleapis/codegen/import_definition.pyc
  34. +1 −1 google-apis-client-generator/src/googleapis/codegen/java_generator.py
  35. BIN google-apis-client-generator/src/googleapis/codegen/java_generator.pyc
  36. +1 −1 google-apis-client-generator/src/googleapis/codegen/java_generator_test.py
  37. +1 −1 google-apis-client-generator/src/googleapis/codegen/java_import_manager.py
  38. BIN google-apis-client-generator/src/googleapis/codegen/java_import_manager.pyc
  39. +1 −1 google-apis-client-generator/src/googleapis/codegen/java_import_manager_test.py
  40. +1 −1 google-apis-client-generator/src/googleapis/codegen/language_model.py
  41. BIN google-apis-client-generator/src/googleapis/codegen/language_model.pyc
  42. +1 −1 google-apis-client-generator/src/googleapis/codegen/library_package.py
  43. BIN google-apis-client-generator/src/googleapis/codegen/library_package.pyc
  44. +1 −1 google-apis-client-generator/src/googleapis/codegen/name_validator.py
  45. BIN google-apis-client-generator/src/googleapis/codegen/name_validator.pyc
  46. +1 −1 google-apis-client-generator/src/googleapis/codegen/name_validator_test.py
  47. +1 −1 google-apis-client-generator/src/googleapis/codegen/objc_generator.py
  48. BIN google-apis-client-generator/src/googleapis/codegen/objc_generator.pyc
  49. +11 −8 google-apis-client-generator/src/googleapis/codegen/php/default/_method.tmpl
  50. +33 −10 google-apis-client-generator/src/googleapis/codegen/php/default/_model_class.tmpl
  51. +2 −1 google-apis-client-generator/src/googleapis/codegen/php/default/_resource.tmpl
  52. +10 −6 google-apis-client-generator/src/googleapis/codegen/php/default/api_service_class.tmpl
  53. +14 −11 google-apis-client-generator/src/googleapis/codegen/php/stable/_method.tmpl
  54. +38 −15 google-apis-client-generator/src/googleapis/codegen/php/stable/_model_class.tmpl
  55. +2 −1 google-apis-client-generator/src/googleapis/codegen/php/stable/_resource.tmpl
  56. +22 −18 google-apis-client-generator/src/googleapis/codegen/php/stable/api_service_class.tmpl
  57. +3 −2 google-apis-client-generator/src/googleapis/codegen/php/stable/api_service_class.tmpl2
  58. +1 −1 google-apis-client-generator/src/googleapis/codegen/php_generator.py
  59. BIN google-apis-client-generator/src/googleapis/codegen/php_generator.pyc
  60. +1 −1 google-apis-client-generator/src/googleapis/codegen/php_generator_test.py
  61. +1 −1 google-apis-client-generator/src/googleapis/codegen/python_skeleton_generator.py
  62. +1 −1 google-apis-client-generator/src/googleapis/codegen/quickstart_push.py
  63. +1 −1 google-apis-client-generator/src/googleapis/codegen/targets.py
  64. BIN google-apis-client-generator/src/googleapis/codegen/targets.pyc
  65. +1 −1 google-apis-client-generator/src/googleapis/codegen/targets_test.py
  66. +6 −3 google-apis-client-generator/src/googleapis/codegen/template_helpers.py
  67. BIN google-apis-client-generator/src/googleapis/codegen/template_helpers.pyc
  68. +1 −1 google-apis-client-generator/src/googleapis/codegen/template_helpers_test.py
  69. +1 −1 google-apis-client-generator/src/googleapis/codegen/template_objects.py
  70. BIN google-apis-client-generator/src/googleapis/codegen/template_objects.pyc
  71. +1 −1 google-apis-client-generator/src/googleapis/codegen/template_objects_test.py
  72. +1 −1 google-apis-client-generator/src/googleapis/codegen/utilities.py
  73. BIN google-apis-client-generator/src/googleapis/codegen/utilities.pyc
  74. +1 −1 google-apis-client-generator/src/googleapis/codegen/utilities_test.py
  75. +1 −1 google-apis-client-generator/src/googleapis/codegen/zip_library_package.py
  76. BIN google-apis-client-generator/src/googleapis/codegen/zip_library_package.pyc
  77. +1 −1 google-apis-client-generator/src/googleapis/codegen/zip_library_package_test.py
@@ -1 +1 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
@@ -1 +1 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
Binary file not shown.
@@ -1 +1 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2010 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2010 Google Inc. All Rights Reserved.
#
Binary file not shown.
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2010 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2011 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2010 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2011 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2011 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2010 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2010 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2010 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2010 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2011 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2011 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2011 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2011 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2011 Google Inc. All Rights Reserved.
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
# Copyright 2011 Google Inc. All Rights Reserved.
"""Contains information necessary to define an import."""
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2010 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2011 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2010 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2011 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2011 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2010 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2011 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2010 Google Inc. All Rights Reserved.
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python2.6
+#!/usr/bin/python
#
# Copyright 2011 Google Inc. All Rights Reserved.
@@ -14,32 +14,35 @@
* @opt_param {{ param.codeType }} {{ param.wireName }} {{ param.description }}{% endfor %}
{% endif %}
{% if method.response %}
+ *
* @return {{ method.responseType.className }}
{% endif %}
*/
{% endfilter %}
-public function {{ method.name }}({% call_template _func_params method method %}) {
+public function {{ method.name }}({% call_template _func_params method method %})
+{
{% filter noblanklines %}
- $params = array({% parameter_list %}
+{% indent %}$params = array({% parameter_list %}
{% for p in method.requiredParameters %}
{% parameter %}'{{ p.wireName }}' => ${{ p.codeName }}{% end_parameter %}
{% endfor %}
{% if method.requestType %}
{% parameter %}'postBody' => $postBody{% end_parameter %}
{% endif %}
- {% end_parameter_list %});
+ {% end_parameter_list %});{% endindent %}
{% if method.optional_parameters %}
- $params = array_merge($params, $optParams);
+{% indent %}$params = array_merge($params, $optParams);{% endindent %}
{% endif %}
- $data = $this->__call('{{ method.wireName }}', array($params));
-{% if method.response %}
+{% indent %}$data = $this->__call('{{ method.wireName }}', array($params));{% endindent %}
+{% indent %}{% if method.response %}
if ($this->useObjects()) {
- return new {{ method.responseType.className }}($data);
+{% indent %}return new {{ method.responseType.className }}($data);{% endindent %}
} else {
- return $data;
+{% indent %}return $data;{% endindent %}
}
{% else %}
return $data;
{% endif %}
+{% endindent %}
{% endfilter %}
}
@@ -1,6 +1,7 @@
{% filter noblanklines %}
-class {{ model.className }} extends apiModel {
+class {{ model.className }} extends apiModel
+{{% indent %}
{% for property in model.properties %}
{% if property.typeHint %}
protected $__{{ property.codeName }}Type = '{{ property.typeHint|cut:" " }}';
@@ -10,19 +11,41 @@ class {{ model.className }} extends apiModel {
{% endfor %}
{% for property in model.properties %}
{% ifequal property.type "array" %}
- public function set{{ property.codeName|capfirst }}(/* array({{ property.codeType }}) */ ${{ property.codeName }}) {
- $this->assertIsArray(${{ property.codeName }}, {{ property.codeType }}, __METHOD__);
- $this->{{ property.codeName }} = ${{ property.codeName }};
+/**
+ * Set {{ property.codeType }} values
+ *
+ * @param array ${{ property.codeName }} {{ property.codeType }}
+ *
+ * @return void
+ */
+public function set{{ property.codeName|capfirst }}(${{ property.codeName }})
+{
+{% indent %}$this->assertIsArray(${{ property.codeName }}, {{ property.codeType }}, __METHOD__);
+$this->{{ property.codeName }} = ${{ property.codeName }};{% endindent %}
}
{% else %}
- public function set{{ property.codeName|capfirst }}({{ property.typeHint }}${{ property.codeName }}) {
- $this->{{ property.codeName }} = ${{ property.codeName }};
+/**
+ * Set {{ property.codeType }} value
+ *
+ * @param {{ property.codeType }} ${{ property.codeName }} {{ property.codeType }}
+ *
+ * @return void
+ */
+public function set{{ property.codeName|capfirst }}({{ property.typeHint }}${{ property.codeName }})
+{
+{% indent %}$this->{{ property.codeName }} = ${{ property.codeName }};{% endindent %}
}
{% endifequal %}
+/**
+ * Get {{ property.codeType }} value
+ *
+ * @return {{ property.codeType }}
+ */
+public function get{{ property.codeName|capfirst }}()
+{
+{% indent %}return $this->{{ property.codeName }};{% endindent %}
+}
- public function get{{ property.codeName|capfirst }}() {
- return $this->{{ property.codeName }};
- }
- {% endfor %}
+ {% endfor %}{% endindent %}
}
{% endfilter %}
@@ -6,7 +6,8 @@
* ${{ resource.codeName }} = ${{ api.name }}Service->{{ resource.codeName }};
* </code>
*/
-class {{ resource.className }}ServiceResource extends apiServiceResource {{% indent %}
+class {{ resource.className }}ServiceResource extends apiServiceResource
+{{% indent %}
{% if resource.hasParams %}{% emit_method_def resource %}{% endif %}
{% for method in resource.methods %}
{% emit_method_def method %}{% endfor %}
@@ -6,7 +6,7 @@ require_once 'service/apiService.php';
require_once 'service/apiServiceRequest.php';
{% for resource in api.resources %}
-{% indent %}{% emit_resource_def resource %}{% endindent %}
+{% emit_resource_def resource %}
{% endfor %}
{% for method in api.methods %}
{% indent %}{% emit_resource_def method %}{% endindent %}
@@ -26,18 +26,21 @@ require_once 'service/apiServiceRequest.php';
*
* @author Google, Inc.
*/
-class api{{ api.className }}Service extends apiService {
+class api{{ api.className }}Service extends apiService
+{
{% filter noblanklines %}{% for resource in api.resources %}
{% indent %}public ${{ resource.wireName }};{% endindent %}
{% endfor %}{% endfilter %}
+{% indent %}
/**{% filter block_comment %}
* Constructs the internal representation of the {{ api.className }} service.
* {% endfilter %}
*
- * @param apiClient apiClient
+ * @param apiClient $apiClient apiClient object
*/
- public function __construct(apiClient $apiClient) {
- $this->rpcPath = '/rpc';
+public function __construct(apiClient $apiClient)
+{
+{% indent %}$this->rpcPath = '/rpc';
$this->restBasePath = '{{ api.basePath }}';
$this->version = '{{ api.version }}';
$this->serviceName = '{{ api.name }}';
@@ -48,6 +51,7 @@ class api{{ api.className }}Service extends apiService {
{% for resource in api.resources %}
$this->{{ resource.wireName }} = new {{ resource.className }}ServiceResource($this, $this->serviceName, '{{ resource.wireName }}', json_decode('{{ resource.json }}', true));
{% endfor %}
-{% endfilter %}
+{% endfilter %}{% endindent %}
}
+{% endindent %}
}
@@ -14,32 +14,35 @@
* @opt_param {{ param.codeType }} {{ param.wireName }} {{ param.description }}{% endfor %}
{% endif %}
{% if method.response %}
+ *
* @return {{ method.responseType.className }}
{% endif %}
*/
{% endfilter %}
-public function {{ method.name }}({% call_template _func_params method method %}) {
+public function {{ method.name }}({% call_template _func_params method method %})
+{
{% filter noblanklines %}
- $params = array({% parameter_list %}
+{% indent %}$params = array({% parameter_list %}
{% for p in method.requiredParameters %}
{% parameter %}'{{ p.wireName }}' => ${{ p.codeName }}{% end_parameter %}
{% endfor %}
{% if method.requestType %}
{% parameter %}'postBody' => $postBody{% end_parameter %}
{% endif %}
- {% end_parameter_list %});
+ {% end_parameter_list %});{% endindent %}
{% if method.optional_parameters %}
- $params = array_merge($params, $optParams);
+{% indent %}$params = array_merge($params, $optParams);{% endindent %}
{% endif %}
- $data = $this->__call('{{ method.wireName }}', array($params));
-{% if method.response %}
- if ($this->useObjects()) {
- return new {{ method.responseType.className }}($data);
- } else {
- return $data;
- }
+{% indent %}$data = $this->__call('{{ method.wireName }}', array($params));{% endindent %}
+{% indent %}{% if method.response %}
+if ($this->useObjects()) {
+{% indent %}return new {{ method.responseType.className }}($data);{% endindent %}
+} else {
+{% indent %}return $data;{% endindent %}
+}
{% else %}
return $data;
{% endif %}
+{% endindent %}
{% endfilter %}
}
Oops, something went wrong.

0 comments on commit 7dfbb46

Please sign in to comment.