Server IP : 127.0.0.2 / Your IP : 3.135.204.121 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/vendor/classpreloader/classpreloader/src/ |
Upload File : |
<?php /* * This file is part of Class Preloader. * * (c) Graham Campbell <graham@alt-three.com> * (c) Michael Dowling <mtdowling@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace ClassPreloader; /** * This is the class loader class. * * This creates an autoloader that intercepts and keeps track of each include * in order that files must be included. This autoloader proxies to all other * underlying autoloaders. */ class ClassLoader { /** * The list of loaded classes. * * @var \ClassPreloader\ClassList */ public $classList; /** * Create a new class loader instance. * * @return void */ public function __construct() { $this->classList = new ClassList(); } /** * Destroy the class loader. * * This makes sure we're unregistered from the autoloader. * * @return void */ public function __destruct() { $this->unregister(); } /** * Wrap a block of code in the autoloader and get a list of loaded classes. * * @param callable $func * * @return \ClassPreloader\Config */ public static function getIncludes($func) { $loader = new static(); call_user_func($func, $loader); $loader->unregister(); $config = new Config(); foreach ($loader->getFilenames() as $file) { $config->addFile($file); } return $config; } /** * Registers this instance as an autoloader. * * @return void */ public function register() { spl_autoload_register([$this, 'loadClass'], true, true); } /** * Unregisters this instance as an autoloader. * * @return void */ public function unregister() { spl_autoload_unregister([$this, 'loadClass']); } /** * Loads the given class, interface or trait. * * We'll return true if it was loaded. * * @param string $class * * @return bool */ public function loadClass($class) { foreach (spl_autoload_functions() as $func) { if (is_array($func) && $func[0] === $this) { continue; } $this->classList->push($class); if (call_user_func($func, $class)) { break; } } $this->classList->next(); return true; } /** * Get an array of loaded file names in order of loading. * * @return array */ public function getFilenames() { $files = []; foreach ($this->classList->getClasses() as $class) { // Push interfaces before classes if not already loaded try { $r = new \ReflectionClass($class); foreach ($r->getInterfaces() as $inf) { $name = $inf->getFileName(); if ($name && !in_array($name, $files)) { $files[] = $name; } } if (!in_array($r->getFileName(), $files)) { $files[] = $r->getFileName(); } } catch (\ReflectionException $e) { // We ignore all exceptions related to reflection because in // some cases class doesn't need to exist. We're ignoring all // problems with classes, interfaces and traits. } } return $files; } }