File: autoload.php

package info (click to toggle)
mysql-8.0 8.0.43-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,904 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,184; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,196; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (21 lines) | stat: -rw-r--r-- 749 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php

define("GOOGLE_INTERNAL_NAMESPACE", "Google\\Protobuf\\Internal\\");
define("GOOGLE_NAMESPACE", "Google\\Protobuf\\");
define("GOOGLE_GPBMETADATA_NAMESPACE", "GPBMetadata\\Google\\Protobuf\\");

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');