diff options
author | Paul Yang <TeBoring@users.noreply.github.com> | 2017-06-30 12:14:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-30 12:14:09 -0700 |
commit | ecca6ea95d56a6f70ff7b223ec3f904758acc8b1 (patch) | |
tree | 728f4aff0d5f00c78a741cf737ea6de58f4ba645 /conformance/autoload.php | |
parent | 5a52b3588d35d2fa0b9ce4eda5630546966a26b4 (diff) | |
download | protobuf-ecca6ea95d56a6f70ff7b223ec3f904758acc8b1.tar.gz protobuf-ecca6ea95d56a6f70ff7b223ec3f904758acc8b1.tar.bz2 protobuf-ecca6ea95d56a6f70ff7b223ec3f904758acc8b1.zip |
Add json encode/decode for php. (#3226)
* Add json encode/decode for php.
* Fix php conformance test on 32-bit machines.
* Fix conformance test for c extension.
* Fix comments
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'); |