mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-10-25 19:03:14 +01:00
The XC_Autoloader fallback was already retired (no-op stub); this deletes it for
good. Resolution is now 100% Composer PSR-4 (+ ModuleLoader for modules), no
legacy scanner, no class-map cache.
- Move `define('MAIN_HOME', ...)` into bootstrap.php (autoload.php used to define
it); bootstrap.php now requires only vendor/autoload.php.
- Drop `\XC_Autoloader::clearCache()/warmCache()` from StartupCommand.
- tests/bootstrap.php: locate-guard + require switched to vendor/autoload.php.
- Entry points that required autoload.php directly — Public/index.php,
Public/admin/index.php, Public/stream/index.php, Public/progress/index.php,
ministra/portal.php and Admin/Reseller TableController — switched to
vendor/autoload.php (defining MAIN_HOME where they did not already). These were
not in the plan's checklist; found via grep during execution.
- phpstan.dist.neon: drop src/autoload.php from scanFiles.
- Makefile: drop autoload.php from LB_ROOT_FILES.
- deleted_files.txt: add autoload.php (client cleanup on update).
- AutoloadOrderTest: now asserts the XC_Autoloader class and file are gone.
- git rm src/autoload.php.
- PSR4_MIGRATION_PLAN.md: mark final-phase step 2 done.
Verified: grep XC_Autoloader:: = 0; php -l clean; PHPStan no errors; PHPUnit
303/303; make gates pass; bootstrap smoke — MAIN_HOME + XC_Bootstrap present,
XC_Autoloader gone, only the Composer autoloader registered.
78 lines
2.4 KiB
PHP
78 lines
2.4 KiB
PHP
<?php
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* Autoloader invariants after the PSR-4 migration (plan: Фаза 0 + Финал).
|
|
*
|
|
* - The Composer PSR-4 autoloader is registered and resolves every XcVm\* class.
|
|
* - The legacy XC_Autoloader directory scanner is RETIRED: its init() is a no-op
|
|
* that registers nothing, so it must not appear in the SPL stack.
|
|
* - No igbinary class-map cache (tmp/cache/autoload_map) is ever written.
|
|
*/
|
|
final class AutoloadOrderTest extends TestCase {
|
|
public function testComposerAutoloaderIsRegistered(): void {
|
|
$hasComposer = false;
|
|
foreach (spl_autoload_functions() as $fn) {
|
|
if (is_array($fn) && is_object($fn[0])
|
|
&& $fn[0] instanceof \Composer\Autoload\ClassLoader) {
|
|
$hasComposer = true;
|
|
break;
|
|
}
|
|
}
|
|
$this->assertTrue($hasComposer, 'Composer ClassLoader must be registered.');
|
|
}
|
|
|
|
public function testComposerResolvesNamespacedClassFromEveryLayer(): void {
|
|
$samples = [
|
|
'XcVm\\Core\\Config\\SettingsManager',
|
|
'XcVm\\Domain\\User\\UserRepository',
|
|
'XcVm\\Infrastructure\\Redis\\RedisManager',
|
|
'XcVm\\Streaming\\Codec\\FfmpegPaths',
|
|
'XcVm\\Cli\\CommandRegistry',
|
|
'XcVm\\Public\\Controllers\\Admin\\UserController',
|
|
];
|
|
foreach ($samples as $fqcn) {
|
|
$this->assertTrue(
|
|
class_exists($fqcn) || interface_exists($fqcn),
|
|
"Composer must autoload {$fqcn}."
|
|
);
|
|
}
|
|
}
|
|
|
|
public function testLegacyScannerIsNotRegistered(): void {
|
|
foreach (spl_autoload_functions() as $fn) {
|
|
if (is_array($fn)) {
|
|
$target = is_object($fn[0]) ? get_class($fn[0]) : (string) $fn[0];
|
|
$this->assertNotSame(
|
|
'XC_Autoloader',
|
|
$target,
|
|
'The retired XC_Autoloader scanner must not be registered.'
|
|
);
|
|
}
|
|
}
|
|
$this->addToAssertionCount(1);
|
|
}
|
|
|
|
public function testLegacyAutoloaderIsRemoved(): void {
|
|
$this->assertFalse(
|
|
class_exists('XC_Autoloader'),
|
|
'The legacy XC_Autoloader class has been removed entirely.'
|
|
);
|
|
$this->assertFileDoesNotExist(
|
|
MAIN_HOME . 'autoload.php',
|
|
'src/autoload.php must be deleted.'
|
|
);
|
|
}
|
|
|
|
public function testNoClassMapCacheIsWritten(): void {
|
|
$cache = MAIN_HOME . 'tmp/cache/autoload_map';
|
|
if (is_file($cache)) {
|
|
@unlink($cache);
|
|
}
|
|
// Trigger an autoload; resolution is live (Composer) with no cache file.
|
|
$this->assertTrue(class_exists('XcVm\\Core\\Logging\\Logger'));
|
|
$this->assertFileDoesNotExist($cache, 'The igbinary class-map cache must be gone.');
|
|
}
|
|
}
|