Welcome to Mitch Addons

Join our community to access exclusive content, participate in discussions, and connect with like-minded individuals. We offer resources, products, and dedicated support to help you succeed.

Fix: PHP 8+ Fatal Error in Mitch Member Reviews (Return Type Mismatch)

Cr0w

New member
Member reviews
View
Joined
Dec 31, 2025
Messages
4
Reaction score
1
Points
3
Credits
327
  • Reputation
    New 3
  • Addon: Mitch Member Reviews
    XenForo Version: XF 2.2+ / 2.3
    PHP Version: PHP 8.0+



    ❌ Error

    Code:
    TypeError:
    Mitch\MemberReviews\Pub\Controller\MemberReviews::actionIndex():
    Return value must be of type XF\Mvc\Reply\View,
    XF\Mvc\Reply\Error returned

    This error occurs when accessing the Member Reviews page without a valid
    user_id, or when the controller returns $this->notFound() /
    $this->error().



    🔍 Root Cause

    The controller method actionIndex() is strictly typed to return:

    PHP:
    XF\Mvc\Reply\View

    However, XenForo controller helpers such as:

    • $this->notFound()
    • $this->error()
    • $this->noPermission()

    return XF\Mvc\Reply\Error.

    Under PHP 8+, this mismatch triggers a fatal TypeError.



    ✅ Correct Fix (XenForo-Compliant)

    XenForo controller actions must return
    XF\Mvc\Reply\AbstractReply, which is the base class for all reply types
    (View, Error, Redirect, etc.).



    🛠️ Quick Find & Replace Fix

    File:
    Code:
    src/addons/Mitch/MemberReviews/Pub/Controller/MemberReviews.php



    1️⃣ FIND

    PHP:
    use XF\Mvc\Reply\View;

    REPLACE WITH

    PHP:
    use XF\Mvc\Reply\AbstractReply;



    2️⃣ FIND

    PHP:
    public function actionIndex(): View

    REPLACE WITH

    PHP:
    public function actionIndex(): AbstractReply



    💡 Result

    • $this->view() → works
    • $this->notFound() → works
    • $this->error() → works
    • No PHP 8+ fatal errors
    • Fully XenForo-compliant controller behavior



    📌 Why This Matters

    PHP 8 enforces strict return types.
    XenForo controllers are designed to return multiple reply types.
    Using AbstractReply is the correct and supported approach.



    ⚠️ Bonus Note

    If this error appears when visiting a URL such as:

    Code:
    /member-reviews/index.php?reputation

    That request does not supply a user_id, so the controller correctly
    returns notFound(). The fatal error only occurs because of the
    incorrect return type declaration.

    After applying this fix, the request safely returns a 404 instead of
    crashing PHP.



    ✔️ Status

    Tested and confirmed working on:

    • XenForo 2.2 / 2.3
    • PHP 8.0 – 8.3



    Regards,
    CR0W
     
    Back
    Top
    Live activity
    Just now · Social proof