Fix route permission instance calls (#344)

## Root cause

`route_t::hasPermission()` and `requirePermission()` are instance
methods. Route code was invoking them with `self::`; the new XL Vask
hall-scope helper made that call from a genuinely static context,
causing PHP to throw:

`Non-static method routes\\xlvaskUsageLogsRoute::hasPermission() cannot
be called statically`

## Changes

- Invoke route permission methods through `$this` across all 273
executable legacy calls in 45 route classes.
- Make `xlvaskUsageLogsRoute::allowedHallIdsForUser()` an instance
helper and update all 13 callers.
- Preserve the existing all-scope and own-scope hall selection rules.
- Add a token-aware regression test that rejects executable
`self::hasPermission()` and `self::requirePermission()` calls, while
ignoring comments.
- Add focused XL Vask tests for global scanner hall scope and
group-limited own scope.
- Update affected route contract assertions to the instance-call form.

## Verification

- PHP lint: all 53 changed PHP files
- Focused PHPStan: changed XL Vask route and both new regression tests —
clean
- Focused regression slice: 58 passed, 748 assertions
- Full local unit suite: 1,300 passed, 9,442 assertions (1 unrelated
existing warning, 1 environment skip)
- Full local API suite: 285 passed, 11,704 assertions
- Exact-SHA GitHub Tests workflow: all 7 jobs passed (unit, API,
integration, legacy, edge gateway, and supporting checks)
- Independent exact-SHA QA gate: PASS, no findings
- Independent exact-SHA security gate: PASS, no findings
- Independent exact-SHA reviewer gate: PASS, no findings
- Remote comparison: exactly one commit ahead of
`40b104abed7723a7d1b7028190ecda0e7aeef829`; all 53 remote blob hashes
matched the reviewed worktree

## Delivery state

Draft only for human review. No merge or deployment is included. Qodana
is skipped while the PR remains draft and is therefore not represented
as a passed gate.
This commit is contained in:
Jeppe B
2026-08-04 16:04:41 +02:00
committed by GitHub
parent 40b104abed
commit ab6c3ba5b6
53 changed files with 486 additions and 297 deletions
@@ -23,7 +23,7 @@ class departmentNotificationSmsRoute
/** Department Notification SMS -> Get */
$this->get('/department/notification/sms', function () {
global $response;
self::requirePermission('department_notification_sms_get');
$this->requirePermission('department_notification_sms_get');
$user = (new authentication())->get_user();
if ($user) {
$department_notification_sms = new department_notification_sms_o();
@@ -61,7 +61,7 @@ class departmentNotificationSmsRoute
/** Department Notification SMS -> Add */
$this->post('/department/notification/sms', function () {
global $response;
self::requirePermission('department_notification_sms_add');
$this->requirePermission('department_notification_sms_add');
$user = (new authentication())->get_user();
if ($user) {
self::requireParameters([
@@ -77,7 +77,7 @@ class departmentNotificationSmsRoute
self::requireMinValue((int)self::getParameter('phone_country_code'), 1);
self::requireType(self::getParameter('phone'), self::type_int());
self::requireMinValue((int)self::getParameter('phone'), 1);
self::requirePermission('department_notification_sms_add');
$this->requirePermission('department_notification_sms_add');
self::requireDepartmentAccess((int)self::getParameter('department'));
$department_notification_sms = new department_notification_sms_o();
@@ -104,7 +104,7 @@ class departmentNotificationSmsRoute
/** Department Notification SMS -> Update */
$this->put('/department/notification/sms', function () {
global $response;
self::requirePermission('department_notification_sms_update');
$this->requirePermission('department_notification_sms_update');
$user = (new authentication())->get_user();
if ($user) {
self::requireParameters([
@@ -131,7 +131,7 @@ class departmentNotificationSmsRoute
self::requireType(self::getParameter('enabled'), self::type_bool());
$data['enabled'] = self::getParameter('enabled') ? 1 : 0;
}
self::requirePermission('department_notification_sms_update');
$this->requirePermission('department_notification_sms_update');
$department_notification_sms = new department_notification_sms_o();
$department_notification_sms->select((int)self::getParameter('id'));
self::requireDepartmentAccess((int)$department_notification_sms->department->value());
@@ -158,7 +158,7 @@ class departmentNotificationSmsRoute
/** Department Notification SMS -> Delete */
$this->delete('/department/notification/sms', function () {
global $response;
self::requirePermission('department_notification_sms_delete');
$this->requirePermission('department_notification_sms_delete');
$user = (new authentication())->get_user();
if ($user) {
self::requireParameters([
@@ -167,7 +167,7 @@ class departmentNotificationSmsRoute
self::requireType((int)self::getParameter('id'), self::type_int());
self::requireSameLength(self::getParameter('id'), (int)self::getParameter('id'));
self::requireMinValue((int)self::getParameter('id'), 1);
self::requirePermission('department_notification_sms_delete');
$this->requirePermission('department_notification_sms_delete');
$department_notification_sms = new department_notification_sms_o();
$department_notification_sms->select((int)self::getParameter('id'));
self::requireDepartmentAccess((int)$department_notification_sms->department->value());