Debian Codegraph @

lib/3rdParty/composer/paragonie/sodium_compat/autoload.php

raw symbols SCIP
1 <?php
2
3 spl_autoload_register(function ($class) {
4 $namespace = 'ParagonIE_Sodium_';
5 // Does the class use the namespace prefix?
6 $len = strlen($namespace);
7 if (strncmp($namespace, $class, $len) !== 0) {
8 // no, move to the next registered autoloader
9 return false;
10 }
11
12 // Get the relative class name
13 $relative_class = substr($class, $len);
14
15 // Replace the namespace prefix with the base directory, replace namespace
16 // separators with directory separators in the relative class name, append
17 // with .php
18 $file = dirname(__FILE__) . '/src/' . str_replace('_', '/', $relative_class) . '.php';
19 // if the file exists, require it
20 if (file_exists($file)) {
21 require_once $file;
22 return true;
23 }
24 return false;
25 });
26
27 /* Explicitly, always load the Compat class: */
28 if (!class_exists('ParagonIE_Sodium_Compat', false)) {
29 require_once dirname(__FILE__) . '/src/Compat.php';
30 }
31 if (!class_exists('ParagonIE_Sodium_File', false)) {
32 require_once dirname(__FILE__) . '/src/File.php';
33 }
34
35 if (!class_exists('SodiumException', false)) {
36 require_once dirname(__FILE__) . '/src/SodiumException.php';
37 }
38
39 if (!defined('SODIUM_CRYPTO_AEAD_AEGIS128L_KEYBYTES')) {
40 require_once dirname(__FILE__) . '/lib/php84compat_const.php';
41 }
42
43 if (!extension_loaded('sodium')) {
44 if (!defined('SODIUM_CRYPTO_SCALARMULT_BYTES')) {
45 require_once dirname(__FILE__) . '/lib/php72compat_const.php';
46 }
47 assert(class_exists('ParagonIE_Sodium_Compat'), 'Possible filesystem/autoloader bug?');
48 require_once(dirname(__FILE__) . '/lib/php72compat.php');
49 } elseif (!function_exists('sodium_crypto_stream_xchacha20_xor')) {
50 // Older versions of {PHP, ext/sodium} will not define these
51 require_once(dirname(__FILE__) . '/lib/php72compat.php');
52 }
53 if (PHP_VERSION_ID < 80400 || !extension_loaded('sodium')) {
54 require_once dirname(__FILE__) . '/lib/php84compat.php';
55 }
56 require_once(dirname(__FILE__) . '/lib/stream-xchacha20.php');
57 require_once(dirname(__FILE__) . '/lib/ristretto255.php');