/usr/share/php/Horde/Test/Autoload.php is in php-horde-test 2.6.3+debian0-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | <?php
/**
* Reduced Horde Autoloader for test suites.
*
* PHP version 5
*
* Copyright 2009-2017 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Test
* @author Jan Schneider <jan@horde.org>
* @author Gunnar Wrobel <wrobel@pardus.de>
* @license http://www.horde.org/licenses/lgpl21 LGPL
* @link http://www.horde.org/components/Horde_Test
*/
class Horde_Test_Autoload
{
/**
* Prefix mappings.
*
* @var array
*/
private static $_mappings = array();
/**
* Only run init code once.
*
* @var boolean
*/
private static $_runonce = false;
/**
* Base autoloader code for Horde PEAR packages.
*/
public static function init()
{
if (self::$_runonce) {
return;
}
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require __DIR__ . '/vendor/autoload.php';
} else {
require __DIR__ . '/../../../bundle/vendor/autoload.php';
}
spl_autoload_register(
function($class) {
$filename = Horde_Test_Autoload::resolve($class);
$err_mask = error_reporting() & ~E_WARNING;
$old_err = error_reporting($err_mask);
include "$filename.php";
error_reporting($old_err);
},
true,
true
);
self::$_runonce = true;
}
/**
* Add a prefix to the autoloader.
*
* @param string $prefix Prefix to add.
* @param string $path Path to the prefix.
*/
public static function addPrefix($prefix, $path)
{
self::$_mappings[$prefix] = $path;
}
/**
* Resolve classname to a filename.
*
* @param string $class Class name.
*
* @return string Resolved filename.
*/
public static function resolve($class)
{
$filename = str_replace(array('::', '_', '\\'), '/', $class);
foreach (self::$_mappings as $prefix => $path) {
if ((strpos($filename, "/") === false) && ($filename == $prefix)) {
$filename = $path . '/' . $filename;
}
if (substr($filename, 0, strlen($prefix)) == $prefix) {
$filename = $path . substr($filename, strlen($prefix));
}
}
return $filename;
}
}
|