diff --git a/composer.json b/composer.json index 88dc097a2eaeea690055ce2c03dd64df8a9f70f2..bce73a4b0f1f0664cc3e096b5a226bc0f406dbdf 100644 --- a/composer.json +++ b/composer.json @@ -21,9 +21,14 @@ ], "autoload": { "psr-4": { - "SimpleSAML\\": "lib/SimpleSAML" - }, - "files": ["lib/_autoload_modules.php"] + "SimpleSAML\\": "lib/SimpleSAML", + "SimpleSAML\\Module\\admin\\": "modules/admin/lib", + "SimpleSAML\\Module\\core\\": "modules/core/lib", + "SimpleSAML\\Module\\cron\\": "modules/cron/lib", + "SimpleSAML\\Module\\exampleauth\\": "modules/exampleauth/lib", + "SimpleSAML\\Module\\multiauth\\": "modules/multiauth/lib", + "SimpleSAML\\Module\\saml\\": "modules/saml/lib" + } }, "autoload-dev": { "psr-4": { @@ -34,8 +39,7 @@ "SimpleSAML\\Test\\Module\\exampleauth\\": ["tests/lib/SimpleSAML/modules/exampleauth/lib"], "SimpleSAML\\Test\\Module\\multiauth\\": ["tests/lib/SimpleSAML/modules/multiauth/lib"], "SimpleSAML\\Test\\Module\\saml\\": ["tests/lib/SimpleSAML/modules/saml/lib"] - }, - "files": ["tests/_autoload_modules.php"] + } }, "require": { "php": ">=7.4 || ^8.0", diff --git a/lib/_autoload.php b/lib/_autoload.php deleted file mode 100644 index 4eabbc022ec4c73829dcd7a408e0bc02687e2fb0..0000000000000000000000000000000000000000 --- a/lib/_autoload.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php - -/** - * This file is a backwards compatible autoloader for SimpleSAMLphp. - * Loads the Composer autoloader. - * - * @package SimpleSAMLphp - */ - -declare(strict_types=1); - -// SSP is loaded as a separate project -if (file_exists(dirname(dirname(__FILE__)) . '/vendor/autoload.php')) { - require_once dirname(dirname(__FILE__)) . '/vendor/autoload.php'; -} else { - // SSP is loaded as a library - if (file_exists(dirname(dirname(__FILE__)) . '/../../autoload.php')) { - require_once dirname(dirname(__FILE__)) . '/../../autoload.php'; - } else { - throw new Exception('Unable to load Composer autoloader'); - } -} diff --git a/lib/_autoload_modules.php b/lib/_autoload_modules.php deleted file mode 100644 index 5d98c4ddac73c22e3596a94c52e9589b4f803c8b..0000000000000000000000000000000000000000 --- a/lib/_autoload_modules.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php - -declare(strict_types=1); - -/** - * This file registers an autoloader for SimpleSAMLphp modules. - * - * @package SimpleSAMLphp - */ - -/** - * Autoload function for SimpleSAMLphp modules following PSR-4. - * - * @param string $className Name of the class. - */ -function sspmodAutoloadPSR4(string $className): void -{ - $elements = explode('\\', $className); - if ($elements[0] === '') { - // class name starting with /, ignore - array_shift($elements); - } - if (count($elements) < 4) { - return; // it can't be a module - } - if (array_shift($elements) !== 'SimpleSAML') { - return; // the first element is not "SimpleSAML" - } - if (array_shift($elements) !== 'Module') { - return; // the second element is not "module" - } - - // this is a SimpleSAMLphp module following PSR-4 - $module = array_shift($elements); - if (!\SimpleSAML\Module::isModuleEnabled($module)) { - return; // module not enabled, avoid giving out any information at all - } - - $file = \SimpleSAML\Module::getModuleDir($module) . '/lib/' . implode('/', $elements) . '.php'; - - if (file_exists($file)) { - require_once($file); - } -} - -spl_autoload_register('sspmodAutoloadPSR4'); diff --git a/tests/_autoload_modules.php b/tests/_autoload_modules.php deleted file mode 100644 index eae6153bc75db09aebbe7ff7c60431c942ac1f7b..0000000000000000000000000000000000000000 --- a/tests/_autoload_modules.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php - -declare(strict_types=1); - -/** - * This file registers an autoloader for test classes used by SimpleSAMLphp modules unit tests. - */ - -/** - * Autoload function for SimpleSAMLphp modules test classes following PSR-4. - * Module test classes have namespaces like SimpleSAML\Test\Module\<moduleName>\Auth\Process - * - * @param string $className Name of the class. - */ -function sspmodTestClassAutoloadPSR4(string $className): void -{ - $elements = explode('\\', $className); - if ($elements[0] === '') { - // class name starting with /, ignore - array_shift($elements); - } - if (count($elements) < 5) { - return; // it can't be a module test class - } - if (array_shift($elements) !== 'SimpleSAML') { - return; // the first element is not "SimpleSAML" - } - if (array_shift($elements) !== 'Test') { - return; // the second element is not "test" - } - if (array_shift($elements) !== 'Module') { - return; // the third element is not "module" - } - - // this is a SimpleSAMLphp module test class following PSR-4 - $module = array_shift($elements); - $moduleTestDir = __DIR__ . '/modules/' . $module; - $file = $moduleTestDir . '/lib/' . implode('/', $elements) . '.php'; - - if (file_exists($file)) { - require_once($file); - } -} - -spl_autoload_register('sspmodTestClassAutoloadPSR4'); diff --git a/tests/routers/configLoader.php b/tests/routers/configLoader.php index f239c902b1c2ae356dd974c37700b27f6b91aa61..5fa2b8888535c5b0cd03908275f118cc7899187d 100644 --- a/tests/routers/configLoader.php +++ b/tests/routers/configLoader.php @@ -2,6 +2,8 @@ declare(strict_types=1); +namespace SimpleSAML\Test; + use SimpleSAML\Configuration; /* diff --git a/www/_include.php b/www/_include.php index 893f1fbf3798d963640dd0074ed273b727960564..8f95031bccc6b261ee1d2a79b6f6485bdb4f574a 100644 --- a/www/_include.php +++ b/www/_include.php @@ -1,8 +1,5 @@ <?php -// initialize the autoloader -require_once(dirname(dirname(__FILE__)) . '/lib/_autoload.php'); - use SAML2\Compat\ContainerSingleton; use SimpleSAML\Compat\SspContainer; use SimpleSAML\Configuration;