updated streamline-setup v2

This commit is contained in:
2025-01-15 08:53:49 -08:00
committed by alec.turner
parent a2ce9248f0
commit 4b569f81b0
20228 changed files with 2932048 additions and 63204 deletions
@@ -16,6 +16,9 @@
namespace PHP_CodeSniffer;
use Composer\Autoload\ClassLoader;
use Exception;
if (class_exists('PHP_CodeSniffer\Autoload', false) === false) {
class Autoload
{
@@ -70,14 +73,14 @@ if (class_exists('PHP_CodeSniffer\Autoload', false) === false) {
// Make sure we don't try to load any of Composer's classes
// while the autoloader is being setup.
if (strpos($class, 'Composer\\') === 0) {
return;
return false;
}
if (strpos(__DIR__, 'phar://') !== 0
&& @file_exists(__DIR__.'/../../autoload.php') === true
) {
self::$composerAutoloader = include __DIR__.'/../../autoload.php';
if (self::$composerAutoloader instanceof \Composer\Autoload\ClassLoader) {
if (self::$composerAutoloader instanceof ClassLoader) {
self::$composerAutoloader->unregister();
self::$composerAutoloader->register();
} else {
@@ -201,7 +204,7 @@ if (class_exists('PHP_CodeSniffer\Autoload', false) === false) {
}
// Since PHP 7.4 get_declared_classes() does not guarantee any order, making
// it impossible to use order to determine which is the parent an which is the child.
// it impossible to use order to determine which is the parent and which is the child.
// Let's reduce the list of candidates by removing all the classes known to be "parents".
// That way, at the end, only the "main" class just included will remain.
$newClasses = array_reduce(
@@ -282,7 +285,7 @@ if (class_exists('PHP_CodeSniffer\Autoload', false) === false) {
public static function getLoadedClassName($path)
{
if (isset(self::$loadedClasses[$path]) === false) {
throw new \Exception("Cannot get class name for $path; file has not been included");
throw new Exception("Cannot get class name for $path; file has not been included");
}
return self::$loadedClasses[$path];
@@ -295,13 +298,13 @@ if (class_exists('PHP_CodeSniffer\Autoload', false) === false) {
*
* @param string $class The name of the class.
*
* @throws \Exception If the class name has not been loaded
* @throws \Exception If the class name has not been loaded.
* @return string
*/
public static function getLoadedFileName($class)
{
if (isset(self::$loadedFiles[$class]) === false) {
throw new \Exception("Cannot get file name for $class; class has not been included");
throw new Exception("Cannot get file name for $class; class has not been included");
}
return self::$loadedFiles[$class];