fix: restore PHPStan dependencies and fix unhandled EventType matches - #85
Closed
Baspa wants to merge 2 commits into
Closed
fix: restore PHPStan dependencies and fix unhandled EventType matches#85Baspa wants to merge 2 commits into
Baspa wants to merge 2 commits into
Conversation
EventType has 29 cases but the badge colour matches handled only 8 with no default arm, so any other event type threw UnhandledMatchError and 500'd the events pages.
Contributor
Author
|
Superseded by backstagephp/cms#299.
|
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.
Problem
composer analyseand the PHPStan CI workflow have both been failing since the Filament v4 upgrade (#49).That PR dropped
nunomaduro/larastan,phpstan/extension-installer,phpstan/phpstan-deprecation-rulesandphpstan/phpstan-phpunitfromrequire-dev, but leftphpstan.neon.dist,phpstan-baseline.neon, theanalysescript and.github/workflows/phpstan.ymlin place. So:The workflow runs
./vendor/bin/phpstan --error-format=github, which has the same problem — the job has been red (or skipped as a missing binary) for every push since.Fix
Restore the dev dependencies at versions matching PHPStan 2:
larastan/larastan: ^3.0(the package was renamed fromnunomaduro/larastan)phpstan/extension-installer: ^1.3phpstan/phpstan-deprecation-rules: ^2.0phpstan.neon.distitself needed no changes.checkOctaneCompatibilityandcheckModelPropertiesare still valid Larastan 3 parameters — they only appeared invalid withoutextension-installerpresent to register Larastan'sextension.neon.composer.jsonalso picks up a trailing newline, which it was missing.Real bug this surfaced
With PHPStan actually running, it found three genuine
match.unhandlederrors:src/Resources/EventResource.php:92src/Resources/EventResource.php:218src/Resources/MailResource.php:225All three are the badge-colour closure:
EventTypehas 29 cases, only 8 are handled, and there is no default arm. Any other event type —transient,blocked,spam_complaint,dns_error,template_rendering_failed,unknown, and the rest of the Postmark-style set — throwsUnhandledMatchErrorwhen the badge renders, which 500s the events table, the event view page and the mail view page.Fixed by adding
default => 'gray'to all three.Verification
Note
The three matches are identical copies of each other, which is how two of them stayed unnoticed. Consolidating them behind a single helper would be worthwhile, but
EventTypelives inbackstage/laravel-mails, so the natural home for acolor()method is that package rather than this one. Left alone here.