aboutsummaryrefslogtreecommitdiffhomepage
path: root/conformance/autoload.php
diff options
context:
space:
mode:
authorGravatar Yilun Chong <chongyilun250@sina.com>2017-06-30 17:38:50 -0700
committerGravatar GitHub <noreply@github.com>2017-06-30 17:38:50 -0700
commite82ba0b8026eb16c40ceba861f02c643c36e8232 (patch)
tree2aa89a917c6091923682221026507aa9eea1aba4 /conformance/autoload.php
parent726ba33d98cd06c268f88b7dedf2a9a7916d978d (diff)
parentecca6ea95d56a6f70ff7b223ec3f904758acc8b1 (diff)
Merge branch 'master' into ConformanceTestYilunChong
Diffstat (limited to 'conformance/autoload.php')
-rw-r--r--conformance/autoload.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/conformance/autoload.php b/conformance/autoload.php
new file mode 100644
index 00000000..2cee31c4
--- /dev/null
+++ b/conformance/autoload.php
@@ -0,0 +1,21 @@
+<?php
+
+define("GOOGLE_INTERNAL_NAMESPACE", "Google\\Protobuf\\Internal\\");
+define("GOOGLE_NAMESPACE", "Google\\Protobuf\\");
+define("GOOGLE_GPBMETADATA_NAMESPACE", "GPBMetadata\\Google\\Protobuf\\Internal\\");
+
+function protobuf_autoloader_impl($class, $prefix) {
+ $length = strlen($prefix);
+ if ((substr($class, 0, $length) === $prefix)) {
+ $path = '../php/src/' . implode('/', array_map('ucwords', explode('\\', $class))) . '.php';
+ include_once $path;
+ }
+}
+
+function protobuf_autoloader($class) {
+ protobuf_autoloader_impl($class, GOOGLE_INTERNAL_NAMESPACE);
+ protobuf_autoloader_impl($class, GOOGLE_NAMESPACE);
+ protobuf_autoloader_impl($class, GOOGLE_GPBMETADATA_NAMESPACE);
+}
+
+spl_autoload_register('protobuf_autoloader');