Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hamzaelmaghari's avatar

Phpstorm marks PHP as error

Hi devs, I have a problem with Phpstorm, it marks all my PHP codes as errors. I use Inertia js with Laravel.

Bellow is a screenshot. https://ibb.co/FHgSbMG

The code is correct. I tried to change PHP version, but didn't work.

0 likes
12 replies
Sinnbeck's avatar

Does not look like an error, but rather phpstorm suggesting a fix. Perhaps the indent is wrong. Hover to see the message

1 like
hamzaelmaghari's avatar

@Sinnbeck

<?php

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
use Inertia\Inertia;

class Handler extends ExceptionHandler
{
    /**
     * A list of exception types with their corresponding custom log levels.
     *
     * @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
     */
    protected $levels = [
        //
    ];

    /**
     * A list of the exception types that are not reported.
     *
     * @var array<int, class-string<\Throwable>>
     */
    protected $dontReport = [
        //
    ];

    /**
     * A list of the inputs that are never flashed to the session on validation exceptions.
     *
     * @var array<int, string>
     */
    protected $dontFlash = [
        'current_password',
        'password',
        'password_confirmation',
    ];

    /**
     * Register the exception handling callbacks for the application.
     *
     * @return void
     */
    public function register()
    {
        $this->reportable(function (Throwable $e) {
            //
        });
    }

    /**
     * Prepare exception for rendering.
     *
     * @param  \Throwable  $e
     * @return \Throwable
     */
    public function render($request, Throwable $e)
    {
        $response = parent::render($request, $e);

        if (!app()->environment('local') && in_array($response->status(), [500, 503, 404, 403])) {
            return Inertia::render('Error', ['status' => $response->status()])
                ->toResponse($request)
                ->setStatusCode($response->status());
        } else if ($response->status() === 419) {
            return back()->with([
                'message' => 'The page expired, please try again.',
            ]);
        }

        return $response;
    }

    //

}
````
1 like
Sinnbeck's avatar

@hamzaelmaghari ok. Instead of @return you can add it to the right of the method.

Here I set it to expect that the code returns an instance of the Response class

public function render($request, Throwable $e) : Response 
1 like

Please or to participate in this conversation.