Repository navigation
fix: clear analyzer findings at help level - #28
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clears this repository's eight
mago analyzefindings so the fleet analyzer can be raised toHelpwithout this repo going red. No baseline entry was added and no existing suppression was extended;webware-tools/mago.tomlis untouched, since a separate change owns raising the analyzer.mixed-assignment (4)
src/Session/SessionPayload.php,src/Session/DbSessionHandler.php(2 sites) andsrc/Session/PhpDbSessionPersistence.php. PhpDb returnsmixedfromunserialize()and fromResultInterface::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 inbackup()and line 143 in__invoke():This is a genuine mago false positive, not dead code. PHP permits an implementing enum to override a public non-final const,
SchemaInterface::NAMEdocuments that as the intended design, andSchemaFactoryTest::itPreservesSchemaFromEnumConstantasserts the branch is live. mago types$schema::NAMEas the literalstring('')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-expectnever 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 reportsunfulfilled-expectand gets removed.Verification
Run inside the tooling container, PHP 8.5.12:
mago analyze --minimum-fail-level help: exit 0, no diagnostics, nounfulfilled-expectmago lint,mago format --checkandmago guard: all cleanThe single escaped mutant (
Coalesceordering inSchemaFactory.php) is pre-existing and unrelated to this change.