Skip to content

Fix route:list crash on LINK/UNLINK verbs#1254

Merged
roxblnfk merged 6 commits into
spiral:masterfrom
gam6itko:route-list-command
Jun 2, 2026
Merged

Fix route:list crash on LINK/UNLINK verbs#1254
roxblnfk merged 6 commits into
spiral:masterfrom
gam6itko:route-list-command

Conversation

@gam6itko
Copy link
Copy Markdown
Contributor

@gam6itko gam6itko commented May 18, 2026

fix for

$ php app.php route:list
[UnhandledMatchError]
Unhandled match case 'link' in vendor/spiral/framework/src/Framework/Command/Router/ListCommand.php:73

tests/app/src/Bootloader/RoutesBootloader.php — Added 9 verb-specific routes (verb-get, verb-head, verb-options, verb-post, verb-patch, verb-put, verb-delete, verb-link, verb-unlink) using lambdas with explicit HTTP methods.

tests/Framework/Command/Router/ListCommandTest.php — Replaced the single vague testExtensions test with 16 focused tests covering:

  • Route names appear in output
    • wildcard when route accepts all verbs
  • Controller->* format for Controller targets
  • Controller->action format for Action targets
  • Closure(file:line) format for callable targets
  • Group names (api, other) appear in the Group column
  • Patterns with prefix (api/test-import, other/test-import)
  • Each of the 9 HTTP verb types (GET, HEAD, OPTIONS, POST, PATCH, PUT, DELETE, LINK, UNLINK)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes route:list crashing when encountering routes restricted to the LINK/UNLINK HTTP verbs by extending verb rendering, and expands the test suite to cover route listing output formatting and verb display.

Changes:

  • Extend route:list verb rendering to handle LINK and UNLINK.
  • Add test-app routes for each HTTP verb so route:list output can be validated reliably.
  • Replace the previous broad route:list test with multiple focused assertions around names, targets, groups, patterns, and verbs.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/Framework/Command/Router/ListCommand.php Adds LINK/UNLINK cases to the verb-to-colored-label mapping to prevent UnhandledMatchError.
tests/app/src/Bootloader/RoutesBootloader.php Registers verb-specific routes (verb-*) used to validate route:list verb rendering.
tests/Framework/Command/Router/ListCommandTest.php Introduces a more granular test suite for route:list output content (names/targets/groups/patterns/verbs).
src/Exceptions/src/Renderer/ConsoleRenderer.php Minor change in global function invocation within Windows color support detection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


public function testAllVerbsShownAsWildcard(): void
{
$this->assertConsoleCommandOutputContainsStrings('route:list', strings: ['*']);
'AuthController',
'auth',
'scope',
'intercepted:without',
Comment on lines +49 to +50
'api',
'other',
try {
if (\DIRECTORY_SEPARATOR === '\\') {
return (\function_exists('sapi_windows_vt100_support') && @\sapi_windows_vt100_support($stream))
return (\function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support($stream))
roxblnfk added 2 commits June 2, 2026 20:03
Prevents UnhandledMatchError if RouteInterface::VERBS gains a verb that
is not enumerated in getVerbs() (the original LINK/UNLINK crash root
cause). Unknown verbs now render uppercased in gray.
@roxblnfk roxblnfk changed the title Route list command Fix route:list crash on LINK/UNLINK verbs Jun 2, 2026
@roxblnfk roxblnfk merged commit fb63168 into spiral:master Jun 2, 2026
9 of 12 checks passed
@roxblnfk roxblnfk added this to the 3.17 milestone Jun 3, 2026
@gam6itko gam6itko deleted the route-list-command branch June 3, 2026 10:39
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.

3 participants