Skip to content

fix: clear analyzer findings at help level - #28

Merged
tyrsson merged 2 commits into
1.0.xfrom
tyrsson-clear-analyzer-findings
Nov 7, 2026
Merged

tyrsson merged 2 commits into
1.0.xfrom
tyrsson-clear-analyzer-findings

Conversation

@tyrsson

@tyrsson tyrsson commented Nov 7, 2026

Copy link
Copy Markdown
Member

Clears this repository's eight mago analyze findings so the fleet analyzer can be raised to Help without this repo going red. No baseline entry was added and no existing suppression was extended; webware-tools/mago.toml is untouched, since a separate change owns raising the analyzer.

mixed-assignment (4)

src/Session/SessionPayload.php, src/Session/DbSessionHandler.php (2 sites) and src/Session/PhpDbSessionPersistence.php. PhpDb returns mixed from unserialize() and from ResultInterface::current(), so each site now carries a local /** @var mixed */ declaration. Type documentation only, no behaviour change.

redundant-comparison and redundant-condition (4)

Both codes come from the same line in src/SchemaFactory.php, at line 96 in backup() and line 143 in __invoke():

$enumSchema = '' === $schema::NAME ? null : $schema::NAME;

This is a genuine mago false positive, not dead code. PHP permits an implementing enum to override a public non-final const, SchemaInterface::NAME documents that as the intended design, and SchemaFactoryTest::itPreservesSchemaFromEnumConstant asserts the branch is live. mago types $schema::NAME as the literal string('') from the interface declaration and therefore treats the else branch as unreachable.

Handled with an inline end-of-line pragma on both lines rather than the own-line form used elsewhere in the fleet. mago issue #2652 is open against 1.59.0: an own-line pragma that matches nothing binds to a later occurrence in the same file, silently swallowing a real finding while unfulfilled-expect never fires. This file has two identical sites, which is exactly that shape. Inline placement is immune to it, and it self-retires: once mago's inference is corrected the pragma reports unfulfilled-expect and gets removed.

Verification

Run inside the tooling container, PHP 8.5.12:

  • mago analyze --minimum-fail-level help: exit 0, no diagnostics, no unfulfilled-expect
  • mago lint, mago format --check and mago guard: all clean
  • unit suite: 70 tests, 141 assertions
  • integration suite: 30 tests, 67 assertions, 2 skipped
  • Infection: 207 mutations, 206 killed, MSI 99% against the 95% gate

The single escaped mutant (Coalesce ordering in SchemaFactory.php) is pre-existing and unrelated to this change.

tyrsson and others added 2 commits November 7, 2026 00:03
mago analyze at Help level flags four mixed-assignment warnings where a
value read from the driver is assigned to an undeclared local:

- SessionPayload::decode() - unserialize() returns mixed
- DbSessionHandler::read() - ResultInterface::current() returns mixed, and
  the array offset read from it is mixed
- PhpDbSessionPersistence::initializeSessionFromRequest() - same current()
  call

Each value is genuinely mixed, so the fix declares it with a local @var
annotation rather than narrowing it to a type the driver does not promise.
No behaviour change: the existing is_array()/is_string() guards still do the
narrowing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
mago types $schema::NAME as the literal string('') from
SchemaInterface::NAME and does not account for an implementing enum
overriding that constant, so it reports the else branch of the
'' === $schema::NAME ternary as unreachable. The branch is live:
WebwareSchema redeclares NAME as 'webware', and
SchemaFactoryTest::itPreservesSchemaFromEnumConstant asserts it.

Suppress both findings with an inline end-of-line pragma rather than
refactoring working code. Inline placement is deliberate: an own-line
pragma that matches nothing binds to the next later occurrence in the
file (mago issue #2652), and this file has two identical sites.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@codecov

codecov Bot commented Nov 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tyrsson
tyrsson merged commit a85ad27 into 1.0.x Nov 7, 2026
12 checks passed
@tyrsson
tyrsson deleted the tyrsson-clear-analyzer-findings branch November 7, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant