You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c62568f
Browse filesBrowse the repository at this point in the historyBrowse files
chore(php): namespace legacy includes under Sbpp\ + class_alias shims (#1290) (#1298)
Phase B of issue #1290. Move every class under `web/includes/` to a
`Sbpp\…` namespace matching its directory and emit a
`class_alias(\Sbpp\…\X::class, 'X')` from each file so the legacy
global names (`Database`, `CUserManager`, `Log`, `Api`, …) keep
resolving for procedural call sites that haven't been migrated yet.
What moved (file path + class name change):
- includes/Database.php → includes/Db/Database.php (Sbpp\Db\Database)
- includes/CUserManager.php → includes/Auth/UserManager.php (Sbpp\Auth\UserManager — drops the hungarian "C")
- includes/AdminTabs.php → includes/View/AdminTabs.php (Sbpp\View\AdminTabs)
- includes/Api.php → includes/Api/Api.php (Sbpp\Api\Api)
- includes/ApiError.php → includes/Api/ApiError.php (Sbpp\Api\ApiError)
- includes/auth/Auth.php → includes/Auth/Auth.php (Sbpp\Auth\Auth)
- includes/auth/Host.php → includes/Auth/Host.php (Sbpp\Auth\Host)
- includes/auth/JWT.php → includes/Auth/JWT.php (Sbpp\Auth\JWT)
- includes/auth/openid.php → includes/Auth/openid.php (LightOpenID — third-party, stays in global ns)
- includes/auth/handler/NormalAuthHandler.php → includes/Auth/Handler/NormalAuthHandler.php (Sbpp\Auth\Handler\NormalAuthHandler)
- includes/auth/handler/SteamAuthHandler.php → includes/Auth/Handler/SteamAuthHandler.php (Sbpp\Auth\Handler\SteamAuthHandler)
- includes/security/CSRF.php → includes/Security/CSRF.php (Sbpp\Security\CSRF)
- includes/security/Crypto.php → includes/Security/Crypto.php (Sbpp\Security\Crypto)
Namespaced in place (no rename):
- includes/Log.php → Sbpp\Log
- includes/Config.php → Sbpp\Config
The `class_alias` shims live below each class declaration so the
runtime aliases register the moment the file is required. The
explicit `require_once` chain at the top of `web/init.php`,
`web/tests/bootstrap.php`, and `web/phpstan-bootstrap.php` stays in
place for that reason — `class_alias()` is a runtime call the PSR-4
autoloader cannot trigger on a global-name lookup. The three lists
were rewritten to load the same 14 namespaced files in the same
order so any class loaded in one but not the other (a latent
regression) would surface immediately. New code consumes the
namespaced names directly via `use Sbpp\Db\Database;` etc.
Adjacent fixes pulled along:
- The PHPStan service registrations that read `Sbpp\PhpStan\…` were
fixed to `Sbpp\PHPStan\…` (the directory is `web/includes/PHPStan/`,
PSR-4 case-sensitive). `phpstan.neon` and `phpstan-dba-bootstrap.php`
match.
- `phpstan.neon`'s `excludePaths` was updated for the `auth/openid.php`
→ `Auth/openid.php` rename, and `Sbpp\Db\Database::query#0` was added
alongside the legacy `Database::query#0` to the SbppSyntaxErrorInQueryMethodRule
watchlist.
- `web/install/template/page.{2..5}.php`, `web/install/includes/converter.inc.php`,
`web/pages/admin.settings.php`, `web/includes/View/AdminThemesView.php`,
`web/includes/Mail/{Mail,Mailer}.php`, `web/includes/page-builder.php`
picked up `use` imports / FQCN updates so the analyser sees the new
namespaces from every entry point.
- `web/themes/default/{core/admin_tabs.tpl, css/theme.css,
page_admin_settings_*.tpl}` doc-comments updated to reference the
new `web/includes/View/AdminTabs.php` path.
- `web/phpstan-baseline.neon` shrank by 18 entries because the
namespaced reflection resolves several previously-unsigned types
(Mail/Mailer hand-offs, AdminTabs constructor types, etc.).
Documentation:
- `AGENTS.md` adds a "Stack at a glance" line, a "Namespacing"
Conventions subsection (with a per-class table), and an
Anti-pattern row pair: top-level `class Foo {}` in
`web/includes/`, AND removing the eager `require_once` chain
"now that PSR-4 exists". Existing references to
`web/includes/auth/…` / `web/includes/security/…` /
`Database` / `CUserManager` were retargeted to the
namespaced shapes, with the legacy alias called out.
- `ARCHITECTURE.md`'s "Web panel → Directory layout" tree was
rewritten with the new paths + namespaced FQCNs, the bootstrap
step now explains why the explicit require chain stays, and the
"Auth" subsystem section was re-pointed at `Sbpp\Auth\*`.
Verified: phpstan + phpunit + ts-check + composer api-contract all
clean. A class-resolution smoke test confirms all 14 legacy global
names resolve to their `Sbpp\…` FQCN counterparts (alias_resolves=yes
across the board).
Co-authored-by: cursor-agent <cursor-agent@cursor.local>
│ ├── CUserManager.php Current admin + permission checks
86
-
│ ├── AdminTabs.php Render Pattern A admin sub-section nav (vertical sidebar via core/admin_sidebar.tpl, or back-link strip via core/admin_tabs.tpl when $tabs is empty)
87
-
│ ├── page-builder.php route() + build() (the page router)
88
-
│ ├── system-functions.php Legacy helpers shared across pages
0 commit comments