<?php /** * @version $Id: class_locator.php 16792 2024-07-26 08:02:31Z alex $ * @package In-Portal * @copyright Copyright (C) 1997 - 2016 Intechnic. All rights reserved. * @license GNU/GPL * In-Portal is Open Source software. * This means that this software may have been modified pursuant * the GNU General Public License, and as distributed it includes * or is derivative of works licensed under the GNU General Public License * or other free or open source software licenses. * See http://www.in-portal.org/license for copyright notices and details. */ use Composer\Autoload\ClassLoader; $start = microtime(true); define('DBG_ZEND_PRESENT', 1); define('INDEX_FILE', 'index.php'); define('FULL_PATH', realpath(dirname(__FILE__) . '/..')); include_once(FULL_PATH . '/core/kernel/startup.php'); $application = kApplication::Instance(); $application->Init(); /** @var ClassLoader $composer_class_loader */ $composer_class_loader = require FULL_PATH . '/vendor/autoload.php'; return function ($class) use ($application, $composer_class_loader) { // 1. Search for class within In-Portal. $file = $application->findClassFile($class); if ( $file !== false ) { return $file; } // 2. Search for class within Composer + register custom autoloaders. $file = $composer_class_loader->findFile($class); if ( $file !== false ) { return $file; } // 3. Use custom autoloaders. $dynamic_autoloader_namespaces = array( 'ConsoleHelpers\\PHPUnitCompat\\', 'Yoast\\PHPUnitPolyfills\\', ); foreach ( $dynamic_autoloader_namespaces as $dynamic_autoloader_namespace ) { if ( strpos($class, $dynamic_autoloader_namespace) !== 0 ) { continue; } return (new ReflectionClass($class))->getFileName(); } return false; };