Files
XC_VM/tests/bootstrap.php
T
Divarion-D 2bed01e660 chore(psr4): final phase step 2 — remove the legacy autoload.php entirely
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.
2026-06-25 21:11:00 +03:00

76 lines
1.7 KiB
PHP

<?php
$projectRoot = dirname(__DIR__);
$srcRoot = $projectRoot . '/src';
$flatRoot = $projectRoot;
if (file_exists($srcRoot . '/vendor/autoload.php')) {
$appRoot = $srcRoot;
} elseif (file_exists($flatRoot . '/vendor/autoload.php')) {
$appRoot = $flatRoot;
} else {
throw new RuntimeException('Unable to locate vendor/autoload.php in expected project paths.');
}
$tmpRoot = __DIR__ . '/.tmp';
$binRoot = $tmpRoot . '/bin';
if (!is_dir($tmpRoot)) {
mkdir($tmpRoot, 0775, true);
}
if (!is_dir($binRoot)) {
mkdir($binRoot, 0775, true);
}
$fakeBinary = $binRoot . '/fake_bin.sh';
if (!file_exists($fakeBinary)) {
file_put_contents($fakeBinary, "#!/bin/sh\nexit 0\n");
chmod($fakeBinary, 0755);
}
if (!defined('MAIN_HOME')) {
define('MAIN_HOME', $appRoot . '/');
}
if (!defined('PHP_BIN')) {
define('PHP_BIN', PHP_BINARY);
}
if (!defined('VOD_PATH')) {
define('VOD_PATH', $tmpRoot . '/vod/');
}
if (!is_dir(VOD_PATH)) {
mkdir(VOD_PATH, 0775, true);
}
foreach (array('40', '71', '80') as $version) {
$ffmpegConst = 'FFMPEG_BIN_' . $version;
$ffprobeConst = 'FFPROBE_BIN_' . $version;
if (!defined($ffmpegConst)) {
define($ffmpegConst, $fakeBinary);
}
if (!defined($ffprobeConst)) {
define($ffprobeConst, $fakeBinary);
}
}
if (!isset($_FILES)) {
$_FILES = array();
}
if (!function_exists('igbinary_serialize')) {
function igbinary_serialize($value) {
return serialize($value);
}
}
if (!function_exists('igbinary_unserialize')) {
function igbinary_unserialize($value) {
return unserialize($value);
}
}
require_once MAIN_HOME . 'vendor/autoload.php';
require_once __DIR__ . '/Unit/M3uParser/ExtCustomTag.php';
// Test support: in-memory SQLite harness for DB-touching repositories/services.
require_once __DIR__ . '/Support/TestDb.php';