Skip to content

fix: Create "Middleware" article in "Internals" (#318) - #554

Open
rhys-mor wants to merge 2 commits into
yiisoft:masterfrom
rhys-mor:fix/issue-318
Open

rhys-mor wants to merge 2 commits into
yiisoft:masterfrom
rhys-mor:fix/issue-318

Conversation

@rhys-mor

@rhys-mor rhys-mor commented Nov 30, 2026 •

Copy link
Copy Markdown

Fixes #318

Summary

Summary by Sourcery

Document middleware failure handler conventions and add the new article to the Internals documentation navigation.

New Features:

  • Add an Internals article documenting middleware failure handler conventions and examples.
  • Expose the new Middleware article in the VitePress Internals navigation and index.

Documentation:

  • Document middleware-specific failure handlers, including handlers that receive throwable context.

@sourcery-ai

sourcery-ai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Configuration

Add Middleware to the Internals sidebar so readers can navigate to the new article.

  • src/.vitepress/config.js L284-285

Documentation

Document middleware failure-handler conventions and examples, and list the article in the Internals index.

  • src/internals/024-middleware.md L1-32
  • src/internals/index.md L32

Lock files and vendored code

Update package-lock metadata associated with the change.

  • package-lock.json L4219 (removed lines)

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai

sourcery-ai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit 21c0de5

#318 Create "Middleware" article in "Internals" · 2 of 3 met

# Requirement Status Notes
1 A middleware-specific failure handler should not implement RequestHandlerInterface. ✅ Met The article states this directly.
2 Create a separate failure handler interface for each middleware. 🟡 Partly met The article says each middleware may have its own failure handler and shows a dedicated interface, but does not explicitly state that each middleware should have a separate interface.
3 Pass required context as a second parameter to the handler method. ✅ Met The article describes adding a second parameter and demonstrates it with Throwable.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/internals/024-middleware.md" line_range="12" />
<code_context>
+```php
+interface AuthenticationFailureHandlerInterface
+{
+    public function handle(ServerRequestInterface $request): ResponseInterface;
+}
+```
</code_context>
<issue_to_address>
**Handler examples fail in namespaces**

When a reader copies either interface into a namespaced PHP file and implements it using the PSR message interfaces, the type names resolve in the code's namespace instead of to PSR message types, so an implementation using the actual PSR interfaces has incompatible method signatures and PHP rejects it.

Add the appropriate `use` statements or fully qualify the PSR types and `Throwable` in both examples.

Also at `src/internals/024-middleware.md:21`.
</issue_to_address>

### Comment 2
<location path="src/internals/024-middleware.md" line_range="1" />
<code_context>
+# Middleware
+
+## Failure Handlers
</code_context>
<issue_to_address>
**Middleware stays undiscoverable**

When the Middleware article is added to navigation without updating the manually maintained Internals Table of Contents, `src/internals/index.md` still ends its Table of Contents at GitHub Actions, so readers using that index cannot find or open the new article.

Add Middleware to the Table of Contents in `src/internals/index.md`.

Also at `src/.vitepress/config.js:285`.
</issue_to_address>

### Comment 3
<location path="src/internals/024-middleware.md" line_range="1" />
<code_context>
+# Middleware
+
+## Failure Handlers
</code_context>
<issue_to_address>
**Localized readers can't find article**

When readers browse the Internals section in a non-English locale, the localized Internals sections have no corresponding article or sidebar link for 024, so readers using those locales cannot find the new guidance there and must switch to English or navigate to it directly.

Add localized versions of the article and corresponding entries to the localized Internals sidebars.

Also at `src/.vitepress/config.js:285`.
</issue_to_address>

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: src/internals/024-middleware.md:12, src/internals/024-middleware.md:1


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/internals/024-middleware.md Resolved
Comment thread src/internals/024-middleware.md Resolved
Comment thread src/internals/024-middleware.md Resolved
Signed-off-by: Rhys Morgan <rhysw@users.noreply.github.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

New gaps against the linked issues


## Failure Handlers

Each middleware may have its own failure handler. A failure handler should **not** implement `RequestHandlerInterface` because it is specific to the middleware.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · State interface convention

The issue asks for a separate failure handler interface for each middleware. The article says each middleware may have its own failure handler, but does not explicitly require a separate interface for each one.

Prompt for AI agents
In `src/internals/024-middleware.md` at line 5:

**State interface convention**

The issue asks for a separate failure handler interface for each middleware. The article says each middleware may have its own failure handler, but does not explicitly require a separate interface for each one.

From #318:

Create a separate failure handler interface for each middleware.

This branch has not been deployed

No deployments
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.

Create "Middleware" article in "Internals"

2 participants