Widen the Rector config to the remaining class-based trees (Streaming,
Public\Controllers, Ministra), keeping the templates, procedural
front-controllers (Public/stream, Public/admin, Ministra/portal.php) and the
streaming hot-path bootstraps out. Also document the recurring dropped-parens
bug + the review grep in the config header.
The resulting 107-file pass (94 Public\Controllers, 11 Streaming, 2 Ministra)
was reviewed against the suite + PHPStan + the usual scans:
- No dropped-parens bug this time (the assignment-in-condition pattern didn't
occur in these files).
- 6 locally-called private static helpers became instance methods
(behaviour-preserving; all called via $this->, no static call sites); one
unused private param dropped (FanoutConfig::desired $rSnapshot, call site
updated).
- De Morgan / ternary / dead-code simplifications; two `$x = getById()`
truthy-assignments folded into the condition (no comparison, safe).
PHPStan level 5 clean; suite 721 tests / 0 errors.
Mechanical, behaviour-preserving reformat produced by 'make cs-fix' under
the new build/phpcs.xml.dist ruleset: K&R braces, tab indentation, and the
other whitespace normalisations. No logic changes.
Replace fully-qualified \XcVm\... class references (in code and in
docblocks/@see/@param/@return/@throws) with short names backed by
top-of-file use imports, project-wide. Same-namespace references drop
the prefix with no import; view templates gain the top-level imports the
check-procedural-use gate expects. Purely mechanical, no behavior change.
Complete the asset flattening: move the still-used legacy assets out of
assets/admin/old/ into the flat new-UI tree and delete old/ entirely.
- css/listings.css, js/listings.js, js/vendor.min.js → assets/{css,js}/
- images/countries, favicon.ico, logo-topbar.png, xcvm-login-bg.png → assets/img/
- libs/videojs → assets/vendor/libs/videojs
- Rewrite every remaining `assets/old/…` reference (EPG grid on admin+reseller
epg_view/live_connections/line_activity, country flags across the log/IP
tables, header logo, login favicon/background, player videojs) to the new
paths, and login.css's background to ../img/.
- Delete assets/admin/old/ — the panel no longer references it.
Verified on canary: all relocated assets serve at the new paths (listings,
country flags, videojs, favicon, logo, login background), admin + reseller
pages render, the old paths now 404; gates green.
Reorganize src/Public/assets/admin/ for the Bootstrap 5 redesign so legacy and new
theme assets live side by side and old solutions stay referenceable:
- Move the legacy admin asset dirs (css/js/libs/images/fonts/videos) into
assets/admin/old/ and reprefix every "assets/<dir>/" reference in the admin,
reseller and layout views (plus ResellerTableRenderer and the admin/reseller
TableController) to "assets/old/<dir>/". Player assets are untouched.
- Add the Bootstrap 5 v10.11.1 Bootstrap5 kit under assets/admin/new/ (vendor core
css/js/fonts + apex-charts, datatables-bs5, select2, flatpickr, sweetalert2,
perfect-scrollbar, node-waves, jquery/popper/hammer/pickr) plus xcvm/custom.css.
The reseller symlink (Public/assets/reseller -> admin) keeps resolving; the
nginx alias maps "/<code>/assets/" to Public/assets/admin/ as before.
Replace the RequestManager::getAll()['key'] whole-array-then-index pattern with
the per-key accessors across controllers, views and infrastructure:
- reads (incl. nested getAll()['order'][0]['column'] and empty(...)) -> get('key')
- isset(getAll()['key']) -> has('key')
get() returns the raw value unchanged, so comparisons, concatenation, ?? and
nested indexing behave exactly as before while missing keys stop raising PHP 8
undefined-key warnings.
Deliberately left as getAll() where get() would be invalid: unset() targets,
write context (getAll()['k'] = ...) and nested isset(getAll()['a']['b']).
Both single- and double-quoted keys and the fully-qualified RequestManager
reference are handled.
Replace SettingsManager::getAll()['key'] with SettingsManager::get('key')
across admin/reseller/player controllers, API controllers and view templates
(296 sites in 139 files). get() returns the raw value, preserving every call
site verbatim (comparisons, concatenation, ?? fallbacks) while adding a default
to silence PHP 8 undefined-key warnings.
RequestManager::getAll() (request parameters, ~1400 sites) is deliberately left
untouched; whole-array `$rSettings = SettingsManager::getAll()` grabs are kept.
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.
Apply 'make cs-fix' — 493 files. Mechanical, import-block only:
- sort use statements alphabetically (class/function/const grouped);
- drop imports left unused by the PSR-4 migration (e.g. classes referenced by
leading-backslash FQCN whose redundant 'use' the automated insertion had added);
- one blank line after namespace and after the import block; collapse stray
blank lines around use.
No logic changes. Verified: php -l clean; PHPStan no errors; PHPUnit 295/295; and a
temporary PHPStan pass over src/Public/Controllers confirms no still-referenced
import was removed (0 unresolved classes). 'use' after inline HTML in view
templates is valid and aliases correctly (verified) — those imports are sorted too.
Namespace all 174 Public controllers into XcVm\Public\Controllers\<Admin|Api|
Player|Reseller>, completing the per-file namespace migration. View templates and
entry points (index.php, admin/*.php, stream/*.php, progress/, routes/*.php,
Views/*) stay procedural/global and only gain use imports.
- Split the 3 multi-class Api files per PSR-4: AdminApiController→+AdminAPIWrapper,
Enigma2ApiController→+SimpleXMLExtended (extends \SimpleXMLElement),
ResellerRestApiController→+ResellerAPIWrapper (use-block copied to each new file).
- Add use to referrers — the procedural route files (routes/admin|player|reseller.php)
and index.php now import each routed controller; sibling controllers extend their
base class in the same namespace.
- Qualify built-ins/ioncube/global in the namespaced controllers (\Exception,
\DateTime, \PDO, \SimpleXMLElement, \ZipArchive, \ReflectionClass,
\XC_Bootstrap, \XC_VM, ...). Verified zero unresolved classes by temporarily
analysing src/Public/Controllers under PHPStan, then reverting to scanDirectories
(the ~346 pre-existing legacy findings there are out of scope for this migration).
Verified: php -l clean; PHPStan no errors; PHPUnit 295/295; no global controller
class-files remain; leading-backslash re-sweep clean.
Move Core/Http into XcVm\Core\Http (ApiClient, CurlClient, RequestManager,
Request, Response, Router) and Core/Http/Pipeline into XcVm\Core\Http\Pipeline
(StreamContext, StreamMiddlewareInterface, StreamPipeline). RequestGuard.php is
procedural (global functions) and stays global.
- Namespace the 9 classes; qualify still-global deps with leading backslash
(\ServerRepository in ApiClient; \Authorization, \ServiceContainer,
\AdminHelpers in Router) and built-in \Throwable; same-namespace siblings
unqualified.
- Add 'use XcVm\Core\Http\...;' to referencing files — RequestManager 128,
Router 19, ApiClient 15, Request 11, Response 6, CurlClient 5, plus Pipeline —
across src/ and tests/.
- Rewrite the modules' 'use Router;' → 'use XcVm\Core\Http\Router;' (plex,
watch, tmdb).
- Fix pre-existing leading-backslash global refs (\Router etc.) to the FQCN.
- Tests: fully-qualify the Router type hint in generated module fixtures
(registerRoutes(\XcVm\Core\Http\Router ...)) and update the
InterfaceContractTest param-type expectation to the FQCN. Also repaired two
fixtures where the use-inserter mis-placed a 'use' (files declare a method
literally named namespace(), which the tokenizer reports as T_NAMESPACE).
- phpstan-baseline.neon regenerated (292→292; class names in frozen messages
gained the namespace, no new/unknown-class errors).
Verified: php -l clean; PHPStan no errors; PHPUnit 295/295; Http classes resolve
via Composer; leading-backslash re-sweep across migrated classes is clean.
Move the last two Core/Config classes into XcVm\Core\Config. SettingsManager
has the largest fan-out of the whole migration (referenced by ~224 files).
- Namespace SettingsManager (self-contained singleton, no class deps) and
SettingsRepository (\FileCache:: qualified).
- Add 'use XcVm\Core\Config\SettingsManager;' to 224 referencing files and
'use ...\SettingsRepository;' to 12 — call sites (SettingsManager::get(), etc.)
unchanged. Done with a token-based inserter (after namespace/declare/<?php,
idempotent, same-namespace files skipped).
- ToolsCommand::processRecaptcha: drop dead class_exists('SettingsManager') +
method_exists guard (always autoloadable now) → call SettingsManager::clearCache()
directly. This was the only string-literal class reference.
Core/Config is now fully namespaced (ConfigReader, DomainResolver, SettingsManager,
SettingsRepository); the procedural constant files (AppConfig/Binaries/Paths)
remain global by design.
Verified: php -l clean (226 files); PHPStan no errors (baseline unchanged — it is
line-independent so the added use-lines don't disturb it); PHPUnit 295/295; all
Config FQCNs resolve via Composer; sample Public referrers lint-clean.