1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-12 17:27:28 +01:00
psalm/tests/fixtures/SuicidalAutoloader/autoloader.php

35 lines
1.2 KiB
PHP
Raw Normal View History

<?php
use React\Promise\PromiseInterface as ReactPromise;
use Composer\InstalledVersions;
2023-10-21 20:45:09 +02:00
spl_autoload_register(static function (string $className) {
$knownBadClasses = [
ReactPromise::class, // amphp/amp
ResourceBundle::class, // symfony/polyfill-php73
Transliterator::class, // symfony/string
InstalledVersions::class, // composer v2
2023-06-07 08:31:53 +02:00
'Mockery\Closure', // Mockery/mockery 1.6.1
'parent', // it's unclear why Psalm tries to autoload parent
'PHPUnit\Framework\ArrayAccess',
'PHPUnit\Framework\Countable',
'PHPUnit\Framework\DOMDocument',
'PHPUnit\Framework\DOMElement',
2020-11-09 06:58:45 +01:00
'Stringable',
2023-06-07 08:41:44 +02:00
'AllowDynamicProperties',
// https://github.com/symfony/symfony/pull/40203
// these are actually functions, referenced as `if (!function_exists(u::class))`
'Symfony\Component\String\u',
'Symfony\Component\String\b',
'Symfony\Component\String\s',
'Symfony\Component\Translation\t',
];
if (in_array($className, $knownBadClasses)) {
return;
}
$ex = new RuntimeException('Attempted to load ' . $className);
echo $ex->__toString() . "\n\n" . $ex->getTraceAsString() . "\n\n";
exit(70);
});