diff options
author | Yilun Chong <yilunchong@google.com> | 2017-07-05 09:51:58 -0700 |
---|---|---|
committer | Yilun Chong <yilunchong@google.com> | 2017-07-05 09:51:58 -0700 |
commit | 30b4194488d37019aaf88f199aa447cd55c74c60 (patch) | |
tree | bb2ec0521516e6c4f950c8382655bcaef1dd2e2e /conformance/autoload.php | |
parent | 7339c25d120246d711486f458cd098a94f8b2455 (diff) | |
parent | e82ba0b8026eb16c40ceba861f02c643c36e8232 (diff) | |
download | protobuf-30b4194488d37019aaf88f199aa447cd55c74c60.tar.gz protobuf-30b4194488d37019aaf88f199aa447cd55c74c60.tar.bz2 protobuf-30b4194488d37019aaf88f199aa447cd55c74c60.zip |
Merge branch 'ConformanceTestYilunChong' of github.com:BSBandme/protobuf into ConformanceTestYilunChong
Diffstat (limited to 'conformance/autoload.php')
-rw-r--r-- | conformance/autoload.php | 21 |
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'); |